group: Introduce Group and PrimeGroup traits
Group represents a cryptographic group with a large prime-order subgroup and a small cofactor. PrimeGroup further constrains the group to have a cofactor of one.
This commit is contained in:
parent
e75b850fe5
commit
78db26b713
|
@ -3,7 +3,7 @@ use std::ops::{AddAssign, MulAssign};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use group::{CurveAffine, CurveProjective, Wnaf};
|
use group::{CurveAffine, CurveProjective, Group, Wnaf};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use super::{Parameters, VerifyingKey};
|
use super::{Parameters, VerifyingKey};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ff::{Field, PrimeField, ScalarEngine};
|
use ff::{Field, PrimeField, ScalarEngine};
|
||||||
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
|
use group::{CurveAffine, CurveProjective, EncodedPoint, Group, GroupDecodingError, PrimeGroup};
|
||||||
use pairing::{Engine, PairingCurveAffine};
|
use pairing::{Engine, PairingCurveAffine};
|
||||||
|
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
|
@ -352,11 +352,7 @@ impl Engine for DummyEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CurveProjective for Fr {
|
impl Group for Fr {
|
||||||
type Affine = Fr;
|
|
||||||
type Base = Fr;
|
|
||||||
type Scalar = Fr;
|
|
||||||
|
|
||||||
fn random<R: RngCore + ?Sized>(rng: &mut R) -> Self {
|
fn random<R: RngCore + ?Sized>(rng: &mut R) -> Self {
|
||||||
<Fr as Field>::random(rng)
|
<Fr as Field>::random(rng)
|
||||||
}
|
}
|
||||||
|
@ -372,6 +368,14 @@ impl CurveProjective for Fr {
|
||||||
fn is_identity(&self) -> bool {
|
fn is_identity(&self) -> bool {
|
||||||
<Fr as Field>::is_zero(self)
|
<Fr as Field>::is_zero(self)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrimeGroup for Fr {}
|
||||||
|
|
||||||
|
impl CurveProjective for Fr {
|
||||||
|
type Affine = Fr;
|
||||||
|
type Base = Fr;
|
||||||
|
type Scalar = Fr;
|
||||||
|
|
||||||
fn batch_normalization(_: &mut [Self]) {}
|
fn batch_normalization(_: &mut [Self]) {}
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,7 @@ fn test_with_bls12() {
|
||||||
acc
|
acc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use group::Group;
|
||||||
use pairing::{bls12_381::Bls12, Engine};
|
use pairing::{bls12_381::Bls12, Engine};
|
||||||
use rand;
|
use rand;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue