pasta_curves
This crate provides an implementation of the Pasta elliptic curve constructions, Pallas and Vesta. More details about the Pasta curves can be found in this blog post.
Documentation
Minimum Supported Rust Version
Requires Rust 1.51 or higher.
Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.
Curve Descriptions
-
Pallas: y2 = x3 + 5 over
GF(0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001)
. -
Vesta: y2 = x3 + 5 over
GF(0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001)
.
The Pasta curves form a cycle with one another: the order of each curve is exactly the base field of the other. This property is critical to the efficiency of recursive proof systems. They are designed to be highly 2-adic, meaning that a large power-of-two multiplicative subgroup exists in each field. This is important for the performance of polynomial arithmetic over their scalar fields and is essential for protocols similar to PLONK.
These curves can be reproducibly obtained using a curve search utility we’ve published.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Design
Note on Language
We use slightly different language than others to describe PLONK concepts. Here's the overview:
- We like to think of PLONK-like arguments as tables, where each column corresponds to a "wire". We refer to entries in this table as "cells".
- We like to call "selector polynomials" and so on "fixed columns" instead. We then refer specifically to a "selector constraint" when a cell in a fixed column is being used to control whether a particular constraint is enabled in that row.
- We call the other polynomials "advice columns" usually, when they're populated by the prover.
- We use the term "rule" to refer to a "gate" like
- TODO: Check how consistent we are with this, and update the code and docs to match.
Implementation
Fields
The Pasta curves are designed to be highly 2-adic, meaning that a large multiplicative subgroup exists in each field. That is, we can write with odd. For both Pallas and Vesta, ; this helps to simplify the field implementations.
Sarkar square-root algorithm (table-based variant)
We use a technique from Sarkar2020 to compute
square roots in
pasta_curves
. The intuition
behind the algorithm is that we can split the task into computing square roots in each
multiplicative subgroup.
Suppose we want to find the square root of modulo one of the Pasta primes , where is a non-zero square in . We define a root of unity where is a non-square in , and precompute the following tables:
Let . We can then define as an element of the multiplicative subgroup.
Let
i = 0, 1
Using , we lookup such that
Define
i = 2
Lookup s.t.
Define
i = 3
Lookup s.t.
Define
Final result
Lookup such that
Let .
We can now write
Squaring the RHS, we observe that Therefore, the square root of is ; the first part we computed earlier, and the second part can be computed with three multiplications using lookups in .