mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-05-05 01:53:28 +00:00
chore: update according to suggestion
This commit is contained in:
parent
7c693c44cf
commit
6956824f02
@ -44,7 +44,7 @@ contract(WakuRlnContract):
|
||||
# this constant describes max message limit of rln contract
|
||||
proc MAX_MESSAGE_LIMIT(): UInt256 {.view.}
|
||||
# this function returns the merkleProof for a given index
|
||||
proc merkleProofElements(index: UInt40): seq[byte] {.view.}
|
||||
# proc merkleProofElements(index: UInt40): seq[byte] {.view.}
|
||||
# this function returns the merkle root
|
||||
proc root(): UInt256 {.view.}
|
||||
|
||||
@ -116,9 +116,7 @@ proc fetchMerkleProofElements*(
|
||||
|
||||
return ok(responseBytes)
|
||||
except CatchableError:
|
||||
error "Failed to fetch Merkle proof elements",
|
||||
errMsg = getCurrentExceptionMsg(), index = g.membershipIndex.get()
|
||||
return err("Failed to fetch Merkle proof elements: " & getCurrentExceptionMsg())
|
||||
error "Failed to fetch Merkle proof elements", error = getCurrentExceptionMsg()
|
||||
|
||||
proc fetchMerkleRoot*(
|
||||
g: OnchainGroupManager
|
||||
@ -128,7 +126,7 @@ proc fetchMerkleRoot*(
|
||||
let merkleRoot = await merkleRootInvocation.call()
|
||||
return ok(merkleRoot)
|
||||
except CatchableError:
|
||||
error "Failed to fetch Merkle root", errMsg = getCurrentExceptionMsg()
|
||||
error "Failed to fetch Merkle root", error = getCurrentExceptionMsg()
|
||||
|
||||
template initializedGuard(g: OnchainGroupManager): untyped =
|
||||
if not g.initialized:
|
||||
@ -338,10 +336,8 @@ method generateProof*(
|
||||
|
||||
let x = keccak.keccak256.digest(data)
|
||||
|
||||
let extNullifierRes = poseidon(@[@(epoch), @(rlnIdentifier)])
|
||||
if extNullifierRes.isErr():
|
||||
return err("Failed to compute external nullifier: " & extNullifierRes.error)
|
||||
let extNullifier = extNullifierRes.get()
|
||||
let extNullifier = poseidon(@[@(epoch), @(rlnIdentifier)]).valueOr:
|
||||
return err("Failed to compute external nullifier: " & error)
|
||||
|
||||
let witness = RLNWitnessInput(
|
||||
identity_secret: identity_secret,
|
||||
@ -419,10 +415,11 @@ method verifyProof*(
|
||||
## -- Verifies an RLN rate-limit proof against the set of valid Merkle roots --
|
||||
|
||||
var normalizedProof = proof
|
||||
let extNullRes = poseidon(@[@(proof.epoch), @(proof.rlnIdentifier)])
|
||||
if extNullRes.isErr():
|
||||
return err("could not construct external nullifier: " & extNullRes.error)
|
||||
normalizedProof.externalNullifier = extNullRes.get()
|
||||
|
||||
normalizedProof.externalNullifier = poseidon(
|
||||
@[@(proof.epoch), @(proof.rlnIdentifier)]
|
||||
).valueOr:
|
||||
return err("Failed to compute external nullifier: " & error)
|
||||
|
||||
let proofBytes = serialize(normalizedProof, input)
|
||||
let proofBuffer = proofBytes.toBuffer()
|
||||
@ -440,7 +437,6 @@ method verifyProof*(
|
||||
)
|
||||
|
||||
if not ffiOk:
|
||||
warn "verify_with_roots() returned failure status", proof = proof
|
||||
return err("could not verify the proof")
|
||||
else:
|
||||
debug "Proof verified successfully !"
|
||||
|
||||
@ -135,6 +135,7 @@ proc generate_proof_with_witness*(
|
||||
): bool {.importc: "generate_rln_proof_with_witness".}
|
||||
|
||||
## rln-v2
|
||||
## witness term refer to collection of secret inputs with proper serialization
|
||||
## input_buffer has to be serialized as [ identity_secret<32> | user_message_limit<32> | message_id<32> | path_elements<Vec<32>> | identity_path_index<Vec<1>> | x<32> | external_nullifier<32> ]
|
||||
## output_buffer holds the proof data and should be parsed as [ proof<128> | root<32> | external_nullifier<32> | share_x<32> | share_y<32> | nullifier<32> ]
|
||||
## rln-v1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user