Fix camelcase function names

This commit is contained in:
Arnaud 2024-12-18 16:49:19 +01:00
parent a2f0528dc4
commit a2f09b2296
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
2 changed files with 23 additions and 23 deletions

View File

@ -24,10 +24,10 @@ import ./merkletree
export merkletree, poseidon2 export merkletree, poseidon2
const const
KeyNoneF = F.fromhex("0x0") KeyNoneF = F.fromHex("0x0")
KeyBottomLayerF = F.fromhex("0x1") KeyBottomLayerF = F.fromHex("0x1")
KeyOddF = F.fromhex("0x2") KeyOddF = F.fromHex("0x2")
KeyOddAndBottomLayerF = F.fromhex("0x3") KeyOddAndBottomLayerF = F.fromHex("0x3")
Poseidon2Zero* = zero Poseidon2Zero* = zero

View File

@ -76,7 +76,7 @@ proc release*(self: CircomCompat) =
## ##
if not isNil(self.backendCfg): if not isNil(self.backendCfg):
self.backendCfg.unsafeAddr.releaseCfg() self.backendCfg.unsafeAddr.release_cfg()
if not isNil(self.vkp): if not isNil(self.vkp):
self.vkp.unsafeAddr.release_key() self.vkp.unsafeAddr.release_key()
@ -102,9 +102,9 @@ proc prove[H](
defer: defer:
if ctx != nil: if ctx != nil:
ctx.addr.releaseCircomCompat() ctx.addr.release_circom_compat()
if initCircomCompat( if init_circom_compat(
self.backendCfg, self.backendCfg,
addr ctx) != ERR_OK or ctx == nil: addr ctx) != ERR_OK or ctx == nil:
raiseAssert("failed to initialize CircomCompat ctx") raiseAssert("failed to initialize CircomCompat ctx")
@ -114,27 +114,27 @@ proc prove[H](
dataSetRoot = input.datasetRoot.toBytes dataSetRoot = input.datasetRoot.toBytes
slotRoot = input.slotRoot.toBytes slotRoot = input.slotRoot.toBytes
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"entropy".cstring, entropy[0].addr, entropy.len.uint32) != ERR_OK: "entropy".cstring, entropy[0].addr, entropy.len.uint32) != ERR_OK:
return failure("Failed to push entropy") return failure("Failed to push entropy")
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"dataSetRoot".cstring, dataSetRoot[0].addr, dataSetRoot.len.uint32) != ERR_OK: "dataSetRoot".cstring, dataSetRoot[0].addr, dataSetRoot.len.uint32) != ERR_OK:
return failure("Failed to push data set root") return failure("Failed to push data set root")
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"slotRoot".cstring, slotRoot[0].addr, slotRoot.len.uint32) != ERR_OK: "slotRoot".cstring, slotRoot[0].addr, slotRoot.len.uint32) != ERR_OK:
return failure("Failed to push data set root") return failure("Failed to push data set root")
if ctx.pushInputU32( if ctx.push_input_u32(
"nCellsPerSlot".cstring, input.nCellsPerSlot.uint32) != ERR_OK: "nCellsPerSlot".cstring, input.nCellsPerSlot.uint32) != ERR_OK:
return failure("Failed to push nCellsPerSlot") return failure("Failed to push nCellsPerSlot")
if ctx.pushInputU32( if ctx.push_input_u32(
"nSlotsPerDataSet".cstring, input.nSlotsPerDataSet.uint32) != ERR_OK: "nSlotsPerDataSet".cstring, input.nSlotsPerDataSet.uint32) != ERR_OK:
return failure("Failed to push nSlotsPerDataSet") return failure("Failed to push nSlotsPerDataSet")
if ctx.pushInputU32( if ctx.push_input_u32(
"slotIndex".cstring, input.slotIndex.uint32) != ERR_OK: "slotIndex".cstring, input.slotIndex.uint32) != ERR_OK:
return failure("Failed to push slotIndex") return failure("Failed to push slotIndex")
@ -143,7 +143,7 @@ proc prove[H](
doAssert(slotProof.len == self.datasetDepth) doAssert(slotProof.len == self.datasetDepth)
# arrays are always flattened # arrays are always flattened
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"slotProof".cstring, "slotProof".cstring,
slotProof[0].addr, slotProof[0].addr,
uint (slotProof[0].len * slotProof.len)) != ERR_OK: uint (slotProof[0].len * slotProof.len)) != ERR_OK:
@ -154,13 +154,13 @@ proc prove[H](
merklePaths = s.merklePaths.mapIt( it.toBytes ) merklePaths = s.merklePaths.mapIt( it.toBytes )
data = s.cellData.mapIt( @(it.toBytes) ).concat data = s.cellData.mapIt( @(it.toBytes) ).concat
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"merklePaths".cstring, "merklePaths".cstring,
merklePaths[0].addr, merklePaths[0].addr,
uint (merklePaths[0].len * merklePaths.len)) != ERR_OK: uint (merklePaths[0].len * merklePaths.len)) != ERR_OK:
return failure("Failed to push merkle paths") return failure("Failed to push merkle paths")
if ctx.pushInputU256Array( if ctx.push_input_u256_array(
"cellData".cstring, "cellData".cstring,
data[0].addr, data[0].addr,
data.len.uint) != ERR_OK: data.len.uint) != ERR_OK:
@ -172,7 +172,7 @@ proc prove[H](
let proof = let proof =
try: try:
if ( if (
let res = self.backendCfg.proveCircuit(ctx, proofPtr.addr); let res = self.backendCfg.prove_circuit(ctx, proofPtr.addr);
res != ERR_OK) or res != ERR_OK) or
proofPtr == nil: proofPtr == nil:
return failure("Failed to prove - err code: " & $res) return failure("Failed to prove - err code: " & $res)
@ -180,7 +180,7 @@ proc prove[H](
proofPtr[] proofPtr[]
finally: finally:
if proofPtr != nil: if proofPtr != nil:
proofPtr.addr.releaseProof() proofPtr.addr.release_proof()
success proof success proof
@ -202,7 +202,7 @@ proc verify*[H](
inputs = inputs.toCircomInputs() inputs = inputs.toCircomInputs()
try: try:
let res = verifyCircuit(proofPtr, inputs.addr, self.vkp) let res = verify_circuit(proofPtr, inputs.addr, self.vkp)
if res == ERR_OK: if res == ERR_OK:
success true success true
elif res == ERR_FAILED_TO_VERIFY_PROOF: elif res == ERR_FAILED_TO_VERIFY_PROOF:
@ -228,18 +228,18 @@ proc init*(
var cfg: ptr CircomBn254Cfg var cfg: ptr CircomBn254Cfg
var zkey = if zkeyPath.len > 0: zkeyPath.cstring else: nil var zkey = if zkeyPath.len > 0: zkeyPath.cstring else: nil
if initCircomConfig( if init_circom_config(
r1csPath.cstring, r1csPath.cstring,
wasmPath.cstring, wasmPath.cstring,
zkey, cfg.addr) != ERR_OK or cfg == nil: zkey, cfg.addr) != ERR_OK or cfg == nil:
if cfg != nil: cfg.addr.releaseCfg() if cfg != nil: cfg.addr.release_cfg()
raiseAssert("failed to initialize circom compat config") raiseAssert("failed to initialize circom compat config")
var var
vkpPtr: ptr VerifyingKey = nil vkpPtr: ptr VerifyingKey = nil
if cfg.getVerifyingKey(vkpPtr.addr) != ERR_OK or vkpPtr == nil: if cfg.get_verifying_key(vkpPtr.addr) != ERR_OK or vkpPtr == nil:
if vkpPtr != nil: vkpPtr.addr.releaseKey() if vkpPtr != nil: vkpPtr.addr.release_key()
raiseAssert("Failed to get verifying key") raiseAssert("Failed to get verifying key")
CircomCompat( CircomCompat(