use p3_challenger::{HashChallenger, SerializingChallenger32}; use p3_circle::{Cfft, CirclePcs}; use p3_commit::ExtensionMmcs; use p3_fri::FriConfig; use p3_keccak::Keccak256Hash; use p3_keccak_air::{generate_trace_rows, KeccakAir}; use p3_matrix::Matrix; use p3_merkle_tree::FieldMerkleTreeMmcs; use p3_mersenne_31::Mersenne31; use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; use p3_uni_stark::{prove, verify, StarkConfig, VerificationError}; use p3_util::log2_strict_usize; use rand::random; use tracing_forest::util::LevelFilter; use tracing_forest::ForestLayer; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::{EnvFilter, Registry}; const NUM_HASHES: usize = 1365; fn main() -> Result<(), VerificationError> { let env_filter = EnvFilter::builder() .with_default_directive(LevelFilter::INFO.into()) .from_env_lossy(); Registry::default() .with(env_filter) .with(ForestLayer::default()) .init(); type Val = Mersenne31; // type Challenge = BinomialExtensionField; type Challenge = Val; type ByteHash = Keccak256Hash; type FieldHash = SerializingHasher32; let byte_hash = ByteHash {}; let field_hash = FieldHash::new(Keccak256Hash {}); type MyCompress = CompressionFunctionFromHasher; let compress = MyCompress::new(byte_hash); type ValMmcs = FieldMerkleTreeMmcs; let val_mmcs = ValMmcs::new(field_hash, compress); type ChallengeMmcs = ExtensionMmcs; let challenge_mmcs = ChallengeMmcs::new(val_mmcs.clone()); type Challenger = SerializingChallenger32>; let _fri_config = FriConfig { log_blowup: 1, num_queries: 100, proof_of_work_bits: 16, mmcs: challenge_mmcs, }; type Pcs = CirclePcs; let pcs = Pcs { log_blowup: 1, cfft: Cfft::default(), mmcs: val_mmcs, }; type MyConfig = StarkConfig; let config = MyConfig::new(pcs); let inputs = (0..NUM_HASHES).map(|_| random()).collect::>(); let trace = generate_trace_rows::(inputs); dbg!(trace.height(), log2_strict_usize(trace.height())); let air = KeccakAir {}; let mut challenger = Challenger::from_hasher(vec![], byte_hash); let proof = prove(&config, &air, &mut challenger, trace, &vec![]); let mut challenger = Challenger::from_hasher(vec![], byte_hash); verify(&config, &air, &mut challenger, &proof, &vec![])?; println!("OK!!! 👍"); Ok(()) }