fix(rln): fix encoding to LE for idcommitments (#1256)

This commit is contained in:
G 2022-10-10 19:35:43 +02:00 committed by GitHub
parent 5e90085242
commit 586d549113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -178,11 +178,11 @@ proc createRLNInstance*(d: int = MerkleTreeDepth): RLNResult {.raises: [Defect,
return res
proc toUInt256*(idCommitment: IDCommitment): UInt256 =
let pk = UInt256.fromBytesBE(idCommitment)
let pk = UInt256.fromBytesLE(idCommitment)
return pk
proc toIDCommitment*(idCommitmentUint: UInt256): IDCommitment =
let pk = IDCommitment(idCommitmentUint.toBytesBE())
let pk = IDCommitment(idCommitmentUint.toBytesLE())
return pk
proc toMembershipIndex(v: UInt256): MembershipIndex =
@ -233,6 +233,7 @@ proc register*(idComm: IDCommitment, ethAccountAddress: Address, ethAccountPrivK
debug "tx log data", arguments=arguments
let
argumentsBytes = arguments.hexToSeqByte()
# In TX log data, uints are encoded in big endian
eventIdCommUint = UInt256.fromBytesBE(argumentsBytes[0..31])
eventIndex = UInt256.fromBytesBE(argumentsBytes[32..^1])
eventIdComm = eventIdCommUint.toIDCommitment()