Skip to content

Commit

Permalink
Merge pull request #86 from zkcrypto/release-0.7.0
Browse files Browse the repository at this point in the history
Release 0.7.0
  • Loading branch information
ebfull authored May 4, 2022
2 parents 14c42d7 + e36879e commit 34dab74
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.51.0
toolchain: 1.56.0
override: true

# Ensure all code has been formatted with rustfmt
Expand All @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.51.0
toolchain: 1.56.0
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.51.0
toolchain: 1.56.0
override: true
- run: rustup target add ${{ matrix.target }}
- name: cargo fetch
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ homepage = "https://github.com/zkcrypto/bls12_381"
license = "MIT/Apache-2.0"
name = "bls12_381"
repository = "https://github.com/zkcrypto/bls12_381"
version = "0.6.1"
edition = "2018"
version = "0.7.0"
edition = "2021"

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
Expand All @@ -37,16 +37,16 @@ version = "0.9"
optional = true

[dependencies.ff]
version = "0.11"
version = "0.12"
default-features = false

[dependencies.group]
version = "0.11"
version = "0.12"
default-features = false
optional = true

[dependencies.pairing]
version = "0.21"
version = "0.22"
optional = true

[dependencies.rand_core]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This crate provides an implementation of the BLS12-381 pairing-friendly elliptic curve construction.

* **This implementation has not been reviewed or audited. Use at your own risk.**
* This implementation targets Rust `1.51` or later.
* This implementation targets Rust `1.56` or later.
* This implementation does not require the Rust standard library.
* All operations are constant time unless explicitly noted.

Expand Down
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.7.0

## Changed
- MSRV bumped to `1.56.0`
- Bumped dependencies to `ff 0.12`, `group 0.12`, `pairing 0.22`.

# 0.6.1

## Changed
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.51.0
1.56.0
3 changes: 1 addition & 2 deletions src/fp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This module provides an implementation of the BLS12-381 base field `GF(p)`
//! where `p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab`
use core::convert::TryFrom;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use rand_core::RngCore;
Expand Down Expand Up @@ -209,7 +208,7 @@ impl Fp {

/// Converts an element of `Fp` into a byte representation in
/// big-endian byte order.
pub fn to_bytes(&self) -> [u8; 48] {
pub fn to_bytes(self) -> [u8; 48] {
// Turn into canonical form by computing
// (a.R) / R = a
let tmp = Fp::montgomery_reduce(
Expand Down
9 changes: 4 additions & 5 deletions src/g1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ fn endomorphism(p: &G1Affine) -> G1Affine {
// Endomorphism of the points on the curve.
// endomorphism_p(x,y) = (BETA * x, y)
// where BETA is a non-trivial cubic root of unity in Fq.
let mut res = p.clone();
let mut res = *p;
res.x *= BETA;
res
}
Expand Down Expand Up @@ -577,8 +577,7 @@ impl_binops_multiplicative_mixed!(G1Affine, Scalar, G1Projective);
fn mul_by_3b(a: Fp) -> Fp {
let a = a + a; // 2
let a = a + a; // 4
let a = a + a + a; // 12
a
a + a + a // 12
}

impl G1Projective {
Expand Down Expand Up @@ -729,7 +728,7 @@ impl G1Projective {
z: z3,
};

G1Projective::conditional_select(&tmp, &self, rhs.is_identity())
G1Projective::conditional_select(&tmp, self, rhs.is_identity())
}

fn multiply(&self, by: &[u8; 32]) -> G1Projective {
Expand Down Expand Up @@ -815,7 +814,7 @@ impl G1Projective {
q.y = p.y * tmp;
q.infinity = Choice::from(0u8);

*q = G1Affine::conditional_select(&q, &G1Affine::identity(), skip);
*q = G1Affine::conditional_select(q, &G1Affine::identity(), skip);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/g2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ impl G2Projective {
z: z3,
};

G2Projective::conditional_select(&tmp, &self, rhs.is_identity())
G2Projective::conditional_select(&tmp, self, rhs.is_identity())
}

fn multiply(&self, by: &[u8]) -> G2Projective {
Expand Down Expand Up @@ -959,7 +959,7 @@ impl G2Projective {
q.y = p.y * tmp;
q.infinity = Choice::from(0u8);

*q = G2Affine::conditional_select(&q, &G2Affine::identity(), skip);
*q = G2Affine::conditional_select(q, &G2Affine::identity(), skip);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
// Catch documentation errors caused by code changes.
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![deny(unsafe_code)]
Expand Down
44 changes: 22 additions & 22 deletions src/notes/design.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,40 @@
//! def q(x):
//! return (((x - 1) ** 2) * ((x**4) - (x**2) + 1) // 3) + x
//! def g1_h(x):
//! return ((x-1)**2) // 3
//! return ((x-1)**2) // 3
//! def g2_h(x):
//! return ((x**8) - (4 * (x**7)) + (5 * (x**6)) - (4 * (x**4)) + (6 * (x**3)) - (4 * (x**2)) - (4*x) + 13) // 9
//! q = q(param)
//! r = r(param)
//! Fq = GF(q)
//! ec = EllipticCurve(Fq, [0, 4])
//! def psqrt(v):
//! assert(not v.is_zero())
//! a = sqrt(v)
//! b = -a
//! if a < b:
//! return a
//! else:
//! return b
//! assert(not v.is_zero())
//! a = sqrt(v)
//! b = -a
//! if a < b:
//! return a
//! else:
//! return b
//! for x in range(0,100):
//! rhs = Fq(x)^3 + 4
//! if rhs.is_square():
//! y = psqrt(rhs)
//! p = ec(x, y) * g1_h(param)
//! if (not p.is_zero()) and (p * r).is_zero():
//! print("g1 generator: {}".format(p))
//! break
//! rhs = Fq(x)^3 + 4
//! if rhs.is_square():
//! y = psqrt(rhs)
//! p = ec(x, y) * g1_h(param)
//! if (not p.is_zero()) and (p * r).is_zero():
//! print("g1 generator: {}".format(p))
//! break
//! Fq2.<i> = GF(q^2, modulus=[1, 0, 1])
//! ec2 = EllipticCurve(Fq2, [0, (4 * (1 + i))])
//! assert(ec2.order() == (r * g2_h(param)))
//! for x in range(0,100):
//! rhs = (Fq2(x))^3 + (4 * (1 + i))
//! if rhs.is_square():
//! y = psqrt(rhs)
//! p = ec2(Fq2(x), y) * g2_h(param)
//! if not p.is_zero() and (p * r).is_zero():
//! print("g2 generator: {}".format(p))
//! break
//! rhs = (Fq2(x))^3 + (4 * (1 + i))
//! if rhs.is_square():
//! y = psqrt(rhs)
//! p = ec2(Fq2(x), y) * g2_h(param)
//! if not p.is_zero() and (p * r).is_zero():
//! print("g2 generator: {}".format(p))
//! break
//! ```
//!
//! ## Nontrivial third root of unity
Expand Down
8 changes: 4 additions & 4 deletions src/pairings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ impl_add_binop_specify_output!(MillerLoopResult, MillerLoopResult, MillerLoopRes
impl AddAssign<MillerLoopResult> for MillerLoopResult {
#[inline]
fn add_assign(&mut self, rhs: MillerLoopResult) {
*self = &*self + &rhs;
*self = *self + rhs;
}
}

impl<'b> AddAssign<&'b MillerLoopResult> for MillerLoopResult {
#[inline]
fn add_assign(&mut self, rhs: &'b MillerLoopResult) {
*self = &*self + rhs;
*self = *self + rhs;
}
}

Expand Down Expand Up @@ -631,8 +631,8 @@ pub fn pairing(p: &G1Affine, q: &G2Affine) -> Gt {
}

let either_identity = p.is_identity() | q.is_identity();
let p = G1Affine::conditional_select(&p, &G1Affine::generator(), either_identity);
let q = G2Affine::conditional_select(&q, &G2Affine::generator(), either_identity);
let p = G1Affine::conditional_select(p, &G1Affine::generator(), either_identity);
let q = G2Affine::conditional_select(q, &G2Affine::generator(), either_identity);

let mut adder = Adder {
cur: G2Projective::from(q),
Expand Down
4 changes: 0 additions & 4 deletions src/scalar.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
//! This module provides an implementation of the BLS12-381 scalar field $\mathbb{F}_q$
//! where `q = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`
use core::convert::TryFrom;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use rand_core::RngCore;

use ff::{Field, PrimeField};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "bits")]
use core::convert::TryInto;

#[cfg(feature = "bits")]
use ff::{FieldBits, PrimeFieldBits};

Expand Down

0 comments on commit 34dab74

Please sign in to comment.