From b84be6a9942658478bd22289e834f6dd176d2f52 Mon Sep 17 00:00:00 2001 From: Irakliy Khaburzaniya Date: Sun, 22 Oct 2023 00:22:29 -0700 Subject: [PATCH] updated crate versions and readme files --- CHANGELOG.md | 3 +++ README.md | 51 ++++++++++++++++++++++++++++++++++--------- air/Cargo.toml | 17 +++++++-------- crypto/Cargo.toml | 16 +++++++------- examples/Cargo.toml | 12 +++++----- fri/Cargo.toml | 14 ++++++------ math/Cargo.toml | 12 +++++----- prover/Cargo.toml | 18 +++++++-------- prover/README.md | 3 ++- utils/core/Cargo.toml | 8 +++---- utils/rand/Cargo.toml | 8 +++---- verifier/Cargo.toml | 16 +++++++------- verifier/README.md | 15 ++++++++++--- winterfell/Cargo.toml | 10 ++++----- winterfell/src/lib.rs | 40 ++++++++++++++++----------------- 15 files changed, 143 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9342f239e..6202c45d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,10 @@ ## 0.7.0 (TBD) * [BREAKING] replaced the `TraceLde` struct with a trait (#207). * [BREAKING] refactored `RandomCoin` trait (#214). +* Improved proven security estimation (#215). * [BREAKING] replaced the `ConstraintEvaluator` struct with a trait (#217). +* Added support for proven security estimation in `no_std` context (#218). +* [BREAKING] refactored `verify()` function to take `AcceptableOptions` as a parameter (#219). ## 0.6.5 (2023-08-09) - math crate only * Added conditional support for serde on field elements (#209) diff --git a/README.md b/README.md index 04cb34e1f..fe7370ba2 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ For more information about arithmetization see [air crate](air#Arithmetization), ```Rust use winterfell::{ math::{fields::f128::BaseElement, FieldElement, ToElements}, - Air, AirContext, Assertion, ByteWriter, EvaluationFrame, ProofOptions, TraceInfo, + Air, AirContext, Assertion, EvaluationFrame, ProofOptions, TraceInfo, TransitionConstraintDegree, }; @@ -235,14 +235,18 @@ pretty simple and has just a few required methods. Here is how our implementatio like: ```Rust use winterfell::{ + crypto::{hashers::Blake3_256, DefaultRandomCoin}, math::{fields::f128::BaseElement, FieldElement}, - ProofOptions, Prover, Trace, TraceTable + DefaultConstraintEvaluator, DefaultTraceLde, ProofOptions, Prover, Trace, TraceTable, }; +// We'll use BLAKE3 as the hash function during proof generation. +type Blake3 = Blake3_256; + // Our prover needs to hold STARK protocol parameters which are specified via ProofOptions // struct. struct WorkProver { - options: ProofOptions + options: ProofOptions, } impl WorkProver { @@ -251,14 +255,19 @@ impl WorkProver { } } -// When implementing Prover trait we set the `Air` associated type to the AIR of the +// When implementing the Prover trait we set the `Air` associated type to the AIR of the // computation we defined previously, and set the `Trace` associated type to `TraceTable` -// struct as we don't need to define a custom trace for our computation. +// struct as we don't need to define a custom trace for our computation. For other +// associated types, we'll use default implementation provided by Winterfell. impl Prover for WorkProver { type BaseField = BaseElement; type Air = WorkAir; - type Trace = TraceTable; - type HashFn = Blake3_256; + type Trace = TraceTable; + type HashFn = Blake3; + type RandomCoin = DefaultRandomCoin; + type TraceLde> = DefaultTraceLde; + type ConstraintEvaluator<'a, E: FieldElement> = + DefaultConstraintEvaluator<'a, WorkAir, E>; // Our public inputs consist of the first and last value in the execution trace. fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs { @@ -269,6 +278,16 @@ impl Prover for WorkProver { } } + // We'll use the default constraint evaluator to evaluate AIR constraints. + fn new_evaluator<'a, E: FieldElement>( + &self, + air: &'a WorkAir, + aux_rand_elements: winterfell::AuxTraceRandElements, + composition_coefficients: winterfell::ConstraintCompositionCoefficients, + ) -> Self::ConstraintEvaluator<'a, E> { + DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients) + } + fn options(&self) -> &ProofOptions { &self.options } @@ -313,11 +332,23 @@ pub fn prove_work() -> (BaseElement, StarkProof) { We can then give this proof (together with the public inputs) to anyone, and they can verify that we did in fact execute the computation and got the claimed result. They can do this like so: ```Rust +use winterfell::{ + crypto::{hashers::Blake3_256, DefaultRandomCoin}, + math::fields::f128::BaseElement, + verify, AcceptableOptions, StarkProof, +}; + +type Blake3 = Blake3_256; + pub fn verify_work(start: BaseElement, result: BaseElement, proof: StarkProof) { - // The number of steps and options are encoded in the proof itself, so we - // don't need to pass them explicitly to the verifier. + // The verifier will accept proofs with parameters which guarantee 95 bits or more of + // conjectured security + let min_opts = AcceptableOptions::MinConjecturedSecurity(95); + + // The number of steps and options are encoded in the proof itself, so we don't need to + // pass them explicitly to the verifier. let pub_inputs = PublicInputs { start, result }; - match winterfell::verify::>(proof, pub_inputs) { + match verify::>(proof, pub_inputs, &min_opts) { Ok(_) => println!("yay! all good!"), Err(_) => panic!("something went terribly wrong!"), } diff --git a/air/Cargo.toml b/air/Cargo.toml index 76beba442..2ff02f15b 100644 --- a/air/Cargo.toml +++ b/air/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-air" -version = "0.6.4" +version = "0.7.0" description = "AIR components for the Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-air/0.6.4" +documentation = "https://docs.rs/winter-air/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "arithmetization", "air"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -20,14 +20,13 @@ default = ["std"] std = ["crypto/std", "fri/std", "math/std", "utils/std"] [dependencies] -crypto = { version = "0.6", path = "../crypto", package = "winter-crypto", default-features = false } -fri = { version = "0.6", path = "../fri", package = "winter-fri", default-features = false } -libm = "0.2.8" -math = { version = "0.6", path = "../math", package = "winter-math", default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +crypto = { version = "0.7", path = "../crypto", package = "winter-crypto", default-features = false } +fri = { version = "0.7", path = "../fri", package = "winter-fri", default-features = false } +math = { version = "0.7", path = "../math", package = "winter-math", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } [dev-dependencies] -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils" } +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils" } # Allow math in docs [package.metadata.docs.rs] diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index a5a7c8c9d..da21055fe 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-crypto" -version = "0.6.4" +version = "0.7.0" description = "Cryptographic library for the Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-crypto/0.6.4" +documentation = "https://docs.rs/winter-crypto/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "merkle-tree", "hash"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -30,12 +30,12 @@ concurrent = ["utils/concurrent", "std"] std = ["blake3/std", "math/std", "sha3/std", "utils/std"] [dependencies] -blake3 = { version = "1.3", default-features = false } -math = { version = "0.6", path = "../math", package = "winter-math", default-features = false } +blake3 = { version = "1.5", default-features = false } +math = { version = "0.7", path = "../math", package = "winter-math", default-features = false } sha3 = { version = "0.10", default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } [dev-dependencies] criterion = "0.5" -proptest = "1.1" -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils" } +proptest = "1.3" +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils" } diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 7d7d5e3d1..b4e4860ee 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "examples" -version = "0.6.4" +version = "0.7.0" description = "Examples of using Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" @@ -8,7 +8,7 @@ license = "MIT" repository = "https://github.com/novifinancial/winterfell" categories = ["cryptography"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -26,12 +26,12 @@ default = ["std"] std = ["hex/std", "winterfell/std", "core-utils/std", "rand-utils"] [dependencies] -winterfell = { version="0.6", path = "../winterfell", default-features = false } -core-utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils", optional = true } +winterfell = { version="0.7", path = "../winterfell", default-features = false } +core-utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils", optional = true } hex = { version = "0.4", optional = true } log = { version = "0.4", default-features = false } -blake3 = { version = "1.3", default-features = false } +blake3 = { version = "1.5", default-features = false } env_logger = { version = "0.10", default-features = false } structopt = { version = "0.3", default-features = false } diff --git a/fri/Cargo.toml b/fri/Cargo.toml index 5d730d19a..09ff3e910 100644 --- a/fri/Cargo.toml +++ b/fri/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-fri" -version = "0.6.4" +version = "0.7.0" description = "Implementation of FRI protocol for the Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-fri/0.6.4" +documentation = "https://docs.rs/winter-fri/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "polynomial", "commitments"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -29,10 +29,10 @@ default = ["std"] std = ["crypto/std", "math/std", "utils/std"] [dependencies] -crypto = { version = "0.6", path = "../crypto", package = "winter-crypto", default-features = false } -math = { version = "0.6", path = "../math", package = "winter-math", default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +crypto = { version = "0.7", path = "../crypto", package = "winter-crypto", default-features = false } +math = { version = "0.7", path = "../math", package = "winter-math", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } [dev-dependencies] criterion = "0.5" -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils" } +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils" } diff --git a/math/Cargo.toml b/math/Cargo.toml index 9d68db776..4b409ae99 100644 --- a/math/Cargo.toml +++ b/math/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-math" -version = "0.6.5" +version = "0.7.0" description = "Math library for the Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-math/0.6.5" +documentation = "https://docs.rs/winter-math/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "finite-fields", "polynomials", "fft"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -34,13 +34,13 @@ std = ["utils/std"] [dependencies] serde = { version = "1.0", features = [ "derive" ], optional = true, default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } [dev-dependencies] criterion = "0.5" num-bigint = "0.4" -proptest = "1.1" -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils" } +proptest = "1.3" +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils" } # Allow math in docs [package.metadata.docs.rs] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 203d4991e..aaa617ffa 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-prover" -version = "0.6.4" +version = "0.7.0" description = "Winterfell STARK prover" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-prover/0.6.4" +documentation = "https://docs.rs/winter-prover/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "zkp", "stark", "prover"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -25,16 +25,16 @@ default = ["std"] std = ["air/std", "crypto/std", "fri/std", "math/std", "utils/std"] [dependencies] -air = { version = "0.6", path = "../air", package = "winter-air", default-features = false } -crypto = { version = "0.6", path = "../crypto", package = "winter-crypto", default-features = false } -fri = { version = "0.6", path = '../fri', package = "winter-fri", default-features = false } +air = { version = "0.7", path = "../air", package = "winter-air", default-features = false } +crypto = { version = "0.7", path = "../crypto", package = "winter-crypto", default-features = false } +fri = { version = "0.7", path = '../fri', package = "winter-fri", default-features = false } log = { version = "0.4", default-features = false } -math = { version = "0.6", path = "../math", package = "winter-math", default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +math = { version = "0.7", path = "../math", package = "winter-math", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } [dev-dependencies] criterion = "0.5" -rand-utils = { version = "0.6", path = "../utils/rand", package = "winter-rand-utils" } +rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils" } # Allow math in docs [package.metadata.docs.rs] diff --git a/prover/README.md b/prover/README.md index 9df0387f9..c5a3fb6ae 100644 --- a/prover/README.md +++ b/prover/README.md @@ -16,9 +16,10 @@ The resulting `StarkProof` object can be serialized and sent to a [verifier](../ Proof generation time is also highly dependent on the specifics of a given computation, but also depends on the capabilities of the machine used to generate the proofs (i.e. on number of CPU cores and memory bandwidth). For some high level benchmarks, see the [performance](..#Performance) section of the root README. ### Prover -To define a prover for a computation, you'll need implement the `Prover` trait. This trait specifies the computation's AIR (via the `Air` associated type) and the shape of its execution trace (via the `Trace` associated type). Besides these, a prover must provide implementations for two methods: +To define a prover for a computation, you'll need implement the `Prover` trait. This trait specifies the computation's AIR (via the `Air` associated type) and the shape of its execution trace (via the `Trace` associated type). The trait also requires specifying several other associated types, but for most of these default implementations provided by Winterfell should be used. Besides these, a prover must provide implementations for three methods: * `get_pub_inputs()`, which describes how a set of public inputs can be extracted from a given instance of an execution trace. These inputs will need to be shared with the verifier in order for them to verify the proof. +* `new_evaluator()`, which constructs a new instance of the AIR constraint evaluator. Unless your prover needs to implement specialized optimizations for evaluating constraints, this method can just return a default constraint evaluator provided by Winterfell. * `options()`, which defines STARK protocol parameters to be used during proof generation. These parameters include number of queries, blowup factor, grinding factor, hash function to be used during proof generation etc.. Values of these parameters directly inform such metrics as proof generation time, proof size, and proof security level. See [air crate](../air) for more info. A prover exposes a `prove()` method which can be used to generate a STARK proof using a given execution trace as a witness. diff --git a/utils/core/Cargo.toml b/utils/core/Cargo.toml index 453f89226..770f67a24 100644 --- a/utils/core/Cargo.toml +++ b/utils/core/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-utils" -version = "0.6.4" +version = "0.7.0" description = "Utilities for the Winterfell STARK prover/verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-utils/0.6.4" +documentation = "https://docs.rs/winter-utils/0.7.0" categories = ["cryptography", "no-std"] keywords = ["serialization", "transmute"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -21,4 +21,4 @@ default = ["std"] std = [] [dependencies] -rayon = { version = "1.7", optional = true } +rayon = { version = "1.8", optional = true } diff --git a/utils/rand/Cargo.toml b/utils/rand/Cargo.toml index 5453ecf20..6e64dcb03 100644 --- a/utils/rand/Cargo.toml +++ b/utils/rand/Cargo.toml @@ -1,22 +1,22 @@ [package] name = "winter-rand-utils" -version = "0.6.4" +version = "0.7.0" description = "Random value generation utilities for Winterfell crates" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-rand-utils/0.6.4" +documentation = "https://docs.rs/winter-rand-utils/0.7.0" categories = ["cryptography"] keywords = ["rand"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false [dependencies] -utils = { version = "0.6", path = "../core", package = "winter-utils" } +utils = { version = "0.7", path = "../core", package = "winter-utils" } [target.'cfg(not(target_family = "wasm"))'.dependencies] rand = { version = "0.8" } diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 1361de180..bb86707b1 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winter-verifier" -version = "0.6.4" +version = "0.7.0" description = "Winterfell STARK verifier" authors = ["winterfell contributors"] readme = "README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winter-verifier/0.6.4" +documentation = "https://docs.rs/winter-verifier/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "zkp", "stark", "verifier"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -20,11 +20,11 @@ default = ["std"] std = ["air/std", "crypto/std", "fri/std", "math/std", "utils/std"] [dependencies] -air = { version = "0.6", path = "../air", package = "winter-air", default-features = false } -crypto = { version = "0.6", path = "../crypto", package = "winter-crypto", default-features = false } -fri = { version = "0.6", path = "../fri", package = "winter-fri", default-features = false } -math = { version = "0.6", path = "../math", package = "winter-math", default-features = false } -utils = { version = "0.6", path = "../utils/core", package = "winter-utils", default-features = false } +air = { version = "0.7", path = "../air", package = "winter-air", default-features = false } +crypto = { version = "0.7", path = "../crypto", package = "winter-crypto", default-features = false } +fri = { version = "0.7", path = "../fri", package = "winter-fri", default-features = false } +math = { version = "0.7", path = "../math", package = "winter-math", default-features = false } +utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false } # Allow math in docs [package.metadata.docs.rs] diff --git a/verifier/README.md b/verifier/README.md index 96a770149..ce5001ae8 100644 --- a/verifier/README.md +++ b/verifier/README.md @@ -4,22 +4,31 @@ This crate contains an implementation of a STARK verifier which can verify proof ## Usage To verify a proof you can use `verifier::verify()` function, which has the following signature: ```Rust -pub fn verify( +pub fn verify( proof: StarkProof, pub_inputs: AIR::PublicInputs, -) -> Result<(), VerifierError>; + acceptable_options: &AcceptableOptions, +) -> Result<(), VerifierError> +where + AIR: Air, + HashFn: ElementHasher, + RandCoin: RandomCoin, ``` where: * `AIR` is a type implementing `Air` trait for your computation (see [air crate](../air) for more info). +* `HashFn` is a type defining the hash function used by the prover during proof generation. +* `RandCoin` is a type defining the methodology for drawing random values during proof generation. * `proof` is the proof generated by the prover attesting that the computation was executed correctly against some set of public inputs. * `pub_inputs` is the set of public inputs against which the computation was executed by the prover. +* `acceptable_options` defines a set of security parameters for the proofs which can be accepted by the verifier. For example, if we have a struct `FibAir` which implements the `Air` trait and describes a computation of a Fibonacci sequence (see [examples crate](../examples) for the concrete implementation), we could verify that the prover computed the 1,048,576th term of the sequence correctly, by executing the following: ```Rust +let min_sec = AcceptableOptions::MinConjecturedSecurity(95); let fib_result = BaseElement::new(226333832811148522147755045522163790995); -match verifier::verify::(proof, fib_result) { +match verifier::verify::>(proof, fib_result, &min_sec) { Ok(_) => debug!("Proof verified!"), Err(err) => debug!("Failed to verify proof: {}", err), } diff --git a/winterfell/Cargo.toml b/winterfell/Cargo.toml index 1d728b5e1..4bca3c9aa 100644 --- a/winterfell/Cargo.toml +++ b/winterfell/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "winterfell" -version = "0.6.4" +version = "0.7.0" description = "Winterfell STARK prover and verifier" authors = ["winterfell contributors"] readme = "../README.md" license = "MIT" repository = "https://github.com/novifinancial/winterfell" -documentation = "https://docs.rs/winterfell/0.6.4" +documentation = "https://docs.rs/winterfell/0.7.0" categories = ["cryptography", "no-std"] keywords = ["crypto", "zkp", "stark", "prover", "verifier"] edition = "2021" -rust-version = "1.67" +rust-version = "1.73" [lib] bench = false @@ -21,8 +21,8 @@ default = ["std"] std = ["prover/std", "verifier/std"] [dependencies] -prover = { version = "0.6", path = "../prover", package = "winter-prover", default-features = false } -verifier = { version = "0.6", path = "../verifier", package = "winter-verifier", default-features = false } +prover = { version = "0.7", path = "../prover", package = "winter-prover", default-features = false } +verifier = { version = "0.7", path = "../verifier", package = "winter-verifier", default-features = false } # Allow math in docs [package.metadata.docs.rs] diff --git a/winterfell/src/lib.rs b/winterfell/src/lib.rs index bc6b9ee42..7705678bb 100644 --- a/winterfell/src/lib.rs +++ b/winterfell/src/lib.rs @@ -150,7 +150,7 @@ //! ```no_run //! use winterfell::{ //! math::{fields::f128::BaseElement, FieldElement, ToElements}, -//! Air, AirContext, Assertion, ByteWriter, EvaluationFrame, ProofOptions, TraceInfo, +//! Air, AirContext, Assertion, EvaluationFrame, ProofOptions, TraceInfo, //! TransitionConstraintDegree, crypto::{hashers::Blake3_256, DefaultRandomCoin}, //! }; //! @@ -332,9 +332,10 @@ //! } //! } //! -//! // When implementing Prover trait we set the `Air` associated type to the AIR of the +//! // When implementing the Prover trait we set the `Air` associated type to the AIR of the //! // computation we defined previously, and set the `Trace` associated type to `TraceTable` -//! // struct as we don't need to define a custom trace for our computation. +//! // struct as we don't need to define a custom trace for our computation. For other +//! // associated types, we'll use default implementation provided by Winterfell. //! impl Prover for WorkProver { //! type BaseField = BaseElement; //! type Air = WorkAir; @@ -342,7 +343,8 @@ //! type HashFn = Blake3_256; //! type RandomCoin = DefaultRandomCoin; //! type TraceLde> = DefaultTraceLde; -//! type ConstraintEvaluator<'a, E: FieldElement> = DefaultConstraintEvaluator<'a, Self::Air, E>; +//! type ConstraintEvaluator<'a, E: FieldElement> = +//! DefaultConstraintEvaluator<'a, Self::Air, E>; //! //! // Our public inputs consist of the first and last value in the execution trace. //! fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs { @@ -357,15 +359,12 @@ //! &self.options //! } //! -//! fn new_evaluator<'a, E>( +//! fn new_evaluator<'a, E: FieldElement>( //! &self, //! air: &'a Self::Air, //! aux_rand_elements: winterfell::AuxTraceRandElements, //! composition_coefficients: winterfell::ConstraintCompositionCoefficients, -//! ) -> Self::ConstraintEvaluator<'a, E> -//! where -//! E: FieldElement, -//! { +//! ) -> Self::ConstraintEvaluator<'a, E> { //! DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients) //! } //! } @@ -381,9 +380,9 @@ //! ``` //! # use winterfell::{ //! # math::{fields::f128::BaseElement, FieldElement, ToElements}, -//! # Air, AirContext, Assertion, ByteWriter, DefaultConstraintEvaluator, DefaultTraceLde, EvaluationFrame, TraceInfo, -//! # TransitionConstraintDegree, TraceTable, FieldExtension, Prover, ProofOptions, -//! # StarkProof, Trace, crypto::{hashers::Blake3_256, DefaultRandomCoin}, +//! # Air, AirContext, Assertion, ByteWriter, DefaultConstraintEvaluator, DefaultTraceLde, +//! # EvaluationFrame, TraceInfo, TransitionConstraintDegree, TraceTable, FieldExtension, +//! # Prover, ProofOptions, StarkProof, Trace, crypto::{hashers::Blake3_256, DefaultRandomCoin}, //! # }; //! # //! # pub fn build_do_work_trace(start: BaseElement, n: usize) -> TraceTable { @@ -473,7 +472,8 @@ //! # type HashFn = Blake3_256; //! # type RandomCoin = DefaultRandomCoin; //! # type TraceLde> = DefaultTraceLde; -//! # type ConstraintEvaluator<'a, E: FieldElement> = DefaultConstraintEvaluator<'a, Self::Air, E>; +//! # type ConstraintEvaluator<'a, E: FieldElement> = +//! # DefaultConstraintEvaluator<'a, Self::Air, E>; //! # //! # fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs { //! # let last_step = trace.length() - 1; @@ -487,15 +487,12 @@ //! # &self.options //! # } //! # -//! # fn new_evaluator<'a, E>( +//! # fn new_evaluator<'a, E: FieldElement>( //! # &self, //! # air: &'a Self::Air, //! # aux_rand_elements: winterfell::AuxTraceRandElements, //! # composition_coefficients: winterfell::ConstraintCompositionCoefficients, -//! # ) -> Self::ConstraintEvaluator<'a, E> -//! # where -//! # E: FieldElement, -//! # { +//! # ) -> Self::ConstraintEvaluator<'a, E> { //! # DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients) //! # } //! # @@ -524,14 +521,17 @@ //! let prover = WorkProver::new(options); //! let proof = prover.prove(trace).unwrap(); //! +//! // The verifier will accept proofs with parameters which guarantee 95 bits or more of +//! // conjectured security +//! let min_opts = winterfell::AcceptableOptions::MinConjecturedSecurity(95); +//! //! // Verify the proof. The number of steps and options are encoded in the proof itself, //! // so we don't need to pass them explicitly to the verifier. //! let pub_inputs = PublicInputs { start, result }; -//! let acceptable_opt = winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]); //! assert!(winterfell::verify::, //! DefaultRandomCoin> -//! >(proof, pub_inputs, &acceptable_opt).is_ok()); +//! >(proof, pub_inputs, &min_opts).is_ok()); //! ``` //! //! That's all there is to it!