mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-11-13 09:37:02 +00:00
Migrate to ff 0.4
This commit is contained in:
@@ -17,10 +17,9 @@ repository = "https://github.com/ebfull/pairing"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.4"
|
rand = "0.4"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
ff = "0.3"
|
ff = { version = "0.4", features = ["derive"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable-features = ["expose-arith"]
|
unstable-features = ["expose-arith"]
|
||||||
expose-arith = []
|
expose-arith = []
|
||||||
u128-support = ["ff/u128-support"]
|
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@@ -6,14 +6,6 @@ This is a Rust crate for using pairing-friendly elliptic curves. Currently, only
|
|||||||
|
|
||||||
Bring the `pairing` crate into your project just as you normally would.
|
Bring the `pairing` crate into your project just as you normally would.
|
||||||
|
|
||||||
If you're using a supported platform and the nightly Rust compiler, you can enable the `u128-support` feature for faster arithmetic.
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[dependencies.pairing]
|
|
||||||
version = "0.14"
|
|
||||||
features = ["u128-support"]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Security Warnings
|
## Security Warnings
|
||||||
|
|
||||||
This library does not make any guarantees about constant-time operations, memory access patterns, or resistance to side-channel attacks.
|
This library does not make any guarantees about constant-time operations, memory access patterns, or resistance to side-channel attacks.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub use self::fr::{Fr, FrRepr};
|
|||||||
|
|
||||||
use super::{CurveAffine, Engine};
|
use super::{CurveAffine, Engine};
|
||||||
|
|
||||||
use ff::{BitIterator, Field};
|
use ff::{BitIterator, Field, ScalarEngine};
|
||||||
|
|
||||||
// The BLS parameter x for BLS12-381 is -0xd201000000010000
|
// The BLS parameter x for BLS12-381 is -0xd201000000010000
|
||||||
const BLS_X: u64 = 0xd201000000010000;
|
const BLS_X: u64 = 0xd201000000010000;
|
||||||
@@ -29,8 +29,11 @@ const BLS_X_IS_NEGATIVE: bool = true;
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Bls12;
|
pub struct Bls12;
|
||||||
|
|
||||||
impl Engine for Bls12 {
|
impl ScalarEngine for Bls12 {
|
||||||
type Fr = Fr;
|
type Fr = Fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Engine for Bls12 {
|
||||||
type G1 = G1;
|
type G1 = G1;
|
||||||
type G1Affine = G1Affine;
|
type G1Affine = G1Affine;
|
||||||
type G2 = G2;
|
type G2 = G2;
|
||||||
|
|||||||
@@ -25,17 +25,14 @@ pub mod bls12_381;
|
|||||||
mod wnaf;
|
mod wnaf;
|
||||||
pub use self::wnaf::Wnaf;
|
pub use self::wnaf::Wnaf;
|
||||||
|
|
||||||
use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField};
|
use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, ScalarEngine, SqrtField};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// An "engine" is a collection of types (fields, elliptic curve groups, etc.)
|
/// An "engine" is a collection of types (fields, elliptic curve groups, etc.)
|
||||||
/// with well-defined relationships. In particular, the G1/G2 curve groups are
|
/// with well-defined relationships. In particular, the G1/G2 curve groups are
|
||||||
/// of prime order `r`, and are equipped with a bilinear pairing function.
|
/// of prime order `r`, and are equipped with a bilinear pairing function.
|
||||||
pub trait Engine: Sized + 'static + Clone {
|
pub trait Engine: ScalarEngine {
|
||||||
/// This is the scalar field of the G1/G2 groups.
|
|
||||||
type Fr: PrimeField + SqrtField;
|
|
||||||
|
|
||||||
/// The projective representation of an element in G1.
|
/// The projective representation of an element in G1.
|
||||||
type G1: CurveProjective<
|
type G1: CurveProjective<
|
||||||
Engine = Self,
|
Engine = Self,
|
||||||
|
|||||||
Reference in New Issue
Block a user