diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ef4831f9a6..fee5069436 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -227,4 +227,4 @@ jobs: cd ../script cargo remove sp1-sdk cargo add sp1-sdk --path $GITHUB_WORKSPACE/sdk - SP1_DEV=1 RUST_LOG=info cargo run --release + SP1_DEV=1 RUST_LOG=info cargo run --release -- --prove diff --git a/.vscode/settings.json b/.vscode/settings.json index eb7b799168..7e4fd0ca18 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,12 +24,16 @@ // // Examples. // "examples/chess/program/Cargo.toml", // "examples/chess/script/Cargo.toml", + // "examples/cycle-tracking/program/Cargo.toml", + // "examples/cycle-tracking/script/Cargo.toml", // "examples/fibonacci/program/Cargo.toml", // "examples/fibonacci/script/Cargo.toml", // "examples/io/program/Cargo.toml", // "examples/io/script/Cargo.toml", // "examples/json/program/Cargo.toml", // "examples/json/script/Cargo.toml", + // "examples/patch-testing/program/Cargo.toml", + // "examples/patch-testing/script/Cargo.toml", // "examples/regex/program/Cargo.toml", // "examples/regex/script/Cargo.toml", // "examples/rsa/program/Cargo.toml", diff --git a/Cargo.lock b/Cargo.lock index 439931343f..d962c8f7b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,7 +58,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "arrayvec", "bytes", @@ -569,7 +569,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn 2.0.72", "which", @@ -706,9 +706,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -722,6 +722,26 @@ dependencies = [ "serde", ] +[[package]] +name = "capstone" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1097e608594dad3bad608295567f757742b883606fe150faf7a9740b849730d8" +dependencies = [ + "capstone-sys", + "libc", +] + +[[package]] +name = "capstone-sys" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7f651d5ec4c2a2e6c508f2c8032655003cd728ec85663e9796616990e25b5a" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "cargo-platform" version = "0.1.8" @@ -953,7 +973,7 @@ version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ - "encode_unicode", + "encode_unicode 0.3.6", "lazy_static", "libc", "unicode-width", @@ -1280,6 +1300,16 @@ dependencies = [ "dirs-sys", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + [[package]] name = "dirs-sys" version = "0.4.1" @@ -1292,6 +1322,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1313,9 +1354,9 @@ dependencies = [ [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecdsa" @@ -1359,7 +1400,6 @@ dependencies = [ "rand_core", "sec1", "subtle", - "tap", "zeroize", ] @@ -1375,6 +1415,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.34" @@ -2002,6 +2048,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "goblin" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" +dependencies = [ + "log", + "plain", + "scroll", +] + [[package]] name = "group" version = "0.12.1" @@ -2608,9 +2665,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" +checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -3585,6 +3642,12 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + [[package]] name = "plotters" version = "0.3.6" @@ -3638,11 +3701,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -3655,6 +3718,20 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "prettytable-rs" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eea25e07510aa6ab6547308ebe3c036016d162b8da920dbb079e3ba8acf3d95a" +dependencies = [ + "csv", + "encode_unicode 1.0.0", + "is-terminal", + "lazy_static", + "term", + "unicode-width", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -3748,34 +3825,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive 0.12.6", -] - -[[package]] -name = "prost" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" -dependencies = [ - "bytes", - "prost-derive 0.13.1", + "prost-derive", ] [[package]] name = "prost-build" -version = "0.13.1" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck", - "itertools 0.13.0", + "itertools 0.12.1", "log", "multimap", "once_cell", "petgraph", "prettyplease", - "prost 0.13.1", + "prost", "prost-types", "regex", "syn 2.0.72", @@ -3795,26 +3862,13 @@ dependencies = [ "syn 2.0.72", ] -[[package]] -name = "prost-derive" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" -dependencies = [ - "anyhow", - "itertools 0.13.0", - "proc-macro2", - "quote", - "syn 2.0.72", -] - [[package]] name = "prost-types" -version = "0.13.1" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.13.1", + "prost", ] [[package]] @@ -3834,16 +3888,17 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.12", + "socket2", "thiserror", "tokio", "tracing", @@ -3851,14 +3906,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.12", "slab", "thiserror", @@ -3875,6 +3930,7 @@ dependencies = [ "libc", "once_cell", "socket2", + "tracing", "windows-sys 0.52.0", ] @@ -3983,9 +4039,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -4095,7 +4151,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.12", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", "serde_json", @@ -4255,6 +4311,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -4329,9 +4391,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -4432,9 +4494,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.6" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ccfb12511cdb770157ace92d7dda771e498445b78f9886e8cdbc5140a4eced" +checksum = "8d777f59627453628a9a5be1ee8d948745b94b1dfc2d0c3099cbd9e08ab89e7c" dependencies = [ "sdd", ] @@ -4454,6 +4516,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scroll" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "scrypt" version = "0.10.0" @@ -4580,9 +4662,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", @@ -4699,9 +4781,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" +checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" dependencies = [ "cc", "cfg-if", @@ -4774,6 +4856,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "snowbridge-amcl" version = "1.0.2" @@ -4796,7 +4884,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anyhow", "cargo_metadata", @@ -4806,19 +4894,25 @@ dependencies = [ [[package]] name = "sp1-cli" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anstyle", "anyhow", + "capstone", "cargo_metadata", "clap", + "ctrlc", "dirs", "downloader", "futures-util", + "goblin", "hex", "indicatif", + "prettytable-rs", "rand", + "regex", "reqwest 0.12.5", + "rustc-demangle", "serde", "serde_json", "sp1-build", @@ -4827,6 +4921,7 @@ dependencies = [ "sp1-sdk", "target-lexicon", "tempfile", + "textwrap", "tokio", "vergen", "yansi", @@ -4834,7 +4929,7 @@ dependencies = [ [[package]] name = "sp1-core" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anyhow", "arrayref", @@ -4898,7 +4993,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "1.0.1" +version = "1.1.1" dependencies = [ "proc-macro2", "quote", @@ -4907,7 +5002,7 @@ dependencies = [ [[package]] name = "sp1-eval" -version = "1.0.1" +version = "1.1.1" dependencies = [ "clap", "csv", @@ -4918,7 +5013,7 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "1.0.1" +version = "1.1.1" dependencies = [ "cargo_metadata", "chrono", @@ -4927,20 +5022,17 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "hex", - "k256", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-primitives" -version = "1.0.1" +version = "1.1.1" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -4952,7 +5044,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anyhow", "bincode", @@ -4988,7 +5080,7 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit" -version = "1.0.1" +version = "1.1.1" dependencies = [ "bincode", "ff 0.13.0", @@ -5019,7 +5111,7 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit-v2" -version = "1.0.1" +version = "1.1.1" dependencies = [ "bincode", "ff 0.13.0", @@ -5057,7 +5149,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "1.0.1" +version = "1.1.1" dependencies = [ "backtrace", "itertools 0.13.0", @@ -5086,7 +5178,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "1.0.1" +version = "1.1.1" dependencies = [ "arrayref", "backtrace", @@ -5121,7 +5213,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core-v2" -version = "1.0.1" +version = "1.1.1" dependencies = [ "arrayref", "backtrace", @@ -5158,7 +5250,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "1.0.1" +version = "1.1.1" dependencies = [ "proc-macro2", "quote", @@ -5167,7 +5259,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-cli" -version = "1.0.1" +version = "1.1.1" dependencies = [ "bincode", "clap", @@ -5176,7 +5268,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "1.0.1" +version = "1.1.1" dependencies = [ "anyhow", "bincode", @@ -5200,7 +5292,7 @@ dependencies = [ [[package]] name = "sp1-recursion-program" -version = "1.0.1" +version = "1.1.1" dependencies = [ "itertools 0.13.0", "p3-air", @@ -5228,7 +5320,7 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "1.0.1" +version = "1.1.1" dependencies = [ "alloy-sol-types", "anyhow", @@ -5249,7 +5341,7 @@ dependencies = [ "p3-field", "p3-fri", "p3-matrix", - "prost 0.12.6", + "prost", "reqwest 0.12.5", "reqwest-middleware", "serde", @@ -5270,11 +5362,11 @@ dependencies = [ [[package]] name = "sp1-server" -version = "1.0.1" +version = "1.1.1" dependencies = [ "bincode", "ctrlc", - "prost 0.13.1", + "prost", "prost-build", "prost-types", "serde", @@ -5284,13 +5376,13 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "twirp", - "twirp-build", + "twirp-build-rs", + "twirp-rs", ] [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.1" dependencies = [ "bincode", "cfg-if", @@ -5487,16 +5579,39 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -5843,30 +5958,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] -name = "twirp" -version = "0.5.0" -source = "git+https://github.com/github/twirp-rs.git#d99f5362200479842caef7de2fffda747812102e" -dependencies = [ - "async-trait", - "axum", - "futures", - "http 1.1.0", - "http-body-util", - "hyper 1.4.1", - "prost 0.13.1", - "reqwest 0.12.5", - "serde", - "serde_json", - "thiserror", - "tokio", - "tower", - "url", -] - -[[package]] -name = "twirp-build" -version = "0.6.0" -source = "git+https://github.com/github/twirp-rs.git#d99f5362200479842caef7de2fffda747812102e" +name = "twirp-build-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25019d8d3244a6a380f621129e4ed63a04bb91617effd46440405aad43588c40" dependencies = [ "prost-build", ] @@ -5884,7 +5979,7 @@ dependencies = [ "http 1.1.0", "http-body-util", "hyper 1.4.1", - "prost 0.12.6", + "prost", "reqwest 0.12.5", "serde", "serde_json", @@ -5936,6 +6031,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.23" @@ -6205,11 +6306,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6255,6 +6356,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -6448,34 +6558,14 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", + "byteorder", + "zerocopy-derive", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d4a32e4971..2da2095b96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ exclude = ["examples/target"] resolver = "2" [workspace.package] -version = "1.0.1" +version = "1.1.1" edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/succinctlabs/sp1" @@ -44,25 +44,26 @@ debug = true debug-assertions = true [workspace.dependencies] -sp1-build = { path = "build", version = "1.0.1" } -sp1-derive = { path = "derive", version = "1.0.1" } -sp1-core = { path = "core", version = "1.0.1" } -sp1-cli = { path = "cli", version = "1.0.1", default-features = false } -sp1-eval = { path = "eval", version = "1.0.1", default-features = false } -sp1-helper = { path = "helper", version = "1.0.1", default-features = false } -sp1-primitives = { path = "primitives", version = "1.0.1" } -sp1-prover = { path = "prover", version = "1.0.1" } -sp1-recursion-compiler = { path = "recursion/compiler", version = "1.0.1" } -sp1-recursion-core = { path = "recursion/core", version = "1.0.1", default-features = false } -sp1-recursion-core-v2 = { path = "recursion/core-v2", version = "1.0.1", default-features = false } -sp1-recursion-derive = { path = "recursion/derive", version = "1.0.1", default-features = false } -sp1-recursion-gnark-ffi = { path = "recursion/gnark-ffi", version = "1.0.1", default-features = false } -sp1-recursion-program = { path = "recursion/program", version = "1.0.1", default-features = false } -sp1-recursion-circuit = { path = "recursion/circuit", version = "1.0.1", default-features = false } -sp1-recursion-circuit-v2 = { path = "recursion/circuit-v2", version = "1.0.1", default-features = false } -sp1-sdk = { path = "sdk", version = "1.0.1" } -sp1-lib = { path = "zkvm/lib", version = "1.0.1", default-features = false } -sp1-zkvm = { path = "zkvm/entrypoint", version = "1.0.1", default-features = false } +sp1-build = { path = "build", version = "1.1.1" } +sp1-derive = { path = "derive", version = "1.1.1" } +sp1-core = { path = "core", version = "1.1.1" } +sp1-cli = { path = "cli", version = "1.1.1", default-features = false } +sp1-eval = { path = "eval", version = "1.1.0", default-features = false } +sp1-helper = { path = "helper", version = "1.1.1", default-features = false } +sp1-primitives = { path = "primitives", version = "1.1.1" } +sp1-prover = { path = "prover", version = "1.1.1" } +sp1-recursion-compiler = { path = "recursion/compiler", version = "1.1.1" } +sp1-recursion-core = { path = "recursion/core", version = "1.1.1", default-features = false } +sp1-recursion-core-v2 = { path = "recursion/core-v2", version = "1.1.1", default-features = false } +sp1-recursion-derive = { path = "recursion/derive", version = "1.1.1", default-features = false } +sp1-recursion-gnark-ffi = { path = "recursion/gnark-ffi", version = "1.1.1", default-features = false } +sp1-recursion-program = { path = "recursion/program", version = "1.1.1", default-features = false } +sp1-recursion-circuit = { path = "recursion/circuit", version = "1.1.1", default-features = false } +sp1-recursion-circuit-v2 = { path = "recursion/circuit-v2", version = "1.1.1", default-features = false } +sp1-sdk = { path = "sdk", version = "1.1.1" } +sp1-server = { path = "server", version = "1.1.1" } +sp1-lib = { path = "zkvm/lib", version = "1.1.1", default-features = false } +sp1-zkvm = { path = "zkvm/entrypoint", version = "1.1.1", default-features = false } p3-air = "0.1.3-succinct" p3-field = "0.1.3-succinct" p3-commit = "0.1.3-succinct" diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b94340addd..77014462c3 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -11,12 +11,18 @@ cd core cargo test ``` +### Tips + +We recommend you install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension. + +Note that if you use `cargo prove new` inside a monorepo, you will need to add the path to the Cargo.toml file to `rust-analyzer.linkedProjects` to get full IDE support. + **Debug Constraint Failure** -To debug constraint failures, you can use the `--features debug` feature alongside `--no-default-features` to eliminate the "perf" feature. For example: +To debug constraint failures, you can use the `--features debug` feature. For example: ``` -RUST_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --release --features debug --no-default-features -- --nocapture +RUST_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --release --features debug -- --nocapture ``` ## Contributing to Docs diff --git a/README.md b/README.md index 163fd5a4d3..d9f0b98e46 100644 --- a/README.md +++ b/README.md @@ -2,52 +2,28 @@ ![SP1](./assets/sp1.png) -SP1 is a performant, 100% open-source, contributor-friendly zero-knowledge virtual machine (zkVM) that can prove the execution of arbitrary Rust (or any LLVM-compiled language) programs. SP1 democratizes access to ZKPs by allowing developers to use programmable truth with popular programming languages. - -SP1 is inspired by the open-source software movement and takes a collaborative approach towards building the best zkVM for rollups, coprocessors and other ZKP applications. We envision a diversity of contributors integrating the latest ZK innovations, creating a zkVM that is _performant_, _customizable_ and will stand the _test of time_. +SP1 is the fastest, most-feature complete zero-knowledge virtual machine (zkVM) that can prove the execution of arbitrary Rust (or any LLVM-compiled language) programs. SP1 makes ZK accessible to *any developer*, by making it easy to write ZKP programs in normal Rust code. **[Install](https://succinctlabs.github.io/sp1/getting-started/install.html)** | [Docs](https://succinctlabs.github.io/sp1) | [Examples](https://github.com/succinctlabs/sp1/tree/main/examples) | [Telegram Chat](https://t.me/+AzG4ws-kD24yMGYx) -## For Developers: Build with SP1 +## Getting Started -Today, developers can write programs, including complex, large programs like a ZK Tendermint light client, in Rust (with std support), generate proofs and verify them. Most Rust crates should be supported and can be used seamlessly by your program. Example programs can be found in the [examples](https://github.com/succinctlabs/sp1/tree/main/examples) folder. +Today, developers can write programs, including complex, large programs like a ZK Tendermint light client or type-1 zkEVM using Reth, in Rust (with std support), generate proofs and verify them. Most Rust crates should be supported and can be used seamlessly by your program. Example programs can be found in the [examples](https://github.com/succinctlabs/sp1/tree/main/examples) folder. To get started, make sure you have [Rust](https://www.rust-lang.org/tools/install) installed. Then follow the [installation](https://succinctlabs.github.io/sp1/getting-started/install.html) guide in the SP1 book and read the [getting started](https://succinctlabs.github.io/sp1/getting-started/quickstart.html) section. -For developers looking for inspiration on what to build, check out the open issues with the [showcase](https://github.com/succinctlabs/sp1/issues?q=is%3Aopen+is%3Aissue+label%3Ashowcase) label to see what sorts of programs that showcase the capabilities of SP1 are interesting to hack on. - -## For Contributors - -Open-source is a core part of SP1's ethos and key to its advantages. We wish to cultivate a vibrant community of open-source contributors that span individuals, teams and geographies. If you want to contribute, or follow along with contributor discussion, you can use our main Telegram to chat with us. Our contributor guidelines can be found in [CONTRIBUTING.md](./CONTRIBUTING.md). - -Find a list of [good first issues](https://github.com/succinctlabs/sp1/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+) in the open issues of this repo. We are always looking for contributors interested in tasks big and small, including minor chores across the codebase, optimizing performance, adding precompiles for commonly used cryptographic operations, adding documentation, creating new example programs and more. Please reach out in the Telegram chat if interested! - -## Roadmap - -Today, SP1 can generate and verify proofs for Rust programs that have been compiled to RISC-V. SP1 supports proving of programs of arbitrary length by using a unique "shared challenges" argument that allows the prover to shard a long computation into small shards, and then generate a global proof that these shards are properly connected together. - -The main priorities in the next few months are performance optimizations, getting the core zkVM -constraint logic audited, as well as wrapping the SP1 STARK proof into a SNARK proof that is cheaply -verifiable in the EVM (by adapting similar [previous -work](https://github.com/succinctlabs/gnark-plonky2-verifier) done by the Succinct Team). - -## Acknowledgements +## Security -We would like to acknowledge the projects below whose previous work has been instrumental in making this project a reality: +SP1 has undergone audits from [Veridise](https://www.veridise.com/), [Cantina](https://cantina.xyz/), +and [KALOS](https://kalos.xyz/) and is recommended for production use. The audit reports are available [here](./audits). -- [Plonky3](https://github.com/Plonky3/Plonky3): The SP1's prover is powered by the Plonky3 toolkit. -- [Valida](https://github.com/valida-xyz/valida): The SP1 cross-table lookup architecture, prover, borrow macro, and chip design are inspired by Valida. -- [RISC0](https://github.com/risc0/risc0): The SP1 Rust toolchain and install/build scripts for the toolchain borrow code from RISC0. -## Security +## For Contributors -SP1 has undergone audits from [Veridise](https://www.veridise.com/), [Cantina](https://cantina.xyz/), -and [KALOS](https://kalos.xyz/). The audit reports are available [here](./audits). +Open-source is a core part of SP1's ethos and key to its advantages. We wish to cultivate a vibrant community of open-source contributors that span individuals, teams and geographies. If you want to contribute, or follow along with contributor discussion, you can use our main Telegram to chat with us. Our contributor guidelines can be found in [CONTRIBUTING.md](./CONTRIBUTING.md). A quick overview of development tips can be found in [DEVELOPMENT.md](./DEVELOPMENT.md). -## Tips +We are always looking for contributors interested in tasks big and small, including minor chores across the codebase, optimizing performance, adding precompiles for commonly used cryptographic operations, adding documentation, creating new example programs and more. Please reach out in the Telegram chat if interested! -We recommend you install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension. -Note that if you use `cargo prove new` inside a monorepo, you will need to add the manifest file to `rust-analyzer.linkedProjects` to get full IDE support. diff --git a/assets/sp1.png b/assets/sp1.png index 86bf73e4a8..abe8a23b8e 100644 Binary files a/assets/sp1.png and b/assets/sp1.png differ diff --git a/book/SUMMARY.md b/book/SUMMARY.md index e1b6d0a19e..ba86732689 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -14,7 +14,7 @@ - [Project Template](./getting-started/project-template.md) -- [Hardware Requirements](./getting-started/hardware-requirements.md) +- [Proof Generation Requirements](./getting-started/hardware-requirements.md) # Writing Programs @@ -22,17 +22,18 @@ - [Basics](./writing-programs/basics.md) -- [Inputs & Outputs](./writing-programs/inputs-and-outputs.md) +- [Compiling Programs](./writing-programs/compiling.md) -- [Precompiles](./writing-programs/precompiles.md) +- [Inputs & Outputs](./writing-programs/inputs-and-outputs.md) - [Patched Crates](./writing-programs/patched-crates.md) +- [Precompiles](./writing-programs/precompiles.md) + - [Cycle Tracking](./writing-programs/cycle-tracking.md) - [Proof Aggregation](./writing-programs/proof-aggregation.md) -- [Build Script](./writing-programs/build-script.md) # Generating Proofs @@ -40,34 +41,34 @@ - [Basics](./generating-proofs/basics.md) -- [Prover Options](./generating-proofs/prover-options.md) +- [Proof Types](./generating-proofs/proof-types.md) + +- [Recommended Workflow](./generating-proofs/recommended-workflow.md) -- [Development Options](./generating-proofs/development-options.md) +- [Prover Network Beta](./generating-proofs/prover-network.md) + - [Usage](./generating-proofs/prover-network/usage.md) + - [Supported Versions](./generating-proofs/prover-network/versions.md) + +- [FAQ](./generating-proofs/sp1-sdk-faq.md) -- [Optimizing Performance](./generating-proofs/optimizing-performance.md) # Onchain Verification - [Setup](./onchain-verification/getting-started.md) -- [Solidity SDK](./onchain-verification/solidity-sdk.md) +- [Solidity Verifier](./onchain-verification/solidity-sdk.md) - [Contract Addresses](./onchain-verification/contract-addresses.md) -# Prover Network - -- [Setup](./prover-network/setup.md) - -- [Usage](./prover-network/usage.md) - -- [Supported Versions](./prover-network/versions.md) # Developers +- [Common Issues](./developers/common-issues.md) + - [Usage in CI](./developers/usage-in-ci.md) +- [RV32IM Specification](./developers/rv32im-specification.md) + - [Building PLONK Artifacts](./developers/building-plonk-artifacts.md) -- [Common Issues](./developers/common-issues.md) -- [RV32IM Specification](./developers/rv32im-specification.md) diff --git a/book/developers/common-issues.md b/book/developers/common-issues.md index ad65d124ac..e88d099483 100644 --- a/book/developers/common-issues.md +++ b/book/developers/common-issues.md @@ -1,5 +1,15 @@ # Common Issues +## Bus Error + +If you are running a executable that uses the `sp1-sdk` crate, you may encounter a bus error like this: + +```txt +zsh: bus error +``` + +This is fixed by running with the `--release` flag, as the `sp1-sdk` crate only supports release builds as of right now. + ## Alloy Errors If you are using a library that depends on `alloy_sol_types`, and encounter an error like this: @@ -12,25 +22,23 @@ This is likely due to two different versions of `alloy_sol_types` being used. To ```toml [dependencies] -sp1-sdk = { version = "1.0.1", default-features = false } +sp1-sdk = { version = "1.1.0", default-features = false } ``` This will configure out the `network` feature which will remove the dependency on `alloy_sol_types` and configure out the `NetworkProver`. ## Rust Version Errors -If you are using `alloy` or another library that has an MSRV (minimum support rust version) of 1.76.0 +If you are using `alloy` or another library that has an MSRV (minimum supported rust version) of 1.76.0 or higher, you may encounter an error like this when building your program. ```txt package `alloy v0.1.1 cannot be built because it requires rustc 1.76 or newer, while the currently active rustc version is 1.75.0-nightly` ``` -This is due to the fact that the Succinct Rust toolchain is built with version 1.75, which is older -than the MSRV of the `alloy` crate. Note: Once the Succinct Rust toolchain is updated, this error will -go away. +This is due to the fact that the Succinct Rust toolchain might be built with a lower version than the MSRV of the crates you are using. You can check the version of the Succinct Rust toolchain by running `cargo +succinct --version`. If we have released a more recent version of the Succinct Rust toolchain, you can update it by running `sp1up` again to update the toolchain and CLI to the latest version. -To fix this, you can: +You can also fix this issue with the following: - If using `cargo prove build` directly, pass the `--ignore-rust-version` flag: @@ -38,7 +46,7 @@ To fix this, you can: cargo prove build --ignore-rust-version ``` -- If using `build_program`, set `ignore_rust_version` to true inside the `BuildArgs` struct and use +- If using `build_program` in an `build.rs` file with the `sp1-build` crate, set `ignore_rust_version` to true inside the `BuildArgs` struct and use `build_program_with_args`: ```rust @@ -64,6 +72,8 @@ Segmentation fault (core dumped) Re-run your script with `--release`. +Note that the core `sp1-core` library and `sp1-recursion` require being compiled with the `release` profile. + ## C Binding Errors If you are building a program that uses C bindings or has dependencies that use C bindings, you may encounter the following errors: diff --git a/book/developers/rv32im-specification.md b/book/developers/rv32im-specification.md index eff0d8f665..84e8aa7584 100644 --- a/book/developers/rv32im-specification.md +++ b/book/developers/rv32im-specification.md @@ -4,5 +4,5 @@ SP1 implements the RISC-V RV32IM instruction set with some implementation detail - LW/SW memory access must be word aligned. - LH/LHU/SH memory access must be half-word aligned. -- Memory access is only valid for addresses [0x20, 0x78000000]. Accessing addresses outside of this range will result in undefined behavior. The global heap allocator in `sp1_zkvm` will panic if memory exceeds this range. -- The ECALL instruction is used for system calls and precompiles. Only valid syscall IDs should be called, and only using the specific convention of loading the ID into register T0 and arguments into registers A0 and A1. If the arguments are addresses, they must be word-aligned. Failure to follow this convention can result in UB. Correct usages can be found in the `sp1_zkvm` crate. +- Memory access is only valid for addresses `0x20, 0x78000000`. Accessing addresses outside of this range will result in undefined behavior. The global heap allocator in `sp1_zkvm` will panic if memory exceeds this range. +- The ECALL instruction is used for system calls and precompiles. Only valid syscall IDs should be called, and only using the specific convention of loading the ID into register T0 and arguments into registers A0 and A1. If the arguments are addresses, they must be word-aligned. Failure to follow this convention can result in undefined behavior. Correct usages can be found in the `sp1_zkvm` and `sp1_lib` crates. diff --git a/book/generating-proofs/advanced.md b/book/generating-proofs/advanced.md index cff65d9d85..2d17439012 100644 --- a/book/generating-proofs/advanced.md +++ b/book/generating-proofs/advanced.md @@ -48,7 +48,7 @@ RUSTFLAGS='-C target-cpu=native' cargo run --release Currently there is support for AVX512 and NEON SIMD instructions. For NEON, you must also enable the `sp1-sdk` feature `neon` in your script crate's `Cargo.toml` file. ```toml -sp1-sdk = { version = "1.0.1", features = ["neon"] } +sp1-sdk = { version = "1.1.0", features = ["neon"] } ``` ## Performance diff --git a/book/generating-proofs/basics.md b/book/generating-proofs/basics.md index ebae7128dd..06a3383ff0 100644 --- a/book/generating-proofs/basics.md +++ b/book/generating-proofs/basics.md @@ -1,6 +1,6 @@ # Generating Proofs: Basics -All the methods you'll need for generating proofs are included in the `sp1_sdk` crate. Most importantly, you'll need to use the `ProverClient` to setup a proving key and verifying key for your program and then use the `prove` and `verify` methods to generate and verify proofs. +All the methods you'll need for generating proofs are included in the `sp1_sdk` crate. Most importantly, you'll need to use the `ProverClient` to setup a proving key and verifying key for your program and then use the `execute`, `prove` and `verify` methods to execute your program, and generate and verify proofs. To make this more concrete, let's walk through a simple example of generating a proof for a Fiboancci program inside the zkVM. @@ -10,4 +10,10 @@ To make this more concrete, let's walk through a simple example of generating a {{#include ../../examples/fibonacci/script/src/main.rs}} ``` -You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. \ No newline at end of file +You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. Note that running the above script will generate a proof locally. + +
+WARNING: Local proving often is much slower than the prover network and for certain proof types (e.g. PLONK) requires a significant amount of RAM and will likely not work on a laptop. +
+ +We recommend using the [prover network](./prover-network.md) to generate proofs. Read more about the [recommended workflow](./recommended-workflow.md) for developing with SP1. \ No newline at end of file diff --git a/book/generating-proofs/development-options.md b/book/generating-proofs/development-options.md deleted file mode 100644 index e16fec2def..0000000000 --- a/book/generating-proofs/development-options.md +++ /dev/null @@ -1,26 +0,0 @@ -# Development Options - -## Execution Only - -We recommend that during the development of large programs (> 1 million cycles) you do not generate proofs each time. -Instead, you should have your script only execute the program with the RISC-V runtime and read `public_values`. Here is an example: - -```rust,noplayground -{{#include ../../examples/fibonacci/script/bin/execute.rs}} -``` - -If the execution of your program succeeds, then proof generation should succeed as well! (Unless there is a bug in our zkVM implementation.) - -## Logging and Tracing Information - -You can use `sp1_sdk::utils::setup_logger()` to enable logging information respectively. You can set the logging level with the `RUST_LOG` environment variable. - -```rust,noplayground -sp1_sdk::utils::setup_logger(); -``` - -Example of setting the logging level to `info` (other options are `debug`, `trace`, and `warn`): - -```bash -RUST_LOG=info cargo run --release -``` \ No newline at end of file diff --git a/book/generating-proofs/optimizing-performance.md b/book/generating-proofs/optimizing-performance.md deleted file mode 100644 index aa3d986923..0000000000 --- a/book/generating-proofs/optimizing-performance.md +++ /dev/null @@ -1,23 +0,0 @@ -# Optimizing Performance - -## CPU Acceleration - -SP1 supports CPU hardware acceleration using AVX256/512 and NEON SIMD instructions. To enable the acceleration, you can use the `RUSTFLAGS` environment variable to generate code that is optimized for your CPU. - -**AVX256 / NEON**: -```bash -RUSTFLAGS='-C target-cpu=native' cargo run --release -``` - -**AVX512**: -```bash -RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl' cargo run --release -``` - -## Enviroment Variables (Advanced) - -`SHARD_SIZE`: The number of cycles that will be proven in each "shard" in the SP1 zkVM. This value -must be set to a power of two. - -`SHARD_BATCH_SIZE`: The number of shards that will be proven in parallel. This value can be tuned -depending on how much memory your machine has to improve performance. \ No newline at end of file diff --git a/book/generating-proofs/proof-types.md b/book/generating-proofs/proof-types.md new file mode 100644 index 0000000000..717b9b9510 --- /dev/null +++ b/book/generating-proofs/proof-types.md @@ -0,0 +1,42 @@ +# Proof Types + +There are a few different types of proofs that can be generated by the SP1 zkVM. Each proof type has its own tradeoffs in terms of proof generation time, verification cost, and proof size. + +The `ProverClient` follows a "builder" pattern that allows you to configure the proof type and other options after creating a `ProverClient` and calling `prove` on it. + +For a full list of options, see the following [docs](https://docs.rs/sp1-sdk/1.1.0/sp1_sdk/action/struct.Prove.html). + +## Core (Default) + +The default prover mode generates a list of STARK proofs that in aggregate have size proportional to + the size of the execution. Use this in settings where you don't care about **verification cost / proof size**. + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).run().unwrap(); +``` + +## Compressed + +The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you +care about **verification cost / proof size**. This is useful for applications where you want to recursively verify SP1 proofs within SP1 (see the [proof aggregation](../writing-programs/proof-aggregation.md) section). + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).compressed().run().unwrap(); +``` + +## PLONK + +
+WARNING: The PLONK prover requires around 128GB of RAM and is only guaranteed to work on official releases of SP1. We recommend using the prover network to generate PLONK proofs. +
+ + +The PLONK prover mode generates a SNARK proof with extremely small proof size and low verification cost. +This mode is necessary for generating proofs that can be verified onchain for around ~300k gas. + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).plonk().run().unwrap(); +``` diff --git a/book/prover-network/setup.md b/book/generating-proofs/prover-network.md similarity index 92% rename from book/prover-network/setup.md rename to book/generating-proofs/prover-network.md index 575b333f45..54943b5410 100644 --- a/book/prover-network/setup.md +++ b/book/generating-proofs/prover-network.md @@ -1,6 +1,6 @@ -# Prover Network: Setup +# Prover Network Beta -> **Currently, the supported version of SP1 on the prover network is `v1.0.1`.** +> **Currently, the supported version of SP1 on the prover network is `v1.1.0`.** So far we've explored how to generate proofs locally, but this can actually be inconvenient on local machines due to high memory / CPU requirements, especially for very large programs. @@ -15,6 +15,8 @@ Network. Completing this form requires you to complete the [key setup](#key-setu The prover network uses Secp256k1 keypairs for authentication, similar to Ethereum wallets. You may generate a new keypair explicitly for use with the prover network, or use an existing keypair. **You do not need to hold any funds in this account, it is used solely for access control.** +After you have your whitelisted key, read the [Usage](./prover-network/usage.md) section to learn how to use it. + ### Generate a new keypair with `cast` Prover network keypair credentials can be generated using the @@ -36,7 +38,7 @@ cast wallet new which will give you an output similar to this: -![Screenshot from running 'cast wallet new' to generate an SP1_PRIVATE_KEY.](key.png) +![Screenshot from running 'cast wallet new' to generate an SP1_PRIVATE_KEY.](./prover-network/key.png) The "Address" what you should submit in the [form](https://forms.gle/rTUvhstS8PFfv9B3A), in the example above this is `0x552f0FC6D736ed965CE07a3D71aA639De15B627b`. The "Private key" should be kept safe and secure. When interacting with the network, you will set your `SP1_PRIVATE_KEY` environment variable diff --git a/book/prover-network/explorer.png b/book/generating-proofs/prover-network/explorer.png similarity index 100% rename from book/prover-network/explorer.png rename to book/generating-proofs/prover-network/explorer.png diff --git a/book/prover-network/key.png b/book/generating-proofs/prover-network/key.png similarity index 100% rename from book/prover-network/key.png rename to book/generating-proofs/prover-network/key.png diff --git a/book/prover-network/usage.md b/book/generating-proofs/prover-network/usage.md similarity index 90% rename from book/prover-network/usage.md rename to book/generating-proofs/prover-network/usage.md index e21304e1b7..c334228d4c 100644 --- a/book/prover-network/usage.md +++ b/book/generating-proofs/prover-network/usage.md @@ -1,6 +1,6 @@ # Prover Network: Usage -> **Currently, the supported version of SP1 on the prover network is `v1.0.1`.** +> **Currently, the supported version of SP1 on the prover network is `v1.1.0`.** ## Sending a proof request @@ -19,8 +19,8 @@ SP1_PROVER=network SP1_PRIVATE_KEY=... RUST_LOG=info cargo run --release - `SP1_PROVER` should be set to `network` when using the prover network. -- `SP1_PRIVATE_KEY` should be set to your [private key](./setup.md#key-setup). You will need - to be using a [permissioned](./setup.md#get-access) key to use the network. +- `SP1_PRIVATE_KEY` should be set to your [private key](../prover-network.md#key-setup). You will need + to be using a [whitelisted](../prover-network.md#get-access) key to use the network. When you call any of the prove functions in ProverClient now, it will first simulate your program, then wait for it to be proven through the network and finally return the proof. @@ -28,7 +28,7 @@ When you call any of the prove functions in ProverClient now, it will first simu You can view your proof and other running proofs on the [explorer](https://explorer.succinct.xyz/). The page for your proof will show details such as the stage of your proof and the cycles used. It also shows the program hash which is the keccak256 of the program bytes. -![Screenshot from explorer.succinct.xyz showing the details of a proof including status, stage, type, program, requester, prover, CPU cycles used, time requested, and time claimed.](explorer.png) +![Screenshot from explorer.succinct.xyz showing the details of a proof including status, stage, type, program, requester, prover, CPU cycles used, time requested, and time claimed.](./explorer.png) ## Advanced Usage diff --git a/book/prover-network/versions.md b/book/generating-proofs/prover-network/versions.md similarity index 87% rename from book/prover-network/versions.md rename to book/generating-proofs/prover-network/versions.md index adfb4d8abb..bf00ee83c3 100644 --- a/book/prover-network/versions.md +++ b/book/generating-proofs/prover-network/versions.md @@ -4,7 +4,7 @@ The prover network currently only supports specific versions of SP1: | Environment | RPC URL | Supported Version | | ----------- | -------------------------- | ----------------- | -| Prod | `https://rpc.succinct.xyz` | v1.0.1 | +| Prod | `https://rpc.succinct.xyz` | v1.1.0 | If you submit a proof request to the prover network and your are not using the supported version, you will receive an error message. @@ -14,14 +14,14 @@ You must switch to a supported version before submitting a proof. To do so, repl ```toml [dependencies] -sp1-zkvm = "1.0.1" +sp1-zkvm = "1.1.0" ``` replace the `sp1-sdk` version in your script's `Cargo.toml`: ```toml [dependencies] -sp1-sdk = "1.0.1" +sp1-sdk = "1.1.0" ``` Re-build your program and script, and then try again. diff --git a/book/generating-proofs/prover-options.md b/book/generating-proofs/prover-options.md deleted file mode 100644 index bae82bdd4b..0000000000 --- a/book/generating-proofs/prover-options.md +++ /dev/null @@ -1,38 +0,0 @@ -# Prover Options - -The prover options can be configured using a "builder" pattern after creating a `ProverClient` and -calling `prove` on it. - -For a full list of options, see the [SP1 SDK](https://github.com/succinctlabs/sp1/blob/dev/sdk/src/action.rs). - -## Core (Default) - -The default prover mode generates a list of STARK proofs that in aggregate have size proportional to - the size of the execution. Use this in settings where you don't care about **verification cost / proof size**. - -```rust,noplayground -let client = ProverClient::new(); -client.prove(&pk, stdin).run().unwrap(); -``` - -## Compressed - -The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you -care about **verification cost / proof size**. - -```rust,noplayground -let client = ProverClient::new(); -client.prove(&pk, stdin).compressed().run().unwrap(); -``` - -## PLONK - -> WARNING: The PLONK prover requires around 128GB of RAM and is only guaranteed to work on official releases of SP1. - -The PLONK prover mode generates a SNARK proof with extremely small proof size and low verification cost. -This mode is necessary for generating proofs that can be verified onchain for around ~300k gas. - -```rust,noplayground -let client = ProverClient::new(); -client.prove(&pk, stdin).plonk().run().unwrap(); -``` diff --git a/book/generating-proofs/recommended-workflow.md b/book/generating-proofs/recommended-workflow.md new file mode 100644 index 0000000000..1f2af07972 --- /dev/null +++ b/book/generating-proofs/recommended-workflow.md @@ -0,0 +1,57 @@ +# Recommended Workflow for Developing with SP1 + +We recommend the following workflow for developing with SP1. + +## Step 1: Iterate on your program with execution only + +While iterating on your SP1 program, you should **only execute** the program with the RISC-V runtime. This will allow you to verify the correctness of your program and test the `SP1Stdin` as well as the `SP1PublicValues` that are returned, without having to generate a proof (which can be slow and/or expensive). If the execution of your program succeeds, then proof generation should succeed as well! + +```rust,noplayground +{{#include ../../examples/fibonacci/script/bin/execute.rs}} +``` + +Note that printing out the total number of executed cycles and the full execution report provides helpful insight into proof generation latency and cost either for local proving or when using the prover network. + +**Crate Setup:** We recommend that your program crate that defines the `main` function (around which you wrap the `sp1_zkvm::entrypoint!` macro) should be kept minimal. Most of your business logic should be in a separate crate (in the same repo/workspace) that can be tested independently and that is not tied to the SP1 zkVM. This will allow you to unit test your program logic without having to worry about the `zkvm` compilation target. This will also allow you to efficient reuse types between your program crate and your crate that generates proofs. + +## Step 2: Generate proofs + +After you have iterated on your program and finalized that it works correctly, you can generate proofs for your program for final end to end testing or production use. + +### Generating proofs on the prover network (recommended) + +Using Succinct's prover prover network will generally be faster and cheaper than local proving, as it parallelizes proof generation amongst multiple machines and also uses SP1's GPU prover that is not yet available for local proving. Follow the [setup instructions](./prover-network.md) to get started with the prover network. Using the prover network only requires adding 1 environment variable from a regular SP1 proof generation script with the `ProverClient`. + +There are a few things to keep in mind when using the prover network. + +### Prover Network FAQ + +#### Benchmarking latency on the prover network + +The prover network currently parallelizes proof generation across multiple machines. This means the latency of proof generation does not scale linearly with the number of cycles of your program, but rather with the number of cycles of your program divided by the number of currently available machines on the prover network. + +Our prover network currently has limited capacity because it is still in beta. If you have an extremely latency sensitive use-case and you want to figure out the **minimal latency possible** for your program, you should [reach out to us](https://partner.succinct.xyz/) and we can onboard you to our reserved capacity cluster that has a dedicated instances that can significantly reduce latency. + +#### Costs on the prover network + +The cost of proof generation on the prover network scales approximately linearly with the number of cycles of your program (along with the number of `syscalls` that your program makes). For larger workloads with regular proof frequency (like rollups and light clients), we can offer discounted pricing. To figure out how much your program will cost to prove, you can get [in touch with us](https://partner.succinct.xyz/) to discuss pricing options. + +Note that **latency is not the same as cost**, because we parallelize proof generation across multiple machines, so two proofs with the same latency can be using a different number of machines, impacting the cost. + +#### Benchmarking on small vs. large programs + +In SP1, there is a fixed overhead for proving that is independent of your program's cycle count. This means that benchmarking on *small programs* is not representative of the performance of larger programs. To get an idea of the scale of programs for real-world workloads, you can refer to our [benchmarking blog post](https://blog.succinct.xyz/sp1-production-benchmarks) and also some numbers below: + +* An average Ethereum block can be between 100-500M cycles (including merkle proof verification for storage and execution of transactions) with our `keccak` and `secp256k1` precompiles. +* For a Tendermint light client, the average cycle count can be between 10M and 50M cycles (including our ed25519 precompiles). +* We consider programs with <2M cycles to be "small" and by default, the fixed overhead of proving will dominate the proof latency. If latency is incredibly important for your use-case, we can specialize the prover network for your program if you reach out to us. + +Note that if you generate PLONK proofs on the prover network, you will encounter a fixed overhead of 90 seconds for the STARK -> SNARK wrapping step. We're actively working on reducing this overhead in our next release. + +#### On-Demand vs. Reserved Capacity + +The prover network is currently in beta and has limited capacity. For high volume use-cases, we can offer discounted pricing and a reserved capacity cluster that has a dedicated instances that can significantly reduce latency and have higher throughput and guaranteed SLAs. + +### Generating proofs locally + +If you want to generate proofs locally, you can use the `sp1_sdk` crate to generate proofs locally as outlined in the [Basics](./basics.md) section. By default, the `ProverClient` will generate proofs locally using your CPU. Check out the hardware requirements for locally proving [here](../getting-started/hardware-requirements.md#local-proving). \ No newline at end of file diff --git a/book/generating-proofs/setup.md b/book/generating-proofs/setup.md index 42726a99fa..9a8561cea0 100644 --- a/book/generating-proofs/setup.md +++ b/book/generating-proofs/setup.md @@ -1,6 +1,6 @@ # Generating Proofs: Setup -In this section, we will teach you how to setup a self-contained crate which can generate proofs of programs that have been compiled with the SP1 toolchain inside the SP1 zkVM. +In this section, we will teach you how to setup a self-contained crate which can generate proofs of programs that have been compiled with the SP1 toolchain inside the SP1 zkVM, using the `sp1-sdk` crate. ## CLI (Recommended) @@ -32,7 +32,7 @@ name = "script" edition = "2021" [dependencies] -sp1-sdk = "1.0.1" +sp1-sdk = "1.1.0" ``` The `sp1-sdk` crate includes the necessary utilities to generate, save, and verify proofs. diff --git a/book/generating-proofs/sp1-sdk-faq.md b/book/generating-proofs/sp1-sdk-faq.md new file mode 100644 index 0000000000..fcfdfe678e --- /dev/null +++ b/book/generating-proofs/sp1-sdk-faq.md @@ -0,0 +1,34 @@ +# FAQ + +## Logging and Tracing Information + +You can use `sp1_sdk::utils::setup_logger()` to enable logging information respectively. You can set the logging level with the `RUST_LOG` environment variable. + +```rust,noplayground +sp1_sdk::utils::setup_logger(); +``` + +Example of setting the logging level to `info` (other options are `debug`, `trace`, and `warn`): + +```bash +RUST_LOG=info cargo run --release +``` + + +## Optimize Local Proving with CPU Acceleration + +SP1 supports CPU hardware acceleration using AVX256/512 and NEON SIMD instructions. To enable the acceleration, you can use the `RUSTFLAGS` environment variable to generate code that is optimized for your CPU. + +**AVX2 / NEON**: +```bash +RUSTFLAGS='-C target-cpu=native' cargo run --release +``` + +**AVX512**: +```bash +RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl' cargo run --release +``` + +## GPU Proving + +Note that SP1 has a GPU prover that is currently in beta, but it is not yet supported in the `sp1-sdk` crate and has experimental support in the `sp1-prover` crate. Our prover network currently runs the SP1 GPU prover, so the recommended way to generate proofs with GPU is via the prover network. \ No newline at end of file diff --git a/book/getting-started/hardware-requirements.md b/book/getting-started/hardware-requirements.md index dc6edd3289..bd31825fe3 100644 --- a/book/getting-started/hardware-requirements.md +++ b/book/getting-started/hardware-requirements.md @@ -1,7 +1,14 @@ -# Hardware Requirements +# Proof Generation Requirements -The hardware requirements for SP1 depend on what features you want to use. These requirements can also -change over time as the design of the zKVM evolves. +## Prover Network (Recommended) + +We recommend that developers who want to use SP1 for non-trivial programs generate proofs on our [Prover Network's](../generating-proofs/prover-network.md) private beta. The prover network generates SP1 proofs across multiple machines, reducing latency and also runs SP1 on optimized hardware instances that result in faster + cheaper proof generation times (including SP1's GPU prover that is not yet available for local proving). + +We recommend that for any production benchmarking, you use the prover network to estimate latency and costs of proof generation. + +## Local Proving + +If you want to generate SP1 proofs locally, here is an overview of the hardware requirements required. These requires depend on which [types of proofs](../generating-proofs/proof-types.md) you want to generate and can also change over time as the design of the zKVM evolves. **The most important requirement is CPU for performance/latency and RAM to prevent running out of memory.** @@ -24,11 +31,12 @@ Our prover requires keeping large matrices (i.e., traces) in memory to generate have a minimum memory requirement, meaning that if you have less than this amount of memory, the process will OOM. This effect is most noticeable when using the PLONK prover, which requires around 128GB of RAM to generate a proof. We use PLONK to avoid -having to perform a trusted setup, which other SNARK provers like Groth16 require. We have future optimizations planned to reduce +having to perform a trusted setup, which other SNARKs like Groth16 require. We have future optimizations planned to reduce the memory requirements of the PLONK prover substantially. ### Disk Disk is required to install the SP1 zkVM toolchain and to install the trused setup artifacts, if you plan to locally build the PLONK prover. -Furthermore, disk is used to checkpoint the state of the program execution, which is required to generate the proofs. \ No newline at end of file +Furthermore, disk is used to checkpoint the state of the program execution, which is required to generate the proofs. + diff --git a/book/getting-started/install.md b/book/getting-started/install.md index 0b91a464e6..dbb91c7899 100644 --- a/book/getting-started/install.md +++ b/book/getting-started/install.md @@ -1,7 +1,7 @@ # Installation SP1 currently runs on Linux and macOS. You can either use prebuilt binaries through sp1up or -build the toolchain and CLI from source. +build the Succinct [Rust toolchain](https://rust-lang.github.io/rustup/concepts/toolchains.html) and CLI from source. ## Requirements @@ -11,8 +11,6 @@ build the toolchain and CLI from source. ## Option 1: Prebuilt Binaries (Recommended) -Currently our prebuilt binaries are built on Ubuntu 20.04 (22.04 on ARM) and macOS. If your OS uses an older GLIBC version, it's possible these may not work and you will need to [build the toolchain from source](#option-2-building-from-source). - sp1up is the SP1 toolchain installer. Open your terminal and run the following command and follow the instructions: ```bash @@ -21,7 +19,7 @@ curl -L https://sp1.succinct.xyz | bash Then simply follow the instructions on-screen, which will make the `sp1up` command available in your CLI. -After following the instructions, you can run `sp1up` to install the toolchain: +After following the instructions, you can run `sp1up` to install the toolchain and the `cargo prove` CLI: ```bash sp1up @@ -30,19 +28,40 @@ sp1up This will install two things: 1. The `succinct` Rust toolchain which has support for the `riscv32im-succinct-zkvm-elf` compilation target. -2. `cargo prove` CLI tool that will let you compile provable programs and then prove their correctness. +2. `cargo prove` CLI tool that provides convenient commands for compiling SP1 programs and other helper functionality. -You can verify the installation by running `cargo prove --version`: +You can verify the installation of the CLI by running `cargo prove --version`: ```bash cargo prove --version ``` +You can check the version of the Succinct Rust toolchain by running: + +```bash +RUSTUP_TOOLCHAIN=succinct cargo --version +``` +or equivalently: + +```bash +cargo +succinct --version +``` + If this works, go to the [next section](./quickstart.md) to compile and prove a simple zkVM program. ### Troubleshooting -If you experience [rate-limiting](https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#rate-limiting) when using the `sp1up` command, you can resolve this by using the `--token` flag and providing your GitHub token. +#### Rate-limiting + +If you experience [rate-limiting](https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#rate-limiting) when using the `sp1up` command, you can resolve this by using the `--token` flag and providing your GitHub token. To create a Github token, follow the instructions [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic). + + + +#### Unsupported OS Architectures + +Currently our prebuilt binaries are built on Ubuntu 20.04 (22.04 on ARM) and macOS. If your OS uses an older GLIBC version, it's possible these may not work and you will need to [build the toolchain from source](#option-2-building-from-source). + +#### Conflicting `cargo-prove` installations If you have installed `cargo-prove` from source, it may conflict with `sp1up`'s `cargo-prove` installation or vice versa. You can remove the `cargo-prove` that was installed from source with the following command: @@ -56,8 +75,13 @@ Or, you can remove the `cargo-prove` that was installed through `sp1up`: rm ~/.sp1/bin/cargo-prove ``` + ## Option 2: Building from Source +
+Warning: This option will take a long time to build and is only recommended for advanced users. +
+ Make sure you have installed the [dependencies](https://github.com/rust-lang/rust/blob/master/INSTALL.md#dependencies) needed to build the rust toolchain from source. Clone the `sp1` repository and navigate to the root directory. diff --git a/book/getting-started/project-template.md b/book/getting-started/project-template.md index d9c04ed48d..b6cbd8d733 100644 --- a/book/getting-started/project-template.md +++ b/book/getting-started/project-template.md @@ -1,3 +1,5 @@ # Project Template -Another option for getting started with SP1 is to use the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/tree/main). \ No newline at end of file +Another option for getting started with SP1 is to use the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/tree/main). + +You can use this as a Github template to create a new repository that has a SP1 program, a script to generate proofs, and also a contracts folder that contains a Solidity contract that can verify SP1 proofs on any EVM chain. diff --git a/book/getting-started/quickstart.md b/book/getting-started/quickstart.md index 86a2de7143..2abd480541 100644 --- a/book/getting-started/quickstart.md +++ b/book/getting-started/quickstart.md @@ -2,28 +2,49 @@ In this section, we will show you how to create a simple Fibonacci program using the SP1 zkVM. -## Create Project +## Create an SP1 Project -The first step is to create a new project using the `cargo prove new ` command. This command will create a new folder in your current directory. +### Option 1: Cargo Prove New CLI (Recommended) + +You can use the `cargo prove` CLI to create a new project using the `cargo prove new ` command. This command will create a new folder in your current directory. ```bash cargo prove new fibonacci cd fibonacci ``` -This will create a new project with the following structure: +### Option 2: Project Template (Solidity Contracts for Onchain Verification) + +If you want to use SP1 to generate proofs that will eventually be verified on an EVM chain, you should use the [SP1 project template](https://github.com/succinctlabs/sp1-project-template/tree/main). This Github template is scaffolded with a SP1 program, a script to generate proofs, and also a contracts folder that contains a Solidity contract that can verify SP1 proofs on any EVM chain. + +Either fork the project template repository or clone it: + +```bash +git clone https://github.com/succinctlabs/sp1-project-template.git +``` + +## Project Overview + +Your new project will have the following structure (ignoring the `contracts` folder, if you are using the project template): ``` . ├── program +│   ├── Cargo.lock │   ├── Cargo.toml │   ├── elf +│   │   └── riscv32im-succinct-zkvm-elf │   └── src │   └── main.rs +├── rust-toolchain └── script + ├── Cargo.lock ├── Cargo.toml + ├── build.rs └── src - └── main.rs + └── bin + ├── prove.rs + └── vkey.rs 6 directories, 4 files ``` @@ -35,37 +56,70 @@ There are 2 directories (each a crate) in the project: We recommend you install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension. Note that if you use `cargo prove new` inside a monorepo, you will need to add the manifest file to `rust-analyzer.linkedProjects` to get full IDE support. -## Generate Proof +## Generate Proofs + +The program in the starter examplesimply computes the `n`-th Fibonacci number. -The program simply computes the `n`-th Fibonacci number. +Before we can run the program inside the zkVM, it must be compiled to a RISC-V executable using the `succinct` Rust toolchain. This is called an [ELF (Executable and Linkable Format)](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format). To compile the program, you can run `cd program && cargo prove build`, which will output the compiled ELF to the file `program/elf/riscv32im-succinct-zkvm-elf`. -Before we can run the program inside the zkVM, it must be compiled to a RISCV executable using the `succinct` Rust toolchain. This is called an [ELF (Executable and Linkable Format)](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format). The `build.rs` file in the `script` directory will use the `cargo prove` toolchain to automatically build the ELF. +In our case, the `build.rs` file in the `script` directory will use run the above command automatically to build the ELF, meaning you don't have to manually run `cargo prove build` every time you make a change to the program. To generate a proof, we take the ELF file generated by the `build.rs` file and execute it within the SP1 zkVM. The code in the `script` directory is already scaffolded with a script that has logic to generate a proof, save the proof to disk, and verify it. +First, you should run the script with the `--execute` flag to *only execute* your program (without generating a proof). In general this is helpful for iterating on your program and verifying that it is correct. + ```bash cd script -cargo run --release +RUST_LOG=info cargo run --release -- --execute ``` -The output should show +Next, you should run the script with the `--prove` flag that will generate a proof and save it to disk. Please go to the [Recommended Workflow](../generating-proofs/recommended-workflow.md) section for more details on how you should develop your SP1 program and generate proofs. + +```bash +cd script +RUST_LOG=info cargo run --release -- --prove +``` + +The output should show something like this: ``` +n: 20 +2024-07-23T17:07:07.874856Z INFO prove_core:collect_checkpoints: clk = 0 pc = 0x2017e8 +2024-07-23T17:07:07.876264Z INFO prove_core:collect_checkpoints: close time.busy=2.00ms time.idle=1.50µs +2024-07-23T17:07:07.913304Z INFO prove_core:shard: close time.busy=32.2ms time.idle=791ns +2024-07-23T17:07:10.724280Z INFO prove_core:commit: close time.busy=2.81s time.idle=1.25µs +2024-07-23T17:07:10.725923Z INFO prove_core:prove_checkpoint: clk = 0 pc = 0x2017e8 num=0 +2024-07-23T17:07:10.729130Z INFO prove_core:prove_checkpoint: close time.busy=3.68ms time.idle=1.17µs num=0 +2024-07-23T17:07:14.648146Z INFO prove_core: execution report (totals): total_cycles=9329, total_syscall_cycles=20 +2024-07-23T17:07:14.648180Z INFO prove_core: execution report (opcode counts): +2024-07-23T17:07:14.648197Z INFO prove_core: 1948 add ... - Compiling fibonacci-script v0.1.0 (.../fibonacci/script) - Finished release [optimized] target(s) in 26.14s - Running `target/release/fibonacci-script` -a: 205697230343233228174223751303346572685 -b: 332825110087067562321196029789634457848 -successfully generated and verified proof for the program! +2024-07-23T17:07:14.648277Z INFO prove_core: execution report (syscall counts): +2024-07-23T17:07:14.648408Z INFO prove_core: 8 commit +... +2024-07-23T17:07:14.648858Z INFO prove_core: summary: cycles=9329, e2e=9.193968459, khz=1014.69, proofSize=1419780 +2024-07-23T17:07:14.653193Z INFO prove_core: close time.busy=9.20s time.idle=12.2µs +Successfully generated proof! +fib(n): 10946 ``` -The program by default is quite small, so proof generation will only take a few seconds locally. After it completes, the proof will be saved in the `proof-with-io.bin` file and also be verified for correctness. +The program by default is quite small, so proof generation will only take a few seconds locally. After it generates, the proof will be verified for correctness. + +**Note:** When benchmarking proof generation times locally, it is important to note that there is a fixed overhead for proving, which means that the proof generation time for programs with a small number of cycles is not representative of the performance of larger programs (which often have better performance characteristics as the overhead is amortized across many cycles). -## Modifying the Program +**Modifying the Program** -You can play around with how many rounds of Fibonacci are executed by playing around with `n` (by default set to `186`) in the file `script/src/main.rs`. Integer overflow will cause larger `n` to result in non-fibonacci output, although the proof will still be generated and verified. +You can play around with how many rounds of Fibonacci are executed by playing around with `n` (by default set to `20`) in the file `script/src/main.rs`. The ELF will be automatically rebuilt every time you modify the program. You can verify that the ELF was re-generated by looking in the `elf` directory and for a file called `riscv32im-succinct-zkvm-elf`: ```bash ls elf # should show riscv32im-succinct-zkvm-elf -``` \ No newline at end of file +``` + +## Recommended Workflow + +Please see the [Recommended Workflow](../generating-proofs/recommended-workflow.md) section for more details on how to develop your SP1 program and generate proofs. + +We *strongly recommend* that developers who want to use SP1 for non-trivial programs generate proofs on the beta version of our [Prover Network](../generating-proofs/prover-network.md). The prover network generates SP1 proofs across multiple machines, reducing latency and also runs SP1 on optimized hardware instances that result in faster + cheaper proof generation times. + +We recommend that for any production benchmarking, you use the prover network to estimate latency and costs of proof generation. We also would love to chat with your team directly to help you get started with the prover network--please fill out this [form](https://partner.succinct.xyz/). + diff --git a/book/introduction.md b/book/introduction.md index a0b2de2ae0..5d8f66bbe3 100644 --- a/book/introduction.md +++ b/book/introduction.md @@ -6,17 +6,28 @@ ![](./sp1.png) -SP1 is a performant, 100% open-source, contributor-friendly zero-knowledge virtual machine (zkVM) that verifies the execution of arbitrary Rust (or any LLVM-compiled language) programs. + +SP1 is a performant, open-source zero-knowledge virtual machine (zkVM) that verifies the execution of arbitrary Rust (or any LLVM-compiled language) programs. [tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fsuccinct%5Fsp1 [tg-url]: https://t.me/+AzG4ws-kD24yMGYx -## The future of truth is programmable +SP1 has undergone multiple audits from leading ZK security firms and is currently used in production by many top blockchain teams. + +## The future of ZK is writing normal code + +Zero-knowledge proofs (ZKPs) are one of the most critical technologies to blockchain scaling, interoperability and privacy. But, historically building ZKP systems was extrememly complicated--requiring large teams with specialized cryptography expertise and taking years to go to production. + +SP1 provides a performant, general-purpose zkVM that enables **any developer** to use ZKPs by writing normal code (in Rust), and get cheap and fast proofs. SP1 will enable ZKPs to become mainstream, introducing a a new era of verifiability for all of blockchain infrastructure and beyond. -**The future of ZK is writing normal code.** Zero-knowledge proofs (ZKPs) are a powerful primitive that will enable a new generation of more secure, scalable and innovative blockchain architectures that rely on truth not trust. But ZKP adoption has been held back because it is “moon math”, requiring specialized knowledge in obscure ZKP frameworks and hard to maintain one-off deployments. -Performant, general-purpose zkVMs, like SP1, will obsolete the current paradigm of specialized teams hand rolling their own custom ZK stack and create a future where all blockchain infrastructure, including rollups, bridges, coprocessors, and more, utilize ZKPs via **maintainable software** written in Rust (or other LLVM-compiled languages). +## SP1 enables a diversity of use-cases -## Built from day one to be customizable and maintained by a diverse ecosystem of contributors +ZKPs enable a diversity of use-cases in blockchain and beyond, including: -SP1 is 100% open-source (MIT / Apache 2.0) with no code obfuscation and built to be contributor friendly, with all development done in the open. Unlike existing zkVMs whose constraint logic is closed-source and impossible to modify, SP1 is modularly architected and designed to be customizable from day one. This customizability (unique to SP1) allows for users to add “precompiles” to the core zkVM logic that yield substantial performance gains, making SP1’s performance not only SOTA vs. existing zkVMs, but also competitive with circuits in a variety of use-cases. +* Rollups: Use SP1 to generate a ZKP for the state transition function of your rollup and connect to Ethereum, Bitcoin or other chains with full validity proofs or ZK fraud proofs. +* Interoperability: Use SP1 for fast-finality, cross rollup interoperability +* Bridges: Use SP1 to generate a ZKP for verifying consensus of L1s, including Tendermint, Ethereum’s Light Client protocol and more, for bridging between chains. +* Oracles: Use SP1 for large scale computations with onchain state, including consensus data and storage data. +* Aggregation: Use SP1 to aggregate and verify other ZKPs for reduced onchain verification costs. +* Privacy: Use SP1 for onchain privacy, including private transactions and private state. diff --git a/book/onchain-verification/contract-addresses.md b/book/onchain-verification/contract-addresses.md index 77fca8a330..63a647277d 100644 --- a/book/onchain-verification/contract-addresses.md +++ b/book/onchain-verification/contract-addresses.md @@ -14,7 +14,7 @@ When using SP1, we recommend using our deployed verifiers. Each contract is a [S | 8453 | Base | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | | 84532 | Base Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | -**Currently officially supported version of SP1 is v1.0.1.** If you'd like official support for a verifier on a different chain, please ask in the [SP1 Telegram](https://t.me/+AzG4ws-kD24yMGYx). +**Currently officially supported version of SP1 is v1.1.0.** If you'd like official support for a verifier on a different chain, please ask in the [SP1 Telegram](https://t.me/+AzG4ws-kD24yMGYx). ## ISP1Verifier Interface diff --git a/book/onchain-verification/getting-started.md b/book/onchain-verification/getting-started.md index 39fad85ba5..110553e7e8 100644 --- a/book/onchain-verification/getting-started.md +++ b/book/onchain-verification/getting-started.md @@ -27,5 +27,5 @@ You can run the above script with `RUST_LOG=info cargo run --bin plonk_bn254 --r If you would like to run the PLONK prover directly without Docker, you must have Go 1.22 installed and enable the `native-plonk` feature in `sp1-sdk`. This path is not recommended and may require additional native dependencies. ```toml -sp1-sdk = { version = "1.0.1", features = ["native-plonk"] } +sp1-sdk = { version = "1.1.0", features = ["native-plonk"] } ``` diff --git a/book/onchain-verification/solidity-sdk.md b/book/onchain-verification/solidity-sdk.md index 164ec7a4cc..51a0e1e23d 100644 --- a/book/onchain-verification/solidity-sdk.md +++ b/book/onchain-verification/solidity-sdk.md @@ -1,4 +1,4 @@ -# Solidity SDK +# Solidity Verifier We maintain a suite of [contracts](https://github.com/succinctlabs/sp1-contracts/tree/main) used for verifying SP1 proofs onchain. We highly recommend using [Foundry](https://book.getfoundry.sh/). diff --git a/book/sp1.png b/book/sp1.png index 86bf73e4a8..abe8a23b8e 100644 Binary files a/book/sp1.png and b/book/sp1.png differ diff --git a/book/what-is-a-zkvm.md b/book/what-is-a-zkvm.md index f58d3240dc..4f91fa3213 100644 --- a/book/what-is-a-zkvm.md +++ b/book/what-is-a-zkvm.md @@ -12,3 +12,24 @@ Conceptually, you can think of the SP1 zkVM as proving the evaluation of a funct As a practical example, `f` could be a simple Fibonacci [program](https://github.com/succinctlabs/sp1/blob/main/examples/fibonacci/program/src/main.rs). The process of generating a proof and verifying it can be seen [here](https://github.com/succinctlabs/sp1/blob/main/examples/fibonacci/script/src/main.rs). For blockchain applications, the verification usually happens inside of a [smart contract](https://github.com/succinctlabs/sp1-project-template/blob/main/contracts/src/Fibonacci.sol). + +## How does SP1 Work? + +At a high level, SP1 works with the following steps: + +* Write a program in Rust that defines the logic of your computation for which you want to generate a ZKP. +* Compile the program to the RISC-V ISA (a standard Rust compilation target) using the `cargo prove` CLI tool (installation instructions [here](./getting-started/install.md)) and generate a RISC-V ELF file. +* SP1 will prove the correct execution of arbitrary RISC-V programs by generating a STARK proof of execution. +* Developers can leverage the `sp1-sdk` crate to generate proofs with their ELF and input data. Under the hood the `sp1-sdk` will either generate proofs locally or use a beta version of Succinct's prover network to generate proofs. + +SP1 leverages performant STARK recursion that allows us to prove the execution of arbitrarily long programs and also has a STARK -> SNARK "wrapping system" that allows us to generate small SNARK proofs that can be efficiently verified on EVM chains. + +## Proof System + +For more technical details, check out the SP1 technical note that explains our proof system in detail. In short, we use: + +* STARKs + FRI over the Baby Bear field +* We use performant STARK recursion that allows us to prove the execution of arbitrarily long programs +* We have a system of performant precompiles that accelerate hash functions and cryptographic signature verification that allow us to get substantial performance gains on blockchain workloads + + diff --git a/book/why-use-sp1.md b/book/why-use-sp1.md index d76551e936..bd9b8f4a4e 100644 --- a/book/why-use-sp1.md +++ b/book/why-use-sp1.md @@ -1,17 +1,40 @@ # Why use SP1? -Zero-knowledge proofs (ZKPs) are a powerful primitive that enable developers to outsource verifiable computation to provers. But ZKP adoption has been held back because it is “moon math”, requiring specialized knowledge in obscure ZKP frameworks and hard to maintain one-off deployments. +## Use-Cases -Performant, general-purpose zkVMs, like SP1, will obsolete the current paradigm of specialized teams hand rolling their own custom ZK stack and create a future where all blockchain infrastructure, including rollups, bridges, coprocessors, and more, utilize ZKPs **via maintainable software written in Rust (or other LLVM-compiled languages)**. +Zero-knowledge proofs (ZKPs) are a powerful primitive that enable **verifiable computation**. With ZKPs, anyone can verify a cryptographic proof that a program has executed correctly, without needing to trust the prover, re-execute the program or even know the inputs to the program. + +Historically, building ZKP systems has been extremely complicated, requiring large teams with specialized cryptography expertise and taking years to go to production. SP1 is a performant, general-purpose zkVM that solves this problem and creates a future where all blockchain infrastructure, including rollups, bridges, coprocessors, and more, utilize ZKPs **via maintainable software written in Rust**. SP1 is especially powerful in blockchain contexts which rely on verifiable computation. Example applications include: -- [Rollups](https://ethereum.org/en/developers/docs/scaling/zk-rollups/): SP1 can be used in combination with existing node infrastructure like [Reth](https://github.com/paradigmxyz/reth) to build rollups with fraud proofs based on zero-knowledge proofs. -- [Coprocessors](https://crypto.mirror.xyz/BFqUfBNVZrqYau3Vz9WJ-BACw5FT3W30iUX3mPlKxtA): SP1 can be used to outsource onchain computation to offchain provers to enable use cases such as accessing historical state and onchain machine learning, dramatically reducing gas costs. +- [Rollups](https://ethereum.org/en/developers/docs/scaling/zk-rollups/): SP1 can be used in combination with existing node infrastructure like [Reth](https://github.com/paradigmxyz/reth) to build rollups with ZKP validity proofs or ZK fraud proofs. +- [Coprocessors](https://crypto.mirror.xyz/BFqUfBNVZrqYau3Vz9WJ-BACw5FT3W30iUX3mPlKxtA): SP1 can be used to outsource onchain computation to offchain provers to enable use cases such as large-scale computation over historical state and onchain machine learning, dramatically reducing gas costs. - [Light Clients](https://ethereum.org/en/developers/docs/nodes-and-clients/light-clients/): SP1 can be used to build light clients that can verify the state of other chains, facilitating interoperability between different blockchains without relying on any trusted third parties. SP1 has already been integrated in many of these applications, including but not limited to: -- [SP1 Reth](https://github.com/succinctlabs/sp1-reth): A performant, type-1 zkEVM written in Rust & SP1. - [SP1 Tendermint](https://github.com/succinctlabs/sp1-tendermint-example): An example of a ZK Tendermint light client on Ethereum powered by SP1. +- [SP1 Reth](https://github.com/succinctlabs/rsp): A performant, type-1 zkEVM written in Rust & SP1 using Reth. - and many more! + +## 100x developer productivity + +SP1 enables teams to use ZKPs in production with minimal overhead and fast timelines. + +**Maintainable:** With SP1, you can reuse existing Rust crates, like `revm`, `reth`, `tendermint-rs`, `serde` and more, to write your ZKP logic in maintainable, Rust code. + +**Go to market faster:** By reusing existng crates and expressing ZKP logic in regular code, SP1 significantly reduces audit surface area and complexity, enabling teams to go to market with ZKPs faster. + +## Blazing Fast Performance + +SP1 is the fastest zkVM and has blazing fast performance on a variety of realistic blockchain workloads, including light clients and rollups. With SP1, ZKP proving costs are an order of magnitude less than alternative zkVMs or even circuits, making it cost-effective and fast for practical use. + +Read more about our benchmarking results [here](https://blog.succinct.xyz/sp1-production-benchmarks). + +## Open Source + +SP1 is 100% open-source (MIT / Apache 2.0) with no code obfuscation and built to be contributor friendly, with all development done in the open. Unlike existing zkVMs whose constraint logic is closed-source and impossible to audit or modify, SP1 is modularly architected and designed to be customizable from day one. This customizability (unique to SP1) allows for users to add “precompiles” to the core zkVM logic that yield substantial performance gains, making SP1’s performance not only SOTA vs. existing zkVMs, but also competitive with circuits in a variety of use-cases. + + + diff --git a/book/writing-programs/basics.md b/book/writing-programs/basics.md index 552a48a37f..8d1d4e8272 100644 --- a/book/writing-programs/basics.md +++ b/book/writing-programs/basics.md @@ -10,4 +10,6 @@ This program is from the `examples` [directory](https://github.com/succinctlabs/ {{#include ../../examples/fibonacci/program/src/main.rs}} ``` -As you can see, writing programs is as simple as writing normal Rust. To read more about how inputs and outputs work, refer to the section on [Inputs & Outputs](./inputs-and-outputs.md). \ No newline at end of file +As you can see, writing programs is as simple as writing normal Rust. + +After you've written your program, you must compile it to an ELF that the SP1 zkVM can prove. To read more about compiling programs, refer to the section on [Compiling Programs](./compiling.md). To read more about how inputs and outputs work, refer to the section on [Inputs & Outputs](./inputs-and-outputs.md). \ No newline at end of file diff --git a/book/writing-programs/build-script.md b/book/writing-programs/build-script.md deleted file mode 100644 index 734409a5d9..0000000000 --- a/book/writing-programs/build-script.md +++ /dev/null @@ -1,30 +0,0 @@ -# Build Script - -> WARNING: This may not generate a reproducible ELF which is necessary for verifying that your binary corresponds to given source code. -> -> When building a ELF that will be used in production, make sure to use the [reproduction build system](../writing-programs/setup.md#build-with-docker-production). - -If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml`): - -```rust,noplayground -{{#include ../../examples/fibonacci/script/build.rs}} -``` - -Make sure to also add `sp1-helper` as a build dependency in `script/Cargo.toml`: - -```toml -[build-dependencies] -sp1-helper = "1.0.1" -``` - -If you run `RUST_LOG=info cargo run --release -vv`, you will see the following output from the build script if the program has changed, indicating that the program was rebuilt: - -```` -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/src -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.toml -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.lock -[fibonacci-script 0.1.0] cargo:warning=fibonacci-program built at 2024-03-02 22:01:26 -[fibonacci-script 0.1.0] [sp1] Compiling fibonacci-program v0.1.0 (/Users/umaroy/Documents/fibonacci/program) -[fibonacci-script 0.1.0] [sp1] Finished release [optimized] target(s) in 0.15s -warning: fibonacci-script@0.1.0: fibonacci-program built at 2024-03-02 22:01:26``` -```` diff --git a/book/writing-programs/compiling.md b/book/writing-programs/compiling.md new file mode 100644 index 0000000000..e40a189d3c --- /dev/null +++ b/book/writing-programs/compiling.md @@ -0,0 +1,102 @@ +# Compiling Programs + +Once you have written an SP1 program, you must compile it to an ELF file that can be executed in the zkVM. The `cargo prove` CLI tool (downloaded during installation) provides convenient commands for compiling SP1 programs. + +## Compile with CLI (Development) + +> WARNING: This may not generate a reproducible ELF which is necessary for verifying that your binary corresponds to given source code. +> +> Use the [reproducible build system](#reproducible-builds-with-docker-production) for production builds. + +To build a program while developing, simply run the following command in the crate that contains your SP1 program: + +```bash +cargo prove build +``` + +This will compile the ELF that can be executed in the zkVM and put it in the file `elf/riscv32im-succinct-zkvm-elf`. The output from the command will look something like this: + +```bash +[sp1] Compiling version_check v0.9.4 +[sp1] Compiling proc-macro2 v1.0.86 +[sp1] Compiling unicode-ident v1.0.12 +[sp1] Compiling cfg-if v1.0.0 +... +[sp1] Compiling sp1-lib v1.0.1 +[sp1] Compiling sp1-zkvm v1.0.1 +[sp1] Compiling fibonacci-program v0.1.0 (/Users/username/Documents/fibonacci/program) +[sp1] Finished `release` profile [optimized] target(s) in 8.33s +``` + +Under the hood, this CLI command calls `cargo build` with the `riscv32im-succinct-zkvm-elf` target and other required environment variables and flags. The logic for this command is defined in the [sp1-build](https://github.com/succinctlabs/sp1/tree/main/build) crate. + +### Advanced build options + +You can pass additional arguments to the `cargo prove build` command to customize the build process, like configuring what features are enabled, customizing the output directory and more. To see all available options, run `cargo prove build --help`. Many of these options mirror the options available in the `cargo build` command. + + +## Reproducible Builds with Docker (Production) + +For production builds of programs, you can build your program inside a Docker container which will generate a **reproducible ELF** on all platforms. To do so, just use the `--docker` flag and optionally the `--tag` flag with the release version you want to use (defaults to `latest`). For example: + +```bash +cargo prove build --docker --tag v1.0.1 +``` + +To verify that your build is reproducible, you can compute the SHA-512 hash of the ELF on different platforms and systems with: + +```bash +$ shasum -a 512 elf/riscv32im-succinct-zkvm-elf +f9afb8caaef10de9a8aad484c4dd3bfa54ba7218f3fc245a20e8a03ed40b38c617e175328515968aecbd3c38c47b2ca034a99e6dbc928512894f20105b03a203 +``` + +## Build Script + +If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml` of your script crate) that utilizes the `sp1-helper` crate: + +```rust,noplayground +{{#include ../../examples/fibonacci/script/build.rs}} +``` + +The path passed in to `build_program` should point to the directory containing the `Cargo.toml` file for your program. Make sure to also add `sp1-helper` as a build dependency in `script/Cargo.toml`: + +```toml +[build-dependencies] +sp1-helper = "1.1.0" +``` + +You will see output like the following from the build script if the program has changed, indicating that the program was rebuilt: + +```` +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/src +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.toml +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.lock +[fibonacci-script 0.1.0] cargo:warning=fibonacci-program built at 2024-03-02 22:01:26 +[fibonacci-script 0.1.0] [sp1] Compiling fibonacci-program v0.1.0 (/Users/umaroy/Documents/fibonacci/program) +[fibonacci-script 0.1.0] [sp1] Finished release [optimized] target(s) in 0.15s +warning: fibonacci-script@0.1.0: fibonacci-program built at 2024-03-02 22:01:26 +```` + +The above output was generated by running `RUST_LOG=info cargo run --release -vv` for the `script` folder of the Fibonacci example. + + +### Advanced build options + +To configure the build process when using the `sp1-helper` crate, you can pass a [`BuildArgs`](https://docs.rs/sp1-helper/1.1.0/sp1_helper/struct.BuildArgs.html) struct to to the [`build_program_with_args`](https://docs.rs/sp1-helper/1.1.0/sp1_helper/fn.build_program_with_args.html) function. The build arguments are the same as the ones available from the `cargo prove build` command. + +As an example, you could use the following code to build the Fibonacci example with the `docker` flag set to `true` and a custom output directory for the generated ELF: + +```rust,noplayground +use sp1_helper::{build_program_with_args, BuildArgs}; + +fn main() { + let args = BuildArgs { + docker: true, + output_directory: "./fibonacci-program".to_string(), + ..Default::default() + }; + build_program_with_args("../program", &args); +} +``` + +**Note:** If you want reproducible builds with the `build.rs` approach, you should use the `docker` flag and the `build_program_with_args` function, as shown in the example above. \ No newline at end of file diff --git a/book/writing-programs/cycle-tracking.md b/book/writing-programs/cycle-tracking.md index 975c591ccd..176249b45e 100644 --- a/book/writing-programs/cycle-tracking.md +++ b/book/writing-programs/cycle-tracking.md @@ -2,19 +2,19 @@ When writing a program, it is useful to know how many RISC-V cycles a portion of the program takes to identify potential performance bottlenecks. SP1 provides a way to track the number of cycles spent in a portion of the program. -## Tracking Cycles +## Tracking Cycles with Annotations To track the number of cycles spent in a portion of the program, you can either put `println!("cycle-tracker-start: block name")` + `println!("cycle-tracker-end: block name")` statements (block name must be same between start and end) around the portion of your program you want to profile or use the `#[sp1_derive::cycle_tracker]` macro on a function. An example is shown below: ```rust,noplayground -{{#include ../../examples/cycle-tracking/program/src/main.rs}} +{{#include ../../examples/cycle-tracking/program/bin/normal.rs}} ``` Note that to use the macro, you must add the `sp1-derive` crate to your dependencies for your program. ```toml [dependencies] -sp1-derive = "1.0.1" +sp1-derive = "1.1.0" ``` In the script for proof generation, setup the logger with `utils::setup_logger()` and run the script with `RUST_LOG=info cargo run --release`. You should see the following output: @@ -41,3 +41,84 @@ stdout: result: 2940 ``` Note that we elegantly handle nested cycle tracking, as you can see above. + +### Get Tracked Cycle Counts +To include tracked cycle counts in the `ExecutionReport` when using `ProverClient::execute`, use the following annotations: + +```rust,noplayground +fn main() { + println!("cycle-tracker-report-start: block name"); + // ... + println!("cycle-tracker-report-end: block name"); +} +``` + +This will log the cycle count for `block name` and include it in the `ExecutionReport` in the `cycle_tracker` map. + +## Tracking Cycles with Tracing + +The `cycle-tracker` annotation is a convenient way to track cycles for specific sections of code. However, sometimes it can also be useful to track what functions are taking the most cycles across the entire program, without having to annotate every function individually. + +First, we need to generate a trace file of the program counter at each cycle while the program is executing. This can be done by simply setting the `TRACE_FILE` environment variable with the path of the file you want to write the trace to. For example, you can run the following command in the `script` directory for any example program: + +```bash +TRACE_FILE=trace.log RUST_LOG=info cargo run --release +``` + +When the `TRACE_FILE` environment variable is set, as SP1's RISC-V runtime is executing, it will write a log of the program counter to the file specified by `TRACE_FILE`. + + +Next, we can use the `cargo prove` CLI with the `trace` command to analyze the trace file and generate a table of instruction counts. This can be done with the following command: + +```bash +cargo prove trace --elf --trace +``` + +The `trace` command will generate a table of instruction counts, sorted by the number of cycles spent in each function. The output will look something like this: + +``` + [00:00:00] [########################################] 17053/17053 (0s) + +Total instructions in trace: 17053 + + + Instruction counts considering call graph ++----------------------------------------+-------------------+ +| Function Name | Instruction Count | +| __start | 17045 | +| main | 12492 | +| sp1_zkvm::syscalls::halt::syscall_halt | 4445 | +| sha2::sha256::compress256 | 4072 | +| sp1_lib::io::commit | 258 | +| sp1_lib::io::SyscallWriter::write | 255 | +| syscall_write | 195 | +| memcpy | 176 | +| memset | 109 | +| sp1_lib::io::read_vec | 71 | +| __rust_alloc | 29 | +| sp1_zkvm::heap::SimpleAlloc::alloc | 22 | +| syscall_hint_len | 3 | +| syscall_hint_read | 2 | ++----------------------------------------+-------------------+ + + + Instruction counts ignoring call graph ++----------------------------------------+-------------------+ +| Function Name | Instruction Count | +| main | 12075 | +| sha2::sha256::compress256 | 4073 | +| sp1_zkvm::syscalls::halt::syscall_halt | 219 | +| memcpy | 180 | +| syscall_write | 123 | +| memset | 111 | +| sp1_lib::io::commit | 88 | +| sp1_lib::io::SyscallWriter::write | 60 | +| __start | 45 | +| sp1_lib::io::read_vec | 35 | +| sp1_zkvm::heap::SimpleAlloc::alloc | 23 | +| anonymous | 7 | +| __rust_alloc | 7 | +| syscall_hint_len | 4 | +| syscall_hint_read | 3 | ++----------------------------------------+-------------------+ +``` diff --git a/book/writing-programs/patched-crates.md b/book/writing-programs/patched-crates.md index 31333eb338..b44188d122 100644 --- a/book/writing-programs/patched-crates.md +++ b/book/writing-programs/patched-crates.md @@ -7,15 +7,17 @@ Under the hood, we use [precompiles](./precompiles.md) to achieve tremendous per ## Supported Libraries -| Crate Name | Repository | Notes | -| ------------------- | ------------------------------------------------------------------------------------- | ---------------------- | -| sha2 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | sha256 | -| sha3 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | keccak256 | -| bigint | [sp1-patches/RustCrypto-bigint](https://github.com/sp1-patches/RustCrypto-bigint) | bigint | -| tiny-keccak | [sp1-patches/tiny-keccak](https://github.com/sp1-patches/tiny-keccak) | keccak256 | -| ed25519-consensus | [sp1-patches/ed25519-consensus](http://github.com/sp1-patches/ed25519-consensus) | ed25519 verify | -| curve25519-dalek-ng | [sp1-patches/curve25519-dalek-ng](https://github.com/sp1-patches/curve25519-dalek-ng) | ed25519 verify | -| curve25519-dalek | [sp1-patches/curve25519-dalek](https://github.com/sp1-patches/curve25519-dalek) | ed25519 verify | +| Crate Name | Repository | Notes | +| ------------------- | ------------------------------------------------------------------------------------- | ---------------- | +| sha2 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | sha256 | +| sha3 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | keccak256 | +| bigint | [sp1-patches/RustCrypto-bigint](https://github.com/sp1-patches/RustCrypto-bigint) | bigint | +| tiny-keccak | [sp1-patches/tiny-keccak](https://github.com/sp1-patches/tiny-keccak) | keccak256 | +| ed25519-consensus | [sp1-patches/ed25519-consensus](http://github.com/sp1-patches/ed25519-consensus) | ed25519 verify | +| curve25519-dalek-ng | [sp1-patches/curve25519-dalek-ng](https://github.com/sp1-patches/curve25519-dalek-ng) | ed25519 verify | +| curve25519-dalek | [sp1-patches/curve25519-dalek](https://github.com/sp1-patches/curve25519-dalek) | ed25519 verify | +| ecdsa-core | [sp1-patches/signatures](http://github.com/sp1-patches/signatures) | secp256k1 verify | +| secp256k1 | [sp1-patches/rust-secp256k1](http://github.com/sp1-patches/rust-secp256k1) | secp256k1 verify | ## Using Patched Crates @@ -30,10 +32,12 @@ sha3-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", packag sha3-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.6" } sha3-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" } crypto-bigint = { git = "https://github.com/sp1-patches/RustCrypto-bigint", branch = "patch-v0.5.5" } -curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-v4.1.1" } +tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" } +curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-curve25519-v4.1.3" } curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.1" } ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } -tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" } +ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "patch-ecdsa-v0.16.9" } +secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", branch = "patch-v0.29.0" } ``` If you are patching a crate from Github instead of from crates.io, you need to specify the @@ -46,44 +50,101 @@ sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sh An example of using patched crates is available in our [Tendermint Example](https://github.com/succinctlabs/sp1/blob/main/examples/tendermint/program/Cargo.toml#L22-L25). +## Ed25519 Acceleration + +To accelerate Ed25519 operations, you'll need to patch crates depending on if you're using the `ed25519-consensus` or `ed25519-dalek` library in your program or dependencies. + +Generally, `ed25519-consensus` has better performance than `ed25519-dalek` by a factor of 2. + +### Patches + +Apply the following patches based on what crates are in your dependencies. + +- `ed25519-consensus` + + ```toml + ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } + ``` + + Note: The curve operations for Ed25519 occur mainly inside of `curve25519-dalek-ng`, but the crate also exposes + a `u32_backend` feature flag which accelerates signature recovery by 10% over the default `u64_backend`, which is why + `ed25519-consensus` is patched rather than `ed25519-dalek`. + +- `ed25519-dalek` + + ```toml + curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-curve25519-v4.1.3" } + ``` + + Note: The curve operations occur inside of the `curve25519-dalek` crate. + +- `curve25519-dalek` + ```toml + curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.3" } + ``` + +## Secp256k1 Acceleration + +To accelerate Secp256k1 operations, you'll need to patch `k256` or `secp256k1` depending on your usage. + +Generally, if a crate you're using (ex. `revm`) has support for using `k256` instead of `secp256k1`, you should use `k256`. + +### Patches + +Apply the following patches based on what crates are in your dependencies. + +- `k256` + + ```toml + ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "patch-ecdsa-v0.16.9" } + ``` + + Note: The curve operations for `k256` are inside of the `ecdsa-core` crate, so you don't need to patch `k256` itself, and just patching `ecdsa-core` is enough. + +- `secp256k1` + ```toml + secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", branch = "patch-v0.29.0" } + ``` + +## Troubleshooting + ### Verifying Patch Usage: Cargo You can check if the patch was applied by using cargo's tree command to print the dependencies of the crate you patched. ```bash -cargo tree -p sha2 cargo tree -p sha2@0.9.8 ``` Next to the package name, it should have a link to the Github repository that you patched with. +Ex. + +``` +sha2 v0.9.8 (https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-sha2-v0.9.8#afdbfb09) +├── ... +``` + ### Verifying Patch Usage: SP1 -To check if a precompile is used by your program, you can observe SP1's log output. Make sure to setup the logger with `sp1_sdk::utils::setup_logger()` and run your program with `RUST_LOG=info`. +To check if a precompile is used by your program, you can view SP1's ExecutionReport, which is returned when executing a program with `execute`. In `ExecutionReport` you can view the `syscall_counts` map to view if a specific syscall was used. -In the example below, note how the `sha256_extend` precompile was reported as being used eight times. +For example, if you wanted to check `sha256` was used, you would look for `SHA_EXTEND` and `SHA_COMPRESS` in `syscall_counts`. -```bash -2024-07-03T04:46:33.753527Z INFO prove_core: execution report (syscall counts): -2024-07-03T04:46:33.753550Z INFO prove_core: 8 sha256_extend -2024-07-03T04:46:33.753550Z INFO prove_core: 8 commit -2024-07-03T04:46:33.753553Z INFO prove_core: 8 commit_deferred_proofs -2024-07-03T04:46:33.753554Z INFO prove_core: 4 write -2024-07-03T04:46:33.753555Z INFO prove_core: 1 halt -``` +An example of this is available in our [Patch Testing Example](https://github.com/succinctlabs/sp1/blob/dd032eb23949828d244d1ad1f1569aa78155837c/examples/patch-testing/script/src/main.rs). -### Troubleshooting +### Cargo Version Issues -You may also need to update your `Cargo.lock` file. For example: +If you encounter issues with version commits on your patches, you should try updating the patched crate manually. ```bash -cargo update -p ed25519-consensus +cargo update -p ``` If you encounter issues relating to cargo / git, you can try setting `CARGO_NET_GIT_FETCH_WITH_CLI`: ```bash -CARGO_NET_GIT_FETCH_WITH_CLI=true cargo update -p ed25519-consensus +CARGO_NET_GIT_FETCH_WITH_CLI=true cargo update -p ``` You can permanently set this value in `~/.cargo/config`: diff --git a/book/writing-programs/precompiles.md b/book/writing-programs/precompiles.md index c65d20ae0b..f96be3e6ff 100644 --- a/book/writing-programs/precompiles.md +++ b/book/writing-programs/precompiles.md @@ -1,8 +1,7 @@ # Precompiles -Precompiles are built into the SP1 zkVM and accelerate commonly used operations such as elliptic curve arithmetic and hashing. -Under the hood, precompiles are implemented as custom tables dedicated to proving one or few operations. **They typically improve the performance -of executing expensive operations by a few orders of magnitude.** +Precompiles are built into the SP1 zkVM and accelerate commonly used operations such as elliptic curve arithmetic and hashing. Under the hood, precompiles are implemented as custom STARK tables dedicated to proving one or few operations. **They typically improve the performance +of executing expensive operations in SP1 by a few orders of magnitude.** Inside the zkVM, precompiles are exposed as system calls executed through the `ecall` RISC-V instruction. Each precompile has a unique system call number and implements an interface for the computation. @@ -11,7 +10,7 @@ SP1 also has been designed specifically to make it easy for external contributor To learn more about this, you can look at implementations of existing precompiles in the [precompiles](https://github.com/succinctlabs/sp1/tree/main/core/src/syscall/precompiles) folder. More documentation on this will be coming soon. **To use precompiles, we typically recommend you interact with them through [patches](./patched-crates.md), which are crates modified -to use these precompiles under the hood.** +to use these precompiles under the hood, without requiring you to call system calls directly.** ## Specification diff --git a/book/writing-programs/proof-aggregation.md b/book/writing-programs/proof-aggregation.md index 38806019c0..4119950d06 100644 --- a/book/writing-programs/proof-aggregation.md +++ b/book/writing-programs/proof-aggregation.md @@ -1,22 +1,30 @@ # Proof Aggregation -SP1 supports proof aggregation and recursion, which allows you to verify proofs within a proof. Use cases include: +SP1 supports proof aggregation and recursion, which allows you to verify an SP1 proof within SP1. Use cases include: -- Reducing on-chain verification costs by aggregating multiple proofs into a single proof. -- Proving logic that is split into multiple proofs, such as proving a statement about a rollup's state transition function. +- Reducing on-chain verification costs by aggregating multiple SP1 proofs into a single SP1 proof. +- Proving logic that is split into multiple proofs, such as proving a statement about a rollup's state transition function by proving each block individually and aggregating these proofs to produce a final proof of a range of blocks. **For an example of how to use proof aggregation and recursion in SP1, refer to the [aggregation example](https://github.com/succinctlabs/sp1/blob/main/examples/aggregation/script/src/main.rs).** +Note that to verify an SP1 proof inside SP1, you must generate a "compressed" SP1 proof (see [Proof Types](../generating-proofs/proof-types.md) for more details). + +### When to use aggregation + +Note that by itself, SP1 can already prove arbitarily large programs by chunking the program's execution into multiple "shards" (contiguous batches of cycles) and generating proofs for each shard in parallel, and then recursively aggregating the proofs. Thus, aggregation is generally **not necessary** for most use-cases, as SP1's proving for large programs is already parallelized. However, aggregation can be useful for aggregating computations that require more than the zkVM's limited (~2GB) memory or for aggregating multiple SP1 proofs from different parties into a single proof to save on onchain verification costs. + ## Verifying Proofs inside the zkVM -To verify a proof inside the zkVM, you can use the `sp1_zkvm::lib::verify_proof` function. +To verify a proof inside the zkVM, you can use the `sp1_zkvm::lib::verify::verify_proof` function. ```rust,noplayground -sp1_zkvm::lib::verify_proof(vkey, public_values_digest); +sp1_zkvm::lib::verify::verify_proof(vkey, public_values_digest); ``` **You do not need to pass in the proof as input into the syscall, as the proof will automatically be read for the proof input stream by the prover.** +Note that you must include the `verify` feature in your `Cargo.toml` for `sp1-zkvm` to be able to use the `verify_proof` function (like [this](https://github.com/succinctlabs/sp1/blob/main/examples/aggregation/program/Cargo.toml#L11)). + ## Generating Proofs with Aggregation To provide an existing proof as input to the SP1 zkVM, you can use the existing `SP1Stdin` object @@ -27,7 +35,8 @@ which is already used for all inputs to the zkVM. let (input_pk, input_vk) = client.setup(PROOF_INPUT_ELF); let (aggregation_pk, aggregation_vk) = client.setup(AGGREGATION_ELF); -// Generate a proof that will be recursively verified / aggregated. +// Generate a proof that will be recursively verified / aggregated. Note that we use the "compressed" +// proof type, which is necessary for aggregation. let mut stdin = SP1Stdin::new(); let input_proof = client .prove(&input_pk, stdin) @@ -37,7 +46,7 @@ let input_proof = client // Create a new stdin object to write the proof and the corresponding verifying key to. let mut stdin = SP1Stdin::new(); -stdin.write_proof(proof, input_vk); +stdin.write_proof(input_proof, input_vk); // Generate a proof that will recusively verify / aggregate the input proof. let aggregation_proof = client diff --git a/book/writing-programs/setup.md b/book/writing-programs/setup.md index 5e89f84509..0346b3b7ad 100644 --- a/book/writing-programs/setup.md +++ b/book/writing-programs/setup.md @@ -11,38 +11,9 @@ cargo prove new cd program ``` -## Build with CLI (Development) - -> WARNING: This may not generate a reproducible ELF which is necessary for verifying that your binary corresponds to given source code. -> -> Use the [reproducible build system](#build-with-docker-production) for production builds. - -To build the program while in development, simply run: - -```bash -cargo prove build -``` - -This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-succinct-zkvm-elf`. - -## Build with Docker (Production) - -For production builds of programs, you can build your program inside a Docker container which will generate a **reproducible ELF** on all platforms. To do so, just use the `--docker` flag and the `--tag` flag with the release version you want to use. For example: - -```bash -cargo prove build --docker --tag v1.0.1 -``` - -To verify that your build is reproducible, you can compute the SHA-512 hash of the ELF on different platforms and systems with: - -```bash -$ shasum -a 512 elf/riscv32im-succinct-zkvm-elf -f9afb8caaef10de9a8aad484c4dd3bfa54ba7218f3fc245a20e8a03ed40b38c617e175328515968aecbd3c38c47b2ca034a99e6dbc928512894f20105b03a203 -``` - ## Manual Project Setup -You can also manually setup a project. First create a new cargo project: +You can also manually setup a project. First create a new Rust project using `cargo`: ```bash cargo new program @@ -51,7 +22,7 @@ cd program ### Cargo Manifest -Inside this crate, add the `sp1-zkvm` crate as a dependency. Your `Cargo.toml` should look like as follows: +Inside this crate, add the `sp1-zkvm` crate as a dependency. Your `Cargo.toml` should look like the following: ```rust,noplayground [workspace] @@ -61,7 +32,7 @@ name = "program" edition = "2021" [dependencies] -sp1-zkvm = "1.0.1" +sp1-zkvm = "1.1.0" ``` The `sp1-zkvm` crate includes necessary utilities for your program, including handling inputs and outputs, @@ -69,12 +40,11 @@ precompiles, patches, and more. ### main.rs -Inside the `src/main.rs` file, you must make sure to include these two lines to ensure that the crate -properly compiles. +Inside the `src/main.rs` file, you must make sure to include these two lines to ensure that your program properly compiles to a valid SP1 program. ```rust,noplayground #![no_main] sp1_zkvm::entrypoint!(main); ``` -These two lines of code wrap your main function with some additional logic to ensure that your program compiles correctly with the RISCV target. +These two lines of code wrap your main function with some additional logic to ensure that your program compiles correctly with the RISC-V target. diff --git a/build/CHANGELOG.md b/build/CHANGELOG.md index e9ccbee6ab..971ec16ea6 100644 --- a/build/CHANGELOG.md +++ b/build/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-build-v1.0.1...sp1-build-v1.1.0) - 2024-08-02 + +### Added +- use C++ toolchain when building programs that need C ([#1092](https://github.com/succinctlabs/sp1/pull/1092)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-build-v1.0.0-rc.1...sp1-build-v1.0.0-rc.1) - 2024-07-19 ### Fixed diff --git a/build/src/docker.rs b/build/src/docker.rs index 2047bf9f8c..618b618198 100644 --- a/build/src/docker.rs +++ b/build/src/docker.rs @@ -18,9 +18,15 @@ fn get_docker_image(tag: &str) -> String { pub fn create_docker_command( args: &BuildArgs, program_dir: &Utf8PathBuf, - workspace_root: &Utf8PathBuf, + program_metadata: &cargo_metadata::Metadata, ) -> Result { let image = get_docker_image(&args.tag); + let canonicalized_program_dir: Utf8PathBuf = program_dir + .canonicalize() + .expect("Failed to canonicalize program directory") + .try_into() + .unwrap(); + let workspace_root = &program_metadata.workspace_root; // Check if docker is installed and running. let docker_check = Command::new("docker") @@ -39,10 +45,29 @@ pub fn create_docker_command( let workspace_root_path = format!("{}:/root/program", workspace_root); let program_dir_path = format!( "/root/program/{}", - program_dir.strip_prefix(workspace_root).unwrap() + canonicalized_program_dir + .strip_prefix(workspace_root) + .unwrap() ); - // Add docker-specific arguments. + // Get the target directory for the ELF in the context of the Docker container. + let relative_target_dir = (program_metadata.target_directory) + .strip_prefix(workspace_root) + .unwrap(); + let target_dir = format!( + "/root/program/{}/{}/{}", + relative_target_dir, + crate::HELPER_TARGET_SUBDIR, + "docker" + ); + + // When executing the Docker command: + // 1. Set the target directory to a subdirectory of the program's target directory to avoid build + // conflicts with the parent process. Source: https://github.com/rust-lang/cargo/issues/6412 + // 2. Set the rustup toolchain to succinct. + // 3. Set the encoded rust flags. + // Note: In Docker, you can't use the .env command to set environment variables, you have to use + // the -e flag. let mut docker_args = vec![ "run".to_string(), "--rm".to_string(), @@ -53,6 +78,8 @@ pub fn create_docker_command( "-w".to_string(), program_dir_path, "-e".to_string(), + format!("CARGO_TARGET_DIR={}", target_dir), + "-e".to_string(), "RUSTUP_TOOLCHAIN=succinct".to_string(), "-e".to_string(), format!("CARGO_ENCODED_RUSTFLAGS={}", get_rust_compiler_flags()), @@ -66,6 +93,8 @@ pub fn create_docker_command( docker_args.extend_from_slice(&get_program_build_args(args)); let mut command = Command::new("docker"); - command.current_dir(program_dir.clone()).args(&docker_args); + command + .current_dir(canonicalized_program_dir.clone()) + .args(&docker_args); Ok(command) } diff --git a/build/src/lib.rs b/build/src/lib.rs index fbb618f057..2cc6a69d05 100644 --- a/build/src/lib.rs +++ b/build/src/lib.rs @@ -13,53 +13,59 @@ use std::{ }; const BUILD_TARGET: &str = "riscv32im-succinct-zkvm-elf"; -const DEFAULT_TAG: &str = "latest"; +const DEFAULT_TAG: &str = "v1.1.0"; const DEFAULT_OUTPUT_DIR: &str = "elf"; const HELPER_TARGET_SUBDIR: &str = "elf-compilation"; -/// [`BuildArgs`] is a struct that holds various arguments used for building a program. +/// Compile an SP1 program. /// -/// This struct can be used to configure the build process, including options for using Docker, +/// Additional arguments are useful for configuring the build process, including options for using Docker, /// specifying binary and ELF names, ignoring Rust version checks, and enabling specific features. #[derive(Clone, Parser, Debug)] pub struct BuildArgs { - #[clap(long, action, help = "Build using Docker for reproducible builds.")] + #[clap( + long, + action, + help = "Run compilation using a Docker container for reproducible builds." + )] pub docker: bool, #[clap( long, - help = "The ghcr.io/succinctlabs/sp1 image tag to use when building with docker.", + help = "The ghcr.io/succinctlabs/sp1 image tag to use when building with Docker.", default_value = DEFAULT_TAG )] pub tag: String, - #[clap(long, action, value_delimiter = ',', help = "Build with features.")] + #[clap( + long, + action, + value_delimiter = ',', + help = "Space or comma separated list of features to activate" + )] pub features: Vec, - #[clap(long, action, help = "Ignore Rust version check.")] + #[clap(long, action, help = "Do not activate the `default` feature")] + pub no_default_features: bool, + #[clap(long, action, help = "Ignore `rust-version` specification in packages")] pub ignore_rust_version: bool, + #[clap(long, action, help = "Assert that `Cargo.lock` will remain unchanged")] + pub locked: bool, #[clap( alias = "bin", long, action, - help = "If building a binary, specify the name.", + help = "Build only the specified binary", default_value = "" )] pub binary: String, - #[clap(long, action, help = "ELF binary name.", default_value = "")] + #[clap(long, action, help = "ELF binary name", default_value = "")] pub elf_name: String, #[clap( + alias = "out-dir", long, action, - help = "The output directory for the built program.", + help = "Copy the compiled ELF to this directory", default_value = DEFAULT_OUTPUT_DIR )] pub output_directory: String, - #[clap( - long, - action, - help = "Lock the dependencies, ensures that Cargo.lock doesn't update." - )] - pub locked: bool, - #[clap(long, action, help = "Build without default features.")] - pub no_default_features: bool, } // Implement default args to match clap defaults. @@ -127,7 +133,11 @@ fn get_rust_compiler_flags() -> String { } /// Get the command to build the program locally. -fn create_local_command(args: &BuildArgs, program_dir: &Utf8PathBuf) -> Command { +fn create_local_command( + args: &BuildArgs, + program_dir: &Utf8PathBuf, + program_metadata: &cargo_metadata::Metadata, +) -> Command { let mut command = Command::new("cargo"); let canonicalized_program_dir = program_dir .canonicalize() @@ -147,34 +157,28 @@ fn create_local_command(args: &BuildArgs, program_dir: &Utf8PathBuf) -> Command } } + // When executing the local command: + // 1. Set the target directory to a subdirectory of the program's target directory to avoid build + // conflicts with the parent process. Source: https://github.com/rust-lang/cargo/issues/6412 + // 2. Set the rustup toolchain to succinct. + // 3. Set the encoded rust flags. + // 4. Remove the rustc configuration, otherwise in a build script it will attempt to compile the + // program with the toolchain of the normal build process, rather than the Succinct toolchain. command .current_dir(canonicalized_program_dir) .env("RUSTUP_TOOLCHAIN", "succinct") .env("CARGO_ENCODED_RUSTFLAGS", get_rust_compiler_flags()) + .env_remove("RUSTC") + .env( + "CARGO_TARGET_DIR", + program_metadata.target_directory.join(HELPER_TARGET_SUBDIR), + ) .args(&get_program_build_args(args)); command } /// Execute the command and handle the output depending on the context. -fn execute_command( - mut command: Command, - docker: bool, - program_metadata: &cargo_metadata::Metadata, -) -> Result<()> { - // Strip the rustc configuration, otherwise in the helper it will attempt to compile the SP1 - // program with the toolchain of the normal build process, rather than the Succinct toolchain. - command.env_remove("RUSTC"); - - // Set the target directory to a subdirectory of the program's target directory to avoid - // build conflicts with the parent process. If removed, programs that share the same target - // directory (i.e. same workspace) as the script will hang indefinitely due to a file lock - // when building in the helper. - // Source: https://github.com/rust-lang/cargo/issues/6412 - command.env( - "CARGO_TARGET_DIR", - program_metadata.target_directory.join(HELPER_TARGET_SUBDIR), - ); - +fn execute_command(mut command: Command, docker: bool) -> Result<()> { // Add necessary tags for stdout and stderr from the command. let mut child = command .stdout(Stdio::piped()) @@ -218,13 +222,27 @@ fn copy_elf_to_output_dir( let root_package = program_metadata.root_package(); let root_package_name = root_package.as_ref().map(|p| &p.name); - // The ELF is written to a target folder specified by the program's package. + // The ELF is written to a target folder specified by the program's package. If built with Docker, + // includes /docker after HELPER_TARGET_SUBDIR. + let mut target_dir_suffix = HELPER_TARGET_SUBDIR.to_string(); + if args.docker { + target_dir_suffix = format!("{}/{}", HELPER_TARGET_SUBDIR, "docker"); + } + + // The ELF's file name is the binary name if it's specified. Otherwise, it is the root package + // name. + let original_elf_file_name = if !args.binary.is_empty() { + args.binary.clone() + } else { + root_package_name.unwrap().clone() + }; + let original_elf_path = program_metadata .target_directory - .join(HELPER_TARGET_SUBDIR) + .join(target_dir_suffix) .join(BUILD_TARGET) .join("release") - .join(root_package_name.unwrap()); + .join(original_elf_file_name); // The order of precedence for the ELF name is: // 1. --elf_name flag @@ -272,17 +290,7 @@ pub fn build_program(args: &BuildArgs, program_dir: Option) -> Result) -> Result --trace <...> +``` + +### Installing the CLI locally from source + +You can install the CLI locally from source by running the following command: ```bash cargo install --locked --path . ``` -## Usage +### Running the CLI after installing + +After installing the CLI, you can run it by simply running the following command: ```bash cargo prove diff --git a/cli/docker/Dockerfile b/cli/docker/Dockerfile index f639579a00..d08d001959 100644 --- a/cli/docker/Dockerfile +++ b/cli/docker/Dockerfile @@ -1,12 +1,16 @@ FROM ubuntu:24.04@sha256:e3f92abc0967a6c19d0dfa2d55838833e947b9d74edbcb0113e48535ad4be12a RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates clang curl libssl-dev pkg-config git dialog \ + && apt-get install -y --no-install-recommends ca-certificates clang curl libssl-dev pkg-config git dialog xz-utils \ && curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL 'https://sh.rustup.rs' | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -RUN curl -L https://sp1.succinct.xyz | bash && ~/.sp1/bin/sp1up +ARG BUILDTIME + +# Use the BUILDTIME argument to break caching and force a new layer +RUN echo "Cache bust: ${BUILDTIME}" > /dev/null && \ + curl -L https://sp1.succinct.xyz | bash && ~/.sp1/bin/sp1up # Install the C++ toolchain for RISC-V and create a symlink to it in /root/.sp1/bin RUN mkdir -p /root/.sp1/riscv \ diff --git a/cli/src/bin/cargo-prove.rs b/cli/src/bin/cargo-prove.rs index 783741e6e3..af04ebaffc 100644 --- a/cli/src/bin/cargo-prove.rs +++ b/cli/src/bin/cargo-prove.rs @@ -3,7 +3,7 @@ use clap::{Parser, Subcommand}; use sp1_cli::{ commands::{ build::BuildCmd, build_toolchain::BuildToolchainCmd, - install_toolchain::InstallToolchainCmd, new::NewCmd, prove::ProveCmd, + install_toolchain::InstallToolchainCmd, new::NewCmd, prove::ProveCmd, trace::TraceCmd, }, SP1_VERSION_MESSAGE, }; @@ -31,6 +31,7 @@ pub enum ProveCliCommands { Prove(ProveCmd), BuildToolchain(BuildToolchainCmd), InstallToolchain(InstallToolchainCmd), + Trace(TraceCmd), } fn main() -> Result<()> { @@ -42,5 +43,6 @@ fn main() -> Result<()> { ProveCliCommands::Prove(cmd) => cmd.run(), ProveCliCommands::BuildToolchain(cmd) => cmd.run(), ProveCliCommands::InstallToolchain(cmd) => cmd.run(), + ProveCliCommands::Trace(cmd) => cmd.run(), } } diff --git a/cli/src/commands/build.rs b/cli/src/commands/build.rs index 51d8d1b64b..d72504c954 100644 --- a/cli/src/commands/build.rs +++ b/cli/src/commands/build.rs @@ -3,11 +3,8 @@ use clap::Parser; use sp1_build::{build_program, BuildArgs}; #[derive(Parser)] -#[command(name = "build", about = "Build a program")] +#[command(name = "build", about = "Compile an SP1 program")] pub struct BuildCmd { - #[clap(long, action)] - verbose: bool, - #[clap(flatten)] build_args: BuildArgs, } diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index cdbcc19a8d..d3a429d0f4 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -3,3 +3,4 @@ pub mod build_toolchain; pub mod install_toolchain; pub mod new; pub mod prove; +pub mod trace; diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index 86798be083..d7d959749d 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -29,6 +29,12 @@ impl NewCmd { fs::create_dir(&self.name)?; } + println!( + " \x1b[1m{}\x1b[0m {}", + Paint::green("Cloning"), + TEMPLATE_REPOSITORY_URL + ); + // Clone the repository with the specified version. let output = Command::new("git") .arg("clone") @@ -65,7 +71,7 @@ impl NewCmd { } println!( - " \x1b[1m{}\x1b[0m {} ({})", + " \x1b[1m{}\x1b[0m {} ({})", Paint::green("Initialized"), self.name, std::fs::canonicalize(root) diff --git a/cli/src/commands/trace.rs b/cli/src/commands/trace.rs new file mode 100644 index 0000000000..25add79789 --- /dev/null +++ b/cli/src/commands/trace.rs @@ -0,0 +1,460 @@ +//! RISC-V tracer for SP1 traces. This tool can be used to analyze function call graphs and +//! instruction counts from a trace file from SP1 execution by setting the `TRACE_FILE` env variable. +// +// Adapted from Sovereign's RISC-V tracer tool: https://github.com/Sovereign-Labs/riscv-cycle-tracer. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Modified by Succinct Labs on July 25, 2024. + +use anyhow::Result; +use clap::Parser; +use goblin::elf::{sym::STT_FUNC, Elf}; +use indicatif::{ProgressBar, ProgressStyle}; +use prettytable::{format, Cell, Row, Table}; +use regex::Regex; +use rustc_demangle::demangle; +use std::cmp::Ordering; +use std::collections::HashMap; +use std::io::Read; +use std::process::Command; +use std::str; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; +use textwrap::wrap; + +#[derive(Parser, Debug)] +#[command( + name = "trace", + about = "Trace a program execution and analyze cycle counts." +)] +pub struct TraceCmd { + /// Include the "top" number of functions. + #[arg(short, long, default_value_t = 30)] + top: usize, + + /// Don't print stack aware instruction counts + #[arg(long)] + no_stack_counts: bool, + + /// Don't print raw (stack un-aware) instruction counts. + #[arg(long)] + no_raw_counts: bool, + + /// Path to the ELF. + #[arg(long, required = true)] + elf: String, + + /// Path to the trace file. Simply run the program with `TRACE_FILE=trace.log` environment + /// variable. File must be one u64 program counter per line + #[arg(long, required = true)] + trace: String, + + /// Strip the hashes from the function name while printing. + #[arg(short, long)] + keep_hashes: bool, + + /// Function name to target for getting stack counts. + #[arg(short, long)] + function_name: Option, + + /// Exclude functions matching these patterns from display. + /// + /// Usage: `-e func1 -e func2 -e func3`. + #[arg(short, long)] + exclude_view: Vec, +} + +fn strip_hash(name_with_hash: &str) -> String { + let re = Regex::new(r"::h[0-9a-fA-F]{16}").unwrap(); + let mut result = re.replace(name_with_hash, "").to_string(); + let re2 = Regex::new(r"^<(.+) as .+>").unwrap(); + result = re2.replace(&result, "$1").to_string(); + let re2 = Regex::new(r"^<(.+) as .+>").unwrap(); + result = re2.replace(&result, "$1").to_string(); + let re2 = Regex::new(r"([^\:])<.+>::").unwrap(); + result = re2.replace_all(&result, "$1::").to_string(); + result +} + +fn print_intruction_counts( + first_header: &str, + count_vec: Vec<(String, usize)>, + top_n: usize, + strip_hashes: bool, + exclude_list: Option<&[String]>, +) { + let mut table = Table::new(); + table.set_format(*format::consts::FORMAT_NO_LINESEP); + table.set_titles(Row::new(vec![ + Cell::new(first_header), + Cell::new("Instruction Count"), + ])); + + let wrap_width = 120; + let mut row_count = 0; + for (key, value) in count_vec { + let mut cont = false; + if let Some(ev) = exclude_list { + for e in ev { + if key.contains(e) { + cont = true; + break; + } + } + if cont { + continue; + } + } + let mut stripped_key = key.clone(); + if strip_hashes { + stripped_key = strip_hash(&key); + } + row_count += 1; + if row_count > top_n { + break; + } + let wrapped_key = wrap(&stripped_key, wrap_width); + let key_cell_content = wrapped_key.join("\n"); + table.add_row(Row::new(vec![ + Cell::new(&key_cell_content), + Cell::new(&value.to_string()), + ])); + } + + table.printstd(); +} + +fn focused_stack_counts( + function_stack: &[String], + filtered_stack_counts: &mut HashMap, usize>, + function_name: &str, + num_instructions: usize, +) { + if let Some(index) = function_stack.iter().position(|s| s == function_name) { + let truncated_stack = &function_stack[0..=index]; + let count = filtered_stack_counts + .entry(truncated_stack.to_vec()) + .or_insert(0); + *count += num_instructions; + } +} + +fn _build_radare2_lookups( + start_lookup: &mut HashMap, + end_lookup: &mut HashMap, + func_range_lookup: &mut HashMap, + elf_name: &str, +) -> std::io::Result<()> { + let output = Command::new("r2") + .arg("-q") + .arg("-c") + .arg("aa;afl") + .arg(elf_name) + .output()?; + + if output.status.success() { + let result_str = str::from_utf8(&output.stdout).unwrap(); + for line in result_str.lines() { + let parts: Vec<&str> = line.split_whitespace().collect(); + let address = u64::from_str_radix(&parts[0][2..], 16).unwrap(); + let size = parts[2].parse::().unwrap(); + let end_address = address + size - 4; + let function_name = parts[3]; + start_lookup.insert(address, function_name.to_string()); + end_lookup.insert(end_address, function_name.to_string()); + func_range_lookup.insert(function_name.to_string(), (address, end_address)); + } + } else { + eprintln!( + "Error executing command: {}", + str::from_utf8(&output.stderr).unwrap() + ); + } + Ok(()) +} + +fn build_goblin_lookups( + start_lookup: &mut HashMap, + end_lookup: &mut HashMap, + func_range_lookup: &mut HashMap, + elf_name: &str, +) -> std::io::Result<()> { + let buffer = std::fs::read(elf_name).unwrap(); + let elf = Elf::parse(&buffer).unwrap(); + + for sym in &elf.syms { + if sym.st_type() == STT_FUNC { + let name = elf.strtab.get_at(sym.st_name).unwrap_or(""); + let demangled_name = demangle(name); + let size = sym.st_size; + let start_address = sym.st_value; + let end_address = start_address + size - 4; + start_lookup.insert(start_address, demangled_name.to_string()); + end_lookup.insert(end_address, demangled_name.to_string()); + func_range_lookup.insert(demangled_name.to_string(), (start_address, end_address)); + } + } + Ok(()) +} + +fn increment_stack_counts( + instruction_counts: &mut HashMap, + function_stack: &[String], + filtered_stack_counts: &mut HashMap, usize>, + function_name: &Option, + num_instructions: usize, +) { + for f in function_stack { + *instruction_counts.entry(f.clone()).or_insert(0) += num_instructions; + } + if let Some(f) = function_name { + focused_stack_counts(function_stack, filtered_stack_counts, f, num_instructions) + } +} + +impl TraceCmd { + pub fn run(&self) -> Result<()> { + let top_n = self.top; + let elf_path = self.elf.clone(); + let trace_path = self.trace.clone(); + let no_stack_counts = self.no_stack_counts; + let no_raw_counts = self.no_raw_counts; + let strip_hashes = !self.keep_hashes; + let function_name = self.function_name.clone(); + let exclude_view = self.exclude_view.clone(); + + let mut start_lookup = HashMap::new(); + let mut end_lookup = HashMap::new(); + let mut func_range_lookup = HashMap::new(); + build_goblin_lookups( + &mut start_lookup, + &mut end_lookup, + &mut func_range_lookup, + &elf_path, + ) + .unwrap(); + + let mut function_ranges: Vec<(u64, u64, String)> = func_range_lookup + .iter() + .map(|(f, &(start, end))| (start, end, f.clone())) + .collect(); + + function_ranges.sort_by_key(|&(start, _, _)| start); + + let file = std::fs::File::open(trace_path).unwrap(); + let file_size = file.metadata().unwrap().len(); + let mut buf = std::io::BufReader::new(file); + let mut function_stack: Vec = Vec::new(); + let mut instruction_counts: HashMap = HashMap::new(); + let mut counts_without_callgraph: HashMap = HashMap::new(); + let mut filtered_stack_counts: HashMap, usize> = HashMap::new(); + let total_lines = file_size / 4; + let mut current_function_range: (u64, u64) = (0, 0); + + let update_interval = 1000usize; + let pb = ProgressBar::new(total_lines); + pb.set_style( + ProgressStyle::default_bar() + .template( + "{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})", + ) + .unwrap() + .progress_chars("#>-"), + ); + + let running = Arc::new(AtomicBool::new(true)); + let r = running.clone(); + + ctrlc::set_handler(move || { + r.store(false, std::sync::atomic::Ordering::SeqCst); + }) + .expect("Error setting Ctrl-C handler"); + + for c in 0..total_lines { + if (c as usize) % update_interval == 0 { + pb.inc(update_interval as u64); + if !running.load(std::sync::atomic::Ordering::SeqCst) { + pb.finish_with_message("Interrupted"); + break; + } + } + + // Parse pc from hex. + let mut pc_bytes = [0u8; 4]; + buf.read_exact(&mut pc_bytes).unwrap(); + let pc = u32::from_be_bytes(pc_bytes) as u64; + + // Only 1 instruction per opcode. + let num_instructions = 1; + + // Raw counts without considering the callgraph at all we're just checking if the PC + // belongs to a function if so we're incrementing. This would ignore the call stack + // so for example "main" would only have a hundred instructions or so. + if let Ok(index) = function_ranges.binary_search_by(|&(start, end, _)| { + if pc < start { + Ordering::Greater + } else if pc > end { + Ordering::Less + } else { + Ordering::Equal + } + }) { + let (_, _, fname) = &function_ranges[index]; + *counts_without_callgraph.entry(fname.clone()).or_insert(0) += num_instructions + } else { + *counts_without_callgraph + .entry("anonymous".to_string()) + .or_insert(0) += num_instructions; + } + + // The next section considers the callstack. We build a callstack and maintain it based + // on some rules. Functions lower in the stack get their counts incremented. + + // We are still in the current function. + if pc > current_function_range.0 && pc <= current_function_range.1 { + increment_stack_counts( + &mut instruction_counts, + &function_stack, + &mut filtered_stack_counts, + &function_name, + num_instructions, + ); + continue; + } + + // Jump to a new function (or the same one). + if let Some(f) = start_lookup.get(&pc) { + increment_stack_counts( + &mut instruction_counts, + &function_stack, + &mut filtered_stack_counts, + &function_name, + num_instructions, + ); + + // Jump to a new function (not recursive). + if !function_stack.contains(f) { + function_stack.push(f.clone()); + current_function_range = *func_range_lookup.get(f).unwrap(); + } + } else { + // This means pc now points to an instruction that is + // + // 1. not in the current function's range + // 2. not a new function call + // + // We now account for a new possibility where we're returning to a function in the + // stack this need not be the immediate parent and can be any of the existing + // functions in the stack due to some optimizations that the compiler can make. + let mut unwind_point = 0; + let mut unwind_found = false; + for (c, f) in function_stack.iter().enumerate() { + let (s, e) = func_range_lookup.get(f).unwrap(); + if pc > *s && pc <= *e { + unwind_point = c; + unwind_found = true; + break; + } + } + + // Unwinding until the parent. + if unwind_found { + function_stack.truncate(unwind_point + 1); + increment_stack_counts( + &mut instruction_counts, + &function_stack, + &mut filtered_stack_counts, + &function_name, + num_instructions, + ); + continue; + } + + // If no unwind point has been found, that means we jumped to some random location + // so we'll just increment the counts for everything in the stack. + increment_stack_counts( + &mut instruction_counts, + &function_stack, + &mut filtered_stack_counts, + &function_name, + num_instructions, + ); + } + } + + pb.finish_with_message("done"); + + let mut raw_counts: Vec<(String, usize)> = instruction_counts + .iter() + .map(|(key, value)| (key.clone(), *value)) + .collect(); + raw_counts.sort_by(|a, b| b.1.cmp(&a.1)); + + println!("\n\nTotal instructions in trace: {}", total_lines); + if !no_stack_counts { + println!("\n\n Instruction counts considering call graph"); + print_intruction_counts( + "Function Name", + raw_counts, + top_n, + strip_hashes, + Some(&exclude_view), + ); + } + + let mut raw_counts: Vec<(String, usize)> = counts_without_callgraph + .iter() + .map(|(key, value)| (key.clone(), *value)) + .collect(); + raw_counts.sort_by(|a, b| b.1.cmp(&a.1)); + if !no_raw_counts { + println!("\n\n Instruction counts ignoring call graph"); + print_intruction_counts( + "Function Name", + raw_counts, + top_n, + strip_hashes, + Some(&exclude_view), + ); + } + + let mut raw_counts: Vec<(String, usize)> = filtered_stack_counts + .iter() + .map(|(stack, count)| { + let numbered_stack = stack + .iter() + .rev() + .enumerate() + .map(|(index, line)| { + let modified_line = if strip_hashes { + strip_hash(line) + } else { + line.clone() + }; + format!("({}) {}", index + 1, modified_line) + }) + .collect::>() + .join("\n"); + (numbered_stack, *count) + }) + .collect(); + + raw_counts.sort_by(|a, b| b.1.cmp(&a.1)); + if let Some(f) = function_name { + println!("\n\n Stack patterns for function '{f}' "); + print_intruction_counts("Function Stack", raw_counts, top_n, strip_hashes, None); + } + Ok(()) + } +} diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 327e04d5ff..2eeb1b9a9e 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-core-v1.0.1...sp1-core-v1.1.0) - 2024-08-02 + +### Added +- experimental gpu support ([#1219](https://github.com/succinctlabs/sp1/pull/1219)) +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) +- streaming recursion ([#1175](https://github.com/succinctlabs/sp1/pull/1175)) +- streaming prover for core ([#1146](https://github.com/succinctlabs/sp1/pull/1146)) + +### Fixed +- memory global generate_dependencies ([#1220](https://github.com/succinctlabs/sp1/pull/1220)) +- device oom ([#1202](https://github.com/succinctlabs/sp1/pull/1202)) +- cycle tracking logs ([#1178](https://github.com/succinctlabs/sp1/pull/1178)) +- UB from `OpcodeSpecificCols` union ([#1050](https://github.com/succinctlabs/sp1/pull/1050)) + +### Other +- merge main into dev ([#1180](https://github.com/succinctlabs/sp1/pull/1180)) +- prover trait cleanup ([#1170](https://github.com/succinctlabs/sp1/pull/1170)) +- *(deps)* bump arrayref from 0.3.7 to 0.3.8 ([#1154](https://github.com/succinctlabs/sp1/pull/1154)) +- *(deps)* bump thiserror from 1.0.61 to 1.0.63 ([#1136](https://github.com/succinctlabs/sp1/pull/1136)) +- generate dep optimizations ([#1125](https://github.com/succinctlabs/sp1/pull/1125)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-core-v1.0.0-rc.1...sp1-core-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/core/src/lib.rs b/core/src/lib.rs index e9e1e56099..7de36a6f03 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -37,4 +37,4 @@ use stark::StarkGenericConfig; /// This string should be updated whenever any step in verifying an SP1 proof changes, including /// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark /// docker image. -pub const SP1_CIRCUIT_VERSION: &str = "v1.0.1"; +pub const SP1_CIRCUIT_VERSION: &str = "v1.1.0"; diff --git a/core/src/runtime/hooks.rs b/core/src/runtime/hooks.rs index 80a4bcf1bf..16158aab24 100644 --- a/core/src/runtime/hooks.rs +++ b/core/src/runtime/hooks.rs @@ -98,6 +98,21 @@ pub struct HookEnv<'a, 'b: 'a> { pub runtime: &'a Runtime<'b>, } +/// Recovers the public key from the signature and message hash using the k256 crate. +/// +/// # Arguments +/// +/// * `env` - The environment in which the hook is invoked. +/// * `buf` - The buffer containing the signature and message hash. +/// - The signature is 65 bytes, the first 64 bytes are the signature and the last byte is the +/// recovery ID. +/// - The message hash is 32 bytes. +/// +/// The result is returned as a pair of bytes, where the first 32 bytes are the X coordinate +/// and the second 32 bytes are the Y coordinate of the decompressed point. +/// +/// WARNING: This function is used to recover the public key outside of the zkVM context. These +/// values must be constrained by the zkVM for correctness. pub fn hook_ecrecover(_env: HookEnv, buf: &[u8]) -> Vec> { assert_eq!( buf.len(), @@ -115,7 +130,7 @@ pub fn hook_ecrecover(_env: HookEnv, buf: &[u8]) -> Vec> { sig = sig_normalized; recovery_id ^= 1 }; - let recid = RecoveryId::from_byte(recovery_id).expect("Recovery ID is valid"); + let recid = RecoveryId::from_byte(recovery_id).expect("Computed recovery ID is invalid!"); let recovered_key = VerifyingKey::recover_from_prehash(&msg_hash[..], &sig, recid).unwrap(); let bytes = recovered_key.to_sec1_bytes(); diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index c651bd725d..37a91794d9 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -15,9 +15,11 @@ mod utils; mod subproof; pub use context::*; +use hashbrown::HashSet; pub use hooks::*; pub use instruction::*; pub use memory::*; +use nohash_hasher::BuildNoHashHasher; pub use opcode::*; pub use program::*; pub use record::*; @@ -117,6 +119,10 @@ pub struct Runtime<'a> { /// The maximum number of cpu cycles to use for execution. pub max_cycles: Option, + + /// Memory addresses that were touched in this batch of shards. Used to minimize the size of + /// checkpoints. + pub touched_memory: HashSet>, } #[derive(Error, Debug, Serialize, Deserialize)] @@ -195,6 +201,7 @@ impl<'a> Runtime<'a> { hook_registry, opts, max_cycles: context.max_cycles, + touched_memory: Default::default(), } } @@ -274,6 +281,7 @@ impl<'a> Runtime<'a> { /// Read a word from memory and create an access record. pub fn mr(&mut self, addr: u32, shard: u32, timestamp: u32) -> MemoryReadRecord { // Get the memory record entry. + self.touched_memory.insert(addr); let entry = self.state.memory.entry(addr); // If we're in unconstrained mode, we don't want to modify state, so we'll save the @@ -315,6 +323,7 @@ impl<'a> Runtime<'a> { /// Write a word to memory and create an access record. pub fn mw(&mut self, addr: u32, value: u32, shard: u32, timestamp: u32) -> MemoryWriteRecord { // Get the memory record entry. + self.touched_memory.insert(addr); let entry = self.state.memory.entry(addr); // If we're in unconstrained mode, we don't want to modify state, so we'll save the @@ -1059,12 +1068,33 @@ impl<'a> Runtime<'a> { Ok((std::mem::take(&mut self.records), done)) } - /// Execute up to `self.shard_batch_size` cycles, returning a copy of the prestate and whether the program ended. + /// Execute up to `self.shard_batch_size` cycles, returning the checkpoint from before execution + /// and whether the program ended. pub fn execute_state(&mut self) -> Result<(ExecutionState, bool), ExecutionError> { + self.touched_memory.clear(); self.emit_events = false; self.print_report = false; - let state = self.state.clone(); + let mut state = self.state.clone(); let done = self.execute()?; + // Remove the untouched addresses from the checkpoint. Skip if `done` since we need all of + // `state.memory` for MemoryFinalize + let touched_memory = std::mem::take(&mut self.touched_memory); + if !done { + state.memory = touched_memory + .iter() + .filter_map(|addr| state.memory.get(addr).map(|record| (*addr, *record))) + .collect(); + + state.uninitialized_memory = touched_memory + .into_iter() + .filter_map(|addr| { + state + .uninitialized_memory + .get(&addr) + .map(|record| (addr, *record)) + }) + .collect(); + } Ok((state, done)) } diff --git a/core/src/runtime/report.rs b/core/src/runtime/report.rs index 7b86a965f4..5eca893497 100644 --- a/core/src/runtime/report.rs +++ b/core/src/runtime/report.rs @@ -12,6 +12,7 @@ use super::*; pub struct ExecutionReport { pub opcode_counts: HashMap, pub syscall_counts: HashMap, + pub cycle_tracker: HashMap, } impl ExecutionReport { diff --git a/core/src/syscall/write.rs b/core/src/syscall/write.rs index 8e9d389cbd..9c42252b93 100644 --- a/core/src/syscall/write.rs +++ b/core/src/syscall/write.rs @@ -1,5 +1,5 @@ use crate::{ - runtime::{Register, Syscall, SyscallContext}, + runtime::{Register, Runtime, Syscall, SyscallContext}, utils::num_to_comma_separated, }; @@ -12,6 +12,24 @@ impl SyscallWrite { } impl Syscall for SyscallWrite { + /// Handle writes to file descriptors during execution. + /// + /// If stdout (fd = 1): + /// - If the stream is a cycle tracker, either log the cycle tracker or accumulate it in the report. + /// - Else, print the stream to stdout. + /// + /// If stderr (fd = 2): + /// - Print the stream to stderr. + /// + /// If fd = 3: + /// - Update the public value stream. + /// + /// If fd = 4: + /// - Update the input stream. + /// + /// If the fd matches a hook in the hook registry, invoke the hook. + /// + /// Else, log a warning. fn execute(&self, ctx: &mut SyscallContext, arg1: u32, arg2: u32) -> Option { let a2 = Register::X12; let rt = &mut ctx.rt; @@ -25,39 +43,16 @@ impl Syscall for SyscallWrite { let slice = bytes.as_slice(); if fd == 1 { let s = core::str::from_utf8(slice).unwrap(); - if s.contains("cycle-tracker-start:") { - let fn_name = s - .split("cycle-tracker-start:") - .last() - .unwrap() - .trim_end() - .trim_start(); - let depth = rt.cycle_tracker.len() as u32; - rt.cycle_tracker - .insert(fn_name.to_string(), (rt.state.global_clk, depth)); - let padding = (0..depth).map(|_| "│ ").collect::(); - log::info!("{}┌╴{}", padding, fn_name); - } else if s.contains("cycle-tracker-end:") { - let fn_name = s - .split("cycle-tracker-end:") - .last() - .unwrap() - .trim_end() - .trim_start(); - let (start, depth) = rt.cycle_tracker.remove(fn_name).unwrap_or((0, 0)); - // Leftpad by 2 spaces for each depth. - let padding = (0..depth).map(|_| "│ ").collect::(); - log::info!( - "{}└╴{} cycles", - padding, - num_to_comma_separated(rt.state.global_clk - start as u64) - ); - } else { - let flush_s = update_io_buf(ctx, fd, s); - if !flush_s.is_empty() { - flush_s - .into_iter() - .for_each(|line| println!("stdout: {}", line)); + match parse_cycle_tracker_command(s) { + Some(command) => handle_cycle_tracker_command(rt, command), + None => { + // If the string does not match any known command, print it to stdout. + let flush_s = update_io_buf(ctx, fd, s); + if !flush_s.is_empty() { + flush_s + .into_iter() + .for_each(|line| println!("stdout: {}", line)); + } } } } else if fd == 2 { @@ -84,7 +79,79 @@ impl Syscall for SyscallWrite { } } -pub fn update_io_buf(ctx: &mut SyscallContext, fd: u32, s: &str) -> Vec { +/// An enum representing the different cycle tracker commands. +#[derive(Clone)] +enum CycleTrackerCommand { + Start(String), + End(String), + ReportStart(String), + ReportEnd(String), +} + +/// Parse a cycle tracker command from a string. If the string does not match any known command, returns None. +fn parse_cycle_tracker_command(s: &str) -> Option { + let (command, fn_name) = s.split_once(':')?; + let trimmed_name = fn_name.trim().to_string(); + + match command { + "cycle-tracker-start" => Some(CycleTrackerCommand::Start(trimmed_name)), + "cycle-tracker-end" => Some(CycleTrackerCommand::End(trimmed_name)), + "cycle-tracker-report-start" => Some(CycleTrackerCommand::ReportStart(trimmed_name)), + "cycle-tracker-report-end" => Some(CycleTrackerCommand::ReportEnd(trimmed_name)), + _ => None, + } +} + +/// Handle a cycle tracker command. +fn handle_cycle_tracker_command(rt: &mut Runtime, command: CycleTrackerCommand) { + match command { + CycleTrackerCommand::Start(name) | CycleTrackerCommand::ReportStart(name) => { + start_cycle_tracker(rt, &name) + } + CycleTrackerCommand::End(name) => { + end_cycle_tracker(rt, &name); + } + CycleTrackerCommand::ReportEnd(name) => { + // Attempt to end the cycle tracker and accumulate the total cycles in the fn_name's + // entry in the ExecutionReport. + if let Some(total_cycles) = end_cycle_tracker(rt, &name) { + rt.report + .cycle_tracker + .entry(name.to_string()) + .and_modify(|cycles| *cycles += total_cycles) + .or_insert(total_cycles); + } + } + } +} + +/// Start tracking cycles for the given name at the specific depth and print out the log. +fn start_cycle_tracker(rt: &mut Runtime, name: &str) { + let depth = rt.cycle_tracker.len() as u32; + rt.cycle_tracker + .insert(name.to_string(), (rt.state.global_clk, depth)); + let padding = "│ ".repeat(depth as usize); + log::info!("{}┌╴{}", padding, name); +} + +/// End tracking cycles for the given name, print out the log, and return the total number of cycles in the span. +/// If the name is not found in the cycle tracker cache, returns None. +fn end_cycle_tracker(rt: &mut Runtime, name: &str) -> Option { + if let Some((start, depth)) = rt.cycle_tracker.remove(name) { + let padding = "│ ".repeat(depth as usize); + let total_cycles = rt.state.global_clk - start as u64; + log::info!( + "{}└╴{} cycles", + padding, + num_to_comma_separated(total_cycles) + ); + return Some(total_cycles); + } + None +} + +/// Update the io buffer for the given file descriptor with the given string. +fn update_io_buf(ctx: &mut SyscallContext, fd: u32, s: &str) -> Vec { let rt = &mut ctx.rt; let entry = rt.io_buf.entry(fd).or_default(); entry.push_str(s); diff --git a/core/src/utils/options.rs b/core/src/utils/options.rs index f0a157bcea..959feb8fe0 100644 --- a/core/src/utils/options.rs +++ b/core/src/utils/options.rs @@ -10,6 +10,7 @@ const DEFAULT_TRACE_GEN_WORKERS: usize = 1; const DEFAULT_CHECKPOINTS_CHANNEL_CAPACITY: usize = 128; const DEFAULT_RECORDS_AND_TRACES_CHANNEL_CAPACITY: usize = 1; +/// Options to configure the SP1 prover for core and recursive proofs. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct SP1ProverOpts { pub core_opts: SP1CoreOpts, diff --git a/derive/CHANGELOG.md b/derive/CHANGELOG.md index 67ba1999ef..449fe7ad87 100644 --- a/derive/CHANGELOG.md +++ b/derive/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-derive-v1.0.1...sp1-derive-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-derive-v1.0.0-rc.1...sp1-derive-v1.0.0-rc.1) - 2024-07-19 ### Other diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 542394c99d..7736faa6c4 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "aggregation-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "hex", "sp1-helper", @@ -68,7 +68,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" +checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" dependencies = [ "arrayvec", "bytes", @@ -129,7 +129,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -141,11 +141,11 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.2.6", + "indexmap 2.3.0", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "syn-solidity", "tiny-keccak", ] @@ -161,7 +161,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "syn-solidity", ] @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -218,33 +218,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -400,7 +400,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -428,7 +428,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -448,9 +448,9 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-util", "itoa", "matchit", @@ -481,7 +481,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "mime", "pin-project-lite", @@ -559,7 +559,7 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cexpr", "clang-sys", "itertools 0.12.1", @@ -572,7 +572,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.66", + "syn 2.0.72", "which", ] @@ -599,9 +599,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -637,16 +637,16 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "rayon", + "rayon-core", ] [[package]] @@ -704,9 +704,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "byteorder" @@ -716,9 +716,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -757,9 +757,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", @@ -782,7 +782,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chess-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-helper", "sp1-sdk", @@ -798,7 +798,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -824,9 +824,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -834,9 +834,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -846,21 +846,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "cobs" @@ -922,9 +922,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "console" @@ -1096,7 +1096,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1114,7 +1114,7 @@ dependencies = [ [[package]] name = "cycle-tracking-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-helper", "sp1-sdk", @@ -1122,9 +1122,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -1132,27 +1132,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1207,7 +1207,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1297,17 +1297,15 @@ dependencies = [ "curve25519-dalek-ng", "hex", "rand_core", - "serde", "sha2 0.9.9", - "thiserror", "zeroize", ] [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elf" @@ -1521,7 +1519,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.66", + "syn 2.0.72", "toml", "walkdir", ] @@ -1539,7 +1537,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1557,7 +1555,7 @@ dependencies = [ "ethabi", "generic-array 0.14.7", "k256", - "num_enum 0.7.2", + "num_enum 0.7.3", "once_cell", "open-fastrlp", "rand", @@ -1565,7 +1563,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.66", + "syn 2.0.72", "tempfile", "thiserror", "tiny-keccak", @@ -1728,7 +1726,7 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "fibonacci-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "itertools 0.12.1", "sha2 0.10.8", @@ -1859,7 +1857,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1957,11 +1955,11 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git2" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "libgit2-sys", "log", @@ -2021,7 +2019,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -2040,7 +2038,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -2179,9 +2177,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", @@ -2196,7 +2194,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -2214,9 +2212,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -2238,16 +2236,16 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", "futures-util", "h2 0.4.5", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "httpdate", "itoa", @@ -2265,7 +2263,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-util", "rustls", "rustls-pki-types", @@ -2282,7 +2280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.29", + "hyper 0.14.30", "native-tls", "tokio", "tokio-native-tls", @@ -2296,7 +2294,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-util", "native-tls", "tokio", @@ -2306,16 +2304,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.3.1", + "http-body 1.0.1", + "hyper 1.4.1", "pin-project-lite", "socket2", "tokio", @@ -2420,9 +2418,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2462,7 +2460,7 @@ dependencies = [ [[package]] name = "io-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "serde", "sp1-helper", @@ -2477,16 +2475,16 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-prime-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-sdk", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2523,9 +2521,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -2541,7 +2539,7 @@ dependencies = [ [[package]] name = "json-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "lib", "serde", @@ -2628,7 +2626,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "serde", ] @@ -2641,9 +2639,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libgit2-sys" -version = "0.16.2+1.7.2" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", @@ -2653,12 +2651,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2673,7 +2671,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -2761,13 +2759,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2897,7 +2896,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2962,11 +2961,11 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ - "num_enum_derive 0.7.2", + "num_enum_derive 0.7.3", ] [[package]] @@ -2983,14 +2982,14 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3010,9 +3009,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -3062,11 +3061,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -3083,7 +3082,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3094,9 +3093,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -3442,7 +3441,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3483,14 +3482,11 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "patch-testing-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ - "ed25519-consensus", - "rand", "sp1-core", "sp1-helper", "sp1-sdk", - "tiny-keccak", ] [[package]] @@ -3538,9 +3534,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", "thiserror", @@ -3574,7 +3570,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3629,9 +3625,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "postcard" @@ -3652,9 +3648,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy 0.6.6", +] [[package]] name = "prettyplease" @@ -3663,7 +3662,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3725,22 +3724,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -3772,7 +3771,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3835,14 +3834,13 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", "socket2", - "tracing", "windows-sys 0.52.0", ] @@ -3931,11 +3929,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -3951,9 +3949,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -3983,7 +3981,7 @@ dependencies = [ [[package]] name = "regex-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-helper", "sp1-sdk", @@ -4015,7 +4013,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -4054,9 +4052,9 @@ dependencies = [ "futures-util", "h2 0.4.5", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.1", "hyper-rustls", "hyper-tls 0.6.0", "hyper-util", @@ -4210,7 +4208,7 @@ dependencies = [ [[package]] name = "rsa-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "rsa", "sp1-helper", @@ -4289,7 +4287,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -4298,9 +4296,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring 0.17.8", @@ -4337,9 +4335,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -4414,9 +4412,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.1" +version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" +checksum = "05ccfb12511cdb770157ace92d7dda771e498445b78f9886e8cdbc5140a4eced" dependencies = [ "sdd", ] @@ -4450,9 +4448,9 @@ dependencies = [ [[package]] name = "sdd" -version = "0.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" +checksum = "177258b64c0faaa9ffd3c65cd3262c2bc7e2588dbbd9c1641d0346145c1bbda8" [[package]] name = "sec1" @@ -4470,11 +4468,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -4483,9 +4481,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -4541,9 +4539,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] @@ -4566,16 +4564,17 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -4598,14 +4597,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -4632,7 +4631,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_derive", "serde_json", @@ -4649,7 +4648,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -4674,7 +4673,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -4810,7 +4809,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "cargo_metadata", @@ -4820,7 +4819,7 @@ dependencies = [ [[package]] name = "sp1-core" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "arrayref", @@ -4881,7 +4880,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "1.0.1" +version = "1.1.0" dependencies = [ "proc-macro2", "quote", @@ -4890,7 +4889,7 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "1.0.1" +version = "1.1.0" dependencies = [ "cargo_metadata", "chrono", @@ -4899,7 +4898,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "1.0.1" +version = "1.1.0" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -4911,7 +4910,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -4947,7 +4946,7 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "itertools 0.13.0", @@ -4969,7 +4968,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "1.0.1" +version = "1.1.0" dependencies = [ "backtrace", "itertools 0.13.0", @@ -4993,7 +4992,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "1.0.1" +version = "1.1.0" dependencies = [ "arrayref", "backtrace", @@ -5027,7 +5026,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "1.0.1" +version = "1.1.0" dependencies = [ "proc-macro2", "quote", @@ -5036,7 +5035,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -5060,7 +5059,7 @@ dependencies = [ [[package]] name = "sp1-recursion-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "itertools 0.13.0", "p3-air", @@ -5088,7 +5087,7 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "1.0.1" +version = "1.1.0" dependencies = [ "alloy-sol-types", "anyhow", @@ -5162,7 +5161,7 @@ dependencies = [ [[package]] name = "ssz-withdrawals-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-helper", "sp1-sdk", @@ -5212,14 +5211,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-encoding" @@ -5249,9 +5248,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -5267,7 +5266,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5326,12 +5325,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -5398,7 +5398,7 @@ dependencies = [ [[package]] name = "tendermint-script" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "itertools 0.12.1", @@ -5432,7 +5432,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5489,9 +5489,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -5504,32 +5504,31 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5568,21 +5567,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.14", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -5593,7 +5592,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "toml_datetime", "winnow 0.5.40", ] @@ -5604,22 +5603,22 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.13", + "winnow 0.6.18", ] [[package]] @@ -5670,7 +5669,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5753,7 +5752,7 @@ dependencies = [ "futures", "http 1.1.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.1", "prost", "reqwest 0.12.5", "serde", @@ -5880,9 +5879,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.1" +version = "8.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" dependencies = [ "anyhow", "cfg-if", @@ -5893,9 +5892,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wait-timeout" @@ -5952,7 +5951,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -5986,7 +5985,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6069,11 +6068,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6089,7 +6088,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6098,7 +6097,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6116,7 +6115,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -6136,18 +6144,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -6158,9 +6166,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -6170,9 +6178,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -6182,15 +6190,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -6200,9 +6208,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -6212,9 +6220,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -6224,9 +6232,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -6236,9 +6244,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -6251,9 +6259,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -6308,22 +6316,43 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" dependencies = [ - "zerocopy-derive", + "byteorder", + "zerocopy-derive 0.6.6", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -6343,7 +6372,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 6a848d88d9..823e75a80f 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -17,7 +17,7 @@ members = [ resolver = "2" [workspace.package] -version = "1.0.1" +version = "1.1.0" edition = "2021" [workspace.dependencies] diff --git a/examples/aggregation/program/Cargo.lock b/examples/aggregation/program/Cargo.lock index 8cc95185ad..89e855237e 100644 --- a/examples/aggregation/program/Cargo.lock +++ b/examples/aggregation/program/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "aggregation-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "hex", "sha2", @@ -388,7 +388,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -398,7 +398,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "1.0.1" +version = "1.1.0" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/aggregation/program/Cargo.toml b/examples/aggregation/program/Cargo.toml index 7de447410e..b9ff04be6e 100644 --- a/examples/aggregation/program/Cargo.toml +++ b/examples/aggregation/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "aggregation-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf b/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf index 5ad0fa1fe7..25579c2dd3 100755 Binary files a/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf and b/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/chess/program/Cargo.lock b/examples/chess/program/Cargo.lock index 973a63cd51..af91bdda0b 100644 --- a/examples/chess/program/Cargo.lock +++ b/examples/chess/program/Cargo.lock @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "chess-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "chess", "sp1-zkvm", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -375,7 +375,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/chess/program/Cargo.toml b/examples/chess/program/Cargo.toml index 553eaa4cbc..0f706c254f 100644 --- a/examples/chess/program/Cargo.toml +++ b/examples/chess/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "chess-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/chess/program/elf/riscv32im-succinct-zkvm-elf b/examples/chess/program/elf/riscv32im-succinct-zkvm-elf index 63fcb4124d..a0b1a26d00 100755 Binary files a/examples/chess/program/elf/riscv32im-succinct-zkvm-elf and b/examples/chess/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/cycle-tracking/program/Cargo.lock b/examples/cycle-tracking/program/Cargo.lock index d65dfc5c1c..09f5e2bf85 100644 --- a/examples/cycle-tracking/program/Cargo.lock +++ b/examples/cycle-tracking/program/Cargo.lock @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cycle-tracking-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-derive", "sp1-zkvm", @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "1.0.1" +version = "1.1.0" dependencies = [ "proc-macro2", "quote", @@ -210,7 +210,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/cycle-tracking/program/Cargo.toml b/examples/cycle-tracking/program/Cargo.toml index b3c4ef408c..fbe98f6940 100644 --- a/examples/cycle-tracking/program/Cargo.toml +++ b/examples/cycle-tracking/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "cycle-tracking-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/cycle-tracking/program/bin/normal.rs b/examples/cycle-tracking/program/bin/normal.rs new file mode 100644 index 0000000000..cfffe0efe7 --- /dev/null +++ b/examples/cycle-tracking/program/bin/normal.rs @@ -0,0 +1,32 @@ +#![no_main] +sp1_zkvm::entrypoint!(main); + +#[sp1_derive::cycle_tracker] +pub fn expensive_function(x: usize) -> usize { + let mut y = 1; + for _ in 0..100 { + y *= x; + y %= 7919; + } + y +} + +pub fn main() { + let mut nums = vec![1, 1]; + + // Setup a large vector with Fibonacci-esque numbers. + println!("cycle-tracker-start: setup"); + for _ in 0..100 { + let mut c = nums[nums.len() - 1] + nums[nums.len() - 2]; + c %= 7919; + nums.push(c); + } + println!("cycle-tracker-end: setup"); + + println!("cycle-tracker-start: main-body"); + for i in 0..2 { + let result = expensive_function(nums[nums.len() - i - 1]); + println!("result: {}", result); + } + println!("cycle-tracker-end: main-body"); +} diff --git a/examples/cycle-tracking/program/bin/report.rs b/examples/cycle-tracking/program/bin/report.rs new file mode 100644 index 0000000000..e60ce2e2af --- /dev/null +++ b/examples/cycle-tracking/program/bin/report.rs @@ -0,0 +1,25 @@ +#![no_main] +sp1_zkvm::entrypoint!(main); + +#[sp1_derive::cycle_tracker] +pub fn expensive_function(x: usize) -> usize { + let mut y = 1; + for _ in 0..100 { + y *= x; + y %= 7919; + } + y +} + +pub fn main() { + let mut nums = vec![1, 1]; + + // Setup a large vector with Fibonacci-esque numbers. + println!("cycle-tracker-report-start: setup"); + for _ in 0..100 { + let mut c = nums[nums.len() - 1] + nums[nums.len() - 2]; + c %= 7919; + nums.push(c); + } + println!("cycle-tracker-report-end: setup"); +} diff --git a/examples/cycle-tracking/program/elf/normal b/examples/cycle-tracking/program/elf/normal new file mode 100755 index 0000000000..812a0f97a3 Binary files /dev/null and b/examples/cycle-tracking/program/elf/normal differ diff --git a/examples/cycle-tracking/program/elf/report b/examples/cycle-tracking/program/elf/report new file mode 100755 index 0000000000..afcc118fd0 Binary files /dev/null and b/examples/cycle-tracking/program/elf/report differ diff --git a/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf b/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf index 7c3f10b487..593ceec7b0 100755 Binary files a/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf and b/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/program/Cargo.lock b/examples/fibonacci/program/Cargo.lock index 98b446bd1a..af71fc09ec 100644 --- a/examples/fibonacci/program/Cargo.lock +++ b/examples/fibonacci/program/Cargo.lock @@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "fibonacci-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "sp1-zkvm", ] @@ -200,7 +200,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -210,7 +210,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/fibonacci/program/Cargo.toml b/examples/fibonacci/program/Cargo.toml index 266e18510e..ade806cdcc 100644 --- a/examples/fibonacci/program/Cargo.toml +++ b/examples/fibonacci/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "fibonacci-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf index 79cba24d82..14f3c9f5f0 100755 Binary files a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf and b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/program/src/main.rs b/examples/fibonacci/program/src/main.rs index b968e86b31..9d5dd74e69 100644 --- a/examples/fibonacci/program/src/main.rs +++ b/examples/fibonacci/program/src/main.rs @@ -11,7 +11,7 @@ sp1_zkvm::entrypoint!(main); pub fn main() { // Read an input to the program. // - // Behind the scenes, this compiles down to a custom system call which handles reading inputs + // Behind the scenes, this compiles down to a system call which handles reading inputs // from the prover. let n = sp1_zkvm::io::read::(); @@ -30,7 +30,7 @@ pub fn main() { // Write the output of the program. // - // Behind the scenes, this also compiles down to a custom system call which handles writing + // Behind the scenes, this also compiles down to a system call which handles writing // outputs to the prover. sp1_zkvm::io::commit(&a); sp1_zkvm::io::commit(&b); diff --git a/examples/fibonacci/script/bin/execute.rs b/examples/fibonacci/script/bin/execute.rs index 9c519428fd..02b27994ba 100644 --- a/examples/fibonacci/script/bin/execute.rs +++ b/examples/fibonacci/script/bin/execute.rs @@ -15,9 +15,15 @@ fn main() { // Only execute the program and get a `SP1PublicValues` object. let client = ProverClient::new(); - let (mut public_values, _) = client.execute(ELF, stdin).run().unwrap(); - - println!("generated proof"); + let (mut public_values, execution_report) = client.execute(ELF, stdin).run().unwrap(); + + // Print the total number of cycles executed and the full execution report with a breakdown of + // the RISC-V opcode and syscall counts. + println!( + "Executed program with {} cycles", + execution_report.total_instruction_count() + execution_report.total_syscall_count() + ); + println!("Full execution report:\n{:?}", execution_report); // Read and verify the output. let _ = public_values.read::(); diff --git a/examples/fibonacci/script/src/main.rs b/examples/fibonacci/script/src/main.rs index 809d1a796e..9f5a81f256 100644 --- a/examples/fibonacci/script/src/main.rs +++ b/examples/fibonacci/script/src/main.rs @@ -10,9 +10,21 @@ fn main() { // Create an input stream and write '500' to it. let n = 1000u32; + // The input stream that the program will read from using `sp1_zkvm::io::read`. Note that the + // types of the elements in the input stream must match the types being read in the program. let mut stdin = SP1Stdin::new(); stdin.write(&n); + // Create a `ProverClient` method. + let client = ProverClient::new(); + + // Execute the program using the `ProverClient.execute` method, without generating a proof. + let (_public_values, report) = client.execute(ELF, stdin.clone()).run().unwrap(); + println!( + "Executed program with {} cycles", + report.total_instruction_count() + ); + // Generate the proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); @@ -21,6 +33,8 @@ fn main() { println!("generated proof"); // Read and verify the output. + // Note that this output is read from values commited to in the program + // using `sp1_zkvm::io::commit`. let _ = proof.public_values.read::(); let a = proof.public_values.read::(); let b = proof.public_values.read::(); diff --git a/examples/io/program/Cargo.lock b/examples/io/program/Cargo.lock index 06d596d9c7..07344ff87e 100644 --- a/examples/io/program/Cargo.lock +++ b/examples/io/program/Cargo.lock @@ -84,7 +84,7 @@ dependencies = [ [[package]] name = "io-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "serde", "sp1-zkvm", @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/io/program/Cargo.toml b/examples/io/program/Cargo.toml index 6466eb3f3b..67bcbb2bce 100644 --- a/examples/io/program/Cargo.toml +++ b/examples/io/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "io-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/io/program/elf/riscv32im-succinct-zkvm-elf b/examples/io/program/elf/riscv32im-succinct-zkvm-elf index e1eb253a4e..a9b731a22f 100755 Binary files a/examples/io/program/elf/riscv32im-succinct-zkvm-elf and b/examples/io/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/is-prime/program/Cargo.toml b/examples/is-prime/program/Cargo.toml index 29123eb9c1..9852131132 100644 --- a/examples/is-prime/program/Cargo.toml +++ b/examples/is-prime/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "is-prime-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/json/program/Cargo.lock b/examples/json/program/Cargo.lock index 0032c912dd..cfb659286e 100644 --- a/examples/json/program/Cargo.lock +++ b/examples/json/program/Cargo.lock @@ -90,7 +90,7 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "json-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "lib", "serde", @@ -106,7 +106,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "serde", ] @@ -233,7 +233,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -243,7 +243,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/json/program/Cargo.toml b/examples/json/program/Cargo.toml index 55e50cd71b..9e1ffe6aca 100644 --- a/examples/json/program/Cargo.toml +++ b/examples/json/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "json-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/json/program/elf/riscv32im-succinct-zkvm-elf b/examples/json/program/elf/riscv32im-succinct-zkvm-elf index 3960bd24dc..428eabcdf7 100755 Binary files a/examples/json/program/elf/riscv32im-succinct-zkvm-elf and b/examples/json/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/patch-testing/program/Cargo.lock b/examples/patch-testing/program/Cargo.lock index 6de95c9db1..d6c90985d8 100644 --- a/examples/patch-testing/program/Cargo.lock +++ b/examples/patch-testing/program/Cargo.lock @@ -2,12 +2,203 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "alloy-primitives" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more", + "hex-literal", + "itoa", + "k256", + "keccak-asm", + "proptest", + "rand", + "ruint", + "serde", + "tiny-keccak", +] + +[[package]] +name = "alloy-rlp" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +dependencies = [ + "arrayvec", + "bytes", +] + [[package]] name = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "auto_impl" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bincode" version = "1.3.3" @@ -17,6 +208,39 @@ dependencies = [ "serde", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -35,18 +259,61 @@ dependencies = [ "generic-array", ] +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + +[[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 = "const-hex" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "proptest", + "serde", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "cpufeatures" version = "0.2.12" @@ -62,6 +329,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -72,18 +351,82 @@ dependencies = [ "typenum", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-curve25519-v4.1.3#1d73fd95f1a76bee8f46643cf78bbccc1fb06ede" +dependencies = [ + "anyhow", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version 0.4.0", + "sp1-lib 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-curve25519-v4.1.3#1d73fd95f1a76bee8f46643cf78bbccc1fb06ede" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "curve25519-dalek-ng" version = "4.1.1" -source = "git+https://github.com/sp1-patches/curve25519-dalek-ng?branch=patch-v4.1.1#f5607edd61ad8e9d80c9be933cd119f4008044d9" +source = "git+https://github.com/sp1-patches/curve25519-dalek-ng?branch=patch-v4.1.1#8dd77b20f3e78965a0cc57070a04465b9d52c49e" dependencies = [ + "anyhow", "byteorder", + "cfg-if", "digest 0.9.0", "rand_core", + "sp1-lib 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle-ng", "zeroize", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.4.0", + "syn 2.0.72", +] + [[package]] name = "digest" version = "0.9.0" @@ -94,150 +437,718 @@ dependencies = [ ] [[package]] -name = "digest" -version = "0.10.7" +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "git+https://github.com/sp1-patches/signatures?branch=patch-ecdsa-v0.16.9#1caae137b2b2c458b8a542b1c4e9fb40293c67a3" +dependencies = [ + "anyhow", + "cfg-if", + "der", + "digest 0.10.7", + "elliptic-curve", + "hex-literal", + "rfc6979", + "signature", + "sp1-lib 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "git+https://github.com/sp1-patches/ed25519-consensus?branch=patch-v2.1.0#2b2c4b43344bc4daf5b1326f367f2d9d661eeabb" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core", + "serde", + "sha2 0.9.8", + "thiserror", + "zeroize", +] + +[[package]] +name = "ed25519-dalek" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2 0.10.8", + "subtle", + "zeroize", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[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 = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature", +] + +[[package]] +name = "keccak-asm" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + +[[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 = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[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", +] + +[[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", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "parity-scale-codec" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "patch-testing-program" +version = "1.1.0" +dependencies = [ + "alloy-primitives", + "curve25519-dalek", + "curve25519-dalek-ng", + "ed25519-consensus", + "ed25519-dalek", + "k256", + "secp256k1", + "sha2 0.10.8", + "sha2 0.9.8", + "sp1-zkvm", + "tiny-keccak", +] + +[[package]] +name = "pest" +version = "2.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[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 = "proptest" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[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 = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "block-buffer 0.10.4", - "crypto-common", + "getrandom", ] [[package]] -name = "ed25519-consensus" -version = "2.1.0" -source = "git+https://github.com/sp1-patches/ed25519-consensus?branch=patch-v2.1.0#4fba9b0acc9fcf7a87d00da84c340d5988e3d7cb" +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "curve25519-dalek-ng", - "hex", "rand_core", - "serde", - "sha2 0.9.8", - "thiserror", - "zeroize", ] [[package]] -name = "generic-array" -version = "0.14.7" +name = "regex-syntax" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "git+https://github.com/sp1-patches/signatures?branch=patch-ecdsa-v0.16.9#1caae137b2b2c458b8a542b1c4e9fb40293c67a3" dependencies = [ - "typenum", - "version_check", + "hmac", + "subtle", ] [[package]] -name = "getrandom" -version = "0.2.15" +name = "rlp" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ - "cfg-if", - "libc", - "wasi", + "bytes", + "rustc-hex", ] [[package]] -name = "hex" -version = "0.4.3" +name = "ruint" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" +dependencies = [ + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint", + "num-traits", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] [[package]] -name = "lazy_static" -version = "1.5.0" +name = "ruint-macro" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] -name = "libc" -version = "0.2.155" +name = "rustc-hex" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] -name = "libm" -version = "0.2.8" +name = "rustc_version" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] [[package]] -name = "once_cell" -version = "1.19.0" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.23", +] [[package]] -name = "opaque-debug" -version = "0.3.1" +name = "rustix" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "patch-testing-program" -version = "1.0.1" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "curve25519-dalek-ng", - "ed25519-consensus", - "sha2 0.10.8", - "sha2 0.9.8", - "sp1-zkvm", - "tiny-keccak", + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "rusty-fork" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] [[package]] -name = "proc-macro2" -version = "1.0.85" +name = "sec1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "unicode-ident", + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +name = "secp256k1" +version = "0.29.0" +source = "git+https://github.com/sp1-patches/rust-secp256k1?branch=patch-secp256k1-v0.29.0#1da89f39f21f1e4ed4f9f869169a59bbe81edc71" dependencies = [ - "proc-macro2", + "cfg-if", + "ecdsa", + "elliptic-curve", + "k256", + "secp256k1-sys", ] [[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +name = "secp256k1-sys" +version = "0.10.0" +source = "git+https://github.com/sp1-patches/rust-secp256k1?branch=patch-secp256k1-v0.29.0#1da89f39f21f1e4ed4f9f869169a59bbe81edc71" dependencies = [ - "libc", - "rand_chacha", - "rand_core", + "cc", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "semver" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "ppv-lite86", - "rand_core", + "semver-parser", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "semver" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" dependencies = [ - "getrandom", + "pest", ] [[package]] @@ -257,7 +1168,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -283,9 +1194,41 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha3-asm" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" +dependencies = [ + "cc", + "cfg-if", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core", +] + [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "serde", +] + +[[package]] +name = "sp1-lib" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de4c2cc40e1019faac8cdbe61172c7be09960cfe240c712be46df3795c53fce8" dependencies = [ "anyhow", "bincode", @@ -295,7 +1238,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", @@ -306,9 +1249,31 @@ dependencies = [ "rand", "serde", "sha2 0.10.8", - "sp1-lib", + "sp1-lib 1.1.0", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "subtle-ng" version = "2.5.0" @@ -317,33 +1282,63 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" [[package]] name = "syn" -version = "2.0.66" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys", +] + [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -355,23 +1350,79 @@ dependencies = [ "crunchy", ] +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[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 = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] [[package]] name = "wasi" @@ -379,11 +1430,137 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] [[patch.unused]] name = "sha2" diff --git a/examples/patch-testing/program/Cargo.toml b/examples/patch-testing/program/Cargo.toml index 110cbed81d..ac57d413db 100644 --- a/examples/patch-testing/program/Cargo.toml +++ b/examples/patch-testing/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "patch-testing-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false @@ -14,13 +14,23 @@ sha2-v0-10-6 = { version = "0.10.6", package = "sha2" } # sha2-v0-10-8 = { version = "0.10.8", package = "sha2" } ed25519-consensus = "2.1.0" +ed25519-dalek = "2.1.0" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -curve25519-dalek-ng = "4.1" +curve25519-dalek = { version = "4.1.3", default-features = false, features = ["alloc"] } +curve25519-dalek-ng = { version = "4.1", default-features = false, features = ["u32_backend", "alloc"] } +k256 = { version = "0.13", default-features = false, features = ["ecdsa"] } +alloy-primitives = { version = "0.7", features = ["k256"] } +secp256k1 = { version = "0.29", features = ["recovery", "global-context"]} [patch.crates-io] -tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" } +tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" } ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.9.8" } sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.6" } # sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" } + curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.1" } +curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-curve25519-v4.1.3" } + +ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "patch-ecdsa-v0.16.9" } +secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", branch = "patch-secp256k1-v0.29.0" } \ No newline at end of file diff --git a/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf b/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf index ac3d523f9d..5bf87b2bff 100755 Binary files a/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf and b/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/patch-testing/program/src/main.rs b/examples/patch-testing/program/src/main.rs index e3b964af07..cdec7a987f 100644 --- a/examples/patch-testing/program/src/main.rs +++ b/examples/patch-testing/program/src/main.rs @@ -1,44 +1,183 @@ #![no_main] sp1_zkvm::entrypoint!(main); -use curve25519_dalek_ng::edwards::CompressedEdwardsY; -use ed25519_consensus::{Signature, VerificationKey}; +use alloy_primitives::{address, hex, Signature}; +use curve25519_dalek::edwards::CompressedEdwardsY as CompressedEdwardsY_dalek; +use curve25519_dalek_ng::edwards::CompressedEdwardsY as CompressedEdwardsY_dalek_ng; +use ed25519_consensus::{ + Signature as Ed25519ConsensusSignature, VerificationKey as Ed25519ConsensusVerificationKey, +}; +use ed25519_dalek::{ + Signature as Ed25519DalekSignature, Verifier, VerifyingKey as Ed25519DalekVerifiyingKey, +}; + use sha2_v0_10_6::{Digest as Digest_10_6, Sha256 as Sha256_10_6}; // use sha2_v0_10_8::{Digest as Digest_10_8, Sha256 as Sha256_10_8}; use sha2_v0_9_8::{Digest as Digest_9_8, Sha256 as Sha256_9_8}; +use std::str::FromStr; use tiny_keccak::{Hasher, Keccak}; -/// To add testing for a new patch, add a new case to the function below. -fn main() { - let input = [1u8; 32]; - - let sig: Signature = sp1_zkvm::io::read(); - let vk: VerificationKey = sp1_zkvm::io::read(); - let msg: Vec = sp1_zkvm::io::read_vec(); +use secp256k1::{ + ecdsa::{ + RecoverableSignature as Secp256k1RecoverableSignature, RecoveryId as Secp256k1RecoveryId, + }, + Message as Secp256k1Message, +}; - // Test Keccak. - let mut hasher = Keccak::v256(); - hasher.update(&input); +/// Simple interface to the [`keccak256`] hash function. +/// +/// [`keccak256`]: https://en.wikipedia.org/wiki/SHA-3 +fn keccak256>(bytes: T) -> [u8; 32] { let mut output = [0u8; 32]; + let mut hasher = Keccak::v256(); + hasher.update(bytes.as_ref()); hasher.finalize(&mut output); + output +} + +/// Emits ED_ADD and ED_DECOMPRESS syscalls. +fn test_ed25519_dalek() { + // Example signature and message. + let vk = hex!("9194c3ead03f5848111db696fe1196fbbeffc69342d51c7cf5e91c502de91eb4"); + let msg = hex!("656432353531392d636f6e73656e7375732074657374206d657373616765"); + let sig = hex!("69261ea5df799b20fc6eeb49aa79f572c8f1e2ba88b37dff184cc55d4e3653d876419bffcc47e5343cdd5fd78121bb32f1c377a5ed505106ad37f19980218f0d"); + + let vk = Ed25519DalekVerifiyingKey::from_bytes(&vk).unwrap(); + let sig = Ed25519DalekSignature::from_bytes(&sig); + + println!("cycle-tracker-start: ed25519-dalek verify"); + vk.verify(&msg, &sig).unwrap(); + println!("cycle-tracker-end: ed25519-dalek verify"); +} + +/// Emits ED_ADD and ED_DECOMPRESS syscalls. +fn test_ed25519_consensus() { + // Example signature and message. + let vk = hex!("9194c3ead03f5848111db696fe1196fbbeffc69342d51c7cf5e91c502de91eb4"); + let msg = hex!("656432353531392d636f6e73656e7375732074657374206d657373616765"); + let sig = hex!("69261ea5df799b20fc6eeb49aa79f572c8f1e2ba88b37dff184cc55d4e3653d876419bffcc47e5343cdd5fd78121bb32f1c377a5ed505106ad37f19980218f0d"); + + let vk: Ed25519ConsensusVerificationKey = vk.try_into().unwrap(); + let sig: Ed25519ConsensusSignature = sig.into(); + + println!("cycle-tracker-start: ed25519-consensus verify"); + vk.verify(&sig, &msg).unwrap(); + println!("cycle-tracker-end: ed25519-consensus verify"); +} + +/// Emits ED_DECOMPRESS syscall. +fn test_curve25519_dalek_ng() { + let input = [1u8; 32]; + let y = CompressedEdwardsY_dalek_ng(input); + + println!("cycle-tracker-start: curve25519-dalek-ng decompress"); + let decompressed_key = y.decompress(); + println!("cycle-tracker-end: curve25519-dalek-ng decompress"); + + let compressed_key = decompressed_key.unwrap().compress(); + assert_eq!(compressed_key, y); +} + +/// Emits ED_DECOMPRESS syscall. +fn test_curve25519_dalek() { + let input = [1u8; 32]; + let y = CompressedEdwardsY_dalek(input); + + println!("cycle-tracker-start: curve25519-dalek decompress"); + let decompressed_key = y.decompress().unwrap(); + println!("cycle-tracker-end: curve25519-dalek decompress"); + + let compressed_key = decompressed_key.compress(); + assert_eq!(compressed_key, y); +} + +/// Emits KECCAK_PERMUTE syscalls. +fn test_keccak() { + let input = [1u8; 32]; + let expected_output = hex!("cebc8882fecbec7fb80d2cf4b312bec018884c2d66667c67a90508214bd8bafc"); + + let output = keccak256(input); + assert_eq!(output, expected_output); +} + +/// Emits SHA_COMPRESS and SHA_EXTEND syscalls. +fn test_sha256() { + let input = [1u8; 32]; + let expected_output = hex!("72cd6e8422c407fb6d098690f1130b7ded7ec2f7f5e1d30bd9d521f015363793"); - // Test SHA256. let mut sha256_9_8 = Sha256_9_8::new(); sha256_9_8.update(input); - let _ = sha256_9_8.finalize(); + let output_9_8: [u8; 32] = sha256_9_8.finalize().into(); + assert_eq!(output_9_8, expected_output); let mut sha256_10_6 = Sha256_10_6::new(); sha256_10_6.update(input); - let _ = sha256_10_6.finalize(); + let output_10_6: [u8; 32] = sha256_10_6.finalize().into(); + assert_eq!(output_10_6, expected_output); + // Can't have two different sha256 versions for the same major version. // let mut sha256_10_8 = Sha256_10_8::new(); // sha256_10_8.update(input); // let output_10_8 = sha256_10_8.finalize(); +} + +/// Emits SECP256K1_ADD, SECP256K1_DOUBLE, and SECP256K1_DECOMPRESS syscalls. +/// Source: https://github.com/alloy-rs/core/blob/adcf7adfa1f35c56e6331bab85b8c56d32a465f1/crates/primitives/src/signature/sig.rs#L620-L631 +fn test_k256_patch() { + let sig = Signature::from_str( + "b91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c" + ).expect("could not parse signature"); + let expected = address!("2c7536E3605D9C16a7a3D7b1898e529396a65c23"); + + println!("cycle-tracker-start: k256 verify"); + let recovered_address = sig.recover_address_from_msg("Some data").expect("could not recover address"); + println!("cycle-tracker-end: k256 verify"); + + assert_eq!(recovered_address, expected); +} + +/// Emits SECP256K1_ADD, SECP256K1_DOUBLE, and SECP256K1_DECOMPRESS syscalls. +fn test_secp256k1_patch() { + let secp = secp256k1::Secp256k1::new(); + let recovery_id = Secp256k1RecoveryId::from_i32(1).unwrap(); + let signature = Secp256k1RecoverableSignature::from_compact( + &hex!("80AEBD912F05D302BA8000A3C5D6E604333AAF34E22CC1BA14BE1737213EAED5040D67D6E9FA5FBDFE6E3457893839631B87A41D90508B7C92991ED7824E962D"), + recovery_id, + ).unwrap(); + let message_bytes: [u8; 32] = [ + 173, 132, 205, 11, 16, 252, 2, 135, 56, 151, 27, 7, 129, 36, 174, 194, 160, 231, 198, 217, + 134, 163, 129, 190, 11, 56, 111, 50, 190, 232, 135, 175, + ]; + let message = Secp256k1Message::from_digest_slice(&message_bytes) + .expect("Message could not be created from bytes"); + let expected = "04e76c446148ca6c558910ee241e7dde6d96a7fe3d5a30c00e65aceabe0af9fd2dd131ee7b5d38edafa79eac5110608be0ce01866c1f1a868596b6d991711699c4"; + + println!("cycle-tracker-start: secp256k1 verify"); + let public_key = secp + .recover_ecdsa(&message, &signature) // Use the new context to call recover + .expect("could not recover public key"); + println!("cycle-tracker-end: secp256k1 verify"); + + let serialized_key = public_key + .serialize_uncompressed(); + + // Use the message in the recover_ecdsa call + assert_eq!(hex::encode(serialized_key), expected); +} + +/// To add testing for a new patch, add a new case to the function below. +fn main() { + // TODO: Specify which syscalls are linked to each function invocation, iterate + // over this list that is shared between the program and script. + test_keccak(); + test_sha256(); + + test_curve25519_dalek_ng(); + test_curve25519_dalek(); - // Test curve25519-dalek-ng. - let y = CompressedEdwardsY(input); - let _ = y.decompress(); + test_ed25519_dalek(); + test_ed25519_consensus(); - // Test ed25519-consensus. - assert_eq!(vk.verify(&sig, &msg[..]), Ok(())) + test_k256_patch(); + test_secp256k1_patch(); } diff --git a/examples/patch-testing/script/Cargo.toml b/examples/patch-testing/script/Cargo.toml index e074ce86c5..29836184d4 100644 --- a/examples/patch-testing/script/Cargo.toml +++ b/examples/patch-testing/script/Cargo.toml @@ -5,11 +5,8 @@ edition = { workspace = true } publish = false [dependencies] -rand = "0.8" -ed25519-consensus = "2.1.0" sp1-core = { workspace = true, features = ["neon"] } sp1-sdk = { workspace = true } -tiny-keccak = { version = "2.0.2", features = ["keccak"] } [build-dependencies] sp1-helper = { workspace = true } diff --git a/examples/patch-testing/script/src/main.rs b/examples/patch-testing/script/src/main.rs index 08ccfb356b..5ffaa22aa1 100644 --- a/examples/patch-testing/script/src/main.rs +++ b/examples/patch-testing/script/src/main.rs @@ -1,5 +1,3 @@ -use ed25519_consensus::{SigningKey, VerificationKey}; -use rand::thread_rng; use sp1_sdk::{utils, ProverClient, SP1Stdin}; const PATCH_TEST_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -8,17 +6,7 @@ const PATCH_TEST_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succin fn main() { utils::setup_logger(); - let mut stdin = SP1Stdin::new(); - - let sk = SigningKey::new(thread_rng()); - let vk = VerificationKey::from(&sk); - - let msg = b"ed25519-consensus test message"; - - let sig = sk.sign(msg); - stdin.write(&sig); - stdin.write(&vk); - stdin.write_vec(msg.to_vec()); + let stdin = SP1Stdin::new(); let client = ProverClient::new(); let (_, report) = client @@ -34,7 +22,7 @@ fn main() { .syscall_counts .contains_key(&sp1_core::runtime::SyscallCode::SHA_EXTEND)); - // Confirm there was at least 1 ED25519_COMPUTE syscalls. + // Confirm there was at least 1 of each ED25519 syscall. assert!(report .syscall_counts .contains_key(&sp1_core::runtime::SyscallCode::ED_ADD)); @@ -47,5 +35,17 @@ fn main() { .syscall_counts .contains_key(&sp1_core::runtime::SyscallCode::KECCAK_PERMUTE)); + // Confirm there was at least 1 SECP256K1_ADD, SECP256K1_DOUBLE and SECP256K1_DECOMPRESS syscall. + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::SECP256K1_ADD)); + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::SECP256K1_DOUBLE)); + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::SECP256K1_DECOMPRESS)); + + println!("Total instructions: {:?}", report.total_instruction_count()); println!("Successfully executed the program & confirmed syscalls."); } diff --git a/examples/regex/program/Cargo.lock b/examples/regex/program/Cargo.lock index 0abaef5418..503d0f9979 100644 --- a/examples/regex/program/Cargo.lock +++ b/examples/regex/program/Cargo.lock @@ -200,7 +200,7 @@ dependencies = [ [[package]] name = "regex-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "regex", "sp1-zkvm", @@ -245,7 +245,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -255,7 +255,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/regex/program/Cargo.toml b/examples/regex/program/Cargo.toml index 161e664670..6b01aece81 100644 --- a/examples/regex/program/Cargo.toml +++ b/examples/regex/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "regex-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/regex/program/elf/riscv32im-succinct-zkvm-elf b/examples/regex/program/elf/riscv32im-succinct-zkvm-elf index 4a8b114e2e..04c2e1e47c 100755 Binary files a/examples/regex/program/elf/riscv32im-succinct-zkvm-elf and b/examples/regex/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/rsa/program/Cargo.lock b/examples/rsa/program/Cargo.lock index 6491ffbf8d..0ab8fe064b 100644 --- a/examples/rsa/program/Cargo.lock +++ b/examples/rsa/program/Cargo.lock @@ -332,7 +332,7 @@ dependencies = [ [[package]] name = "rsa-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "digest 0.10.7", "rand", @@ -392,7 +392,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -402,7 +402,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", diff --git a/examples/rsa/program/Cargo.toml b/examples/rsa/program/Cargo.toml index 22d2305dc4..cfb330ab48 100644 --- a/examples/rsa/program/Cargo.toml +++ b/examples/rsa/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "rsa-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf b/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf index c6eedf5521..eb6c2aae4b 100755 Binary files a/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf and b/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/rsa/program/src/main.rs b/examples/rsa/program/src/main.rs index 298eccd8a3..67c21cd146 100644 --- a/examples/rsa/program/src/main.rs +++ b/examples/rsa/program/src/main.rs @@ -10,7 +10,7 @@ use sha2::Sha256; pub fn main() { // Read an input to the program. // - // Behind the scenes, this compiles down to a custom system call which handles reading inputs + // Behind the scenes, this compiles down to a system call which handles reading inputs let pk_der = sp1_zkvm::io::read::>(); let message = sp1_zkvm::io::read::>(); let signature = sp1_zkvm::io::read::>(); @@ -37,6 +37,6 @@ pub fn main() { // Write the output of the program. // - // Behind the scenes, this also compiles down to a custom system call which handles writing + // Behind the scenes, this also compiles down to a system call which handles writing sp1_zkvm::io::commit(&verified); } diff --git a/examples/ssz-withdrawals/program/Cargo.lock b/examples/ssz-withdrawals/program/Cargo.lock index add833022a..d74a4b8aa6 100644 --- a/examples/ssz-withdrawals/program/Cargo.lock +++ b/examples/ssz-withdrawals/program/Cargo.lock @@ -1312,7 +1312,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -1322,7 +1322,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", @@ -1348,7 +1348,7 @@ dependencies = [ [[package]] name = "ssz-withdrawals-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "alloy-primitives", "hex", diff --git a/examples/ssz-withdrawals/program/Cargo.toml b/examples/ssz-withdrawals/program/Cargo.toml index d5b89c89f2..95d1f111af 100644 --- a/examples/ssz-withdrawals/program/Cargo.toml +++ b/examples/ssz-withdrawals/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "ssz-withdrawals-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf b/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf index 3f6d3b5b27..bcd6245c2b 100755 Binary files a/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf and b/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/tendermint/program/Cargo.lock b/examples/tendermint/program/Cargo.lock index 2eeaaec5f4..c6c0aea2ea 100644 --- a/examples/tendermint/program/Cargo.lock +++ b/examples/tendermint/program/Cargo.lock @@ -573,7 +573,7 @@ checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" [[package]] name = "sp1-lib" -version = "1.0.1" +version = "1.1.0" dependencies = [ "anyhow", "bincode", @@ -583,7 +583,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.0.1" +version = "1.1.0" dependencies = [ "bincode", "cfg-if", @@ -694,7 +694,7 @@ dependencies = [ [[package]] name = "tendermint-program" -version = "1.0.1" +version = "1.1.0" dependencies = [ "serde", "serde_cbor", diff --git a/examples/tendermint/program/Cargo.toml b/examples/tendermint/program/Cargo.toml index 28f722b4dc..e45d506e8f 100644 --- a/examples/tendermint/program/Cargo.toml +++ b/examples/tendermint/program/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "tendermint-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf index f1f2001b88..7e38cf4299 100755 Binary files a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf and b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/helper/CHANGELOG.md b/helper/CHANGELOG.md index 8d8d0025d8..8b47f9b844 100644 --- a/helper/CHANGELOG.md +++ b/helper/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-helper-v1.0.1...sp1-helper-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-helper-v1.0.0-rc.1...sp1-helper-v1.0.0-rc.1) - 2024-07-19 ### Fixed diff --git a/helper/src/lib.rs b/helper/src/lib.rs index 523c81509d..82371b4ae7 100644 --- a/helper/src/lib.rs +++ b/helper/src/lib.rs @@ -61,14 +61,10 @@ fn execute_build_cmd( } // Build the program with the given arguments. - let path_output = if let Some(args) = args { - sp1_build::build_program(&args, Some(program_dir.as_ref().to_path_buf())) - } else { - sp1_build::build_program( - &BuildArgs::default(), - Some(program_dir.as_ref().to_path_buf()), - ) - }; + let path_output = sp1_build::build_program( + &args.unwrap_or_default(), + Some(program_dir.as_ref().to_path_buf()), + ); if let Err(err) = path_output { panic!("Failed to build SP1 program: {}.", err); } diff --git a/primitives/CHANGELOG.md b/primitives/CHANGELOG.md index ff4bc3a29b..34c35c3d0c 100644 --- a/primitives/CHANGELOG.md +++ b/primitives/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-primitives-v1.0.1...sp1-primitives-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-primitives-v1.0.0-rc.1...sp1-primitives-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/prover/CHANGELOG.md b/prover/CHANGELOG.md index b99e027080..161cfb8942 100644 --- a/prover/CHANGELOG.md +++ b/prover/CHANGELOG.md @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-prover-v1.0.1...sp1-prover-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) +- lazy init prover programs and keys ([#1177](https://github.com/succinctlabs/sp1/pull/1177)) +- streaming recursion ([#1175](https://github.com/succinctlabs/sp1/pull/1175)) +- streaming prover for core ([#1146](https://github.com/succinctlabs/sp1/pull/1146)) + +### Fixed +- verify subproof in execute ([#1204](https://github.com/succinctlabs/sp1/pull/1204)) + +### Other +- *(deps)* bump serde_json from 1.0.120 to 1.0.121 ([#1196](https://github.com/succinctlabs/sp1/pull/1196)) +- Merge branch 'main' into dev +- prover trait cleanup ([#1170](https://github.com/succinctlabs/sp1/pull/1170)) +- *(deps)* bump thiserror from 1.0.61 to 1.0.63 ([#1136](https://github.com/succinctlabs/sp1/pull/1136)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-prover-v1.0.0-rc.1...sp1-prover-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/circuit/CHANGELOG.md b/recursion/circuit/CHANGELOG.md index f5ece00116..ee32d93bd9 100644 --- a/recursion/circuit/CHANGELOG.md +++ b/recursion/circuit/CHANGELOG.md @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-circuit-v1.0.1...sp1-recursion-circuit-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + +### Fixed +- BabyBear range check Gnark ([#1225](https://github.com/succinctlabs/sp1/pull/1225)) + +### Other +- Merge branch 'main' into dev +- prover trait cleanup ([#1170](https://github.com/succinctlabs/sp1/pull/1170)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-circuit-v1.0.0-rc.1...sp1-recursion-circuit-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/compiler/CHANGELOG.md b/recursion/compiler/CHANGELOG.md index a7c84a38f4..0826ab86d7 100644 --- a/recursion/compiler/CHANGELOG.md +++ b/recursion/compiler/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-compiler-v1.0.1...sp1-recursion-compiler-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + +### Fixed +- BabyBear range check Gnark ([#1225](https://github.com/succinctlabs/sp1/pull/1225)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-compiler-v1.0.0-rc.1...sp1-recursion-compiler-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/core/CHANGELOG.md b/recursion/core/CHANGELOG.md index dcfd321d6f..1f859293d0 100644 --- a/recursion/core/CHANGELOG.md +++ b/recursion/core/CHANGELOG.md @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-core-v1.0.1...sp1-recursion-core-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + +### Fixed +- UB from `OpcodeSpecificCols` union ([#1050](https://github.com/succinctlabs/sp1/pull/1050)) + +### Other +- Merge branch 'main' into dev +- *(deps)* bump arrayref from 0.3.7 to 0.3.8 ([#1154](https://github.com/succinctlabs/sp1/pull/1154)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-core-v1.0.0-rc.1...sp1-recursion-core-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/derive/CHANGELOG.md b/recursion/derive/CHANGELOG.md index 5f89140ab1..05c7977501 100644 --- a/recursion/derive/CHANGELOG.md +++ b/recursion/derive/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-derive-v1.0.1...sp1-recursion-derive-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-derive-v1.0.0-rc.1...sp1-recursion-derive-v1.0.0-rc.1) - 2024-07-19 ### Other diff --git a/recursion/gnark-cli/CHANGELOG.md b/recursion/gnark-cli/CHANGELOG.md index 36df8dba2c..6084a52d03 100644 --- a/recursion/gnark-cli/CHANGELOG.md +++ b/recursion/gnark-cli/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-cli-v1.0.1...sp1-recursion-gnark-cli-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-cli-v1.0.0-rc.1...sp1-recursion-gnark-cli-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/gnark-ffi/CHANGELOG.md b/recursion/gnark-ffi/CHANGELOG.md index 08995dbe72..1d7abddc03 100644 --- a/recursion/gnark-ffi/CHANGELOG.md +++ b/recursion/gnark-ffi/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-ffi-v1.0.1...sp1-recursion-gnark-ffi-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + +### Fixed +- BabyBear range check Gnark ([#1225](https://github.com/succinctlabs/sp1/pull/1225)) + +### Other +- *(deps)* bump serde_json from 1.0.120 to 1.0.121 ([#1196](https://github.com/succinctlabs/sp1/pull/1196)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-ffi-v1.0.0-rc.1...sp1-recursion-gnark-ffi-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/recursion/program/CHANGELOG.md b/recursion/program/CHANGELOG.md index 0cd85b7d28..11ab52f1c5 100644 --- a/recursion/program/CHANGELOG.md +++ b/recursion/program/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-recursion-program-v1.0.1...sp1-recursion-program-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) +- streaming recursion ([#1175](https://github.com/succinctlabs/sp1/pull/1175)) + +### Other +- Merge branch 'main' into dev +- prover trait cleanup ([#1170](https://github.com/succinctlabs/sp1/pull/1170)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-program-v1.0.0-rc.1...sp1-recursion-program-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 8c73016ec1..99b25672aa 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-sdk-v1.0.1...sp1-sdk-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) +- lazy init prover programs and keys ([#1177](https://github.com/succinctlabs/sp1/pull/1177)) +- streaming prover for core ([#1146](https://github.com/succinctlabs/sp1/pull/1146)) + +### Fixed +- verify subproof in execute ([#1204](https://github.com/succinctlabs/sp1/pull/1204)) + +### Other +- *(deps)* bump serde_json from 1.0.120 to 1.0.121 ([#1196](https://github.com/succinctlabs/sp1/pull/1196)) +- *(deps)* bump tokio from 1.38.1 to 1.39.2 ([#1195](https://github.com/succinctlabs/sp1/pull/1195)) +- Merge branch 'main' into dev +- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1152](https://github.com/succinctlabs/sp1/pull/1152)) +- *(deps)* bump thiserror from 1.0.61 to 1.0.63 ([#1136](https://github.com/succinctlabs/sp1/pull/1136)) +- *(deps)* bump tokio from 1.38.0 to 1.38.1 ([#1137](https://github.com/succinctlabs/sp1/pull/1137)) +- add audit reports ([#1142](https://github.com/succinctlabs/sp1/pull/1142)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-sdk-v1.0.0-rc.1...sp1-sdk-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/sdk/src/action.rs b/sdk/src/action.rs index 5701e5b92d..103b2d9b84 100644 --- a/sdk/src/action.rs +++ b/sdk/src/action.rs @@ -5,8 +5,9 @@ use sp1_core::{ use sp1_prover::{components::DefaultProverComponents, SP1ProvingKey, SP1PublicValues, SP1Stdin}; use anyhow::{Ok, Result}; +use std::time::Duration; -use crate::{Prover, SP1ProofKind, SP1ProofWithPublicValues}; +use crate::{provers::ProofOpts, Prover, SP1ProofKind, SP1ProofWithPublicValues}; /// Builder to prepare and configure execution of a program on an input. /// May be run with [Self::run]. @@ -89,6 +90,7 @@ pub struct Prove<'a> { stdin: SP1Stdin, core_opts: SP1CoreOpts, recursion_opts: SP1CoreOpts, + timeout: Option, } impl<'a> Prove<'a> { @@ -109,6 +111,7 @@ impl<'a> Prove<'a> { context_builder: Default::default(), core_opts: SP1CoreOpts::default(), recursion_opts: SP1CoreOpts::recursion(), + timeout: None, } } @@ -122,14 +125,19 @@ impl<'a> Prove<'a> { mut context_builder, core_opts, recursion_opts, + timeout, } = self; let opts = SP1ProverOpts { core_opts, recursion_opts, }; + let proof_opts = ProofOpts { + sp1_prover_opts: opts, + timeout, + }; let context = context_builder.build(); - prover.prove(pk, stdin, opts, context, kind) + prover.prove(pk, stdin, proof_opts, context, kind) } /// Set the proof kind to the core mode. This is the default. @@ -198,4 +206,12 @@ impl<'a> Prove<'a> { self.context_builder.max_cycles(cycle_limit); self } + + /// Set the timeout for the proof's generation. + /// + /// This parameter is only used when the prover is run in network mode. + pub fn timeout(mut self, timeout: Duration) -> Self { + self.timeout = Some(timeout); + self + } } diff --git a/sdk/src/network/prover.rs b/sdk/src/network/prover.rs index 4d84fb47b8..1e225404ad 100644 --- a/sdk/src/network/prover.rs +++ b/sdk/src/network/prover.rs @@ -1,3 +1,4 @@ +use std::time::Instant; use std::{env, time::Duration}; use crate::install::block_on; @@ -15,7 +16,7 @@ use sp1_prover::components::DefaultProverComponents; use sp1_prover::{SP1Prover, SP1Stdin, SP1_CIRCUIT_VERSION}; use tokio::time::sleep; -use crate::provers::{LocalProver, ProverType}; +use crate::provers::{LocalProver, ProofOpts, ProverType}; /// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server. pub struct NetworkProver { @@ -82,11 +83,23 @@ impl NetworkProver { Ok(proof_id) } - /// Waits for a proof to be generated and returns the proof. - pub async fn wait_proof(&self, proof_id: &str) -> Result

{ + /// Waits for a proof to be generated and returns the proof. If a timeout is supplied, the + /// function will return an error if the proof is not generated within the timeout. + pub async fn wait_proof( + &self, + proof_id: &str, + timeout: Option, + ) -> Result

{ let client = &self.client; let mut is_claimed = false; + let start_time = Instant::now(); loop { + if let Some(timeout) = timeout { + if start_time.elapsed() > timeout { + return Err(anyhow::anyhow!("Proof generation timed out.")); + } + } + let (status, maybe_proof) = client.get_proof_status::

(proof_id).await?; match status.status() { @@ -117,9 +130,10 @@ impl NetworkProver { elf: &[u8], stdin: SP1Stdin, mode: ProofMode, + timeout: Option, ) -> Result { let proof_id = self.request_proof(elf, stdin, mode).await?; - self.wait_proof(&proof_id).await + self.wait_proof(&proof_id, timeout).await } } @@ -140,12 +154,12 @@ impl Prover for NetworkProver { &'a self, pk: &SP1ProvingKey, stdin: SP1Stdin, - opts: SP1ProverOpts, + opts: ProofOpts, context: SP1Context<'a>, kind: SP1ProofKind, ) -> Result { - warn_if_not_default(&opts, &context); - block_on(self.prove(&pk.elf, stdin, kind.into())) + warn_if_not_default(&opts.sp1_prover_opts, &context); + block_on(self.prove(&pk.elf, stdin, kind.into(), opts.timeout)) } } diff --git a/sdk/src/provers/local.rs b/sdk/src/provers/local.rs index ed60265fa5..c172c32193 100644 --- a/sdk/src/provers/local.rs +++ b/sdk/src/provers/local.rs @@ -1,10 +1,10 @@ use anyhow::Result; -use sp1_core::{runtime::SP1Context, utils::SP1ProverOpts}; +use sp1_core::runtime::SP1Context; use sp1_prover::{components::SP1ProverComponents, SP1Prover, SP1Stdin}; use sysinfo::System; use crate::{ - install::try_install_plonk_bn254_artifacts, Prover, SP1Proof, SP1ProofKind, + install::try_install_plonk_bn254_artifacts, provers::ProofOpts, Prover, SP1Proof, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey, }; @@ -45,7 +45,7 @@ impl Prover for LocalProver { &'a self, pk: &SP1ProvingKey, stdin: SP1Stdin, - opts: SP1ProverOpts, + opts: ProofOpts, context: SP1Context<'a>, kind: SP1ProofKind, ) -> Result { @@ -56,7 +56,9 @@ impl Prover for LocalProver { )); } - let proof = self.prover.prove_core(pk, &stdin, opts, context)?; + let proof = self + .prover + .prove_core(pk, &stdin, opts.sp1_prover_opts, context)?; if kind == SP1ProofKind::Core { return Ok(SP1ProofWithPublicValues { proof: SP1Proof::Core(proof.proof.0), @@ -67,7 +69,9 @@ impl Prover for LocalProver { } let deferred_proofs = stdin.proofs.iter().map(|p| p.0.clone()).collect(); let public_values = proof.public_values.clone(); - let reduce_proof = self.prover.compress(&pk.vk, proof, deferred_proofs, opts)?; + let reduce_proof = + self.prover + .compress(&pk.vk, proof, deferred_proofs, opts.sp1_prover_opts)?; if kind == SP1ProofKind::Compressed { return Ok(SP1ProofWithPublicValues { proof: SP1Proof::Compressed(reduce_proof.proof), @@ -76,8 +80,10 @@ impl Prover for LocalProver { sp1_version: self.version().to_string(), }); } - let compress_proof = self.prover.shrink(reduce_proof, opts)?; - let outer_proof = self.prover.wrap_bn254(compress_proof, opts)?; + let compress_proof = self.prover.shrink(reduce_proof, opts.sp1_prover_opts)?; + let outer_proof = self + .prover + .wrap_bn254(compress_proof, opts.sp1_prover_opts)?; let plonk_bn254_aritfacts = if sp1_prover::build::sp1_dev_mode() { sp1_prover::build::try_build_plonk_bn254_artifacts_dev( diff --git a/sdk/src/provers/mock.rs b/sdk/src/provers/mock.rs index c3a53359ee..893643ba6b 100644 --- a/sdk/src/provers/mock.rs +++ b/sdk/src/provers/mock.rs @@ -12,14 +12,13 @@ use p3_fri::{FriProof, TwoAdicFriPcsProof}; use sp1_core::{ runtime::SP1Context, stark::{ShardCommitment, ShardOpenedValues, ShardProof}, - utils::SP1ProverOpts, }; use sp1_prover::{ components::DefaultProverComponents, verify::verify_plonk_bn254_public_inputs, HashableKey, PlonkBn254Proof, SP1Prover, SP1Stdin, }; -use super::ProverType; +use super::{ProofOpts, ProverType}; /// An implementation of [crate::ProverClient] that can generate mock proofs. pub struct MockProver { @@ -51,7 +50,7 @@ impl Prover for MockProver { &'a self, pk: &SP1ProvingKey, stdin: SP1Stdin, - opts: SP1ProverOpts, + opts: ProofOpts, context: SP1Context<'a>, kind: SP1ProofKind, ) -> Result { diff --git a/sdk/src/provers/mod.rs b/sdk/src/provers/mod.rs index 75acc8e488..51ab930eb9 100644 --- a/sdk/src/provers/mod.rs +++ b/sdk/src/provers/mod.rs @@ -15,6 +15,7 @@ use sp1_prover::SP1CoreProofData; use sp1_prover::SP1Prover; use sp1_prover::SP1ReduceProof; use sp1_prover::{SP1ProvingKey, SP1Stdin, SP1VerifyingKey}; +use std::time::Duration; use strum_macros::EnumString; use thiserror::Error; @@ -31,6 +32,15 @@ pub enum ProverType { Network, } +/// Options to configure proof generation. +#[derive(Clone, Default)] +pub struct ProofOpts { + /// Options to configure the SP1 prover. + pub sp1_prover_opts: SP1ProverOpts, + /// Optional timeout duration for proof generation. + pub timeout: Option, +} + #[derive(Error, Debug)] pub enum SP1VerificationError { #[error("Version mismatch")] @@ -60,7 +70,7 @@ pub trait Prover: Send + Sync { &'a self, pk: &SP1ProvingKey, stdin: SP1Stdin, - opts: SP1ProverOpts, + opts: ProofOpts, context: SP1Context<'a>, kind: SP1ProofKind, ) -> Result; diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md new file mode 100644 index 0000000000..9d0e1d206c --- /dev/null +++ b/server/CHANGELOG.md @@ -0,0 +1,36 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.1.0](https://github.com/succinctlabs/sp1/releases/tag/sp1-server-v1.1.0) - 2024-08-02 + +### Added +- experimental gpu support ([#1219](https://github.com/succinctlabs/sp1/pull/1219)) +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) +- v1.0.1 ([#1165](https://github.com/succinctlabs/sp1/pull/1165)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed +- wait longer for server to start ([#1231](https://github.com/succinctlabs/sp1/pull/1231)) + +### Other +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/server/Cargo.toml b/server/Cargo.toml index 07f28671fb..88bc49b877 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -12,20 +12,20 @@ categories = { workspace = true } [dependencies] sp1-core = { workspace = true } sp1-prover = { workspace = true } -prost = "0.13" -prost-types = "0.13" +prost = "0.12" +prost-types = "0.12" bincode = "1.3.3" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" tokio = { version = "^1.38.0", features = ["full"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -twirp = { git = "https://github.com/github/twirp-rs.git" } +twirp = { package = "twirp-rs", version = "0.3.0-succinct" } ctrlc = "3.4.4" [build-dependencies] -prost-build = { version = "0.13", optional = true } -twirp-build = { git = "https://github.com/github/twirp-rs.git", optional = true } +prost-build = { version = "0.12", optional = true } +twirp-build = { package = "twirp-build-rs", version = "0.3.0-succinct", optional = true } [dev-dependencies] sp1-core = { workspace = true, features = ["programs"] } diff --git a/server/build.rs b/server/build.rs index 3dee9fc32c..ffa6f54a50 100644 --- a/server/build.rs +++ b/server/build.rs @@ -4,9 +4,10 @@ fn main() { // println!("cargo:rerun-if-changed=."); // let mut config = prost_build::Config::new(); // config + // .protoc_arg("--experimental_allow_proto3_optional") // .out_dir("src/proto") // .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]") // .service_generator(twirp_build::service_generator()) - // .compile_protos(&["./proto/api.proto"], &["./proto"]) + // .compile_protos(&["proto/api.proto"], &["proto"]) // .unwrap(); } diff --git a/server/src/lib.rs b/server/src/lib.rs index 98a3dfaf19..33c653a003 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -68,7 +68,7 @@ impl SP1ProverServer { /// [SP1ProverClient] that can be used to communicate with the container. pub fn new() -> Self { let container_name = "sp1-gpu"; - let image_name = "jtguibas/sp1-gpu:v1.1.0"; + let image_name = "jtguibas/sp1-gpu:v1.1.5"; let cleaned_up = Arc::new(AtomicBool::new(false)); let cleanup_name = container_name; @@ -109,8 +109,8 @@ impl SP1ProverServer { }) .unwrap(); - tracing::debug!("sleeping for 10 seconds to allow server to start"); - std::thread::sleep(Duration::from_secs(10)); + tracing::debug!("sleeping for 20 seconds to allow server to start"); + std::thread::sleep(Duration::from_secs(20)); SP1ProverServer { client: Client::from_base_url( diff --git a/server/src/proto/api.rs b/server/src/proto/api.rs index a3ee846b67..28390e38e0 100644 --- a/server/src/proto/api.rs +++ b/server/src/proto/api.rs @@ -78,12 +78,14 @@ impl ProverServiceClient for twirp::client::Client { &self, req: ProveCoreRequest, ) -> Result { - self.request("api.ProverService/ProveCore", req).await + let url = self.base_url.join("api.ProverService/ProveCore")?; + self.request(url, req).await } async fn compress( &self, req: CompressRequest, ) -> Result { - self.request("api.ProverService/Compress", req).await + let url = self.base_url.join("api.ProverService/Compress")?; + self.request(url, req).await } } diff --git a/sp1up/install b/sp1up/install index 39dd6b941d..09cc58e73e 100755 --- a/sp1up/install +++ b/sp1up/install @@ -4,7 +4,7 @@ set -e -echo Installing sp1up... +echo "🚀 Installing sp1up..." && echo BASE_DIR=$HOME SP1_DIR=${SP1_DIR-"$BASE_DIR/.sp1"} @@ -57,5 +57,13 @@ if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/openssl/lib/libssl.3.dyl echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install openssl)." fi -echo && echo "Detected your preferred shell is ${PREF_SHELL} and added sp1up to PATH. Run 'source ${PROFILE}' or start a new terminal session to use sp1up." -echo "Then, simply run 'sp1up' to install SP1." +echo && echo "✅ Installation complete!" + +echo && echo "🔍 Detected shell: ${PREF_SHELL}" +echo "🔗 Added sp1up to PATH" + +echo && echo "To start using sp1up, please run:" +echo && echo "▶ source ${PROFILE}" +echo "▶ sp1up" + +echo && echo "🎉 Enjoy using sp1up! For help, type 'sp1up --help'" \ No newline at end of file diff --git a/tests/bls12381-add/Cargo.toml b/tests/bls12381-add/Cargo.toml index edb1eb3171..c5064dfe74 100644 --- a/tests/bls12381-add/Cargo.toml +++ b/tests/bls12381-add/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bls12381-add-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/bls12381-decompress/Cargo.toml b/tests/bls12381-decompress/Cargo.toml index b76c3c8d02..6fae053215 100644 --- a/tests/bls12381-decompress/Cargo.toml +++ b/tests/bls12381-decompress/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bls-decompress-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/bls12381-double/Cargo.toml b/tests/bls12381-double/Cargo.toml index 72ddc804fc..6e82630b4c 100644 --- a/tests/bls12381-double/Cargo.toml +++ b/tests/bls12381-double/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bls12381-double-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/bls12381-mul/Cargo.toml b/tests/bls12381-mul/Cargo.toml index 42131b2613..41abc9f442 100644 --- a/tests/bls12381-mul/Cargo.toml +++ b/tests/bls12381-mul/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bls12381-mul-test" -version = "1.0.1" +version = "1.1.0" publish = false diff --git a/tests/bn254-add/Cargo.toml b/tests/bn254-add/Cargo.toml index 4cddb64d22..e5edb35537 100644 --- a/tests/bn254-add/Cargo.toml +++ b/tests/bn254-add/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bn254-add-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/bn254-double/Cargo.toml b/tests/bn254-double/Cargo.toml index f51eff7840..52dfeafb2b 100644 --- a/tests/bn254-double/Cargo.toml +++ b/tests/bn254-double/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bn254-double-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/bn254-mul/Cargo.toml b/tests/bn254-mul/Cargo.toml index e3d12710b9..9985c0f2a4 100644 --- a/tests/bn254-mul/Cargo.toml +++ b/tests/bn254-mul/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "bn254-mul-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/cycle-tracker/Cargo.toml b/tests/cycle-tracker/Cargo.toml index b3ce0e21d8..6fac65d348 100644 --- a/tests/cycle-tracker/Cargo.toml +++ b/tests/cycle-tracker/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "cycle-tracker-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/ecrecover/Cargo.toml b/tests/ecrecover/Cargo.toml index 30a3774b79..eab2009709 100644 --- a/tests/ecrecover/Cargo.toml +++ b/tests/ecrecover/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "ecrecover-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/ed-add/Cargo.toml b/tests/ed-add/Cargo.toml index 7347c6c67e..2c0800689c 100644 --- a/tests/ed-add/Cargo.toml +++ b/tests/ed-add/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "ed-add-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/ed-decompress/Cargo.toml b/tests/ed-decompress/Cargo.toml index cc88095513..942b409dcf 100644 --- a/tests/ed-decompress/Cargo.toml +++ b/tests/ed-decompress/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "ed-decompress-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/ed25519/Cargo.toml b/tests/ed25519/Cargo.toml index 7f36187ce7..e201cbae60 100644 --- a/tests/ed25519/Cargo.toml +++ b/tests/ed25519/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "ed25519-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/fibonacci/Cargo.toml b/tests/fibonacci/Cargo.toml index eba3e580ba..af98f45c4b 100644 --- a/tests/fibonacci/Cargo.toml +++ b/tests/fibonacci/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "fibonacci-program-tests" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/fibonacci/src/main.rs b/tests/fibonacci/src/main.rs index a78bef922d..c4b5b6726a 100644 --- a/tests/fibonacci/src/main.rs +++ b/tests/fibonacci/src/main.rs @@ -11,7 +11,7 @@ sp1_zkvm::entrypoint!(main); pub fn main() { // Read an input to the program. // - // Behind the scenes, this compiles down to a custom system call which handles reading inputs + // Behind the scenes, this compiles down to a system call which handles reading inputs // from the prover. let n = 10; // Compute the n'th fibonacci number, using normal Rust code. diff --git a/tests/hint-io/Cargo.toml b/tests/hint-io/Cargo.toml index a4e3853eb2..935ea483b8 100644 --- a/tests/hint-io/Cargo.toml +++ b/tests/hint-io/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "hint-io-test" -version = "1.0.1" +version = "1.1.0" publish = false [dependencies] diff --git a/tests/keccak-permute/Cargo.toml b/tests/keccak-permute/Cargo.toml index 1d0a2f950f..b1857d36a0 100644 --- a/tests/keccak-permute/Cargo.toml +++ b/tests/keccak-permute/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "keccak-permute-test" -version = "1.0.1" +version = "1.1.0" publish = false [dependencies] diff --git a/tests/keccak256/Cargo.toml b/tests/keccak256/Cargo.toml index c76f041294..defae4ea98 100644 --- a/tests/keccak256/Cargo.toml +++ b/tests/keccak256/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "keccak256-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/panic/Cargo.toml b/tests/panic/Cargo.toml index 26bc8983db..b56c32ad79 100644 --- a/tests/panic/Cargo.toml +++ b/tests/panic/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "panic-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/rand/Cargo.toml b/tests/rand/Cargo.toml index 13bf348b94..d9176332b6 100644 --- a/tests/rand/Cargo.toml +++ b/tests/rand/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "rand-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/secp256k1-add/Cargo.toml b/tests/secp256k1-add/Cargo.toml index 1105a6854f..12841390ec 100644 --- a/tests/secp256k1-add/Cargo.toml +++ b/tests/secp256k1-add/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "secp256k1-add-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/secp256k1-decompress/Cargo.toml b/tests/secp256k1-decompress/Cargo.toml index 4501a60676..05b94a8ebf 100644 --- a/tests/secp256k1-decompress/Cargo.toml +++ b/tests/secp256k1-decompress/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "secp256k1-decompress-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/secp256k1-double/Cargo.toml b/tests/secp256k1-double/Cargo.toml index 0e730b634a..178f65b9fd 100644 --- a/tests/secp256k1-double/Cargo.toml +++ b/tests/secp256k1-double/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "secp256k1-double-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/secp256k1-mul/Cargo.toml b/tests/secp256k1-mul/Cargo.toml index 20069bcd86..1426fce533 100644 --- a/tests/secp256k1-mul/Cargo.toml +++ b/tests/secp256k1-mul/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "secp256k1-mul-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/sha-compress/Cargo.toml b/tests/sha-compress/Cargo.toml index 9952188518..641c3fec32 100644 --- a/tests/sha-compress/Cargo.toml +++ b/tests/sha-compress/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "sha-compress-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/sha-extend/Cargo.toml b/tests/sha-extend/Cargo.toml index 2f4c8e6c1f..1ca31848f5 100644 --- a/tests/sha-extend/Cargo.toml +++ b/tests/sha-extend/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "sha-extend-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/sha2/Cargo.toml b/tests/sha2/Cargo.toml index 959c6d20f0..1861ae92bf 100644 --- a/tests/sha2/Cargo.toml +++ b/tests/sha2/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "sha2-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/tendermint-benchmark/Cargo.toml b/tests/tendermint-benchmark/Cargo.toml index e819697907..bc0652eb14 100644 --- a/tests/tendermint-benchmark/Cargo.toml +++ b/tests/tendermint-benchmark/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "tendermint-benchmark-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/uint256-arith/Cargo.toml b/tests/uint256-arith/Cargo.toml index 295f4559ee..4402276fb1 100644 --- a/tests/uint256-arith/Cargo.toml +++ b/tests/uint256-arith/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "uint256-arith-program" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/uint256-mul/Cargo.toml b/tests/uint256-mul/Cargo.toml index 841a631b7f..f512b0393b 100644 --- a/tests/uint256-mul/Cargo.toml +++ b/tests/uint256-mul/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "biguint-mul-test" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/tests/verify-proof/Cargo.toml b/tests/verify-proof/Cargo.toml index fff214e0b5..957056ff08 100644 --- a/tests/verify-proof/Cargo.toml +++ b/tests/verify-proof/Cargo.toml @@ -1,7 +1,7 @@ [workspace] [package] name = "verify-proof" -version = "1.0.1" +version = "1.1.0" edition = "2021" publish = false diff --git a/zkvm/entrypoint/CHANGELOG.md b/zkvm/entrypoint/CHANGELOG.md index 3334a3e874..752b8e6467 100644 --- a/zkvm/entrypoint/CHANGELOG.md +++ b/zkvm/entrypoint/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-zkvm-v1.0.1...sp1-zkvm-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + +### Fixed +- mutable static ref warning in halt syscall ([#1217](https://github.com/succinctlabs/sp1/pull/1217)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-zkvm-v1.0.0-rc.1...sp1-zkvm-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/zkvm/entrypoint/Cargo.toml b/zkvm/entrypoint/Cargo.toml index d51bccbf6a..bd9fed0147 100644 --- a/zkvm/entrypoint/Cargo.toml +++ b/zkvm/entrypoint/Cargo.toml @@ -36,6 +36,3 @@ verify = [ "dep:p3-field", "sp1-lib/verify", ] -bn254 = ["sp1-lib/bn254"] -secp256k1 = ["sp1-lib/secp256k1"] -bls12381 = ["sp1-lib/bls12381"] diff --git a/zkvm/entrypoint/src/lib.rs b/zkvm/entrypoint/src/lib.rs index eb8c5b7264..c49e856d1c 100644 --- a/zkvm/entrypoint/src/lib.rs +++ b/zkvm/entrypoint/src/lib.rs @@ -7,31 +7,12 @@ pub mod syscalls; pub mod io { pub use sp1_lib::io::*; } + #[cfg(feature = "lib")] pub mod lib { pub use sp1_lib::*; } -#[macro_export] -macro_rules! entrypoint { - ($path:path) => { - const ZKVM_ENTRY: fn() = $path; - - use $crate::heap::SimpleAlloc; - - #[global_allocator] - static HEAP: SimpleAlloc = SimpleAlloc; - - mod zkvm_generated_main { - - #[no_mangle] - fn main() { - super::ZKVM_ENTRY() - } - } - }; -} - #[cfg(all(target_os = "zkvm", feature = "libm"))] mod libm; @@ -44,7 +25,6 @@ mod zkvm { use crate::syscalls::syscall_halt; use cfg_if::cfg_if; - use getrandom::{register_custom_getrandom, Error}; use sha2::{Digest, Sha256}; cfg_if! { @@ -98,7 +78,7 @@ mod zkvm { sym STACK_TOP ); - fn zkvm_getrandom(s: &mut [u8]) -> Result<(), Error> { + pub fn zkvm_getrandom(s: &mut [u8]) -> Result<(), getrandom::Error> { unsafe { crate::syscalls::sys_rand(s.as_mut_ptr(), s.len()); } @@ -106,5 +86,25 @@ mod zkvm { Ok(()) } - register_custom_getrandom!(zkvm_getrandom); + getrandom::register_custom_getrandom!(zkvm_getrandom); +} + +#[macro_export] +macro_rules! entrypoint { + ($path:path) => { + const ZKVM_ENTRY: fn() = $path; + + use $crate::heap::SimpleAlloc; + + #[global_allocator] + static HEAP: SimpleAlloc = SimpleAlloc; + + mod zkvm_generated_main { + + #[no_mangle] + fn main() { + super::ZKVM_ENTRY() + } + } + }; } diff --git a/zkvm/entrypoint/src/syscalls/bigint.rs b/zkvm/entrypoint/src/syscalls/bigint.rs index 85db9c7929..b7d1e7018d 100644 --- a/zkvm/entrypoint/src/syscalls/bigint.rs +++ b/zkvm/entrypoint/src/syscalls/bigint.rs @@ -1,20 +1,28 @@ use super::syscall_uint256_mulmod; -pub const BIGINT_WIDTH_WORDS: usize = 8; +/// The number of limbs in a "uint256". +const N: usize = 8; -/// Sets result to be (x op y) % modulus. Currently only multiplication is supported. If modulus is -/// zero, the modulus applied is 2^256. +/// Sets `result` to be `(x op y) % modulus`. +/// +/// Currently only multiplication is supported and `op` is not used. If the modulus is zero, then +/// the modulus applied is 2^256. +/// +/// ### Safety +/// +/// The caller must ensure that `result`, `x`, `y`, and `modulus` are valid pointers to data that is +/// aligned along a four byte boundary. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn sys_bigint( - result: *mut [u32; BIGINT_WIDTH_WORDS], + result: *mut [u32; N], op: u32, - x: *const [u32; BIGINT_WIDTH_WORDS], - y: *const [u32; BIGINT_WIDTH_WORDS], - modulus: *const [u32; BIGINT_WIDTH_WORDS], + x: *const [u32; N], + y: *const [u32; N], + modulus: *const [u32; N], ) { // Instantiate a new uninitialized array of words to place the concatenated y and modulus. - let mut concat_y_modulus = core::mem::MaybeUninit::<[u32; BIGINT_WIDTH_WORDS * 2]>::uninit(); + let mut concat_y_modulus = core::mem::MaybeUninit::<[u32; N * 2]>::uninit(); unsafe { let result_ptr = result as *mut u32; let x_ptr = x as *const u32; @@ -22,21 +30,19 @@ pub extern "C" fn sys_bigint( let concat_ptr = concat_y_modulus.as_mut_ptr() as *mut u32; // First copy the y value into the concatenated array. - core::ptr::copy(y_ptr, concat_ptr, BIGINT_WIDTH_WORDS); + core::ptr::copy(y_ptr, concat_ptr, N); // Then, copy the modulus value into the concatenated array. Add the width of the y value // to the pointer to place the modulus value after the y value. - core::ptr::copy( - modulus as *const u32, - concat_ptr.add(BIGINT_WIDTH_WORDS), - BIGINT_WIDTH_WORDS, - ); + core::ptr::copy(modulus as *const u32, concat_ptr.add(N), N); // Copy x into the result array, as our syscall will write the result into the first input. - core::ptr::copy(x as *const u32, result_ptr, BIGINT_WIDTH_WORDS); + core::ptr::copy(x as *const u32, result_ptr, N); // Call the uint256_mul syscall to multiply the x value with the concatenated y and modulus. // This syscall writes the result in-place, so it will mutate the result ptr appropriately. + let result_ptr = result_ptr as *mut [u32; N]; + let concat_ptr = concat_ptr as *mut [u32; N]; syscall_uint256_mulmod(result_ptr, concat_ptr); } } diff --git a/zkvm/entrypoint/src/syscalls/bls12381.rs b/zkvm/entrypoint/src/syscalls/bls12381.rs index e4c34d5828..121834a3aa 100644 --- a/zkvm/entrypoint/src/syscalls/bls12381.rs +++ b/zkvm/entrypoint/src/syscalls/bls12381.rs @@ -4,9 +4,14 @@ use core::arch::asm; /// Adds two Bls12381 points. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` and `q` are valid pointers to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_bls12381_add(p: *mut u32, q: *const u32) { +pub extern "C" fn syscall_bls12381_add(p: *mut [u32; 24], q: *const [u32; 24]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -24,9 +29,14 @@ pub extern "C" fn syscall_bls12381_add(p: *mut u32, q: *const u32) { /// Double a Bls12381 point. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_bls12381_double(p: *mut u32) { +pub extern "C" fn syscall_bls12381_double(p: *mut [u32; 24]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -40,8 +50,13 @@ pub extern "C" fn syscall_bls12381_double(p: *mut u32) { /// Decompresses a compressed BLS12-381 point. /// -/// The first half of the input array should contain the X coordinate. -/// The second half of the input array will be overwritten with the Y coordinate. +/// The first half of the input array should contain the X coordinate. The second half of the input +/// array will be overwritten with the Y coordinate. +/// +/// ### Safety +/// +/// The caller must ensure that `point` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_bls12381_decompress(point: &mut [u8; 96], sign_bit: bool) { diff --git a/zkvm/entrypoint/src/syscalls/bn254.rs b/zkvm/entrypoint/src/syscalls/bn254.rs index be24fad923..6ac4e98c1d 100644 --- a/zkvm/entrypoint/src/syscalls/bn254.rs +++ b/zkvm/entrypoint/src/syscalls/bn254.rs @@ -4,9 +4,14 @@ use core::arch::asm; /// Adds two Bn254 points. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` and `q` are valid pointers to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_bn254_add(p: *mut u32, q: *const u32) { +pub extern "C" fn syscall_bn254_add(p: *mut [u32; 16], q: *const [u32; 16]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -24,9 +29,14 @@ pub extern "C" fn syscall_bn254_add(p: *mut u32, q: *const u32) { /// Double a Bn254 point. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_bn254_double(p: *mut u32) { +pub extern "C" fn syscall_bn254_double(p: *mut [u32; 16]) { #[cfg(target_os = "zkvm")] unsafe { asm!( diff --git a/zkvm/entrypoint/src/syscalls/ed25519.rs b/zkvm/entrypoint/src/syscalls/ed25519.rs index 9775fb2d4c..e2554209c9 100644 --- a/zkvm/entrypoint/src/syscalls/ed25519.rs +++ b/zkvm/entrypoint/src/syscalls/ed25519.rs @@ -4,9 +4,14 @@ use core::arch::asm; /// Adds two Edwards points. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` and `q` are valid pointers to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_ed_add(p: *mut u32, q: *mut u32) { +pub extern "C" fn syscall_ed_add(p: *mut [u32; 16], q: *const [u32; 16]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -26,6 +31,11 @@ pub extern "C" fn syscall_ed_add(p: *mut u32, q: *mut u32) { /// The second half of the input array should contain the compressed Y point with the final bit as /// the sign bit. The first half of the input array will be overwritten with the decompressed point, /// and the sign bit will be removed. +/// +/// ### Safety +/// +/// The caller must ensure that `point` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_ed_decompress(point: &mut [u8; 64]) { diff --git a/zkvm/entrypoint/src/syscalls/halt.rs b/zkvm/entrypoint/src/syscalls/halt.rs index 3691bf981a..0673cee42b 100644 --- a/zkvm/entrypoint/src/syscalls/halt.rs +++ b/zkvm/entrypoint/src/syscalls/halt.rs @@ -1,6 +1,4 @@ -use cfg_if::cfg_if; - -cfg_if! { +cfg_if::cfg_if! { if #[cfg(target_os = "zkvm")] { use core::arch::asm; use sha2::Digest; @@ -9,13 +7,15 @@ cfg_if! { } } -cfg_if! { +cfg_if::cfg_if! { if #[cfg(all(target_os = "zkvm", feature = "verify"))] { use p3_field::PrimeField32; } } -/// Halts the program. +/// Halts the program with the given exit code. +/// +/// Before halting, the syscall will commit to the public values. #[allow(unused_variables)] pub extern "C" fn syscall_halt(exit_code: u8) -> ! { #[cfg(target_os = "zkvm")] @@ -31,12 +31,11 @@ pub extern "C" fn syscall_halt(exit_code: u8) -> ! { // into the runtime's execution record's public values digest. In the AIR, it will be used // to verify that the provided public values digest matches the one computed by the program. for i in 0..PV_DIGEST_NUM_WORDS { - // Convert the digest bytes into words, since we will call COMMIT one word at a time. let word = u32::from_le_bytes(pv_digest_bytes[i * 4..(i + 1) * 4].try_into().unwrap()); asm!("ecall", in("t0") crate::syscalls::COMMIT, in("a0") i, in("a1") word); } - cfg_if! { + cfg_if::cfg_if! { if #[cfg(feature = "verify")] { let deferred_proofs_digest = zkvm::DEFERRED_PROOFS_DIGEST.as_mut().unwrap(); diff --git a/zkvm/entrypoint/src/syscalls/io.rs b/zkvm/entrypoint/src/syscalls/io.rs index 6ba7c62ddd..a6099e8a17 100644 --- a/zkvm/entrypoint/src/syscalls/io.rs +++ b/zkvm/entrypoint/src/syscalls/io.rs @@ -6,7 +6,7 @@ cfg_if::cfg_if! { } } -/// Write data to the prover. +/// Write `nbytes` of data to the prover to a given file descriptor `fd` from `write_buf`. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize) { @@ -36,6 +36,7 @@ pub extern "C" fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize) { } } +/// Returns the length of the next element in the hint stream. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_hint_len() -> usize { @@ -54,6 +55,7 @@ pub extern "C" fn syscall_hint_len() -> usize { unreachable!() } +/// Reads the next element in the hint stream into the given buffer. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_hint_read(ptr: *mut u8, len: usize) { diff --git a/zkvm/entrypoint/src/syscalls/keccak_permute.rs b/zkvm/entrypoint/src/syscalls/keccak_permute.rs index 0140d739ba..dfa8086560 100644 --- a/zkvm/entrypoint/src/syscalls/keccak_permute.rs +++ b/zkvm/entrypoint/src/syscalls/keccak_permute.rs @@ -2,9 +2,14 @@ use core::arch::asm; /// Executes the Keccak256 permutation on the given state. +/// +/// ### Safety +/// +/// The caller must ensure that `state` is valid pointer to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_keccak_permute(state: *mut u64) { +pub extern "C" fn syscall_keccak_permute(state: *mut [u64; 25]) { #[cfg(target_os = "zkvm")] unsafe { asm!( diff --git a/zkvm/entrypoint/src/syscalls/secp256k1.rs b/zkvm/entrypoint/src/syscalls/secp256k1.rs index a9851482df..7cfe22b405 100644 --- a/zkvm/entrypoint/src/syscalls/secp256k1.rs +++ b/zkvm/entrypoint/src/syscalls/secp256k1.rs @@ -4,9 +4,14 @@ use core::arch::asm; /// Adds two Secp256k1 points. /// /// The result is stored in the first point. +/// +/// ### Safety +/// +/// The caller must ensure that `p` and `q` are valid pointers to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_secp256k1_add(p: *mut u32, q: *mut u32) { +pub extern "C" fn syscall_secp256k1_add(p: *mut [u32; 16], q: *mut [u32; 16]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -23,10 +28,15 @@ pub extern "C" fn syscall_secp256k1_add(p: *mut u32, q: *mut u32) { /// Double a Secp256k1 point. /// -/// The result is stored in the first point. +/// The result is stored in-place in the supplied buffer. +/// +/// ### Safety +/// +/// The caller must ensure that `p` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_secp256k1_double(p: *mut u32) { +pub extern "C" fn syscall_secp256k1_double(p: *mut [u32; 16]) { #[cfg(target_os = "zkvm")] unsafe { asm!( @@ -43,8 +53,14 @@ pub extern "C" fn syscall_secp256k1_double(p: *mut u32) { /// Decompresses a compressed Secp256k1 point. /// -/// The input array should be 32 bytes long, with the first 16 bytes containing the X coordinate in -/// big-endian format. The second half of the input will be overwritten with the decompressed point. +/// The input array should be 64 bytes long, with the first 32 bytes containing the X coordinate in +/// big-endian format. The second half of the input will be overwritten with the Y coordinate of the +/// decompressed point in big-endian format using the point's parity (is_odd). +/// +/// ### Safety +/// +/// The caller must ensure that `point` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] pub extern "C" fn syscall_secp256k1_decompress(point: &mut [u8; 64], is_odd: bool) { diff --git a/zkvm/entrypoint/src/syscalls/sha_compress.rs b/zkvm/entrypoint/src/syscalls/sha_compress.rs index 069d283d4b..7f11bf917b 100644 --- a/zkvm/entrypoint/src/syscalls/sha_compress.rs +++ b/zkvm/entrypoint/src/syscalls/sha_compress.rs @@ -1,9 +1,15 @@ #[cfg(target_os = "zkvm")] use core::arch::asm; +/// Executes the SHA256 compress operation on the given word array and a given state. +/// +/// ### Safety +/// +/// The caller must ensure that `w` and `state` are valid pointers to data that is aligned along a +/// four byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_sha256_compress(w: *mut u32, state: *mut u32) { +pub extern "C" fn syscall_sha256_compress(w: *mut [u32; 64], state: *mut [u32; 8]) { #[cfg(target_os = "zkvm")] unsafe { asm!( diff --git a/zkvm/entrypoint/src/syscalls/sha_extend.rs b/zkvm/entrypoint/src/syscalls/sha_extend.rs index dc90849da1..500dd42e1b 100644 --- a/zkvm/entrypoint/src/syscalls/sha_extend.rs +++ b/zkvm/entrypoint/src/syscalls/sha_extend.rs @@ -1,9 +1,15 @@ #[cfg(target_os = "zkvm")] use core::arch::asm; +/// Executes the SHA256 extend operation on the given word array. +/// +/// ### Safety +/// +/// The caller must ensure that `w` is valid pointer to data that is aligned along a four byte +/// boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_sha256_extend(w: *mut u32) { +pub extern "C" fn syscall_sha256_extend(w: *mut [u32; 64]) { #[cfg(target_os = "zkvm")] unsafe { asm!( diff --git a/zkvm/entrypoint/src/syscalls/uint256_mul.rs b/zkvm/entrypoint/src/syscalls/uint256_mul.rs index 07a76f181d..c5ce19951a 100644 --- a/zkvm/entrypoint/src/syscalls/uint256_mul.rs +++ b/zkvm/entrypoint/src/syscalls/uint256_mul.rs @@ -4,9 +4,14 @@ use core::arch::asm; /// Uint256 multiplication operation. /// /// The result is written over the first input. +/// +/// ### Safety +/// +/// The caller must ensure that `x` and `y` are valid pointers to data that is aligned along a four +/// byte boundary. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_uint256_mulmod(x: *mut u32, y: *const u32) { +pub extern "C" fn syscall_uint256_mulmod(x: *mut [u32; 8], y: *const [u32; 8]) { #[cfg(target_os = "zkvm")] unsafe { asm!( diff --git a/zkvm/lib/CHANGELOG.md b/zkvm/lib/CHANGELOG.md index 036dc4895a..0e0ca7d60d 100644 --- a/zkvm/lib/CHANGELOG.md +++ b/zkvm/lib/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/succinctlabs/sp1/compare/sp1-lib-v1.0.1...sp1-lib-v1.1.0) - 2024-08-02 + +### Added +- update tg ([#1214](https://github.com/succinctlabs/sp1/pull/1214)) + ## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-lib-v1.0.0-rc.1...sp1-lib-v1.0.0-rc.1) - 2024-07-19 ### Added diff --git a/zkvm/lib/Cargo.toml b/zkvm/lib/Cargo.toml index c7030d1b53..48ea0f008e 100644 --- a/zkvm/lib/Cargo.toml +++ b/zkvm/lib/Cargo.toml @@ -15,22 +15,6 @@ bincode = "1.3.3" cfg-if = "1.0.0" serde = { version = "1.0.204", features = ["derive"] } -# bls12-381 -amcl = { package = "snowbridge-amcl", version = "1.0.2", default-features = false, features = [ - "bls381", -], optional = true } -hex = { version = "0.4.3", optional = true } - -# k256 -k256 = { version = "0.13.3", features = [ - "ecdsa", - "std", - "bits", -], optional = true } - [features] default = [] verify = [] -bn254 = [] -secp256k1 = ["dep:k256"] -bls12381 = ["dep:amcl", "dep:hex"] diff --git a/zkvm/lib/src/bls12381.rs b/zkvm/lib/src/bls12381.rs index ebf39876ca..4250fdaf1a 100644 --- a/zkvm/lib/src/bls12381.rs +++ b/zkvm/lib/src/bls12381.rs @@ -1,63 +1,49 @@ -#![allow(unused_imports)] -use crate::utils::CurveOperations; -use crate::{syscall_bls12381_add, syscall_bls12381_decompress, syscall_bls12381_double}; +use crate::utils::AffinePoint; +use crate::{syscall_bls12381_add, syscall_bls12381_double}; -use amcl::bls381::bls381::utils::deserialize_g1; -use anyhow::Result; +/// The number of limbs in [Bls12381AffinePoint]. +pub const N: usize = 24; +/// An affine point on the BLS12-381 curve. #[derive(Copy, Clone)] -pub struct Bls12381; +#[repr(align(4))] +pub struct Bls12381AffinePoint(pub [u32; N]); -const NUM_WORDS: usize = 24; - -impl CurveOperations for Bls12381 { - /// The generator has been taken from py_ecc python library by the Ethereum Foundation: +impl AffinePoint for Bls12381AffinePoint { + /// The generator was taken from "py_ecc" python library by the Ethereum Foundation: /// /// https://github.com/ethereum/py_ecc/blob/7b9e1b3/py_ecc/bls12_381/bls12_381_curve.py#L38-L45 - const GENERATOR: [u32; NUM_WORDS] = [ + const GENERATOR: [u32; N] = [ 3676489403, 4214943754, 4185529071, 1817569343, 387689560, 2706258495, 2541009157, 3278408783, 1336519695, 647324556, 832034708, 401724327, 1187375073, 212476713, 2726857444, 3493644100, 738505709, 14358731, 3587181302, 4243972245, 1948093156, 2694721773, 3819610353, 146011265, ]; - fn add_assign(limbs: &mut [u32; NUM_WORDS], other: &[u32; NUM_WORDS]) { - unsafe { - syscall_bls12381_add(limbs.as_mut_ptr(), other.as_ptr()); - } + fn new(limbs: [u32; N]) -> Self { + Self(limbs) + } + + fn limbs_ref(&self) -> &[u32; N] { + &self.0 } - fn double(limbs: &mut [u32; NUM_WORDS]) { + fn limbs_mut(&mut self) -> &mut [u32; N] { + &mut self.0 + } + + fn add_assign(&mut self, other: &Self) { + let a = self.limbs_mut(); + let b = other.limbs_ref(); unsafe { - syscall_bls12381_double(limbs.as_mut_ptr()); + syscall_bls12381_add(a, b); } } -} -/// Decompresses a compressed public key using bls12381_decompress precompile. -pub fn decompress_pubkey(compressed_key: &[u8; 48]) -> Result<[u8; 96]> { - cfg_if::cfg_if! { - if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] { - let mut decompressed_key = [0u8; 96]; - decompressed_key[..48].copy_from_slice(compressed_key); - - let sign_bit = ((decompressed_key[0] & 0b_0010_0000) >> 5) == 1; - decompressed_key[0] &= 0b_0001_1111; - unsafe { - syscall_bls12381_decompress(&mut decompressed_key, sign_bit); - } - - Ok(decompressed_key) - } else { - let point = deserialize_g1(compressed_key.as_slice()).unwrap(); - let x = point.getx().to_string(); - let y = point.gety().to_string(); - - let decompressed_key = hex::decode(format!("{x}{y}")).unwrap(); - let mut result = [0u8; 96]; - result.copy_from_slice(&decompressed_key); - - Ok(result) + fn double(&mut self) { + let a = self.limbs_mut(); + unsafe { + syscall_bls12381_double(a); } } } diff --git a/zkvm/lib/src/bn254.rs b/zkvm/lib/src/bn254.rs index 86a4cf94f1..011c614347 100644 --- a/zkvm/lib/src/bn254.rs +++ b/zkvm/lib/src/bn254.rs @@ -1,26 +1,44 @@ -use crate::utils::CurveOperations; +use crate::utils::AffinePoint; use crate::{syscall_bn254_add, syscall_bn254_double}; -#[derive(Copy, Clone)] -pub struct Bn254; +/// The number of limbs in [Bn254AffinePoint]. +pub const N: usize = 16; -const NUM_WORDS: usize = 16; +/// An affine point on the BLS12-381 curve. +#[derive(Copy, Clone)] +#[repr(align(4))] +pub struct Bn254AffinePoint(pub [u32; N]); -impl CurveOperations for Bn254 { +impl AffinePoint for Bn254AffinePoint { /// The generator has been taken from py_pairing python library by the Ethereum Foundation: /// /// https://github.com/ethereum/py_pairing/blob/5f609da/py_ecc/bn128/bn128_field_elements.py - const GENERATOR: [u32; NUM_WORDS] = [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]; + const GENERATOR: [u32; N] = [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]; + + fn new(limbs: [u32; N]) -> Self { + Self(limbs) + } + + fn limbs_ref(&self) -> &[u32; N] { + &self.0 + } + + fn limbs_mut(&mut self) -> &mut [u32; N] { + &mut self.0 + } - fn add_assign(limbs: &mut [u32; NUM_WORDS], other: &[u32; NUM_WORDS]) { + fn add_assign(&mut self, other: &Self) { + let a = self.limbs_mut(); + let b = other.limbs_ref(); unsafe { - syscall_bn254_add(limbs.as_mut_ptr(), other.as_ptr()); + syscall_bn254_add(a, b); } } - fn double(limbs: &mut [u32; NUM_WORDS]) { + fn double(&mut self) { + let a = self.limbs_mut(); unsafe { - syscall_bn254_double(limbs.as_mut_ptr()); + syscall_bn254_double(a); } } } diff --git a/zkvm/lib/src/ed25519.rs b/zkvm/lib/src/ed25519.rs new file mode 100644 index 0000000000..f801ee310a --- /dev/null +++ b/zkvm/lib/src/ed25519.rs @@ -0,0 +1,55 @@ +use crate::syscall_ed_add; +use crate::utils::AffinePoint; + +/// The number of limbs in [Ed25519AffinePoint]. +pub const N: usize = 16; + +/// An affine point on the Ed25519 curve. +#[derive(Copy, Clone)] +#[repr(align(4))] +pub struct Ed25519AffinePoint(pub [u32; N]); + +impl AffinePoint for Ed25519AffinePoint { + /// The generator/base point for the Ed25519 curve. Reference: https://datatracker.ietf.org/doc/html/rfc7748#section-4.1 + const GENERATOR: [u32; N] = [ + 216936062, 3086116296, 2351951131, 1681893421, 3444223839, 2756123356, 3800373269, + 3284567716, 2518301344, 752319464, 3983256831, 1952656717, 3669724772, 3793645816, + 3665724614, 2969860233, + ]; + + fn new(limbs: [u32; N]) -> Self { + Self(limbs) + } + + fn limbs_ref(&self) -> &[u32; N] { + &self.0 + } + + fn limbs_mut(&mut self) -> &mut [u32; N] { + &mut self.0 + } + + fn add_assign(&mut self, other: &Self) { + let a = self.limbs_mut(); + let b = other.limbs_ref(); + unsafe { + syscall_ed_add(a, b); + } + } + + /// In Edwards curves, doubling is the same as adding a point to itself. + fn double(&mut self) { + let a = self.limbs_mut(); + unsafe { + syscall_ed_add(a, a); + } + } +} + +impl Ed25519AffinePoint { + const IDENTITY: [u32; N] = [0; N]; + + pub fn identity() -> Self { + Self(Self::IDENTITY) + } +} diff --git a/zkvm/lib/src/lib.rs b/zkvm/lib/src/lib.rs index 4aa0f62e15..90dd99c6e5 100644 --- a/zkvm/lib/src/lib.rs +++ b/zkvm/lib/src/lib.rs @@ -1,11 +1,12 @@ -//! System calls for the SP1 zkVM. +//! Syscalls for the SP1 zkVM. +//! +//! Documentation for these syscalls can be found in the zkVM entrypoint +//! `sp1_zkvm::syscalls` module. -#[cfg(feature = "bls12381")] pub mod bls12381; -#[cfg(feature = "bn254")] pub mod bn254; +pub mod ed25519; pub mod io; -#[cfg(feature = "secp256k1")] pub mod secp256k1; pub mod unconstrained; pub mod utils; @@ -23,43 +24,43 @@ extern "C" { pub fn syscall_read(fd: u32, read_buf: *mut u8, nbytes: usize); /// Executes the SHA-256 extend operation on the given word array. - pub fn syscall_sha256_extend(w: *mut u32); + pub fn syscall_sha256_extend(w: *mut [u32; 64]); /// Executes the SHA-256 compress operation on the given word array and a given state. - pub fn syscall_sha256_compress(w: *mut u32, state: *mut u32); + pub fn syscall_sha256_compress(w: *mut [u32; 64], state: *mut [u32; 8]); /// Executes an Ed25519 curve addition on the given points. - pub fn syscall_ed_add(p: *mut u32, q: *mut u32); + pub fn syscall_ed_add(p: *mut [u32; 16], q: *const [u32; 16]); /// Executes an Ed25519 curve decompression on the given point. pub fn syscall_ed_decompress(point: &mut [u8; 64]); /// Executes an Sepc256k1 curve addition on the given points. - pub fn syscall_secp256k1_add(p: *mut u32, q: *const u32); + pub fn syscall_secp256k1_add(p: *mut [u32; 16], q: *const [u32; 16]); /// Executes an Secp256k1 curve doubling on the given point. - pub fn syscall_secp256k1_double(p: *mut u32); + pub fn syscall_secp256k1_double(p: *mut [u32; 16]); /// Executes an Secp256k1 curve decompression on the given point. pub fn syscall_secp256k1_decompress(point: &mut [u8; 64], is_odd: bool); /// Executes a Bn254 curve addition on the given points. - pub fn syscall_bn254_add(p: *mut u32, q: *const u32); + pub fn syscall_bn254_add(p: *mut [u32; 16], q: *const [u32; 16]); /// Executes a Bn254 curve doubling on the given point. - pub fn syscall_bn254_double(p: *mut u32); + pub fn syscall_bn254_double(p: *mut [u32; 16]); /// Executes a BLS12-381 curve addition on the given points. - pub fn syscall_bls12381_add(p: *mut u32, q: *const u32); + pub fn syscall_bls12381_add(p: *mut [u32; 24], q: *const [u32; 24]); /// Executes a BLS12-381 curve doubling on the given point. - pub fn syscall_bls12381_double(p: *mut u32); + pub fn syscall_bls12381_double(p: *mut [u32; 24]); /// Executes the Keccak-256 permutation on the given state. - pub fn syscall_keccak_permute(state: *mut u64); + pub fn syscall_keccak_permute(state: *mut [u64; 25]); /// Executes an uint256 multiplication on the given inputs. - pub fn syscall_uint256_mulmod(x: *mut u32, y: *const u32); + pub fn syscall_uint256_mulmod(x: *mut [u32; 8], y: *const [u32; 8]); /// Enters unconstrained mode. pub fn syscall_enter_unconstrained() -> bool; diff --git a/zkvm/lib/src/secp256k1.rs b/zkvm/lib/src/secp256k1.rs index 973985bca1..6624bed56d 100644 --- a/zkvm/lib/src/secp256k1.rs +++ b/zkvm/lib/src/secp256k1.rs @@ -1,226 +1,46 @@ -#![allow(unused)] +use crate::utils::AffinePoint; +use crate::{syscall_secp256k1_add, syscall_secp256k1_double}; -use crate::io::{self, FD_ECRECOVER_HOOK}; -use crate::unconstrained; -use crate::utils::{AffinePoint, CurveOperations}; -use crate::{syscall_secp256k1_add, syscall_secp256k1_decompress, syscall_secp256k1_double}; - -use anyhow::Context; -use anyhow::{anyhow, Result}; -use core::convert::TryInto; -use k256::ecdsa::hazmat::bits2field; -use k256::ecdsa::signature::hazmat::PrehashVerifier; -use k256::ecdsa::{RecoveryId, Signature, VerifyingKey}; -use k256::elliptic_curve::ff::PrimeFieldBits; -use k256::elliptic_curve::ops::Invert; -use k256::elliptic_curve::sec1::ToEncodedPoint; -use k256::elliptic_curve::PrimeField; -use k256::{PublicKey, Scalar, Secp256k1}; - -const NUM_WORDS: usize = 16; +/// The number of limbs in [Secp256k1AffinePoint]. +pub const N: usize = 16; +/// An affine point on the Secp256k1 curve. #[derive(Copy, Clone)] -pub struct Secp256k1Operations; +#[repr(align(4))] +pub struct Secp256k1AffinePoint(pub [u32; N]); -impl CurveOperations for Secp256k1Operations { - // The values are taken from https://en.bitcoin.it/wiki/Secp256k1. - const GENERATOR: [u32; NUM_WORDS] = [ +impl AffinePoint for Secp256k1AffinePoint { + /// The values are taken from https://en.bitcoin.it/wiki/Secp256k1. + const GENERATOR: [u32; N] = [ 385357720, 1509065051, 768485593, 43777243, 3464956679, 1436574357, 4191992748, 2042521214, 4212184248, 2621952143, 2793755673, 4246189128, 235997352, 1571093500, 648266853, 1211816567, ]; - fn add_assign(limbs: &mut [u32; NUM_WORDS], other: &[u32; NUM_WORDS]) { - unsafe { - syscall_secp256k1_add(limbs.as_mut_ptr(), other.as_ptr()); - } - } - fn double(limbs: &mut [u32; NUM_WORDS]) { - unsafe { - syscall_secp256k1_double(limbs.as_mut_ptr()); - } + fn new(limbs: [u32; N]) -> Self { + Self(limbs) } -} -/// Decompresses a compressed public key using secp256k1_decompress precompile. -pub fn decompress_pubkey(compressed_key: &[u8; 33]) -> Result<[u8; 65]> { - cfg_if::cfg_if! { - if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] { - let mut decompressed_key: [u8; 64] = [0; 64]; - decompressed_key[..32].copy_from_slice(&compressed_key[1..]); - let is_odd = match compressed_key[0] { - 2 => false, - 3 => true, - _ => return Err(anyhow!("Invalid compressed key")), - }; - unsafe { - syscall_secp256k1_decompress(&mut decompressed_key, is_odd); - } - - let mut result: [u8; 65] = [0; 65]; - result[0] = 4; - result[1..].copy_from_slice(&decompressed_key); - Ok(result) - } else { - let public_key = PublicKey::from_sec1_bytes(compressed_key).context("invalid pubkey")?; - let bytes = public_key.to_encoded_point(false).to_bytes(); - let mut result: [u8; 65] = [0; 65]; - result.copy_from_slice(&bytes); - Ok(result) - } + fn limbs_ref(&self) -> &[u32; N] { + &self.0 } -} - -/// Verifies a secp256k1 signature using the public key and the message hash. If the s_inverse is -/// provided, it will be validated and used to verify the signature. Otherwise, the inverse of s -/// will be computed and used. -/// -/// Warning: this function does not check if the key is actually on the curve. -pub fn verify_signature( - pubkey: &[u8; 65], - msg_hash: &[u8; 32], - signature: &Signature, - s_inverse: Option<&Scalar>, -) -> bool { - cfg_if::cfg_if! { - if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] { - let pubkey_x = Scalar::from_repr(bits2field::(&pubkey[1..33]).unwrap()).unwrap(); - let pubkey_y = Scalar::from_repr(bits2field::(&pubkey[33..]).unwrap()).unwrap(); - - let mut pubkey_x_le_bytes = pubkey_x.to_bytes(); - pubkey_x_le_bytes.reverse(); - let mut pubkey_y_le_bytes = pubkey_y.to_bytes(); - pubkey_y_le_bytes.reverse(); - - // Convert the public key to an affine point - let affine = AffinePoint::::from(&pubkey_x_le_bytes, &pubkey_y_le_bytes); - - const GENERATOR: AffinePoint = AffinePoint::::generator_in_affine(); - - let field = bits2field::(msg_hash); - if field.is_err() { - return false; - } - let field = Scalar::from_repr(field.unwrap()).unwrap(); - let z = field; - let (r, s) = signature.split_scalars(); - let computed_s_inv; - let s_inv = match s_inverse { - Some(s_inv) => { - assert_eq!(s_inv * s.as_ref(), Scalar::ONE); - s_inv - } - None => { - computed_s_inv = s.invert(); - &computed_s_inv - } - }; - - let u1 = z * s_inv; - let u2 = *r * s_inv; - - let res = double_and_add_base(&u1, &GENERATOR, &u2, &affine).unwrap(); - let mut x_bytes_be = [0u8; 32]; - for i in 0..8 { - x_bytes_be[i * 4..(i * 4) + 4].copy_from_slice(&res.limbs[i].to_le_bytes()); - } - x_bytes_be.reverse(); - - let x_field = bits2field::(&x_bytes_be); - if x_field.is_err() { - return false; - } - *r == Scalar::from_repr(x_field.unwrap()).unwrap() - } else { - let public_key = PublicKey::from_sec1_bytes(pubkey); - if public_key.is_err() { - return false; - } - let public_key = public_key.unwrap(); - let verify_key = VerifyingKey::from(&public_key); - let res = verify_key - .verify_prehash(msg_hash, signature) - .context("invalid signature"); - - res.is_ok() - } + fn limbs_mut(&mut self) -> &mut [u32; N] { + &mut self.0 } -} -#[allow(non_snake_case)] -fn double_and_add_base( - a: &Scalar, - A: &AffinePoint, - b: &Scalar, - B: &AffinePoint, -) -> Option> { - let mut res: Option> = None; - let mut temp_A = *A; - let mut temp_B = *B; - - let a_bits = a.to_le_bits(); - let b_bits = b.to_le_bits(); - for (a_bit, b_bit) in a_bits.iter().zip(b_bits) { - if *a_bit { - match res.as_mut() { - Some(res) => res.add_assign(&temp_A), - None => res = Some(temp_A), - }; - } - - if b_bit { - match res.as_mut() { - Some(res) => res.add_assign(&temp_B), - None => res = Some(temp_B), - }; + fn add_assign(&mut self, other: &Self) { + let a = self.limbs_mut(); + let b = other.limbs_ref(); + unsafe { + syscall_secp256k1_add(a, b); } - - temp_A.double(); - temp_B.double(); - } - - res -} - -/// Outside of the VM, computes the pubkey and s_inverse value from a signature and a message hash. -/// -/// WARNING: The values are read from outside of the VM and are not constrained to be correct. -/// Either use `decompress_pubkey` and `verify_signature` to verify the results of this function, or -/// use `ecrecover`. -pub fn unconstrained_ecrecover(sig: &[u8; 65], msg_hash: &[u8; 32]) -> ([u8; 33], Scalar) { - // The `unconstrained!` wrapper is used since none of these computations directly affect - // the output values of the VM. The remainder of the function sets the constraints on the values - // instead. Removing the `unconstrained!` wrapper slightly increases the cycle count. - unconstrained! { - let mut buf = [0; 65 + 32]; - let (buf_sig, buf_msg_hash) = buf.split_at_mut(sig.len()); - buf_sig.copy_from_slice(sig); - buf_msg_hash.copy_from_slice(msg_hash); - io::write(FD_ECRECOVER_HOOK, &buf); } - let recovered_bytes: [u8; 33] = io::read_vec().try_into().unwrap(); - - let s_inv_bytes: [u8; 32] = io::read_vec().try_into().unwrap(); - let s_inverse = Scalar::from_repr(bits2field::(&s_inv_bytes).unwrap()).unwrap(); - - (recovered_bytes, s_inverse) -} - -/// Given a signature and a message hash, returns the public key that signed the message. -pub fn ecrecover(sig: &[u8; 65], msg_hash: &[u8; 32]) -> Result<[u8; 65]> { - let (pubkey, s_inv) = unconstrained_ecrecover(sig, msg_hash); - let pubkey = decompress_pubkey(&pubkey).context("decompress pubkey failed")?; - let verified = verify_signature( - &pubkey, - msg_hash, - &Signature::from_slice(&sig[..64]).unwrap(), - Some(&s_inv), - ); - if verified { - Ok(pubkey) - } else { - Err(anyhow!("failed to verify signature")) + fn double(&mut self) { + let a = self.limbs_mut(); + unsafe { + syscall_secp256k1_double(a); + } } } diff --git a/zkvm/lib/src/utils.rs b/zkvm/lib/src/utils.rs index 34cc3db02e..16d432a795 100644 --- a/zkvm/lib/src/utils.rs +++ b/zkvm/lib/src/utils.rs @@ -1,72 +1,65 @@ -pub trait CurveOperations { - const GENERATOR: [u32; NUM_WORDS]; +pub trait AffinePoint: Clone + Sized { + /// The generator. + const GENERATOR: [u32; N]; - fn add_assign(limbs: &mut [u32; NUM_WORDS], other: &[u32; NUM_WORDS]); - fn double(limbs: &mut [u32; NUM_WORDS]); -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub struct AffinePoint, const NUM_WORDS: usize> { - pub(crate) limbs: [u32; NUM_WORDS], - _marker: std::marker::PhantomData, -} - -#[derive(Debug)] -pub enum MulAssignError { - ZeroScalar, -} + /// Creates a new [`AffinePoint`] from the given limbs. + fn new(limbs: [u32; N]) -> Self; -impl + Copy, const NUM_WORDS: usize> AffinePoint { - const GENERATOR: [u32; NUM_WORDS] = C::GENERATOR; + /// Returns a reference to the limbs. + fn limbs_ref(&self) -> &[u32; N]; - pub const fn generator_in_affine() -> Self { - Self { - limbs: Self::GENERATOR, - _marker: std::marker::PhantomData, - } - } + /// Returns a mutable reference to the limbs. + fn limbs_mut(&mut self) -> &mut [u32; N]; - pub const fn new(limbs: [u32; NUM_WORDS]) -> Self { - Self { - limbs, - _marker: std::marker::PhantomData, - } - } + /// Creates a new [`AffinePoint`] from the given x and y coordinates. + /// + /// The bytes are the concatenated little endian representations of the coordinates. + fn from(x: &[u8], y: &[u8]) -> Self { + debug_assert!(x.len() == N * 2); + debug_assert!(y.len() == N * 2); - /// x_bytes and y_bytes are the concatenated little endian representations of the x and y coordinates. - /// The length of x_bytes and y_bytes must each be NUM_WORDS * 2. - pub fn from(x_bytes: &[u8], y_bytes: &[u8]) -> Self { - debug_assert!(x_bytes.len() == NUM_WORDS * 2); - debug_assert!(y_bytes.len() == NUM_WORDS * 2); + let mut limbs = [0u32; N]; + let x = bytes_to_words_le(x); + let y = bytes_to_words_le(y); - let mut limbs = [0u32; NUM_WORDS]; - let x = bytes_to_words_le(x_bytes); - let y = bytes_to_words_le(y_bytes); - debug_assert!(x.len() == NUM_WORDS / 2); - debug_assert!(y.len() == NUM_WORDS / 2); + debug_assert!(x.len() == N / 2); + debug_assert!(y.len() == N / 2); - limbs[..(NUM_WORDS / 2)].copy_from_slice(&x); - limbs[(NUM_WORDS / 2)..].copy_from_slice(&y); + limbs[..(N / 2)].copy_from_slice(&x); + limbs[(N / 2)..].copy_from_slice(&y); Self::new(limbs) } - pub fn add_assign(&mut self, other: &AffinePoint) { - C::add_assign(&mut self.limbs, &other.limbs); + /// Creates a new [`AffinePoint`] from the given bytes in little endian. + fn from_le_bytes(bytes: &[u8]) -> Self { + let limbs = bytes_to_words_le(bytes); + debug_assert!(limbs.len() == N); + Self::new(limbs.try_into().unwrap()) } - pub fn double(&mut self) { - C::double(&mut self.limbs); + /// Creates a new [`AffinePoint`] from the given bytes in big endian. + fn to_le_bytes(&self) -> Vec { + let le_bytes = words_to_bytes_le(self.limbs_ref()); + debug_assert!(le_bytes.len() == N * 4); + le_bytes } - pub fn mul_assign(&mut self, scalar: &[u32]) -> Result<(), MulAssignError> { - debug_assert!(scalar.len() == NUM_WORDS / 2); + /// Adds the given [`AffinePoint`] to `self`. + fn add_assign(&mut self, other: &Self); + + /// Doubles `self`. + fn double(&mut self); + + /// Multiplies `self` by the given scalar. + fn mul_assign(&mut self, scalar: &[u32]) -> Result<(), MulAssignError> { + debug_assert!(scalar.len() == N / 2); let mut res: Option = None; - let mut temp = *self; + let mut temp = self.clone(); let scalar_is_zero = scalar.iter().all(|&words| words == 0); if scalar_is_zero { - return Err(MulAssignError::ZeroScalar); + return Err(MulAssignError::ScalarIsZero); } for &words in scalar.iter() { @@ -74,7 +67,7 @@ impl + Copy, const NUM_WORDS: usize> AffinePoint> i) & 1 == 1 { match res.as_mut() { Some(res) => res.add_assign(&temp), - None => res = Some(temp), + None => res = Some(temp.clone()), }; } @@ -86,21 +79,43 @@ impl + Copy, const NUM_WORDS: usize> AffinePoint Self { - let u32_limbs = bytes_to_words_le(limbs); - debug_assert!(u32_limbs.len() == NUM_WORDS); + /// Performs multi-scalar multiplication (MSM) on slices of bit vectors and points. Note: + /// a_bits_le and b_bits_le should be in little endian order. + fn multi_scalar_multiplication( + a_bits_le: &[bool], + a: Self, + b_bits_le: &[bool], + b: Self, + ) -> Option { + let mut res: Option = None; + let mut temp_a = a.clone(); + let mut temp_b = b.clone(); + for (a_bit, b_bit) in a_bits_le.iter().zip(b_bits_le.iter()) { + if *a_bit { + match res.as_mut() { + Some(res) => res.add_assign(&temp_a), + None => res = Some(temp_a.clone()), + }; + } + + if *b_bit { + match res.as_mut() { + Some(res) => res.add_assign(&temp_b), + None => res = Some(temp_b.clone()), + }; + } - Self { - limbs: u32_limbs.try_into().unwrap(), - _marker: std::marker::PhantomData, + temp_a.double(); + temp_b.double(); } + res } +} - pub fn to_le_bytes(&self) -> Vec { - let le_bytes = words_to_bytes_le(&self.limbs); - debug_assert!(le_bytes.len() == NUM_WORDS * 4); - le_bytes - } +/// Errors that can occur during scalar multiplication of an [`AffinePoint`]. +#[derive(Debug)] +pub enum MulAssignError { + ScalarIsZero, } /// Converts a slice of words to a byte array in little endian.