Skip to content

Commit

Permalink
Merge branch 'main' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Jul 9, 2024
2 parents c810df0 + 128515f commit 16f1692
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/air/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct AddrValue {
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct Page(Vec<AddrValue>);
pub struct Page(pub Vec<AddrValue>);

impl Deref for Page {
type Target = Vec<AddrValue>;
Expand Down
8 changes: 5 additions & 3 deletions crates/stark/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
};

impl StarkProof {
pub fn verify(&self, security_bits: Felt) -> Result<(), Error> {
pub fn verify(&self, security_bits: Felt) -> Result<Felt, Error> {
self.config.validate(security_bits)?;

// Validate the public input.
Expand Down Expand Up @@ -33,14 +33,16 @@ impl StarkProof {
);

// STARK verify phase.
Ok(stark_verify(
stark_verify(
NUM_COLUMNS_FIRST as usize,
NUM_COLUMNS_SECOND as usize,
&queries,
stark_commitment,
&self.witness,
stark_domains,
)?)
)?;

Ok(digest)
}
}

Expand Down
20 changes: 20 additions & 0 deletions crates/stark/src/tests/commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use cairovm_verifier_transcript::transcript::Transcript;
use starknet_crypto::Felt;

use super::*;

#[test]
pub fn test_stark_commit() {
// let mut channel = Transcript::new_with_counter(
// Felt::from_hex_unchecked(
// "0xaf91f2c71f4a594b1575d258ce82464475c82d8fb244142d0db450491c1b52",
// ),
// Felt::from_hex_unchecked("0x0"),
// );

// let public_input = public_input::get();
// let unsent_commitment = unsent_commitment::get();
// let config = stone_proof_fibonacci_keccak::stark::config::get();
// let stark_domains = stone_proof_fibonacci_keccak::stark::domains::get();
panic!("TODO: implement test_stark_commit()")
}
4 changes: 3 additions & 1 deletion crates/stark/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

pub mod commit;
pub mod public_input;
pub mod unsent_commitment;
236 changes: 236 additions & 0 deletions crates/stark/src/tests/public_input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
use cairovm_verifier_air::{
public_memory::PublicInput,
types::{AddrValue, Page, SegmentInfo},
};
use starknet_crypto::Felt;

pub fn get() -> PublicInput {
PublicInput {
log_n_steps: Felt::from_hex_unchecked("0xe"),
range_check_min: Felt::from_hex_unchecked("0x7ffa"),
range_check_max: Felt::from_hex_unchecked("0x8001"),
layout: Felt::from_hex_unchecked("0x726563757273697665"),
dynamic_params: vec![],
segments: vec![
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x1"),
stop_ptr: Felt::from_hex_unchecked("0x5"),
},
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x25"),
stop_ptr: Felt::from_hex_unchecked("0x68"),
},
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x68"),
stop_ptr: Felt::from_hex_unchecked("0x6a"),
},
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x6a"),
stop_ptr: Felt::from_hex_unchecked("0x6a"),
},
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x1ea"),
stop_ptr: Felt::from_hex_unchecked("0x1ea"),
},
SegmentInfo {
begin_addr: Felt::from_hex_unchecked("0x9ea"),
stop_ptr: Felt::from_hex_unchecked("0x9ea"),
},
],
padding_addr: Felt::from_hex_unchecked("0x1"),
padding_value: Felt::from_hex_unchecked("0x40780017fff7fff"),
main_page: Page(vec![
AddrValue {
address: Felt::from_hex("0x1").unwrap(),
value: Felt::from_hex("0x40780017fff7fff").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x2").unwrap(),
value: Felt::from_hex("0x4").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x3").unwrap(),
value: Felt::from_hex("0x1104800180018000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x4").unwrap(),
value: Felt::from_hex("0x4").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x5").unwrap(),
value: Felt::from_hex("0x10780017fff7fff").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x6").unwrap(),
value: Felt::from_hex("0x0").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x7").unwrap(),
value: Felt::from_hex("0x40780017fff7fff").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x8").unwrap(),
value: Felt::from_hex("0x1").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x9").unwrap(),
value: Felt::from_hex("0x400380007ffa8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xa").unwrap(),
value: Felt::from_hex("0x480680017fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xb").unwrap(),
value: Felt::from_hex("0x1").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xc").unwrap(),
value: Felt::from_hex("0x480680017fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xd").unwrap(),
value: Felt::from_hex("0x1").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xe").unwrap(),
value: Felt::from_hex("0x480a80007fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0xf").unwrap(),
value: Felt::from_hex("0x1104800180018000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x10").unwrap(),
value: Felt::from_hex("0x9").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x11").unwrap(),
value: Felt::from_hex("0x400280017ffa7fff").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x12").unwrap(),
value: Felt::from_hex("0x482680017ffa8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x13").unwrap(),
value: Felt::from_hex("0x2").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x14").unwrap(),
value: Felt::from_hex("0x480a7ffb7fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x15").unwrap(),
value: Felt::from_hex("0x480a7ffc7fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x16").unwrap(),
value: Felt::from_hex("0x480a7ffd7fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x17").unwrap(),
value: Felt::from_hex("0x208b7fff7fff7ffe").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x18").unwrap(),
value: Felt::from_hex("0x20780017fff7ffd").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x19").unwrap(),
value: Felt::from_hex("0x4").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1a").unwrap(),
value: Felt::from_hex("0x480a7ffc7fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1b").unwrap(),
value: Felt::from_hex("0x208b7fff7fff7ffe").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1c").unwrap(),
value: Felt::from_hex("0x480a7ffc7fff8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1d").unwrap(),
value: Felt::from_hex("0x482a7ffc7ffb8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1e").unwrap(),
value: Felt::from_hex("0x482680017ffd8000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x1f").unwrap(),
value: Felt::from_hex(
"0x800000000000011000000000000000000000000000000000000000000000000",
)
.unwrap(),
},
AddrValue {
address: Felt::from_hex("0x20").unwrap(),
value: Felt::from_hex("0x1104800180018000").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x21").unwrap(),
value: Felt::from_hex(
"0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff9",
)
.unwrap(),
},
AddrValue {
address: Felt::from_hex("0x22").unwrap(),
value: Felt::from_hex("0x208b7fff7fff7ffe").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x23").unwrap(),
value: Felt::from_hex("0x25").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x24").unwrap(),
value: Felt::from_hex("0x0").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x25").unwrap(),
value: Felt::from_hex("0x68").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x26").unwrap(),
value: Felt::from_hex("0x6a").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x27").unwrap(),
value: Felt::from_hex("0x1ea").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x28").unwrap(),
value: Felt::from_hex("0x9ea").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x64").unwrap(),
value: Felt::from_hex("0x6a").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x65").unwrap(),
value: Felt::from_hex("0x6a").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x66").unwrap(),
value: Felt::from_hex("0x1ea").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x67").unwrap(),
value: Felt::from_hex("0x9ea").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x68").unwrap(),
value: Felt::from_hex("0xa").unwrap(),
},
AddrValue {
address: Felt::from_hex("0x69").unwrap(),
value: Felt::from_hex("0x90").unwrap(),
},
]),
continuous_page_headers: vec![],
}
}
13 changes: 13 additions & 0 deletions crates/stark/src/tests/unsent_commitment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use starknet_crypto::Felt;

use crate::types::StarkUnsentCommitment;

use super::*;

pub fn get() -> StarkUnsentCommitment {
// StarkUnsentCommitment {
// traces:

// }
todo!("implement get()")
}

0 comments on commit 16f1692

Please sign in to comment.