Skip to content

Commit

Permalink
fix: safe cast
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Mar 6, 2024
1 parent 7116127 commit 5d5c5ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion waku/waku_rln_relay/rln/wrappers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ proc poseidon*(data: seq[seq[byte]]): RlnRelayResult[array[32, byte]] =
when defined(rln_v2):
proc toLeaf*(rateCommitment: RateCommitment): RlnRelayResult[seq[byte]] =
let idCommitment = rateCommitment.idCommitment
let userMessageLimit = cast[array[32, byte]](rateCommitment.userMessageLimit)
var userMessageLimit: array[32, byte]
discard userMessageLimit.copyFrom(toBytes(rateCommitment.userMessageLimit, Endianness.littleEndian))
let leaf = poseidon(@[@idCommitment, @userMessageLimit]).valueOr:
return err("could not convert the rate commitment to a leaf")
var retLeaf = newSeq[byte](leaf.len)
Expand Down

0 comments on commit 5d5c5ca

Please sign in to comment.