Skip to content

Commit e645eef

Browse files
committed
chore: update to work with the updated integrity-calldata-generator lib
https://github.com/zksecurity/integrity-calldata-generator has been updated to commit 6f2dd268274e40e5ea75e2f17aff6b8e53f8f499
1 parent 57a10c5 commit e645eef

File tree

6 files changed

+60
-35
lines changed

6 files changed

+60
-35
lines changed

Cargo.lock

+46-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ swiftness_air = { git = "https://github.com/zksecurity/integrity-calldata-genera
2424
swiftness_fri = { git = "https://github.com/zksecurity/integrity-calldata-generator" }
2525
swiftness_proof_parser = { git = "https://github.com/zksecurity/integrity-calldata-generator" }
2626
swiftness_stark = { git = "https://github.com/zksecurity/integrity-calldata-generator" }
27+
swiftness = { git = "https://github.com/zksecurity/integrity-calldata-generator" }
2728
starknet-crypto = "0.7.2"
28-
tempfile = "3.10.1"
29+
tempfile = "3.10.1"
2930
thiserror = "1.0.61"
3031
uuid = "1.9.1"
3132

src/cairo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct CairoRunResult {
2626
pub enum Error {
2727
#[error("Failed to interact with the file system")]
2828
IO(#[from] std::io::Error),
29-
#[error("The cairo program execution failed")]
29+
#[error(transparent)]
3030
Runner(#[from] CairoRunError),
3131
#[error(transparent)]
3232
EncodeTrace(#[from] EncodeTraceError),

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() -> anyhow::Result<()> {
2222
match cli {
2323
Cli::Prove(args) => {
2424
let result = run_cairo(&args, &tmp_dir)
25-
.map_err(|e| anyhow::anyhow!("Failed to run cairo1: {}", e))
25+
.map_err(|e| anyhow::anyhow!("Failed to run cairo: {}", e))
2626
.and_then(|run_cairo_result| {
2727
run_stone_prover(
2828
&args,

src/serialize.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use std::fs::write;
1212
use std::io::BufRead;
1313
use std::path::Path;
1414
use std::path::PathBuf;
15+
use swiftness::transform::{Expr, StarkProofExprs};
16+
use swiftness::transform_stark::TransformTo;
1517
use swiftness_air::layout::*;
1618
use swiftness_fri::{CONST_STATE, VAR_STATE, WITNESS};
17-
use swiftness_proof_parser::{parse, parse_as_exprs, Expr, ParseStarkProof};
19+
use swiftness_proof_parser::parse;
1820
use swiftness_stark::stark;
1921
use thiserror::Error;
2022
use vec252::VecFelt252;
@@ -70,7 +72,7 @@ pub fn serialize_proof(args: SerializeArgs) -> Result<(), Error> {
7072
Some(SerializationType::monolith) => {
7173
let output = args.output.clone().unwrap();
7274
let input = std::fs::read_to_string(proof_file.clone())?;
73-
let stark_proof: ParseStarkProof = parse_as_exprs(input)?;
75+
let stark_proof: StarkProofExprs = parse(input)?.into();
7476
let config: VecFelt252 =
7577
serde_json::from_str(&stark_proof.config.to_string()).unwrap();
7678
let public_input: VecFelt252 =
@@ -99,7 +101,7 @@ pub fn serialize_proof(args: SerializeArgs) -> Result<(), Error> {
99101
let output_dir = args.output_dir.clone().unwrap();
100102
let layout = args.layout.unwrap();
101103
let input = std::fs::read_to_string(proof_file.clone())?;
102-
let stark_proof = parse(input.clone())?;
104+
let stark_proof = parse(input.clone())?.transform_to();
103105
let security_bits = stark_proof.config.security_bits();
104106

105107
match layout {
@@ -132,8 +134,7 @@ pub fn serialize_proof(args: SerializeArgs) -> Result<(), Error> {
132134

133135
let (const_state, mut var_state, mut witness) =
134136
unsafe { (CONST_STATE.clone(), VAR_STATE.clone(), WITNESS.clone()) };
135-
let cairo_version = Felt252::from(0);
136-
let initial = serialize(input, cairo_version)?
137+
let initial = serialize(input)?
137138
.split_whitespace()
138139
.map(|s| Felt::from_dec_str(s).unwrap().to_hex_string())
139140
.join(" ");
@@ -163,8 +164,8 @@ pub fn serialize_proof(args: SerializeArgs) -> Result<(), Error> {
163164
Ok(())
164165
}
165166

166-
fn serialize(input: String, cairo_version: Felt252) -> Result<String, Error> {
167-
let mut parsed = parse_as_exprs(input)?;
167+
fn serialize(input: String) -> Result<String, Error> {
168+
let mut parsed: StarkProofExprs = parse(input)?.into();
168169

169170
let config: VecFelt252 = serde_json::from_str(&parsed.config.to_string()).unwrap();
170171
let public_input: VecFelt252 = serde_json::from_str(&parsed.public_input.to_string()).unwrap();
@@ -200,15 +201,13 @@ fn serialize(input: String, cairo_version: Felt252) -> Result<String, Error> {
200201
parsed.witness.0.push(Expr::Array(vec![]));
201202
let witness: VecFelt252 = serde_json::from_str(&parsed.witness.to_string()).unwrap();
202203

203-
let proof = chain!(
204+
let calldata = chain!(
204205
config.into_iter(),
205206
public_input.into_iter(),
206207
unsent_commitment.into_iter(),
207208
witness.into_iter()
208209
);
209210

210-
let calldata = chain!(proof, vec![cairo_version].into_iter());
211-
212211
let calldata_string = calldata
213212
.map(|f| f.to_string())
214213
.collect::<Vec<String>>()

tests/resources/proofs/starknet/split/layouts/starknet/serialized/initial

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)