Replace Fq implementation with bls12_381::Scalar
This commit is contained in:
parent
e2e0f5089f
commit
4c1da9d8bc
|
@ -11,7 +11,7 @@ jobs:
|
|||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.33.0
|
||||
toolchain: 1.36.0
|
||||
override: true
|
||||
|
||||
# Ensure all code has been formatted with rustfmt
|
||||
|
@ -33,7 +33,7 @@ jobs:
|
|||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.33.0
|
||||
toolchain: 1.36.0
|
||||
override: true
|
||||
- name: cargo fetch
|
||||
uses: actions-rs/cargo@v1
|
||||
|
@ -58,7 +58,7 @@ jobs:
|
|||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.33.0
|
||||
toolchain: 1.36.0
|
||||
override: true
|
||||
- run: rustup target add thumbv6m-none-eabi
|
||||
- name: cargo fetch
|
||||
|
|
|
@ -13,6 +13,10 @@ repository = "https://github.com/zkcrypto/jubjub"
|
|||
version = "0.2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies.bls12_381]
|
||||
version = "0.1"
|
||||
default-features = false
|
||||
|
||||
[dependencies.byteorder]
|
||||
version = "1"
|
||||
default-features = false
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
This is a pure Rust implementation of the Jubjub elliptic curve group and its associated fields.
|
||||
|
||||
* **This implementation has not been reviewed or audited. Use at your own risk.**
|
||||
* This implementation targets Rust `1.33` or later.
|
||||
* This implementation targets Rust `1.36` or later.
|
||||
* All operations are constant time unless explicitly noted.
|
||||
|
||||
## Features
|
||||
|
|
69
src/lib.rs
69
src/lib.rs
|
@ -43,9 +43,8 @@ use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
|||
#[macro_use]
|
||||
mod util;
|
||||
|
||||
mod fq;
|
||||
mod fr;
|
||||
pub use fq::Fq;
|
||||
pub use bls12_381::Scalar as Fq;
|
||||
pub use fr::Fr;
|
||||
|
||||
const FR_MODULUS_BYTES: [u8; 32] = [
|
||||
|
@ -463,9 +462,9 @@ impl AffinePoint {
|
|||
/// for use in multiple additions.
|
||||
pub const fn to_niels(&self) -> AffineNielsPoint {
|
||||
AffineNielsPoint {
|
||||
v_plus_u: self.v.field_add(&self.u),
|
||||
v_minus_u: self.v.subtract(&self.u),
|
||||
t2d: self.u.multiply(&self.v).multiply(&EDWARDS_D2),
|
||||
v_plus_u: Fq::add(&self.v, &self.u),
|
||||
v_minus_u: Fq::sub(&self.v, &self.u),
|
||||
t2d: Fq::mul(&Fq::mul(&self.u, &self.v), &EDWARDS_D2),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -953,17 +952,17 @@ fn test_extended_niels_point_identity() {
|
|||
#[test]
|
||||
fn test_assoc() {
|
||||
let p = ExtendedPoint::from(AffinePoint {
|
||||
u: Fq([
|
||||
0xc0115cb656ae4839,
|
||||
0x623dc3ff81d64c26,
|
||||
0x5868e739b5794f2c,
|
||||
0x23bd4fbb18d39c9c,
|
||||
u: Fq::from_raw([
|
||||
0x81c571e5d883cfb0,
|
||||
0x049f7a686f147029,
|
||||
0xf539c860bc3ea21f,
|
||||
0x4284715b7ccc8162,
|
||||
]),
|
||||
v: Fq([
|
||||
0x7588ee6d6dd40deb,
|
||||
0x9d6d7a23ebdb7c4c,
|
||||
0x46462e26d4edb8c7,
|
||||
0x10b4c1517ca82e9b,
|
||||
v: Fq::from_raw([
|
||||
0xbf096275684bb8ca,
|
||||
0xc7ba245890af256d,
|
||||
0x59119f3e86380eb0,
|
||||
0x3793de182f9fb1d2,
|
||||
]),
|
||||
})
|
||||
.mul_by_cofactor();
|
||||
|
@ -979,17 +978,17 @@ fn test_assoc() {
|
|||
#[test]
|
||||
fn test_batch_normalize() {
|
||||
let mut p = ExtendedPoint::from(AffinePoint {
|
||||
u: Fq([
|
||||
0xc0115cb656ae4839,
|
||||
0x623dc3ff81d64c26,
|
||||
0x5868e739b5794f2c,
|
||||
0x23bd4fbb18d39c9c,
|
||||
u: Fq::from_raw([
|
||||
0x81c571e5d883cfb0,
|
||||
0x049f7a686f147029,
|
||||
0xf539c860bc3ea21f,
|
||||
0x4284715b7ccc8162,
|
||||
]),
|
||||
v: Fq([
|
||||
0x7588ee6d6dd40deb,
|
||||
0x9d6d7a23ebdb7c4c,
|
||||
0x46462e26d4edb8c7,
|
||||
0x10b4c1517ca82e9b,
|
||||
v: Fq::from_raw([
|
||||
0xbf096275684bb8ca,
|
||||
0xc7ba245890af256d,
|
||||
0x59119f3e86380eb0,
|
||||
0x3793de182f9fb1d2,
|
||||
]),
|
||||
})
|
||||
.mul_by_cofactor();
|
||||
|
@ -1214,17 +1213,17 @@ fn test_mul_consistency() {
|
|||
]);
|
||||
assert_eq!(a * b, c);
|
||||
let p = ExtendedPoint::from(AffinePoint {
|
||||
u: Fq([
|
||||
0xc0115cb656ae4839,
|
||||
0x623dc3ff81d64c26,
|
||||
0x5868e739b5794f2c,
|
||||
0x23bd4fbb18d39c9c,
|
||||
u: Fq::from_raw([
|
||||
0x81c571e5d883cfb0,
|
||||
0x049f7a686f147029,
|
||||
0xf539c860bc3ea21f,
|
||||
0x4284715b7ccc8162,
|
||||
]),
|
||||
v: Fq([
|
||||
0x7588ee6d6dd40deb,
|
||||
0x9d6d7a23ebdb7c4c,
|
||||
0x46462e26d4edb8c7,
|
||||
0x10b4c1517ca82e9b,
|
||||
v: Fq::from_raw([
|
||||
0xbf096275684bb8ca,
|
||||
0xc7ba245890af256d,
|
||||
0x59119f3e86380eb0,
|
||||
0x3793de182f9fb1d2,
|
||||
]),
|
||||
})
|
||||
.mul_by_cofactor();
|
||||
|
|
Loading…
Reference in New Issue