Skip to content

Commit

Permalink
dequeue extension rows
Browse files Browse the repository at this point in the history
Co-authored-by: Alan Szepieniec <[email protected]>
Co-authored-by: Ferdinand Sauer <[email protected]>
  • Loading branch information
3 people committed Mar 18, 2024
1 parent dfa800b commit 39bc56d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
22 changes: 21 additions & 1 deletion src/tests_and_benchmarks/ozk/programs/recufier/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ fn recufy() {
// Check leafs
// Dequeue base elements
// Could be read from secret-in, but it's much more efficient to get them from memory
let base_table_rows: Box<Vec<[BFieldElement; 356]>> = proof_iter.next_as_masterbasetablerows();
let base_table_rows: Box<Vec<BaseRow<BFieldElement>>> =
proof_iter.next_as_masterbasetablerows();
{
let mut i: usize = 0;
while i < fri.num_colinearity_checks as usize {
Expand All @@ -468,6 +469,8 @@ fn recufy() {
{
let _dummy: Box<Vec<Digest>> = proof_iter.next_as_authenticationstructure();
}

// hash base rows to get leafs
let mut leaf_digests_base: Vec<Digest> = Vec::<Digest>::default();
{
let mut i: usize = 0;
Expand Down Expand Up @@ -496,6 +499,23 @@ fn recufy() {
}
}

// dequeue extension elements
let ext_table_rows: Box<Vec<ExtensionRow>> = proof_iter.next_as_masterexttablerows();

// hash extension rows to get leafs
let mut leaf_digests_ext: Vec<Digest> = Vec::<Digest>::default();
{
let mut i: usize = 0;
while i < fri.num_colinearity_checks as usize {
leaf_digests_ext.push(tasm::tasm_hashing_algebraic_hasher_hash_varlen(
&ext_table_rows[i],
83 * 3,
));
i += 1;
}
}
RecufyDebug::dump_digests(&leaf_digests_ext);

// Ensure that sponge-states are in sync
RecufyDebug::sponge_state(Tip5WithState::squeeze());
return;
Expand Down
9 changes: 6 additions & 3 deletions src/tests_and_benchmarks/ozk/rust_shadows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,14 @@ pub(super) fn tasm_hashing_merkle_verify(
assert!(mt_inclusion_proof.verify(root));
}

pub(super) fn tasm_hashing_algebraic_hasher_hash_varlen(
preimage: &[BFieldElement],
_length: usize,
pub(super) fn tasm_hashing_algebraic_hasher_hash_varlen<T: BFieldCodec>(
preimage: &[T],
length: usize,
) -> Digest {
assert!(T::static_length().is_some());

// Mutate sponge state the same way that Triton-VM does
let preimage = &preimage.iter().flat_map(|c| c.encode()).collect_vec()[..length];
SPONGE_STATE.with_borrow_mut(|sponge| {
HashVarlen.sponge_mutation(sponge.as_mut().unwrap(), preimage);
});
Expand Down

0 comments on commit 39bc56d

Please sign in to comment.