Skip to content

Commit

Permalink
Merge pull request #35 from iosis-tech/output_hash
Browse files Browse the repository at this point in the history
Output hash
  • Loading branch information
Okm165 authored Aug 19, 2024
2 parents 68bba34 + 8cca680 commit 5760f1a
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 68 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
license-file = "LICENSE"
readme = "README.md"
repository = "https://github.com/iosis-tech/swiftness"
version = "0.0.7"
version = "0.0.8"

[workspace.dependencies]
blake2 = { version = "0.10.6", default-features = false }
Expand All @@ -38,9 +38,9 @@ starknet-types-core = { version = "0.1.5", default-features = false }
thiserror = "1.0.61"
thiserror-no-std = "2.0.2"

swiftness_air = { path = "crates/air", default-features = false, version = "0.0.7" }
swiftness_commitment = { path = "crates/commitment", default-features = false, version = "0.0.7" }
swiftness_fri = { path = "crates/fri", default-features = false, version = "0.0.7" }
swiftness_pow = { path = "crates/pow", default-features = false, version = "0.0.7" }
swiftness_stark = { path = "crates/stark", default-features = false, version = "0.0.7" }
swiftness_transcript = { path = "crates/transcript", default-features = false, version = "0.0.7" }
swiftness_air = { path = "crates/air", default-features = false, version = "0.0.8" }
swiftness_commitment = { path = "crates/commitment", default-features = false, version = "0.0.8" }
swiftness_fri = { path = "crates/fri", default-features = false, version = "0.0.8" }
swiftness_pow = { path = "crates/pow", default-features = false, version = "0.0.8" }
swiftness_stark = { path = "crates/stark", default-features = false, version = "0.0.8" }
swiftness_transcript = { path = "crates/transcript", default-features = false, version = "0.0.8" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

![Version](https://img.shields.io/badge/v0.0.7-green?style=flat-square&logo=git&logoColor=white&label=version)
![Version](https://img.shields.io/badge/v0.0.8-green?style=flat-square&logo=git&logoColor=white&label=version)
![Continuous Integration](https://img.shields.io/github/actions/workflow/status/iosis-tech/swiftness/ci.yml?style=flat-square&logo=githubactions&logoColor=white&label=Continuous%20Integration)

[![Crates.io Version](https://img.shields.io/crates/v/swiftness?style=flat-square&logo=lootcrate)](https://crates.io/crates/swiftness)
Expand Down
16 changes: 8 additions & 8 deletions cli/Cargo.lock

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

8 changes: 4 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ edition = "2021"
license-file = "LICENSE"
readme = "../README.md"
repository = "https://github.com/iosis-tech/swiftness"
version = "0.0.7"
version = "0.0.8"

[dependencies]
clap = { version = "4.4.4", features = ["derive"] }

swiftness_air = { path = "../crates/air", default-features = false, features = [
"std",
], version = "0.0.7" }
], version = "0.0.8" }
swiftness_stark = { path = "../crates/stark", default-features = false, features = [
"std",
], version = "0.0.7" }
], version = "0.0.8" }
swiftness_proof_parser = { path = "../proof_parser", default-features = false, features = [
"std",
], version = "0.0.7" }
], version = "0.0.8" }

[features]
default = ["recursive", "keccak"]
Expand Down
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
6 changes: 4 additions & 2 deletions crates/air/src/layout/starknet_with_keccak/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,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
10 changes: 7 additions & 3 deletions crates/stark/src/tests/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
fixtures::{config, unsent_commitment, witness},
types::StarkProof,
};
use starknet_crypto::Felt;
use starknet_crypto::{pedersen_hash, Felt};
use swiftness_air::{fixtures::public_input, layout::recursive::Layout};

#[test]
Expand All @@ -25,8 +25,12 @@ fn test_stark_proof_fibonacci_verify() {
);
assert_eq!(
output_hash,
Felt::from_hex_unchecked(
"0x615be5409121774c863b7dfefd55d0bcab6d1d09eeecbbc4ee3b88daaa69c81"
pedersen_hash(
&pedersen_hash(
&pedersen_hash(&Felt::ZERO, &Felt::from_hex_unchecked("0xa")),
&Felt::from_hex_unchecked("0x90")
),
&Felt::TWO
)
);
}
14 changes: 7 additions & 7 deletions proof_parser/Cargo.lock

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

14 changes: 7 additions & 7 deletions proof_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license-file = "LICENSE"
readme = "README.md"
repository = "https://github.com/iosis-tech/swiftness"
version = "0.0.7"
version = "0.0.8"

[features]
default = ["std", "keccak"]
Expand Down Expand Up @@ -37,9 +37,9 @@ clap = { version = "4.5.1", features = ["derive"] }
regex = "1.10.3"
serde_json = "1.0.114"

swiftness_air = { path = "../crates/air", default-features = false, version = "0.0.7" }
swiftness_commitment = { path = "../crates/commitment", default-features = false, version = "0.0.7" }
swiftness_fri = { path = "../crates/fri", default-features = false, version = "0.0.7" }
swiftness_pow = { path = "../crates/pow", default-features = false, version = "0.0.7" }
swiftness_stark = { path = "../crates/stark", default-features = false, version = "0.0.7" }
swiftness_transcript = { path = "../crates/transcript", default-features = false, version = "0.0.7" }
swiftness_air = { path = "../crates/air", default-features = false, version = "0.0.8" }
swiftness_commitment = { path = "../crates/commitment", default-features = false, version = "0.0.8" }
swiftness_fri = { path = "../crates/fri", default-features = false, version = "0.0.8" }
swiftness_pow = { path = "../crates/pow", default-features = false, version = "0.0.8" }
swiftness_stark = { path = "../crates/stark", default-features = false, version = "0.0.8" }
swiftness_transcript = { path = "../crates/transcript", default-features = false, version = "0.0.8" }
Loading

0 comments on commit 5760f1a

Please sign in to comment.