1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use ark_ec::{
models::{ModelParameters, MontgomeryModelParameters, TEModelParameters},
twisted_edwards_extended::{GroupAffine, GroupProjective},
};
use ark_ff::field_new;
use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = GroupAffine<EdwardsParameters>;
pub type EdwardsProjective = GroupProjective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsParameters;
impl ModelParameters for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
}
impl TEModelParameters for EdwardsParameters {
#[rustfmt::skip]
const COEFF_A: Fq = field_new!(Fq, "-1");
#[rustfmt::skip]
const COEFF_D: Fq = field_new!(Fq, "79743");
const COFACTOR: &'static [u64] = &[8];
#[rustfmt::skip]
const COFACTOR_INV: Fr = field_new!(Fr, "12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560");
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = (GENERATOR_X, GENERATOR_Y);
type MontgomeryModelParameters = EdwardsParameters;
#[inline(always)]
fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField {
-*elem
}
}
impl MontgomeryModelParameters for EdwardsParameters {
#[rustfmt::skip]
const COEFF_A: Fq = field_new!(Fq, "90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765");
#[rustfmt::skip]
const COEFF_B: Fq = field_new!(Fq, "168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410");
type TEModelParameters = EdwardsParameters;
}
#[rustfmt::skip]
const GENERATOR_X: Fq = field_new!(Fq, "174701772324485506941690903512423551998294352968833659960042362742684869862495746426366187462669992073196420267127");
#[rustfmt::skip]
const GENERATOR_Y: Fq = field_new!(Fq, "208487200052258845495340374451540775445408439654930191324011635560142523886549663106522691296420655144190624954833");