Catch up with algebra (#106)

Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
This commit is contained in:
Marcin
2022-07-29 21:16:16 +02:00
committed by GitHub
parent 76579d0fbb
commit 93e64df895
120 changed files with 934 additions and 1653 deletions

View File

@@ -1,12 +1,17 @@
use ark_ec::models::{ModelParameters, SWModelParameters};
use ark_ff::{MontFp, Zero};
use ark_ec::{
models::{short_weierstrass::SWCurveConfig, CurveConfig},
short_weierstrass::Affine,
};
use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fr};
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Parameters;
impl ModelParameters for Parameters {
pub type G1Affine = Affine<Parameters>;
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -14,19 +19,18 @@ impl ModelParameters for Parameters {
const COFACTOR: &'static [u64] = &[0x1];
/// COFACTOR_INV = COFACTOR^{-1} mod r = 1
const COFACTOR_INV: Fr = MontFp!(Fr, "1");
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWModelParameters for Parameters {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = MontFp!(Fq, "0");
const COEFF_A: Fq = Fq::ZERO;
/// COEFF_B = 3
const COEFF_B: Fq = MontFp!(Fq, "3");
const COEFF_B: Fq = MontFp!("3");
/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
(G1_GENERATOR_X, G1_GENERATOR_Y);
const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y);
#[inline(always)]
fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
@@ -35,7 +39,7 @@ impl SWModelParameters for Parameters {
}
/// G1_GENERATOR_X = 1
pub const G1_GENERATOR_X: Fq = MontFp!(Fq, "1");
pub const G1_GENERATOR_X: Fq = Fq::ONE;
/// G1_GENERATOR_Y = 2
pub const G1_GENERATOR_Y: Fq = MontFp!(Fq, "2");
pub const G1_GENERATOR_Y: Fq = MontFp!("2");