From 0753871fed43235f394e5c775ee0184c961979f8 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Thu, 24 Oct 2024 11:55:56 +0700 Subject: [PATCH 01/16] add fibonacci example --- exercises/plonky3/fibonacci/Cargo.toml | 31 ++++++ exercises/plonky3/fibonacci/main.rs | 126 +++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 exercises/plonky3/fibonacci/Cargo.toml create mode 100644 exercises/plonky3/fibonacci/main.rs diff --git a/exercises/plonky3/fibonacci/Cargo.toml b/exercises/plonky3/fibonacci/Cargo.toml new file mode 100644 index 0000000000..98b310d620 --- /dev/null +++ b/exercises/plonky3/fibonacci/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "plonky3_fibonacci" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-field = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mersenne-31 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-util = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-circle = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-commit = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-dft = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-fri = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mds = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git" } +rand = "0.8.5" +tracing-subscriber = { version = "0.3.17", features = ["std", "env-filter"] } +tracing-forest = { version = "0.1.6", features = ["ansi", "smallvec"] } diff --git a/exercises/plonky3/fibonacci/main.rs b/exercises/plonky3/fibonacci/main.rs new file mode 100644 index 0000000000..d351a6748f --- /dev/null +++ b/exercises/plonky3/fibonacci/main.rs @@ -0,0 +1,126 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::Matrix; +use p3_matrix::dense::RowMajorMatrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +pub struct FibonacciAir { + pub num_steps: usize, + pub final_value: u32, +} + +impl BaseAir for FibonacciAir { + fn width(&self) -> usize { + 2 + } +} + +impl Air for FibonacciAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + let next = main.row_slice(1); + + + builder.when_first_row().assert_eq(local[0], AB::Expr::zero()); + builder.when_first_row().assert_eq(local[1], AB::Expr::one()); + + + builder.when_transition().assert_eq(next[0], local[1]); + builder.when_transition().assert_eq(next[1], local[0] + local[1]); + + + let final_value = AB::Expr::from_canonical_u32(self.final_value); + builder.when_last_row().assert_eq(local[1], final_value); + } +} + +pub fn generate_fibonacci_trace(num_steps: usize) -> RowMajorMatrix { + let mut values = Vec::with_capacity(num_steps * 2); + let mut a = F::zero(); + let mut b = F::one(); + for _ in 0..num_steps { + values.push(a); + values.push(b); + let c = a + b; + a = b; + b = c; + } + RowMajorMatrix::new(values, 2) +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + let num_steps = 16; + let final_value = 987; + let air = FibonacciAir { num_steps, final_value }; + let trace = generate_fibonacci_trace::(num_steps); + + 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![]) +} \ No newline at end of file From 4e7448553abe6405b00d100576e1840e44909bea Mon Sep 17 00:00:00 2001 From: Kenil shah Date: Thu, 24 Oct 2024 11:59:18 +0700 Subject: [PATCH 02/16] src added --- exercises/plonky3/fibonacci/Cargo.lock | 889 ++++++++++++++++++++++++ exercises/plonky3/fibonacci/src/main.rs | 126 ++++ 2 files changed, 1015 insertions(+) create mode 100644 exercises/plonky3/fibonacci/Cargo.lock create mode 100644 exercises/plonky3/fibonacci/src/main.rs diff --git a/exercises/plonky3/fibonacci/Cargo.lock b/exercises/plonky3/fibonacci/Cargo.lock new file mode 100644 index 0000000000..bcd7050552 --- /dev/null +++ b/exercises/plonky3/fibonacci/Cargo.lock @@ -0,0 +1,889 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "arrayref" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "blake3" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "gcd" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", + "rand", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "nums" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3c74f925fb8cfc49a8022f2afce48a0683b70f9e439885594e84c5edbf5b01" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", + "rand", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "p3-air" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-field", + "p3-matrix", +] + +[[package]] +name = "p3-baby-bear" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "num-bigint", + "p3-field", + "p3-mds", + "p3-monty-31", + "p3-poseidon2", + "p3-symmetric", + "rand", + "serde", +] + +[[package]] +name = "p3-blake3" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "blake3", + "p3-symmetric", +] + +[[package]] +name = "p3-challenger" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-field", + "p3-maybe-rayon", + "p3-symmetric", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-circle" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-commit" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-challenger", + "p3-field", + "p3-matrix", + "p3-util", + "serde", +] + +[[package]] +name = "p3-dft" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-field" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "num-bigint", + "num-integer", + "num-traits", + "nums", + "p3-util", + "rand", + "serde", +] + +[[package]] +name = "p3-fri" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-interpolation", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-goldilocks" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "num-bigint", + "p3-dft", + "p3-field", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "rand", + "serde", +] + +[[package]] +name = "p3-interpolation" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-field", + "p3-matrix", + "p3-util", +] + +[[package]] +name = "p3-keccak" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-symmetric", + "tiny-keccak", +] + +[[package]] +name = "p3-matrix" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-field", + "p3-maybe-rayon", + "p3-util", + "rand", + "serde", + "tracing", + "transpose", +] + +[[package]] +name = "p3-maybe-rayon" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" + +[[package]] +name = "p3-mds" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.12.1", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-symmetric", + "p3-util", + "rand", +] + +[[package]] +name = "p3-merkle-tree" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-commit", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-symmetric", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-mersenne-31" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "num-bigint", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "rand", + "serde", +] + +[[package]] +name = "p3-monty-31" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "num-bigint", + "p3-field", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "rand", + "serde", +] + +[[package]] +name = "p3-poseidon" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "p3-field", + "p3-mds", + "p3-symmetric", + "rand", +] + +[[package]] +name = "p3-poseidon2" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "gcd", + "p3-field", + "p3-mds", + "p3-symmetric", + "rand", +] + +[[package]] +name = "p3-symmetric" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-field", + "serde", +] + +[[package]] +name = "p3-uni-stark" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "itertools 0.13.0", + "p3-air", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-util" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" +dependencies = [ + "serde", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "plonky3_fibonacci" +version = "0.1.0" +dependencies = [ + "p3-air", + "p3-baby-bear", + "p3-blake3", + "p3-challenger", + "p3-circle", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-goldilocks", + "p3-keccak", + "p3-matrix", + "p3-mds", + "p3-merkle-tree", + "p3-mersenne-31", + "p3-poseidon", + "p3-poseidon2", + "p3-symmetric", + "p3-uni-stark", + "p3-util", + "rand", + "tracing-forest", + "tracing-subscriber", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-forest" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" +dependencies = [ + "ansi_term", + "smallvec", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/exercises/plonky3/fibonacci/src/main.rs b/exercises/plonky3/fibonacci/src/main.rs new file mode 100644 index 0000000000..d351a6748f --- /dev/null +++ b/exercises/plonky3/fibonacci/src/main.rs @@ -0,0 +1,126 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::Matrix; +use p3_matrix::dense::RowMajorMatrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +pub struct FibonacciAir { + pub num_steps: usize, + pub final_value: u32, +} + +impl BaseAir for FibonacciAir { + fn width(&self) -> usize { + 2 + } +} + +impl Air for FibonacciAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + let next = main.row_slice(1); + + + builder.when_first_row().assert_eq(local[0], AB::Expr::zero()); + builder.when_first_row().assert_eq(local[1], AB::Expr::one()); + + + builder.when_transition().assert_eq(next[0], local[1]); + builder.when_transition().assert_eq(next[1], local[0] + local[1]); + + + let final_value = AB::Expr::from_canonical_u32(self.final_value); + builder.when_last_row().assert_eq(local[1], final_value); + } +} + +pub fn generate_fibonacci_trace(num_steps: usize) -> RowMajorMatrix { + let mut values = Vec::with_capacity(num_steps * 2); + let mut a = F::zero(); + let mut b = F::one(); + for _ in 0..num_steps { + values.push(a); + values.push(b); + let c = a + b; + a = b; + b = c; + } + RowMajorMatrix::new(values, 2) +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + let num_steps = 16; + let final_value = 987; + let air = FibonacciAir { num_steps, final_value }; + let trace = generate_fibonacci_trace::(num_steps); + + 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![]) +} \ No newline at end of file From 63ab4a797b235e484c29e0722f5400ad4622c84d Mon Sep 17 00:00:00 2001 From: Kenil shah Date: Thu, 24 Oct 2024 12:00:40 +0700 Subject: [PATCH 03/16] main.rs shifted to src --- exercises/plonky3/fibonacci/main.rs | 126 ---------------------------- 1 file changed, 126 deletions(-) delete mode 100644 exercises/plonky3/fibonacci/main.rs diff --git a/exercises/plonky3/fibonacci/main.rs b/exercises/plonky3/fibonacci/main.rs deleted file mode 100644 index d351a6748f..0000000000 --- a/exercises/plonky3/fibonacci/main.rs +++ /dev/null @@ -1,126 +0,0 @@ -use std::fmt::Debug; -use std::marker::PhantomData; - -use p3_air::{Air, AirBuilder, BaseAir}; -use p3_field::{AbstractField, Field}; -use p3_matrix::Matrix; -use p3_matrix::dense::RowMajorMatrix; - -use p3_challenger::{HashChallenger, SerializingChallenger32}; -use p3_circle::CirclePcs; -use p3_commit::ExtensionMmcs; -use p3_field::extension::BinomialExtensionField; -use p3_fri::FriConfig; -use p3_keccak::Keccak256Hash; -use p3_merkle_tree::FieldMerkleTreeMmcs; -use p3_mersenne_31::Mersenne31; -use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; -use p3_uni_stark::{prove, verify, StarkConfig}; -use tracing_forest::util::LevelFilter; -use tracing_forest::ForestLayer; -use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{EnvFilter, Registry}; - -pub struct FibonacciAir { - pub num_steps: usize, - pub final_value: u32, -} - -impl BaseAir for FibonacciAir { - fn width(&self) -> usize { - 2 - } -} - -impl Air for FibonacciAir { - fn eval(&self, builder: &mut AB) { - let main = builder.main(); - let local = main.row_slice(0); - let next = main.row_slice(1); - - - builder.when_first_row().assert_eq(local[0], AB::Expr::zero()); - builder.when_first_row().assert_eq(local[1], AB::Expr::one()); - - - builder.when_transition().assert_eq(next[0], local[1]); - builder.when_transition().assert_eq(next[1], local[0] + local[1]); - - - let final_value = AB::Expr::from_canonical_u32(self.final_value); - builder.when_last_row().assert_eq(local[1], final_value); - } -} - -pub fn generate_fibonacci_trace(num_steps: usize) -> RowMajorMatrix { - let mut values = Vec::with_capacity(num_steps * 2); - let mut a = F::zero(); - let mut b = F::one(); - for _ in 0..num_steps { - values.push(a); - values.push(b); - let c = a + b; - a = b; - b = c; - } - RowMajorMatrix::new(values, 2) -} - -fn main() -> Result<(), impl Debug> { - 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 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 { - mmcs: val_mmcs, - fri_config, - _phantom: PhantomData, - }; - - type MyConfig = StarkConfig; - let config = MyConfig::new(pcs); - - let num_steps = 16; - let final_value = 987; - let air = FibonacciAir { num_steps, final_value }; - let trace = generate_fibonacci_trace::(num_steps); - - 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![]) -} \ No newline at end of file From bb9f9daa1ef528237ddfa4b346d55cab07f5457b Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Thu, 24 Oct 2024 13:17:37 +0700 Subject: [PATCH 04/16] fibonacci_mersenne31 example added --- exercises/plonky3/fibonacci/Cargo.lock | 58 +++++++++++++------------- exercises/plonky3/fibonacci/Cargo.toml | 4 +- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/exercises/plonky3/fibonacci/Cargo.lock b/exercises/plonky3/fibonacci/Cargo.lock index bcd7050552..bb93cf0e41 100644 --- a/exercises/plonky3/fibonacci/Cargo.lock +++ b/exercises/plonky3/fibonacci/Cargo.lock @@ -87,6 +87,35 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "fibonacci" +version = "0.1.0" +dependencies = [ + "p3-air", + "p3-baby-bear", + "p3-blake3", + "p3-challenger", + "p3-circle", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-goldilocks", + "p3-keccak", + "p3-matrix", + "p3-mds", + "p3-merkle-tree", + "p3-mersenne-31", + "p3-poseidon", + "p3-poseidon2", + "p3-symmetric", + "p3-uni-stark", + "p3-util", + "rand", + "tracing-forest", + "tracing-subscriber", +] + [[package]] name = "gcd" version = "2.3.0" @@ -522,35 +551,6 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" -[[package]] -name = "plonky3_fibonacci" -version = "0.1.0" -dependencies = [ - "p3-air", - "p3-baby-bear", - "p3-blake3", - "p3-challenger", - "p3-circle", - "p3-commit", - "p3-dft", - "p3-field", - "p3-fri", - "p3-goldilocks", - "p3-keccak", - "p3-matrix", - "p3-mds", - "p3-merkle-tree", - "p3-mersenne-31", - "p3-poseidon", - "p3-poseidon2", - "p3-symmetric", - "p3-uni-stark", - "p3-util", - "rand", - "tracing-forest", - "tracing-subscriber", -] - [[package]] name = "ppv-lite86" version = "0.2.20" diff --git a/exercises/plonky3/fibonacci/Cargo.toml b/exercises/plonky3/fibonacci/Cargo.toml index 98b310d620..d689a339e0 100644 --- a/exercises/plonky3/fibonacci/Cargo.toml +++ b/exercises/plonky3/fibonacci/Cargo.toml @@ -1,8 +1,10 @@ [package] -name = "plonky3_fibonacci" +name = "fibonacci" version = "0.1.0" edition = "2021" +[workspace] +members = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] From fc596f50b5ac8a8972b758ffcb153282f2111a45 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Fri, 25 Oct 2024 11:10:09 +0700 Subject: [PATCH 05/16] addition example added --- exercises/plonky3/fibonacci/Cargo.toml | 8 ++ exercises/plonky3/fibonacci/src/addition.rs | 133 ++++++++++++++++++ .../fibonacci/src/{main.rs => fibonacci.rs} | 33 +++-- 3 files changed, 160 insertions(+), 14 deletions(-) create mode 100644 exercises/plonky3/fibonacci/src/addition.rs rename exercises/plonky3/fibonacci/src/{main.rs => fibonacci.rs} (88%) diff --git a/exercises/plonky3/fibonacci/Cargo.toml b/exercises/plonky3/fibonacci/Cargo.toml index d689a339e0..f912a0f5ec 100644 --- a/exercises/plonky3/fibonacci/Cargo.toml +++ b/exercises/plonky3/fibonacci/Cargo.toml @@ -7,6 +7,14 @@ edition = "2021" members = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "fibonacci" +path = "src/fibonacci.rs" + +[[bin]] +name = "addition" +path = "src/addition.rs" + [dependencies] p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } p3-field = { git = "https://github.com/Plonky3/Plonky3.git" } diff --git a/exercises/plonky3/fibonacci/src/addition.rs b/exercises/plonky3/fibonacci/src/addition.rs new file mode 100644 index 0000000000..431e3c0130 --- /dev/null +++ b/exercises/plonky3/fibonacci/src/addition.rs @@ -0,0 +1,133 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::dense::RowMajorMatrix; +use p3_matrix::Matrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +// Define the Air for proving a + b = c +pub struct AdditionAir { + pub a: u32, + pub b: u32, + pub c: u32, +} + +impl BaseAir for AdditionAir { + fn width(&self) -> usize { + 3 // a, b, and c will be part of the trace. + } +} + +impl Air for AdditionAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + + // We only want to enforce the constraint on the first row + builder.when_first_row().assert_eq(local[0] + local[1], local[2]); + + // Add the final check to assert c is the correct sum, but only for the first row + let final_value = AB::Expr::from_canonical_u32(self.c); + builder.when_first_row().assert_eq(local[2], final_value); + } +} + +// Generate the trace for the equation a + b = c +// Generate the trace for the equation a + b = c, padded to at least 4 rows +pub fn generate_addition_trace(a: u32, b: u32, c: u32) -> RowMajorMatrix { + let mut values = Vec::with_capacity(3 * 4); // Padding to 4 rows + let a_f = F::from_canonical_u32(a); + let b_f = F::from_canonical_u32(b); + let c_f = F::from_canonical_u32(c); + + // First row: actual values of a, b, c + values.push(a_f); + values.push(b_f); + values.push(c_f); + + // Second, third, and fourth rows: just duplicate or pad with zeros + for _ in 0..3 { + values.push(F::zero()); + values.push(F::zero()); + values.push(F::zero()); + } + + RowMajorMatrix::new(values, 3) // Still 3 columns (a, b, c), but padded to 4 rows +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + + let a = 4; + let b = 5; + let c = 9; + let air = AdditionAir { a, b, c }; + let trace = generate_addition_trace::(a, b, c); + + 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![]) +} \ No newline at end of file diff --git a/exercises/plonky3/fibonacci/src/main.rs b/exercises/plonky3/fibonacci/src/fibonacci.rs similarity index 88% rename from exercises/plonky3/fibonacci/src/main.rs rename to exercises/plonky3/fibonacci/src/fibonacci.rs index d351a6748f..d4ef96ceb8 100644 --- a/exercises/plonky3/fibonacci/src/main.rs +++ b/exercises/plonky3/fibonacci/src/fibonacci.rs @@ -3,8 +3,8 @@ use std::marker::PhantomData; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::{AbstractField, Field}; -use p3_matrix::Matrix; use p3_matrix::dense::RowMajorMatrix; +use p3_matrix::Matrix; use p3_challenger::{HashChallenger, SerializingChallenger32}; use p3_circle::CirclePcs; @@ -29,7 +29,7 @@ pub struct FibonacciAir { impl BaseAir for FibonacciAir { fn width(&self) -> usize { - 2 + 2 } } @@ -39,14 +39,16 @@ impl Air for FibonacciAir { let local = main.row_slice(0); let next = main.row_slice(1); - - builder.when_first_row().assert_eq(local[0], AB::Expr::zero()); - builder.when_first_row().assert_eq(local[1], AB::Expr::one()); - - + builder + .when_first_row() + .assert_eq(local[0], AB::Expr::zero()); + builder + .when_first_row() + .assert_eq(local[1], AB::Expr::one()); builder.when_transition().assert_eq(next[0], local[1]); - builder.when_transition().assert_eq(next[1], local[0] + local[1]); - + builder + .when_transition() + .assert_eq(next[1], local[0] + local[1]); let final_value = AB::Expr::from_canonical_u32(self.final_value); builder.when_last_row().assert_eq(local[1], final_value); @@ -113,14 +115,17 @@ fn main() -> Result<(), impl Debug> { type MyConfig = StarkConfig; let config = MyConfig::new(pcs); - let num_steps = 16; - let final_value = 987; - let air = FibonacciAir { num_steps, final_value }; + let num_steps = 16; + let final_value = 987; + let air = FibonacciAir { + num_steps, + final_value, + }; let trace = generate_fibonacci_trace::(num_steps); 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![]) -} \ No newline at end of file +} From 125dcd6331c0bae39ff94ea1f00b3e567c38e43a Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Fri, 25 Oct 2024 11:22:00 +0700 Subject: [PATCH 06/16] separated addition --- exercises/plonky3/addition/Cargo.toml | 35 +++++++ exercises/plonky3/addition/src/main.rs | 127 +++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 exercises/plonky3/addition/Cargo.toml create mode 100644 exercises/plonky3/addition/src/main.rs diff --git a/exercises/plonky3/addition/Cargo.toml b/exercises/plonky3/addition/Cargo.toml new file mode 100644 index 0000000000..1c53659a54 --- /dev/null +++ b/exercises/plonky3/addition/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "fibonacci" +version = "0.1.0" +edition = "2021" + +[workspace] +members = [] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + + +[dependencies] +p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-field = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mersenne-31 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-util = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-circle = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-commit = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-dft = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-fri = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mds = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git" } +rand = "0.8.5" +tracing-subscriber = { version = "0.3.17", features = ["std", "env-filter"] } +tracing-forest = { version = "0.1.6", features = ["ansi", "smallvec"] } diff --git a/exercises/plonky3/addition/src/main.rs b/exercises/plonky3/addition/src/main.rs new file mode 100644 index 0000000000..4648010b3f --- /dev/null +++ b/exercises/plonky3/addition/src/main.rs @@ -0,0 +1,127 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::dense::RowMajorMatrix; +use p3_matrix::Matrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +pub struct AdditionAir { + pub a: u32, + pub b: u32, + pub c: u32, +} + +impl BaseAir for AdditionAir { + fn width(&self) -> usize { + 3 + } +} + +impl Air for AdditionAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + + builder + .when_first_row() + .assert_eq(local[0] + local[1], local[2]); + + let final_value = AB::Expr::from_canonical_u32(self.c); + builder.when_first_row().assert_eq(local[2], final_value); + } +} + +pub fn generate_addition_trace(a: u32, b: u32, c: u32) -> RowMajorMatrix { + let mut values = Vec::with_capacity(3 * 4); + let a_f = F::from_canonical_u32(a); + let b_f = F::from_canonical_u32(b); + let c_f = F::from_canonical_u32(c); + + values.push(a_f); + values.push(b_f); + values.push(c_f); + + for _ in 0..3 { + values.push(F::zero()); + values.push(F::zero()); + values.push(F::zero()); + } + + RowMajorMatrix::new(values, 3) +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + let a = 4; + let b = 5; + let c = 9; + let air = AdditionAir { a, b, c }; + let trace = generate_addition_trace::(a, b, c); + + 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![]) +} From 103bd3cdb8afcfd86e370b936080b450bee9a898 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Fri, 25 Oct 2024 11:34:51 +0700 Subject: [PATCH 07/16] separated addition --- exercises/plonky3/addition/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/plonky3/addition/src/main.rs b/exercises/plonky3/addition/src/main.rs index 4648010b3f..f01aa765b3 100644 --- a/exercises/plonky3/addition/src/main.rs +++ b/exercises/plonky3/addition/src/main.rs @@ -1,6 +1,5 @@ use std::fmt::Debug; use std::marker::PhantomData; - use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; From 78a814159c2261824f77e86985a278491d868592 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Fri, 25 Oct 2024 11:36:55 +0700 Subject: [PATCH 08/16] added plonky3 examples --- exercises/plonky3/addition/README.md | 0 exercises/plonky3/fibonacci/Cargo.toml | 7 - exercises/plonky3/fibonacci/src/addition.rs | 133 ------------------ .../fibonacci/src/{fibonacci.rs => main.rs} | 0 4 files changed, 140 deletions(-) create mode 100644 exercises/plonky3/addition/README.md delete mode 100644 exercises/plonky3/fibonacci/src/addition.rs rename exercises/plonky3/fibonacci/src/{fibonacci.rs => main.rs} (100%) diff --git a/exercises/plonky3/addition/README.md b/exercises/plonky3/addition/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/exercises/plonky3/fibonacci/Cargo.toml b/exercises/plonky3/fibonacci/Cargo.toml index f912a0f5ec..372bfc7657 100644 --- a/exercises/plonky3/fibonacci/Cargo.toml +++ b/exercises/plonky3/fibonacci/Cargo.toml @@ -7,13 +7,6 @@ edition = "2021" members = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[[bin]] -name = "fibonacci" -path = "src/fibonacci.rs" - -[[bin]] -name = "addition" -path = "src/addition.rs" [dependencies] p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } diff --git a/exercises/plonky3/fibonacci/src/addition.rs b/exercises/plonky3/fibonacci/src/addition.rs deleted file mode 100644 index 431e3c0130..0000000000 --- a/exercises/plonky3/fibonacci/src/addition.rs +++ /dev/null @@ -1,133 +0,0 @@ -use std::fmt::Debug; -use std::marker::PhantomData; - -use p3_air::{Air, AirBuilder, BaseAir}; -use p3_field::{AbstractField, Field}; -use p3_matrix::dense::RowMajorMatrix; -use p3_matrix::Matrix; - -use p3_challenger::{HashChallenger, SerializingChallenger32}; -use p3_circle::CirclePcs; -use p3_commit::ExtensionMmcs; -use p3_field::extension::BinomialExtensionField; -use p3_fri::FriConfig; -use p3_keccak::Keccak256Hash; -use p3_merkle_tree::FieldMerkleTreeMmcs; -use p3_mersenne_31::Mersenne31; -use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; -use p3_uni_stark::{prove, verify, StarkConfig}; -use tracing_forest::util::LevelFilter; -use tracing_forest::ForestLayer; -use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{EnvFilter, Registry}; - -// Define the Air for proving a + b = c -pub struct AdditionAir { - pub a: u32, - pub b: u32, - pub c: u32, -} - -impl BaseAir for AdditionAir { - fn width(&self) -> usize { - 3 // a, b, and c will be part of the trace. - } -} - -impl Air for AdditionAir { - fn eval(&self, builder: &mut AB) { - let main = builder.main(); - let local = main.row_slice(0); - - // We only want to enforce the constraint on the first row - builder.when_first_row().assert_eq(local[0] + local[1], local[2]); - - // Add the final check to assert c is the correct sum, but only for the first row - let final_value = AB::Expr::from_canonical_u32(self.c); - builder.when_first_row().assert_eq(local[2], final_value); - } -} - -// Generate the trace for the equation a + b = c -// Generate the trace for the equation a + b = c, padded to at least 4 rows -pub fn generate_addition_trace(a: u32, b: u32, c: u32) -> RowMajorMatrix { - let mut values = Vec::with_capacity(3 * 4); // Padding to 4 rows - let a_f = F::from_canonical_u32(a); - let b_f = F::from_canonical_u32(b); - let c_f = F::from_canonical_u32(c); - - // First row: actual values of a, b, c - values.push(a_f); - values.push(b_f); - values.push(c_f); - - // Second, third, and fourth rows: just duplicate or pad with zeros - for _ in 0..3 { - values.push(F::zero()); - values.push(F::zero()); - values.push(F::zero()); - } - - RowMajorMatrix::new(values, 3) // Still 3 columns (a, b, c), but padded to 4 rows -} - -fn main() -> Result<(), impl Debug> { - 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 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 { - mmcs: val_mmcs, - fri_config, - _phantom: PhantomData, - }; - - type MyConfig = StarkConfig; - let config = MyConfig::new(pcs); - - - let a = 4; - let b = 5; - let c = 9; - let air = AdditionAir { a, b, c }; - let trace = generate_addition_trace::(a, b, c); - - 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![]) -} \ No newline at end of file diff --git a/exercises/plonky3/fibonacci/src/fibonacci.rs b/exercises/plonky3/fibonacci/src/main.rs similarity index 100% rename from exercises/plonky3/fibonacci/src/fibonacci.rs rename to exercises/plonky3/fibonacci/src/main.rs From 50d90d63c8a881e87231f078324c24005d7d9c15 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Fri, 25 Oct 2024 11:59:23 +0700 Subject: [PATCH 09/16] added addition example --- exercises/plonky3/addition/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exercises/plonky3/addition/README.md b/exercises/plonky3/addition/README.md index e69de29bb2..b6d4f6fc53 100644 --- a/exercises/plonky3/addition/README.md +++ b/exercises/plonky3/addition/README.md @@ -0,0 +1,8 @@ +### Addition example using Plonky3 + +For now you will need to clone the repo and run the following command in the root directory: + +```bash +cd exercises/plonky3/addition +cargo run +``` From 519d8078bfe684caf3910ebd8b71912b503398f9 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Mon, 28 Oct 2024 11:12:33 +0700 Subject: [PATCH 10/16] added to zkmacro --- exercises/plonky3/{addition => }/Cargo.toml | 6 + exercises/plonky3/addition/README.md | 8 - exercises/plonky3/fibonacci/Cargo.lock | 889 ------------------ exercises/plonky3/fibonacci/Cargo.toml | 34 - .../{addition/src/main.rs => src/addition.rs} | 0 .../src/main.rs => src/fibonacci.rs} | 0 6 files changed, 6 insertions(+), 931 deletions(-) rename exercises/plonky3/{addition => }/Cargo.toml (94%) delete mode 100644 exercises/plonky3/addition/README.md delete mode 100644 exercises/plonky3/fibonacci/Cargo.lock delete mode 100644 exercises/plonky3/fibonacci/Cargo.toml rename exercises/plonky3/{addition/src/main.rs => src/addition.rs} (100%) rename exercises/plonky3/{fibonacci/src/main.rs => src/fibonacci.rs} (100%) diff --git a/exercises/plonky3/addition/Cargo.toml b/exercises/plonky3/Cargo.toml similarity index 94% rename from exercises/plonky3/addition/Cargo.toml rename to exercises/plonky3/Cargo.toml index 1c53659a54..fbcda59080 100644 --- a/exercises/plonky3/addition/Cargo.toml +++ b/exercises/plonky3/Cargo.toml @@ -6,7 +6,13 @@ edition = "2021" [workspace] members = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "fibonacci" +path = "src/fibonacci.rs" +[[bin]] +name = "addition" +path = "src/addition.rs" [dependencies] diff --git a/exercises/plonky3/addition/README.md b/exercises/plonky3/addition/README.md deleted file mode 100644 index b6d4f6fc53..0000000000 --- a/exercises/plonky3/addition/README.md +++ /dev/null @@ -1,8 +0,0 @@ -### Addition example using Plonky3 - -For now you will need to clone the repo and run the following command in the root directory: - -```bash -cd exercises/plonky3/addition -cargo run -``` diff --git a/exercises/plonky3/fibonacci/Cargo.lock b/exercises/plonky3/fibonacci/Cargo.lock deleted file mode 100644 index bb93cf0e41..0000000000 --- a/exercises/plonky3/fibonacci/Cargo.lock +++ /dev/null @@ -1,889 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "arrayref" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "blake3" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cc" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "constant_time_eq" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "fibonacci" -version = "0.1.0" -dependencies = [ - "p3-air", - "p3-baby-bear", - "p3-blake3", - "p3-challenger", - "p3-circle", - "p3-commit", - "p3-dft", - "p3-field", - "p3-fri", - "p3-goldilocks", - "p3-keccak", - "p3-matrix", - "p3-mds", - "p3-merkle-tree", - "p3-mersenne-31", - "p3-poseidon", - "p3-poseidon2", - "p3-symmetric", - "p3-uni-stark", - "p3-util", - "rand", - "tracing-forest", - "tracing-subscriber", -] - -[[package]] -name = "gcd" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", - "rand", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nums" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3c74f925fb8cfc49a8022f2afce48a0683b70f9e439885594e84c5edbf5b01" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "rand", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "p3-air" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-field", - "p3-matrix", -] - -[[package]] -name = "p3-baby-bear" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "num-bigint", - "p3-field", - "p3-mds", - "p3-monty-31", - "p3-poseidon2", - "p3-symmetric", - "rand", - "serde", -] - -[[package]] -name = "p3-blake3" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "blake3", - "p3-symmetric", -] - -[[package]] -name = "p3-challenger" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-field", - "p3-maybe-rayon", - "p3-symmetric", - "p3-util", - "tracing", -] - -[[package]] -name = "p3-circle" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-challenger", - "p3-commit", - "p3-dft", - "p3-field", - "p3-fri", - "p3-matrix", - "p3-maybe-rayon", - "p3-util", - "serde", - "tracing", -] - -[[package]] -name = "p3-commit" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-challenger", - "p3-field", - "p3-matrix", - "p3-util", - "serde", -] - -[[package]] -name = "p3-dft" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-field", - "p3-matrix", - "p3-maybe-rayon", - "p3-util", - "tracing", -] - -[[package]] -name = "p3-field" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "num-bigint", - "num-integer", - "num-traits", - "nums", - "p3-util", - "rand", - "serde", -] - -[[package]] -name = "p3-fri" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-challenger", - "p3-commit", - "p3-dft", - "p3-field", - "p3-interpolation", - "p3-matrix", - "p3-maybe-rayon", - "p3-util", - "serde", - "tracing", -] - -[[package]] -name = "p3-goldilocks" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "num-bigint", - "p3-dft", - "p3-field", - "p3-mds", - "p3-poseidon2", - "p3-symmetric", - "p3-util", - "rand", - "serde", -] - -[[package]] -name = "p3-interpolation" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-field", - "p3-matrix", - "p3-util", -] - -[[package]] -name = "p3-keccak" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-symmetric", - "tiny-keccak", -] - -[[package]] -name = "p3-matrix" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-field", - "p3-maybe-rayon", - "p3-util", - "rand", - "serde", - "tracing", - "transpose", -] - -[[package]] -name = "p3-maybe-rayon" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" - -[[package]] -name = "p3-mds" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.12.1", - "p3-dft", - "p3-field", - "p3-matrix", - "p3-symmetric", - "p3-util", - "rand", -] - -[[package]] -name = "p3-merkle-tree" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-commit", - "p3-field", - "p3-matrix", - "p3-maybe-rayon", - "p3-symmetric", - "p3-util", - "serde", - "tracing", -] - -[[package]] -name = "p3-mersenne-31" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "num-bigint", - "p3-dft", - "p3-field", - "p3-matrix", - "p3-maybe-rayon", - "p3-mds", - "p3-poseidon2", - "p3-symmetric", - "p3-util", - "rand", - "serde", -] - -[[package]] -name = "p3-monty-31" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "num-bigint", - "p3-field", - "p3-mds", - "p3-poseidon2", - "p3-symmetric", - "rand", - "serde", -] - -[[package]] -name = "p3-poseidon" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "p3-field", - "p3-mds", - "p3-symmetric", - "rand", -] - -[[package]] -name = "p3-poseidon2" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "gcd", - "p3-field", - "p3-mds", - "p3-symmetric", - "rand", -] - -[[package]] -name = "p3-symmetric" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-field", - "serde", -] - -[[package]] -name = "p3-uni-stark" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "itertools 0.13.0", - "p3-air", - "p3-challenger", - "p3-commit", - "p3-dft", - "p3-field", - "p3-matrix", - "p3-maybe-rayon", - "p3-util", - "serde", - "tracing", -] - -[[package]] -name = "p3-util" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git#a650e8c5b1e800de7fce43b4e9b22a41e36eaa03" -dependencies = [ - "serde", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "regex" -version = "1.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "serde" -version = "1.0.204" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.204" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "strength_reduce" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" - -[[package]] -name = "syn" -version = "2.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-forest" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" -dependencies = [ - "ansi_term", - "smallvec", - "thiserror", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "transpose" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" -dependencies = [ - "num-integer", - "strength_reduce", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/exercises/plonky3/fibonacci/Cargo.toml b/exercises/plonky3/fibonacci/Cargo.toml deleted file mode 100644 index 372bfc7657..0000000000 --- a/exercises/plonky3/fibonacci/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "fibonacci" -version = "0.1.0" -edition = "2021" - -[workspace] -members = [] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - - -[dependencies] -p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-field = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-mersenne-31 = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-util = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-circle = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-commit = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-dft = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-fri = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-mds = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-poseidon = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git" } -p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git" } -rand = "0.8.5" -tracing-subscriber = { version = "0.3.17", features = ["std", "env-filter"] } -tracing-forest = { version = "0.1.6", features = ["ansi", "smallvec"] } diff --git a/exercises/plonky3/addition/src/main.rs b/exercises/plonky3/src/addition.rs similarity index 100% rename from exercises/plonky3/addition/src/main.rs rename to exercises/plonky3/src/addition.rs diff --git a/exercises/plonky3/fibonacci/src/main.rs b/exercises/plonky3/src/fibonacci.rs similarity index 100% rename from exercises/plonky3/fibonacci/src/main.rs rename to exercises/plonky3/src/fibonacci.rs From 0ad98d95b99c2c8233095b83f28f903f4c396230 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Mon, 28 Oct 2024 23:32:11 +0700 Subject: [PATCH 11/16] added to zklings macro --- dev/Cargo.toml | 4 + exercises/plonky3/src/README.md | 0 solutions/plonky3/Cargo.toml | 41 +++++++++ solutions/plonky3/src/addition.rs | 126 +++++++++++++++++++++++++++ solutions/plonky3/src/fibonacci.rs | 131 +++++++++++++++++++++++++++++ zklings-macros/info.toml | 20 ++++- 6 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 exercises/plonky3/src/README.md create mode 100644 solutions/plonky3/Cargo.toml create mode 100644 solutions/plonky3/src/addition.rs create mode 100644 solutions/plonky3/src/fibonacci.rs diff --git a/dev/Cargo.toml b/dev/Cargo.toml index e8ade3b9b1..22abbfc348 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -24,6 +24,10 @@ bin = [ { name = "dlp1_sol", path = "../solutions/zk-protocols-basics/01_discrete_log_problem/dlp1.rs" }, { name = "dlp2", path = "../exercises/zk-protocols-basics/01_discrete_log_problem/dlp2.rs" }, { name = "dlp2_sol", path = "../solutions/zk-protocols-basics/01_discrete_log_problem/dlp2.rs" }, + { name = "addition", path = "../exercises/plonky3/src/addition.rs" }, + { name = "addition_sol", path = "../solutions/plonky3/src/addition.rs" }, + { name = "fibonacci", path = "../exercises/plonky3/src/fibonacci.rs" }, + { name = "fibonacci_sol", path = "../solutions/plonky3/src/fibonacci.rs" }, ] [package] diff --git a/exercises/plonky3/src/README.md b/exercises/plonky3/src/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/solutions/plonky3/Cargo.toml b/solutions/plonky3/Cargo.toml new file mode 100644 index 0000000000..fbcda59080 --- /dev/null +++ b/solutions/plonky3/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "fibonacci" +version = "0.1.0" +edition = "2021" + +[workspace] +members = [] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "fibonacci" +path = "src/fibonacci.rs" + +[[bin]] +name = "addition" +path = "src/addition.rs" + + +[dependencies] +p3-air = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-field = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mersenne-31 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-util = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-circle = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-commit = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-dft = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-fri = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-mds = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git" } +p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git" } +rand = "0.8.5" +tracing-subscriber = { version = "0.3.17", features = ["std", "env-filter"] } +tracing-forest = { version = "0.1.6", features = ["ansi", "smallvec"] } diff --git a/solutions/plonky3/src/addition.rs b/solutions/plonky3/src/addition.rs new file mode 100644 index 0000000000..f01aa765b3 --- /dev/null +++ b/solutions/plonky3/src/addition.rs @@ -0,0 +1,126 @@ +use std::fmt::Debug; +use std::marker::PhantomData; +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::dense::RowMajorMatrix; +use p3_matrix::Matrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +pub struct AdditionAir { + pub a: u32, + pub b: u32, + pub c: u32, +} + +impl BaseAir for AdditionAir { + fn width(&self) -> usize { + 3 + } +} + +impl Air for AdditionAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + + builder + .when_first_row() + .assert_eq(local[0] + local[1], local[2]); + + let final_value = AB::Expr::from_canonical_u32(self.c); + builder.when_first_row().assert_eq(local[2], final_value); + } +} + +pub fn generate_addition_trace(a: u32, b: u32, c: u32) -> RowMajorMatrix { + let mut values = Vec::with_capacity(3 * 4); + let a_f = F::from_canonical_u32(a); + let b_f = F::from_canonical_u32(b); + let c_f = F::from_canonical_u32(c); + + values.push(a_f); + values.push(b_f); + values.push(c_f); + + for _ in 0..3 { + values.push(F::zero()); + values.push(F::zero()); + values.push(F::zero()); + } + + RowMajorMatrix::new(values, 3) +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + let a = 4; + let b = 5; + let c = 9; + let air = AdditionAir { a, b, c }; + let trace = generate_addition_trace::(a, b, c); + + 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![]) +} diff --git a/solutions/plonky3/src/fibonacci.rs b/solutions/plonky3/src/fibonacci.rs new file mode 100644 index 0000000000..d4ef96ceb8 --- /dev/null +++ b/solutions/plonky3/src/fibonacci.rs @@ -0,0 +1,131 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, Field}; +use p3_matrix::dense::RowMajorMatrix; +use p3_matrix::Matrix; + +use p3_challenger::{HashChallenger, SerializingChallenger32}; +use p3_circle::CirclePcs; +use p3_commit::ExtensionMmcs; +use p3_field::extension::BinomialExtensionField; +use p3_fri::FriConfig; +use p3_keccak::Keccak256Hash; +use p3_merkle_tree::FieldMerkleTreeMmcs; +use p3_mersenne_31::Mersenne31; +use p3_symmetric::{CompressionFunctionFromHasher, SerializingHasher32}; +use p3_uni_stark::{prove, verify, StarkConfig}; +use tracing_forest::util::LevelFilter; +use tracing_forest::ForestLayer; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; +use tracing_subscriber::{EnvFilter, Registry}; + +pub struct FibonacciAir { + pub num_steps: usize, + pub final_value: u32, +} + +impl BaseAir for FibonacciAir { + fn width(&self) -> usize { + 2 + } +} + +impl Air for FibonacciAir { + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local = main.row_slice(0); + let next = main.row_slice(1); + + builder + .when_first_row() + .assert_eq(local[0], AB::Expr::zero()); + builder + .when_first_row() + .assert_eq(local[1], AB::Expr::one()); + builder.when_transition().assert_eq(next[0], local[1]); + builder + .when_transition() + .assert_eq(next[1], local[0] + local[1]); + + let final_value = AB::Expr::from_canonical_u32(self.final_value); + builder.when_last_row().assert_eq(local[1], final_value); + } +} + +pub fn generate_fibonacci_trace(num_steps: usize) -> RowMajorMatrix { + let mut values = Vec::with_capacity(num_steps * 2); + let mut a = F::zero(); + let mut b = F::one(); + for _ in 0..num_steps { + values.push(a); + values.push(b); + let c = a + b; + a = b; + b = c; + } + RowMajorMatrix::new(values, 2) +} + +fn main() -> Result<(), impl Debug> { + 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 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 { + mmcs: val_mmcs, + fri_config, + _phantom: PhantomData, + }; + + type MyConfig = StarkConfig; + let config = MyConfig::new(pcs); + + let num_steps = 16; + let final_value = 987; + let air = FibonacciAir { + num_steps, + final_value, + }; + let trace = generate_fibonacci_trace::(num_steps); + + 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![]) +} diff --git a/zklings-macros/info.toml b/zklings-macros/info.toml index c6b5b303f7..6b74ce97a6 100644 --- a/zklings-macros/info.toml +++ b/zklings-macros/info.toml @@ -166,4 +166,22 @@ dir = "zk-protocols-basics/01_discrete_log_problem" test = true hint = """ Implement the discrete log function returning an array with at least five solutions for the same modulo result. -""" \ No newline at end of file +""" + +[[exercises]] +name = "addition" +ext = "rs" +dir = "plonky3/src" +test = false +hint = """ +Proving addition of two numbers == third number +""" + +[[exercises]] +name = "fibonacci" +ext = "rs" +dir = "plonky3/src" +test = false +hint = """ +Proving fibonacci sequence using Plonky3 +""" From 7159160868cc01d7612f84cf902467c57b1923ea Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Tue, 5 Nov 2024 20:02:35 +0700 Subject: [PATCH 12/16] added readme --- exercises/plonky3/src/README.md | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/exercises/plonky3/src/README.md b/exercises/plonky3/src/README.md index e69de29bb2..32ab8e37b9 100644 --- a/exercises/plonky3/src/README.md +++ b/exercises/plonky3/src/README.md @@ -0,0 +1,86 @@ + + +## What is Plonky3 and How does it work? + +Plonky3 is a toolkit for implementing polynomial IOPs (PIOPs), such as STARKs, allowing developers to configure a variety of to-spec implementations from a single ZK proving system. + +Polygon Plonky3 supports several finite fields and hash functions. Currently, the only supported polynomial commitment scheme is FRI, but future releases will support several, including Brakedown. + +### Understand Plonky3 + +Plonky3 is a toolkit for designing a custom ZK proving implementation that can then be used to power application-optimized zkVMs and zkEVMs. + +In the same way an AI dev uses Pytorch and Tensorflow for building AI models, Polygon Plonky3 provides the same flexibility for building ZK proving systems. Polygon Plonky3 enables simple builds, such as the Fibonacci sequence prover in this repo that requires only one AIR Scripts, to complex systems, such as SP1 from Succinct labs with multiple AIR scripts for different components of a single zkVM. + +### How does Plonky3 work? + +Here's a TLDR version: + +1. Define the computation using Algebraic Intermediate Representation (AIR). +2. Generate a trace of the computation based on the AIR. +3. Utilize efficient finite field implementations for arithmetic operations. +4. Apply a vector commitment scheme (like MMCS) to create a succinct commitment to the trace. +5. Construct polynomials from the committed trace and commit to these polynomials using a polynomial commitment scheme (like Circle PCS). +6. Perform fast polynomial operations using FFTs and related algorithms. +7. Implement the FRI (Fast Reed-Solomon IOP) protocol to prove properties about committed polynomials. +8. Employ a challenger mechanism with the Fiat-Shamir heuristic for non-interactive proofs. +9. The unified STARK prover combines all components to generate the proof. +10. The verifier uses the same components to efficiently check the proof's validity. + +Plonky3's modular design allows for easy customization and optimization of different components, making it adaptable to various use cases and performance requirements. + +# Fibonacci Air Implementation in Plonky3 + +
+

+ + pull requests welcome badge + + + Twitter + +

+
+ +This repo implements a Fibonacci sequence generator and prover using the Plonky3 framework. + +## What is Plonky3 and How does it work? + +Plonky3 is a toolkit for implementing polynomial IOPs (PIOPs), such as STARKs, allowing developers to configure a variety of to-spec implementations from a single ZK proving system. + +Polygon Plonky3 supports several finite fields and hash functions. Currently, the only supported polynomial commitment scheme is FRI, but future releases will support several, including Brakedown. + +### Understand Plonky3 + +Plonky3 is a toolkit for designing a custom ZK proving implementation that can then be used to power application-optimized zkVMs and zkEVMs. + +In the same way an AI dev uses Pytorch and Tensorflow for building AI models, Polygon Plonky3 provides the same flexibility for building ZK proving systems. Polygon Plonky3 enables simple builds, such as the Fibonacci sequence prover in this repo that requires only one AIR Scripts, to complex systems, such as SP1 from Succinct labs with multiple AIR scripts for different components of a single zkVM. + +### How does Plonky3 work? + +Here's a TLDR version: + +1. Define the computation using Algebraic Intermediate Representation (AIR). +2. Generate a trace of the computation based on the AIR. +3. Utilize efficient finite field implementations for arithmetic operations. +4. Apply a vector commitment scheme (like MMCS) to create a succinct commitment to the trace. +5. Construct polynomials from the committed trace and commit to these polynomials using a polynomial commitment scheme (like Circle PCS). +6. Perform fast polynomial operations using FFTs and related algorithms. +7. Implement the FRI (Fast Reed-Solomon IOP) protocol to prove properties about committed polynomials. +8. Employ a challenger mechanism with the Fiat-Shamir heuristic for non-interactive proofs. +9. The unified STARK prover combines all components to generate the proof. +10. The verifier uses the same components to efficiently check the proof's validity. + +Plonky3's modular design allows for easy customization and optimization of different components, making it adaptable to various use cases and performance requirements. + +#### "Seems very complicated, I don't understand half of the steps." +*Don't worry, These are the underlying workflow of Plonky3 based ZK system, if you are builders who are using Plonky3, your main job is at Step 1 and Step 2, the rest is just configuration!* + +## Understand Steps to create a proof + +So now that we briefly walked through what Plonky3 is and how does it work, let's see this simple hands-on example to learn more! + +We will walk through our fibonacci example code via blow steps + +![Plonky3 Steps](https://github.com/BrianSeong99/plonky3_fibonacci/blob/master/pics/p3_fib_steps.png?raw=true) + From 47c5f71727e7eb8566f6ccd2485a300836d9222b Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Tue, 5 Nov 2024 20:04:02 +0700 Subject: [PATCH 13/16] added readme --- exercises/plonky3/src/README.md | 43 --------------------------------- 1 file changed, 43 deletions(-) diff --git a/exercises/plonky3/src/README.md b/exercises/plonky3/src/README.md index 32ab8e37b9..8ff3f3530f 100644 --- a/exercises/plonky3/src/README.md +++ b/exercises/plonky3/src/README.md @@ -1,48 +1,5 @@ -## What is Plonky3 and How does it work? - -Plonky3 is a toolkit for implementing polynomial IOPs (PIOPs), such as STARKs, allowing developers to configure a variety of to-spec implementations from a single ZK proving system. - -Polygon Plonky3 supports several finite fields and hash functions. Currently, the only supported polynomial commitment scheme is FRI, but future releases will support several, including Brakedown. - -### Understand Plonky3 - -Plonky3 is a toolkit for designing a custom ZK proving implementation that can then be used to power application-optimized zkVMs and zkEVMs. - -In the same way an AI dev uses Pytorch and Tensorflow for building AI models, Polygon Plonky3 provides the same flexibility for building ZK proving systems. Polygon Plonky3 enables simple builds, such as the Fibonacci sequence prover in this repo that requires only one AIR Scripts, to complex systems, such as SP1 from Succinct labs with multiple AIR scripts for different components of a single zkVM. - -### How does Plonky3 work? - -Here's a TLDR version: - -1. Define the computation using Algebraic Intermediate Representation (AIR). -2. Generate a trace of the computation based on the AIR. -3. Utilize efficient finite field implementations for arithmetic operations. -4. Apply a vector commitment scheme (like MMCS) to create a succinct commitment to the trace. -5. Construct polynomials from the committed trace and commit to these polynomials using a polynomial commitment scheme (like Circle PCS). -6. Perform fast polynomial operations using FFTs and related algorithms. -7. Implement the FRI (Fast Reed-Solomon IOP) protocol to prove properties about committed polynomials. -8. Employ a challenger mechanism with the Fiat-Shamir heuristic for non-interactive proofs. -9. The unified STARK prover combines all components to generate the proof. -10. The verifier uses the same components to efficiently check the proof's validity. - -Plonky3's modular design allows for easy customization and optimization of different components, making it adaptable to various use cases and performance requirements. - -# Fibonacci Air Implementation in Plonky3 - -
-

- - pull requests welcome badge - - - Twitter - -

-
- -This repo implements a Fibonacci sequence generator and prover using the Plonky3 framework. ## What is Plonky3 and How does it work? From ecb6536bfc771f1019132d0a554f0843fb236906 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Tue, 5 Nov 2024 20:05:38 +0700 Subject: [PATCH 14/16] added readme --- exercises/plonky3/{src => }/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename exercises/plonky3/{src => }/README.md (100%) diff --git a/exercises/plonky3/src/README.md b/exercises/plonky3/README.md similarity index 100% rename from exercises/plonky3/src/README.md rename to exercises/plonky3/README.md From a4ab2d89134d91564c7ad2e69a434619f7874a57 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Tue, 5 Nov 2024 20:51:47 +0700 Subject: [PATCH 15/16] added readme --- zklings-macros/info.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/zklings-macros/info.toml b/zklings-macros/info.toml index 6b74ce97a6..afe314bfce 100644 --- a/zklings-macros/info.toml +++ b/zklings-macros/info.toml @@ -185,3 +185,4 @@ test = false hint = """ Proving fibonacci sequence using Plonky3 """ + From 68d67c61da6bac940bb0670d03296e15d2950324 Mon Sep 17 00:00:00 2001 From: Kenil Shah Date: Tue, 5 Nov 2024 21:48:16 +0700 Subject: [PATCH 16/16] added readme --- exercises/plonky3/{ => src}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename exercises/plonky3/{ => src}/README.md (100%) diff --git a/exercises/plonky3/README.md b/exercises/plonky3/src/README.md similarity index 100% rename from exercises/plonky3/README.md rename to exercises/plonky3/src/README.md