mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 12:31:22 +00:00
Use group crate for curve traits and wNAF
This commit is contained in:
@@ -14,13 +14,14 @@ bit-vec = "0.4.4"
|
|||||||
ff = "0.4"
|
ff = "0.4"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
futures-cpupool = "0.1"
|
futures-cpupool = "0.1"
|
||||||
|
group = "0.1"
|
||||||
num_cpus = "1"
|
num_cpus = "1"
|
||||||
crossbeam = "0.3"
|
crossbeam = "0.3"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
|
|
||||||
[dependencies.pairing]
|
[dependencies.pairing]
|
||||||
git = "https://github.com/ebfull/pairing"
|
git = "https://github.com/str4d/pairing"
|
||||||
rev = "183a64b08e9dc7067f78624ec161371f1829623e"
|
rev = "3d41ee5abaa4888ff3607689aba007be8856816d"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
@@ -10,11 +10,9 @@
|
|||||||
//! This allows us to perform polynomial operations in O(n)
|
//! This allows us to perform polynomial operations in O(n)
|
||||||
//! by performing an O(n log n) FFT over such a domain.
|
//! by performing an O(n log n) FFT over such a domain.
|
||||||
|
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField, ScalarEngine};
|
||||||
use pairing::{
|
use group::CurveProjective;
|
||||||
Engine,
|
use pairing::Engine;
|
||||||
CurveProjective
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
SynthesisError
|
SynthesisError
|
||||||
@@ -188,7 +186,7 @@ impl<E: Engine, G: Group<E>> EvaluationDomain<E, G> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Group<E: Engine>: Sized + Copy + Clone + Send + Sync {
|
pub trait Group<E: ScalarEngine>: Sized + Copy + Clone + Send + Sync {
|
||||||
fn group_zero() -> Self;
|
fn group_zero() -> Self;
|
||||||
fn group_mul_assign(&mut self, by: &E::Fr);
|
fn group_mul_assign(&mut self, by: &E::Fr);
|
||||||
fn group_add_assign(&mut self, other: &Self);
|
fn group_add_assign(&mut self, other: &Self);
|
||||||
|
@@ -3,12 +3,8 @@ use rand::Rng;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::{
|
use group::{CurveAffine, CurveProjective, Wnaf};
|
||||||
Engine,
|
use pairing::Engine;
|
||||||
Wnaf,
|
|
||||||
CurveProjective,
|
|
||||||
CurveAffine
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Parameters,
|
Parameters,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
use group::{CurveAffine, EncodedPoint};
|
||||||
use pairing::{
|
use pairing::{
|
||||||
Engine,
|
Engine,
|
||||||
CurveAffine,
|
PairingCurveAffine,
|
||||||
EncodedPoint
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use ::{
|
use ::{
|
||||||
@@ -385,9 +385,9 @@ pub struct PreparedVerifyingKey<E: Engine> {
|
|||||||
/// Pairing result of alpha*beta
|
/// Pairing result of alpha*beta
|
||||||
alpha_g1_beta_g2: E::Fqk,
|
alpha_g1_beta_g2: E::Fqk,
|
||||||
/// -gamma in G2
|
/// -gamma in G2
|
||||||
neg_gamma_g2: <E::G2Affine as CurveAffine>::Prepared,
|
neg_gamma_g2: <E::G2Affine as PairingCurveAffine>::Prepared,
|
||||||
/// -delta in G2
|
/// -delta in G2
|
||||||
neg_delta_g2: <E::G2Affine as CurveAffine>::Prepared,
|
neg_delta_g2: <E::G2Affine as PairingCurveAffine>::Prepared,
|
||||||
/// Copy of IC from `VerifiyingKey`.
|
/// Copy of IC from `VerifiyingKey`.
|
||||||
ic: Vec<E::G1Affine>
|
ic: Vec<E::G1Affine>
|
||||||
}
|
}
|
||||||
|
@@ -5,11 +5,8 @@ use std::sync::Arc;
|
|||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::{
|
use group::{CurveAffine, CurveProjective};
|
||||||
Engine,
|
use pairing::Engine;
|
||||||
CurveProjective,
|
|
||||||
CurveAffine
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
ParameterSource,
|
ParameterSource,
|
||||||
|
@@ -1,13 +1,8 @@
|
|||||||
use ff::{
|
use ff::{
|
||||||
Field, LegendreSymbol, PrimeField, PrimeFieldDecodingError,
|
Field, LegendreSymbol, PrimeField, PrimeFieldDecodingError,
|
||||||
PrimeFieldRepr, ScalarEngine, SqrtField};
|
PrimeFieldRepr, ScalarEngine, SqrtField};
|
||||||
use pairing::{
|
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
|
||||||
Engine,
|
use pairing::{Engine, PairingCurveAffine};
|
||||||
CurveProjective,
|
|
||||||
CurveAffine,
|
|
||||||
GroupDecodingError,
|
|
||||||
EncodedPoint
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -277,8 +272,8 @@ impl Engine for DummyEngine {
|
|||||||
|
|
||||||
fn miller_loop<'a, I>(i: I) -> Self::Fqk
|
fn miller_loop<'a, I>(i: I) -> Self::Fqk
|
||||||
where I: IntoIterator<Item=&'a (
|
where I: IntoIterator<Item=&'a (
|
||||||
&'a <Self::G1Affine as CurveAffine>::Prepared,
|
&'a <Self::G1Affine as PairingCurveAffine>::Prepared,
|
||||||
&'a <Self::G2Affine as CurveAffine>::Prepared
|
&'a <Self::G2Affine as PairingCurveAffine>::Prepared
|
||||||
)>
|
)>
|
||||||
{
|
{
|
||||||
let mut acc = <Fr as Field>::zero();
|
let mut acc = <Fr as Field>::zero();
|
||||||
@@ -401,11 +396,8 @@ impl EncodedPoint for FakePoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CurveAffine for Fr {
|
impl CurveAffine for Fr {
|
||||||
type Pair = Fr;
|
|
||||||
type PairingResult = Fr;
|
|
||||||
type Compressed = FakePoint;
|
type Compressed = FakePoint;
|
||||||
type Uncompressed = FakePoint;
|
type Uncompressed = FakePoint;
|
||||||
type Prepared = Fr;
|
|
||||||
type Projective = Fr;
|
type Projective = Fr;
|
||||||
type Base = Fr;
|
type Base = Fr;
|
||||||
type Scalar = Fr;
|
type Scalar = Fr;
|
||||||
@@ -437,6 +429,16 @@ impl CurveAffine for Fr {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_projective(&self) -> Self::Projective {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PairingCurveAffine for Fr {
|
||||||
|
type Prepared = Fr;
|
||||||
|
type Pair = Fr;
|
||||||
|
type PairingResult = Fr;
|
||||||
|
|
||||||
fn prepare(&self) -> Self::Prepared {
|
fn prepare(&self) -> Self::Prepared {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
@@ -444,8 +446,4 @@ impl CurveAffine for Fr {
|
|||||||
fn pairing_with(&self, other: &Self::Pair) -> Self::PairingResult {
|
fn pairing_with(&self, other: &Self::Pair) -> Self::PairingResult {
|
||||||
self.mul(*other)
|
self.mul(*other)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_projective(&self) -> Self::Projective {
|
|
||||||
*self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
use ff::PrimeField;
|
use ff::PrimeField;
|
||||||
use pairing::{
|
use group::{CurveAffine, CurveProjective};
|
||||||
Engine,
|
use pairing::{Engine, PairingCurveAffine};
|
||||||
CurveProjective,
|
|
||||||
CurveAffine,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Proof,
|
Proof,
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
extern crate ff;
|
extern crate ff;
|
||||||
|
extern crate group;
|
||||||
extern crate pairing;
|
extern crate pairing;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
use ff::{Field, PrimeField, PrimeFieldRepr, ScalarEngine};
|
use ff::{Field, PrimeField, PrimeFieldRepr, ScalarEngine};
|
||||||
use pairing::{
|
use group::{CurveAffine, CurveProjective};
|
||||||
CurveAffine,
|
|
||||||
CurveProjective,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::io;
|
use std::io;
|
||||||
use bit_vec::{self, BitVec};
|
use bit_vec::{self, BitVec};
|
||||||
|
Reference in New Issue
Block a user