diff --git a/src/coprocessor/trie/mod.rs b/src/coprocessor/trie/mod.rs index 8db6e07a11..8fa4a69281 100644 --- a/src/coprocessor/trie/mod.rs +++ b/src/coprocessor/trie/mod.rs @@ -617,10 +617,14 @@ impl<'a, F: LurkField, const ARITY: usize, const HEIGHT: usize> Trie<'a, F, ARIT cs: &mut CS, key: &AllocatedNum, ) -> Result>, SynthesisError> { + let (arity_bits, bits_needed) = Self::path_bit_dimensions(); + let mut bits = key.to_bits_le_strict(&mut cs.namespace(|| "bits"))?; + for _ in 0..bits_needed - bits.len() { + bits.push(Boolean::Constant(false)); + } bits.reverse(); - let (arity_bits, bits_needed) = Self::path_bit_dimensions(); // each chunk is reversed due to little-endian encoding let path = bits[bits.len() - bits_needed..] .chunks(arity_bits) diff --git a/src/proof/tests/nova_tests_lem.rs b/src/proof/tests/nova_tests_lem.rs index d358570318..afb7e8c98a 100644 --- a/src/proof/tests/nova_tests_lem.rs +++ b/src/proof/tests/nova_tests_lem.rs @@ -4188,7 +4188,7 @@ fn test_trie_lang() { let expr = s.read(state.clone(), expr).unwrap(); let res = s .read_with_default_state( - "0x1cc5b90039db85fd519af975afa1de9d2b92960a585a546637b653b115bc3b53", + "0x2bfc4f437d5ca652511d67e06201b4fdf95c314c85ea987988746a253071bed6", ) .unwrap(); nova_test_full_aux2::<_, TrieCoproc<_>>( @@ -4206,7 +4206,7 @@ fn test_trie_lang() { ); let expr2 = - "(.lurk.trie.lookup 0x1cc5b90039db85fd519af975afa1de9d2b92960a585a546637b653b115bc3b53 123)"; + "(.lurk.trie.lookup 0x2bfc4f437d5ca652511d67e06201b4fdf95c314c85ea987988746a253071bed6 123)"; let expr2 = s.read(state.clone(), expr2).unwrap(); let res2 = s.comm(Fr::zero()); nova_test_full_aux2::<_, TrieCoproc<_>>( @@ -4224,11 +4224,11 @@ fn test_trie_lang() { ); let expr3 = - "(.lurk.trie.insert 0x1cc5b90039db85fd519af975afa1de9d2b92960a585a546637b653b115bc3b53 123 456)"; + "(.lurk.trie.insert 0x2bfc4f437d5ca652511d67e06201b4fdf95c314c85ea987988746a253071bed6 123 456)"; let expr3 = s.read(state.clone(), expr3).unwrap(); let res3 = s .read_with_default_state( - "0x1b22dc5a394231c34e4529af674dc56a736fbd07508acfd1d12c0e67c8b4de27", + "0x21ad1dd339f26bb824ab861dbcf110c1bcb3b7658eea4b5e84780a3b4958bf95", ) .unwrap(); nova_test_full_aux2::<_, TrieCoproc<_>>( @@ -4246,7 +4246,7 @@ fn test_trie_lang() { ); let expr4 = - "(.lurk.trie.lookup 0x1b22dc5a394231c34e4529af674dc56a736fbd07508acfd1d12c0e67c8b4de27 123)"; + "(.lurk.trie.lookup 0x21ad1dd339f26bb824ab861dbcf110c1bcb3b7658eea4b5e84780a3b4958bf95 123)"; let expr4 = s.read(state.clone(), expr4).unwrap(); let res4 = s.comm(Fr::from(456)); nova_test_full_aux2::<_, TrieCoproc<_>>(