()
| 155 | } |
| 156 | |
| 157 | func initCompilePtr() { |
| 158 | compilePtrLock.Lock() |
| 159 | defer compilePtrLock.Unlock() |
| 160 | if compilePtr != nil { |
| 161 | return |
| 162 | } |
| 163 | cacheDir, err := getCacheDir() |
| 164 | if err != nil { |
| 165 | panic(fmt.Sprintf("failed to get cache dir: %v", err)) |
| 166 | } |
| 167 | soPath := filepath.Join(cacheDir, getLibName()) |
| 168 | updateLib(soPath) |
| 169 | handle := C.dlopen(C.CString(soPath), C.RTLD_LAZY) |
| 170 | if handle == nil { |
| 171 | panic("failed to load libec_go_lib, you may need to install openmpi") |
| 172 | } |
| 173 | abiVersionPtr := C.dlsym(handle, C.CString("abi_version")) |
| 174 | if abiVersionPtr == nil { |
| 175 | panic("failed to load abi_version function") |
| 176 | } |
| 177 | abiVersion := C.abi_version(abiVersionPtr) |
| 178 | if abiVersion != ABI_VERSION { |
| 179 | panic("abi_version mismatch, please consider update the go package") |
| 180 | } |
| 181 | compilePtr = C.dlsym(handle, C.CString("compile")) |
| 182 | if compilePtr == nil { |
| 183 | panic("failed to load compile function") |
| 184 | } |
| 185 | proveCircuitFilePtr = C.dlsym(handle, C.CString("prove_circuit_file")) |
| 186 | if proveCircuitFilePtr == nil { |
| 187 | panic("failed to load prove_circuit_file function") |
| 188 | } |
| 189 | verifyCircuitFilePtr = C.dlsym(handle, C.CString("verify_circuit_file")) |
| 190 | if verifyCircuitFilePtr == nil { |
| 191 | panic("failed to load verify_circuit_file function") |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // from c to go |
| 196 | func goBytes(data *C.uint8_t, length C.uint64_t) []byte { |
no test coverage detected