Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GLVParameters trait definition #301

Merged
merged 12 commits into from
Sep 6, 2021
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Pending

- [\#301](https://github.com/arkworks-rs/algebra/pull/301) (ark-ec) Add `GLVParameters` trait definition.

### Breaking changes

- [\#300](https://github.com/arkworks-rs/algebra/pull/300) (ark-ec) Change the implementation of `Hash` trait of `GroupProjective` to use the affine coordinates.
Expand Down
35 changes: 35 additions & 0 deletions ec/src/glv.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use crate::ModelParameters;

/// The GLV parameters that are useful to compute the endomorphism
/// and scalar decomposition.
pub trait GLVParameters: Send + Sync + 'static + ModelParameters {
type CurveAffine;
type CurveProjective;

// phi(P) = lambda*P for all P
// constants that are used to calculate phi(P)
const COEFF_A1: Self::BaseField;
weikengchen marked this conversation as resolved.
Show resolved Hide resolved
const COEFF_A2: Self::BaseField;
const COEFF_A3: Self::BaseField;
const COEFF_B1: Self::BaseField;
const COEFF_B2: Self::BaseField;
const COEFF_B3: Self::BaseField;
const COEFF_C1: Self::BaseField;
const COEFF_C2: Self::BaseField;

// constants that are used to perform scalar decomposition
// This is a matrix which is practically the LLL reduced bases
const COEFF_N11: Self::ScalarField;
const COEFF_N12: Self::ScalarField;
const COEFF_N21: Self::ScalarField;
const COEFF_N22: Self::ScalarField;

/// mapping a point G to phi(G):= lambda G where psi is the endomorphism
fn endomorphism(base: &Self::CurveAffine) -> Self::CurveAffine;

/// decompose a scalar s into k1, k2, s.t. s = k1 + lambda k2
fn scalar_decomposition(k: &Self::ScalarField) -> (Self::ScalarField, Self::ScalarField);

/// perform GLV multiplication
fn glv_mul(base: &Self::CurveAffine, scalar: &Self::ScalarField) -> Self::CurveProjective;
}
2 changes: 2 additions & 0 deletions ec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use zeroize::Zeroize;
pub mod models;
pub use self::models::*;

pub mod glv;

pub mod group;

pub mod msm;
Expand Down