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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use ark_ec::{
models::CurveConfig,
short_weierstrass::{self, SWCurveConfig},
twisted_edwards::{Affine, MontCurveConfig, Projective, TECurveConfig},
};
use ark_ff::MontFp;
use crate::{Fq, Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<JubjubConfig>;
pub type EdwardsProjective = Projective<JubjubConfig>;
pub type SWAffine = short_weierstrass::Affine<JubjubConfig>;
pub type SWProjective = short_weierstrass::Projective<JubjubConfig>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct JubjubConfig;
pub type EdwardsConfig = JubjubConfig;
pub type SWConfig = JubjubConfig;
impl CurveConfig for JubjubConfig {
type BaseField = Fq;
type ScalarField = Fr;
const COFACTOR: &'static [u64] = &[8];
const COFACTOR_INV: Fr =
MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775");
}
impl TECurveConfig for JubjubConfig {
const COEFF_A: Fq = MontFp!("-1");
const COEFF_D: Fq =
MontFp!("19257038036680949359750312669786877991949435402254120286184196891950884077233");
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = JubjubConfig;
#[inline(always)]
fn mul_by_a(elem: Self::BaseField) -> Self::BaseField {
-elem
}
}
impl MontCurveConfig for JubjubConfig {
const COEFF_A: Fq = MontFp!("40962");
const COEFF_B: Fq = MontFp!("-40964");
type TECurveConfig = JubjubConfig;
}
const GENERATOR_X: Fq =
MontFp!("8076246640662884909881801758704306714034609987455869804520522091855516602923");
const GENERATOR_Y: Fq =
MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458");
impl SWCurveConfig for JubjubConfig {
const COEFF_A: Self::BaseField =
MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210");
const COEFF_B: Self::BaseField =
MontFp!("48351165704696163914533707656614864561753505123260775585269522553028192119009");
const GENERATOR: SWAffine = SWAffine::new_unchecked(SW_GENERATOR_X, SW_GENERATOR_Y);
}
const SW_GENERATOR_X: Fq =
MontFp!("33835869156188682335217394949746694649676633840125476177319971163079011318731");
const SW_GENERATOR_Y: Fq =
MontFp!("43777270878440091394432848052353307184915192688165709016756678962558652055320");