Skip to content

Commit

Permalink
test: More recufier, now with base table rows and their digests
Browse files Browse the repository at this point in the history
Next up is Merkle-tree verification of the base leaf digests.
  • Loading branch information
Sword-Smith committed Mar 17, 2024
1 parent 53a27da commit 933fa96
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ num = "0.4"
rand = "0"
strum = { version = "0.26", features = ["derive"] }
syn = { version = "1.0", features = ["full", "extra-traits"] }
tasm-lib = { git = "https://github.com/TritonVM/tasm-lib.git", rev = "f955d7a2" }
tasm-lib = { git = "https://github.com/TritonVM/tasm-lib.git", rev = "5828932c" }
quote = "1.0"

[dev-dependencies]
Expand Down
35 changes: 16 additions & 19 deletions src/tests_and_benchmarks/ozk/programs/recufier/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl RecufyDebug {
return;
}

#[allow(clippy::ptr_arg)]
pub fn dump_digests(digests: &Vec<Digest>) {
let mut i: usize = 0;
while i < digests.len() {
Expand Down Expand Up @@ -466,26 +467,22 @@ fn recufy() {

// Read base authentication structure but ignore its value, as we divine-in the digests instead
{
let dummy: Box<Vec<Digest>> = proof_iter.next_as_authenticationstructure();
}
// let mut leaf_digests_base: Vec<Digest> = Vec::<Digest>::default();
// {
// let mut i: usize = 0;
// while i < fri.num_colinearity_checks as usize {
// leaf_digests_base.push(tasm::tasm_hashing_algebraic_hasher_hash_varlen(
// &base_table_rows[i],
// 356,
// ));
// i += 1;
// }
// }
// RecufyDebug::dump_digests(&leaf_digests_base);

// tasm_hashing_algebraic_hasher_hash_varlen
// fn input_field_names(&self) -> Vec<String> {
// vec!["*addr".to_string(), "length".to_string()]
// }
let _dummy: Box<Vec<Digest>> = proof_iter.next_as_authenticationstructure();
}
let mut leaf_digests_base: Vec<Digest> = Vec::<Digest>::default();
{
let mut i: usize = 0;
while i < fri.num_colinearity_checks as usize {
leaf_digests_base.push(tasm::tasm_hashing_algebraic_hasher_hash_varlen(
&base_table_rows[i],
356,
));
i += 1;
}
}
RecufyDebug::dump_digests(&leaf_digests_base);

// Ensure that sponge-states are in sync
RecufyDebug::sponge_state(Tip5WithState::squeeze());
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/tests_and_benchmarks/ozk/rust_shadows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::vec::Vec;
use itertools::Itertools;
use num::One;
use num::Zero;
use tasm_lib::hashing::algebraic_hasher::hash_varlen::HashVarlen;
use tasm_lib::memory::encode_to_memory;
use tasm_lib::recufier::master_ext_table::air_constraint_evaluation::AirConstraintEvaluation;
use tasm_lib::recufier::master_ext_table::air_constraint_evaluation::AirConstraintSnippetInputs;
Expand Down Expand Up @@ -326,6 +327,11 @@ pub(super) fn tasm_hashing_algebraic_hasher_hash_varlen(
preimage: &[BFieldElement],
_length: usize,
) -> Digest {
// Mutate sponge state the same way that Triton-VM does
SPONGE_STATE.with_borrow_mut(|sponge| {
HashVarlen.sponge_mutation(sponge.as_mut().unwrap(), preimage);
});

Tip5::hash_varlen(preimage)
}

Expand Down

0 comments on commit 933fa96

Please sign in to comment.