From b33ddb347b431f5c5972fbf860ab02872dcc00ff Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 16 Jan 2024 20:30:11 -0600 Subject: [PATCH] truncate entropy to 31 bytes, otherwise it might be > than mod --- codex/slots/sampler/sampler.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/codex/slots/sampler/sampler.nim b/codex/slots/sampler/sampler.nim index 7282f57e..7ddf5351 100644 --- a/codex/slots/sampler/sampler.nim +++ b/codex/slots/sampler/sampler.nim @@ -18,6 +18,7 @@ import pkg/constantine/math/arithmetic import pkg/poseidon2 import pkg/poseidon2/types import pkg/poseidon2/io +import pkg/stew/arrayops import ../../market import ../../blocktype as bt @@ -86,9 +87,9 @@ proc getProofInput*( ## Generate proofs as input to the proving circuit. ## - without entropy =? Poseidon2Hash.fromBytes(entropy): - error "Failed to parse entropy" - return failure("Failed to parse entropy") + let + entropy = Poseidon2Hash.fromBytes( + array[31, byte].initCopyFrom(entropy[0..30])) # truncate to 31 bytes, otherwise it _might_ be greater than mod without verifyTree =? self.builder.verifyTree and verifyProof =? verifyTree.getProof(self.index) and