Skip to content

Commit

Permalink
fixed trie coprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-barrett committed Jan 19, 2024
1 parent 8b2669f commit e99db39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/coprocessor/trie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,14 @@ impl<'a, F: LurkField, const ARITY: usize, const HEIGHT: usize> Trie<'a, F, ARIT
cs: &mut CS,
key: &AllocatedNum<F>,
) -> Result<Vec<Vec<Boolean>>, 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)
Expand Down
10 changes: 5 additions & 5 deletions src/proof/tests/nova_tests_lem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>>(
Expand All @@ -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<_>>(
Expand All @@ -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<_>>(
Expand All @@ -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<_>>(
Expand Down

0 comments on commit e99db39

Please sign in to comment.