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

Migrate to ff 0.13 #94

Merged
merged 4 commits into from
Mar 20, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0
toolchain: 1.60.0
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0
toolchain: 1.60.0
override: true
- name: Add target
run: rustup target add ${{ matrix.target }}
Expand All @@ -65,7 +65,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0
toolchain: 1.60.0
override: true
# Build benchmarks to prevent bitrot
- name: Build benchmarks
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0
toolchain: 1.60.0
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lints-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ on: pull_request

jobs:
clippy:
name: Clippy (1.56.0)
name: Clippy (1.60.0)
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0
toolchain: 1.60.0
components: clippy
override: true
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
name: Clippy (1.56.0)
name: Clippy (1.60.0)
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- MSRV bumped to `1.60.0`
- Bumped dependencies to `ff 0.13`, `group 0.13`, `pairing 0.23`.

## [0.13.1] - 2022-07-05
### Added
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ name = "bellman"
repository = "https://github.com/zkcrypto/bellman"
version = "0.13.1"
edition = "2021"
rust-version = "1.60"

[dependencies]
bitvec = "1"
blake2s_simd = "1"
ff = "0.12"
group = "0.12"
pairing = { version = "0.22", optional = true }
ff = "0.13"
group = "0.13"
pairing = { version = "0.23", optional = true }
rand_core = "0.6"
byteorder = "1"
subtle = "2.2.1"
Expand All @@ -30,8 +31,8 @@ num_cpus = { version = "1", optional = true }
rayon = { version = "1.5.1", optional = true }

[dev-dependencies]
bls12_381 = "0.7"
criterion = "0.3"
bls12_381 = "0.8"
criterion = "0.4"
hex-literal = "0.3"
rand = "0.8"
rand_xorshift = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.56.0
1.60.0
22 changes: 11 additions & 11 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<S: PrimeField, G: Group<S>> EvaluationDomain<S, G> {
}

// Compute omega, the 2^exp primitive root of unity
let mut omega = S::root_of_unity();
let mut omega = S::ROOT_OF_UNITY;
for _ in exp..S::S {
omega = omega.square();
}
Expand All @@ -73,7 +73,7 @@ impl<S: PrimeField, G: Group<S>> EvaluationDomain<S, G> {
exp,
omega,
omegainv: omega.invert().unwrap(),
geninv: S::multiplicative_generator().invert().unwrap(),
geninv: S::MULTIPLICATIVE_GENERATOR.invert().unwrap(),
minv: S::from(m as u64).invert().unwrap(),
})
}
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<S: PrimeField, G: Group<S>> EvaluationDomain<S, G> {
}

pub fn coset_fft(&mut self, worker: &Worker) {
self.distribute_powers(worker, S::multiplicative_generator());
self.distribute_powers(worker, S::MULTIPLICATIVE_GENERATOR);
self.fft(worker);
}

Expand All @@ -128,7 +128,7 @@ impl<S: PrimeField, G: Group<S>> EvaluationDomain<S, G> {
/// tau^m - 1 for these radix-2 domains.
pub fn z(&self, tau: &S) -> S {
let mut tmp = tau.pow_vartime(&[self.coeffs.len() as u64]);
tmp.sub_assign(&S::one());
tmp.sub_assign(&S::ONE);

tmp
}
Expand All @@ -137,7 +137,7 @@ impl<S: PrimeField, G: Group<S>> EvaluationDomain<S, G> {
/// evaluation domain, so we must perform division over
/// a coset.
pub fn divide_by_z_on_coset(&mut self, worker: &Worker) {
let i = self.z(&S::multiplicative_generator()).invert().unwrap();
let i = self.z(&S::MULTIPLICATIVE_GENERATOR).invert().unwrap();

worker.scope(self.coeffs.len(), |scope, chunk| {
for v in self.coeffs.chunks_mut(chunk) {
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<S: PrimeField> Clone for Scalar<S> {

impl<S: PrimeField> Group<S> for Scalar<S> {
fn group_zero() -> Self {
Scalar(S::zero())
Scalar(S::ZERO)
}
fn group_mul_assign(&mut self, by: &S) {
self.0.mul_assign(by);
Expand Down Expand Up @@ -295,7 +295,7 @@ fn serial_fft<S: PrimeField, T: Group<S>>(a: &mut [T], omega: &S, log_n: u32) {

let mut k = 0;
while k < n {
let mut w = S::one();
let mut w = S::ONE;
for j in 0..m {
let mut t = a[(k + j + m) as usize];
t.group_mul_assign(&w);
Expand Down Expand Up @@ -336,7 +336,7 @@ fn parallel_fft<S: PrimeField, T: Group<S>>(
let omega_j = omega.pow_vartime(&[j as u64]);
let omega_step = omega.pow_vartime(&[(j as u64) << log_new_n]);

let mut elt = S::one();
let mut elt = S::ONE;
for (i, tmp) in tmp.iter_mut().enumerate() {
for s in 0..num_cpus {
let idx = (i + (s << log_new_n)) % (1 << log_n);
Expand Down Expand Up @@ -392,7 +392,7 @@ fn polynomial_arith() {
.collect();

// naive evaluation
let mut naive = vec![Scalar(S::zero()); coeffs_a + coeffs_b];
let mut naive = vec![Scalar(S::ZERO); coeffs_a + coeffs_b];
for (i1, a) in a.iter().enumerate() {
for (i2, b) in b.iter().enumerate() {
let mut prod = *a;
Expand All @@ -401,8 +401,8 @@ fn polynomial_arith() {
}
}

a.resize(coeffs_a + coeffs_b, Scalar(S::zero()));
b.resize(coeffs_a + coeffs_b, Scalar(S::zero()));
a.resize(coeffs_a + coeffs_b, Scalar(S::ZERO));
b.resize(coeffs_a + coeffs_b, Scalar(S::ZERO));

let mut a = EvaluationDomain::from_coeffs(a).unwrap();
let mut b = EvaluationDomain::from_coeffs(b).unwrap();
Expand Down