Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking PR for v0.9 release #279

Merged
merged 18 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 49 additions & 84 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,114 +1,79 @@
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
pull_request:
types: [opened, repoened, synchronize]

jobs:
check:
name: Check with ${{matrix.features}}
light-checks:
name: Light checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable]
os: [ubuntu]
features: [--all-features, --no-default-features]
steps:
- uses: actions/checkout@main
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
override: true
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-targets ${{matrix.features}}
- name: Clippy
run: |
rustup update --no-self-update nightly
rustup +nightly component add clippy
# Specifically, don't enable `async` feature in winter-prover crate
cargo +nightly clippy --workspace --all-targets --features std,concurrent -- -D clippy::all -D warnings

test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
- name: Rustfmt
run: |
rustup +nightly component add rustfmt
cargo +nightly fmt --all --check

# Note: the examples won't compile when the prover is built with the `async` feature, since they're designed to be sync only.
# Hence, we avoid this scenario explicitly.
check:
name: Check all features and all targets against the MSRV, except for winter-prover and winterfell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
override: true
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
- name: Perform checks
run: |
rustup update --no-self-update stable
cargo +stable install cargo-hack --locked
RUSTFLAGS=-Dwarnings cargo +stable hack --no-private --feature-powerset --keep-going check --rust-version --verbose --all-targets --workspace --exclude winter-prover --exclude winterfell

clippy:
name: Clippy
# Check prover and winterfell alone; specifically, that the `async` feature builds correctly
check-prover:
name: Check prover and winterfell packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install minimal nightly with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy
override: true
- name: Perform check
run: |
rustup update --no-self-update stable
cargo +stable install cargo-hack --locked
RUSTFLAGS=-Dwarnings cargo +stable hack --package winter-prover --package winterfell --no-private --feature-powerset --keep-going check --rust-version --verbose

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D clippy::all -D warnings
env:
# Seems necessary until https://github.com/rust-lang/rust/pull/115819 is merged.
CARGO_INCREMENTAL: 0

rustfmt:
name: rustfmt
test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
steps:
- uses: actions/checkout@main
- name: Install minimal nightly with rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true

- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run test
run: |
rustup update --no-self-update ${{ matrix.toolchain }}
cargo +${{ matrix.toolchain }} test

no-std:
name: no-std
name: Build for no-std
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
target:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@main
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
override: true
- run: rustup target add wasm32-unknown-unknown
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --no-default-features --target ${{ matrix.target }}
- name: Build for no-std
run: |
rustup update --no-self-update ${{ matrix.toolchain }}
rustup +${{ matrix.toolchain }} target add wasm32-unknown-unknown
cargo +${{ matrix.toolchain }} build --verbose --no-default-features --target wasm32-unknown-unknown
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.9.0 (2024-05-09)
- [BREAKING] Merged `TraceLayout` into `TraceInfo` (#245).
- Implemented Lagrange Kernel constraints (#247, )
- [BREAKING] refactored `TraceOodFrame` struct (#266, #274).
- [BREAKING] explicitly limited the number of auxiliary trace segments to 1 (#267).
- Implemented additional field conversions for the `f64` field (#268).
- [BREAKING] Added support for auxiliary proofs (#271).
- Introduced async prover (enabled via `async` feature) (#280).
- [BREAKING] removed `group_vector_elements()` utility function (#282).
- [BREAKING] removed `FieldElement::zeroed_vector()` function (#282).
- [BREAKING] removed previously deprecated re-exports of core modules.
- Updated minimum supported Rust version to 1.78.

## 0.8.4 (2024-03-28) - `math` crate only
* Added more to/from conversions for `f64` field (#268).

Expand All @@ -11,7 +24,7 @@
* Extended range of possible implementations of `ByteReader` and `ByteWriter`. (#262).

## 0.8.2 (2024-02-27) - `utils/core` crate only
* Extend `write_many` to support `IntoIterator` (#251)
* Extended `write_many` to support `IntoIterator` (#251)

## 0.8.1 (2024-02-21)
* Refactored utils module re-exports to comply with latest clippy updates (#250).
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"utils/core",
"utils/maybe_async",
"utils/rand",
"math",
"crypto",
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<a href="https://github.com/novifinancial/winterfell/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<img src="https://github.com/novifinancial/winterfell/workflows/CI/badge.svg?branch=main">
<a href="https://deps.rs/repo/github/novifinancial/winterfell"><img src="https://deps.rs/repo/github/novifinancial/winterfell/status.svg"></a>
<img src="https://img.shields.io/badge/prover-rustc_1.75+-lightgray.svg">
<img src="https://img.shields.io/badge/verifier-rustc_1.75+-lightgray.svg">
<img src="https://img.shields.io/badge/prover-rustc_1.78+-lightgray.svg">
<img src="https://img.shields.io/badge/verifier-rustc_1.78+-lightgray.svg">
<a href="https://crates.io/crates/winterfell"><img src="https://img.shields.io/crates/v/winterfell"></a>

A STARK prover and verifier for arbitrary computations.
Expand All @@ -31,11 +31,15 @@ Winterfell is a fully-functional, multi-threaded STARK prover and verifier with

**WebAssembly support.** The library is written in pure Rust and can be compiled to WebAssembly. The `std` standard library is enabled as feature by default for both prover and verifier crates. For WASM targets, one can compile with default features disabled by using `--no-default-features` flag.

**Async prover.** The library supports both sync and async variants of the `Prover` trait. By default, the sync version is exported. The async version of the trait can be enabled via the `async` feature flag.

#### Planned features

Over time, we hope extend the library with additional features:

**Perfect zero-knowledge.** The current implementation provides succinct proofs but NOT perfect zero-knowledge. This means that, in its current form, the library may not be suitable for use cases where proofs must not leak any info about secret inputs.
**Perfect zero-knowledge.** The current implementation provides succinct proofs but NOT perfect zero-knowledge. This means that, in its current form, the library may not be suitable for use cases where proofs must not leak any info about secret inputs.

**Auxiliary GKR proofs.** It will be possible to attach auxiliary GKR-based proofs to the base STARK proofs. This will enable powerful new ways of defining constraints and optimizing prover performance.

### Project structure
The project is organized into several crates like so:
Expand Down Expand Up @@ -290,7 +294,7 @@ impl Prover for WorkProver {
fn new_evaluator<'a, E: FieldElement<BaseField = BaseElement>>(
&self,
air: &'a WorkAir,
aux_rand_elements: winterfell::AuxTraceRandElements<E>,
aux_rand_elements: Option<Self::AuxRandElements<E>>,
composition_coefficients: winterfell::ConstraintCompositionCoefficients<E>,
) -> Self::ConstraintEvaluator<'a, E> {
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
Expand All @@ -307,10 +311,10 @@ Now, we are finally ready to generate a STARK proof. The function below, will ex
```Rust
use winterfell::{
math::{fields::f128::BaseElement, FieldElement},
FieldExtension, HashFunction, ProofOptions, StarkProof,
FieldExtension, HashFunction, ProofOptions, Proof,
};

pub fn prove_work() -> (BaseElement, StarkProof) {
pub fn prove_work() -> (BaseElement, Proof) {
// We'll just hard-code the parameters here for this example.
let start = BaseElement::new(3);
let n = 1_048_576;
Expand Down Expand Up @@ -343,12 +347,12 @@ We can then give this proof (together with the public inputs) to anyone, and the
use winterfell::{
crypto::{hashers::Blake3_256, DefaultRandomCoin},
math::fields::f128::BaseElement,
verify, AcceptableOptions, StarkProof,
verify, AcceptableOptions, Proof,
};

type Blake3 = Blake3_256<BaseElement>;

pub fn verify_work(start: BaseElement, result: BaseElement, proof: StarkProof) {
pub fn verify_work(start: BaseElement, result: BaseElement, proof: Proof) {
// The verifier will accept proofs with parameters which guarantee 95 bits or more of
// conjectured security
let min_opts = AcceptableOptions::MinConjecturedSecurity(95);
Expand Down
16 changes: 8 additions & 8 deletions air/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "winter-air"
version = "0.8.3"
version = "0.9.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.8.3"
documentation = "https://docs.rs/winter-air/0.9.0"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "arithmetization", "air"]
edition = "2021"
rust-version = "1.75"
rust-version = "1.78"

[lib]
bench = false
Expand All @@ -20,14 +20,14 @@ default = ["std"]
std = ["crypto/std", "fri/std", "math/std", "utils/std"]

[dependencies]
crypto = { version = "0.8", path = "../crypto", package = "winter-crypto", default-features = false }
fri = { version = "0.8", path = "../fri", package = "winter-fri", default-features = false }
crypto = { version = "0.9", path = "../crypto", package = "winter-crypto", default-features = false }
fri = { version = "0.9", path = "../fri", package = "winter-fri", default-features = false }
libm = "0.2.8"
math = { version = "0.8", path = "../math", package = "winter-math", default-features = false }
utils = { version = "0.8", path = "../utils/core", package = "winter-utils", default-features = false }
math = { version = "0.9", path = "../math", package = "winter-math", default-features = false }
utils = { version = "0.9", path = "../utils/core", package = "winter-utils", default-features = false }

[dev-dependencies]
rand-utils = { version = "0.8", path = "../utils/rand", package = "winter-rand-utils" }
rand-utils = { version = "0.9", path = "../utils/rand", package = "winter-rand-utils" }

# Allow math in docs
[package.metadata.docs.rs]
Expand Down
10 changes: 5 additions & 5 deletions air/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ To define such columns for your computation, you can override `get_periodic_colu
### Randomized AIR
Randomized AIR is a powerful extension of AIR which enables, among other things, multiset and permutation checks similar to the ones available in PLONKish systems. These, in turn, allow efficient descriptions of "non-local" constraints which can be used to build such components as efficient range checks, random access memory, and many others.

With Randomized AIR, construction of the execution trace is split into multiple stages. During the first stage, the *main trace segment* is built in a manner similar to how the trace is built for regular AIR. In the subsequent stages, *auxiliary trace segments* are built. When building auxiliary trace segments, the prover has access to extra randomness sent by the verifier (in the non-interactive version of the protocol, this randomness is derived from the previous trace segment commitments). Currently, the number of auxiliary trace segments is limited to one.
With Randomized AIR, construction of the execution trace is split into multiple stages. During the first stage, the *main trace segment* is built in a manner similar to how the trace is built for regular AIR. In the subsequent stages, *auxiliary trace segment* is built. When building the auxiliary trace segment, the prover has access to extra randomness sent by the verifier (in the non-interactive version of the protocol, this randomness is derived from the previous trace segment commitments).

To describe Randomized AIR, you will need to do the following when implementing the `Air` trait:
* The `AirContext` struct returned from `Air::context()` method must be instantiated using `AirContext::new_multi_segment()` constructor. When building AIR context in this way, you will need to provide a `TraceLayout` which describes the shape of a multi-segment execution trace.
* Override `Air::evaluate_aux_transition()` method. This method is similar to the `Air::evaluate_transition()` method but it also accepts two extra parameters: `aux_evaluation_frame` and `aux_rand_elements`. These parameters are needed for evaluating transition constraints over the auxiliary trace segments.
* Override `Air::get_aux_assertions()` method. This method is similar to the `Air::get_assertions()` method, but it should return assertions against columns of the auxiliary trace segments.
* Override `Air::evaluate_aux_transition()` method. This method is similar to the `Air::evaluate_transition()` method but it also accepts two extra parameters: `aux_evaluation_frame` and `aux_rand_elements`. These parameters are needed for evaluating transition constraints over the auxiliary trace segment.
* Override `Air::get_aux_assertions()` method. This method is similar to the `Air::get_assertions()` method, but it should return assertions against columns of the auxiliary trace segment.

## Protocol parameters
`ProofOptions` struct defines a set of options which are used during STARK proof generation and verification. These options have a direct impact on the security of the generated proofs as well as the proof generation time. Specifically, security of STARK proofs depends on:
Expand All @@ -81,7 +81,7 @@ To describe Randomized AIR, you will need to do the following when implementing
4. Blowup factor - higher values increase proof security, but also increase proof generation time and proof size. However, higher blowup factors require fewer queries for the same security level. Thus, it is frequently possible to increase blowup factor and at the same time decrease the number of queries in such a way that the proofs become smaller.
5. Grinding factor - higher values increase proof security, but also may increase proof generation time.

See [options.rs](src/options.rs) for more info on currently available options and their meaning. Additionally, security level of a proof can be estimated using `StarkProof::security_level()` function.
See [options.rs](src/options.rs) for more info on currently available options and their meaning. Additionally, security level of a proof can be estimated using `Proof::security_level()` function.

## Crate features
This crate can be compiled with the following features:
Expand All @@ -94,4 +94,4 @@ To compile with `no_std`, disable default features via `--no-default-features` f
License
-------

This project is [MIT licensed](../LICENSE).
This project is [MIT licensed](../LICENSE).
6 changes: 4 additions & 2 deletions air/src/air/assertions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

use crate::errors::AssertionError;
use alloc::vec::Vec;
use core::{
cmp::Ordering,
fmt::{Display, Formatter},
};

use math::FieldElement;

use crate::errors::AssertionError;

#[cfg(test)]
mod tests;

Expand Down Expand Up @@ -326,7 +328,7 @@ impl<E: FieldElement> Display for Assertion<E> {
_ => {
let second_step = self.first_step + self.stride;
write!(f, "steps=[{}, {}, ...], ", self.first_step, second_step)?;
}
},
}
match self.values.len() {
1 => write!(f, "value={})", self.values[0]),
Expand Down
4 changes: 3 additions & 1 deletion air/src/air/assertions/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

use super::{Assertion, AssertionError};
use alloc::vec::Vec;

use math::{fields::f128::BaseElement, FieldElement};
use rand_utils::{rand_value, rand_vector};

use super::{Assertion, AssertionError};

// SINGLE ASSERTIONS
// ================================================================================================
#[test]
Expand Down
Loading