### 4 releases (breaking)

Uses new Rust 2021

0.4.0 | Apr 29, 2022 |
---|---|

0.3.0 | Jan 5, 2022 |

0.2.0 | Aug 24, 2021 |

0.1.0 | Aug 4, 2021 |

#**318** in Cryptography

**1,068** downloads per month

Used in **3** crates
(2 directly)

**MIT**license

795KB

12K
SLoC

# Winterfell STARK verifier

This crate contains an implementation of a STARK verifier which can verify proofs generated by a prover from the prover crate.

## Usage

To verify a proof you can use

function, which has the following signature:`verifier ::`verify

`(`

`)`

`pub` `fn` `verify``<`AIR`:` Air`>``(`
`proof``:` StarkProof,
`pub_inputs``:` `AIR``::`PublicInputs,
`)`` ``->` `Result``<``(``)`, VerifierError`>``;`

where:

is a type implementing`AIR`

trait for your computation (see air crate for more info).`Air`

is the proof generated by the prover attesting that the computation was executed correctly against some set of public inputs.`proof`

is the set of public inputs against which the computation was executed by the prover.`pub_inputs`

For example, if we have a struct

which implements the `FibAir`

trait and describes a computation of a Fibonacci sequence (see examples crate for the concrete implementation), we could verify that the prover computed the 1,048,576th term of the sequence correctly, by executing the following:`Air`

`let` fib_result `=` `BaseElement``::`new`(``226333832811148522147755045522163790995``)``;`
`match` `verifier``::``verify``::``<`FibAir`>``(`proof`,` fib_result`)` `{`
`Ok``(``_``)` `=>` `debug!``(``"`Proof verified!`"``)``,`
`Err``(`err`)` `=>` `debug!``(``"`Failed to verify proof: {}`"``,` err`)``,`
`}`

where,

is the 1,048,576th term of the Fibonacci sequence when the sequence is computed in a 128-bit field with modulus 2`226333832811148522147755045522163790995`^{128} - 45 * 2^{40}.

## Performance

Proof verification is extremely fast and is nearly independent of the complexity of the computation being verified. In vast majority of cases proofs can be verified in 3 - 5 ms on a modern mid-range laptop CPU (using a single core).

There is one exception, however: if a computation requires a lot of

assertions (see air crate for more info), the verification time may grow beyond 5 ms. But for the impact to be noticeable, the number of asserted values would need to be in tens of thousands. And even for hundreds of thousands of `sequence`

assertions, the verification time should not exceed 50 ms.`sequence`

## Crate features

This crate can be compiled with the following features:

- enabled by default and relies on the Rust standard library.`std`

- does not rely on the Rust standard library and enables compilation to WebAssembly.`no_std`

To compile with

, disable default features via `no_std`

flag.`--no-default-features`

## License

This project is MIT licensed.

#### Dependencies

~2.5MB

~47K SLoC