Skip to content

Commit

Permalink
output hash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Aug 18, 2024
1 parent 87e27ed commit ef960a5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 490,345 deletions.
6 changes: 4 additions & 2 deletions crates/air/src/layout/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ impl LayoutTrait for Layout {
let program_hash = pedersen_hash(&hash, &Felt::from(program.len()));

let output_len: usize = (output_stop - output_start).to_bigint().try_into().unwrap();
let output = &memory[memory.len() - output_len..];
let output_hash = output.iter().fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output = &memory[memory.len() - output_len * 2..];
let hash =
output.iter().skip(1).step_by(2).fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output_hash = pedersen_hash(&hash, &Felt::from(output_len));

Ok((program_hash, output_hash))
}
Expand Down
6 changes: 4 additions & 2 deletions crates/air/src/layout/recursive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,10 @@ impl LayoutTrait for Layout {
let program_hash = pedersen_hash(&hash, &Felt::from(program.len()));

let output_len: usize = (output_stop - output_start).to_bigint().try_into().unwrap();
let output = &memory[memory.len() - output_len..];
let output_hash = output.iter().fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output = &memory[memory.len() - output_len * 2..];
let hash =
output.iter().skip(1).step_by(2).fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output_hash = pedersen_hash(&hash, &Felt::from(output_len));

Ok((program_hash, output_hash))
}
Expand Down
6 changes: 4 additions & 2 deletions crates/air/src/layout/recursive_with_poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,10 @@ impl LayoutTrait for Layout {
let program_hash = pedersen_hash(&hash, &Felt::from(program.len()));

let output_len: usize = (output_stop - output_start).to_bigint().try_into().unwrap();
let output = &memory[memory.len() - output_len..];
let output_hash = output.iter().fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output = &memory[memory.len() - output_len * 2..];
let hash =
output.iter().skip(1).step_by(2).fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output_hash = pedersen_hash(&hash, &Felt::from(output_len));

Ok((program_hash, output_hash))
}
Expand Down
6 changes: 4 additions & 2 deletions crates/air/src/layout/small/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ impl LayoutTrait for Layout {
let program_hash = pedersen_hash(&hash, &Felt::from(program.len()));

let output_len: usize = (output_stop - output_start).to_bigint().try_into().unwrap();
let output = &memory[memory.len() - output_len..];
let output_hash = output.iter().fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output = &memory[memory.len() - output_len * 2..];
let hash =
output.iter().skip(1).step_by(2).fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output_hash = pedersen_hash(&hash, &Felt::from(output_len));

Ok((program_hash, output_hash))
}
Expand Down
6 changes: 4 additions & 2 deletions crates/air/src/layout/starknet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,10 @@ impl LayoutTrait for Layout {
let program_hash = pedersen_hash(&hash, &Felt::from(program.len()));

let output_len: usize = (output_stop - output_start).to_bigint().try_into().unwrap();
let output = &memory[memory.len() - output_len..];
let output_hash = output.iter().fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output = &memory[memory.len() - output_len * 2..];
let hash =
output.iter().skip(1).step_by(2).fold(Felt::ZERO, |acc, e| pedersen_hash(&acc, e));
let output_hash = pedersen_hash(&hash, &Felt::from(output_len));

Ok((program_hash, output_hash))
}
Expand Down
2 changes: 0 additions & 2 deletions crates/air/src/layout/starknet_with_keccak/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pub mod autogenerated;
pub mod global_values;

use std::println;

use crate::{
diluted::get_diluted_product,
layout::stark_curve,
Expand Down
490,333 changes: 0 additions & 490,333 deletions examples/proofs/starknet_with_keccak/proof.json

This file was deleted.

0 comments on commit ef960a5

Please sign in to comment.