1use num::{BigInt, Num};
2
3pub trait CurveId {
14 fn curve_id() -> u64;
19
20 fn curve_type() -> CurveType;
21
22 fn field() -> BigInt;
23}
24
25macro_rules! define_curve {
26 ($name:ident, $id:expr, $field:expr) => {
27 pub struct $name;
28
29 impl CurveId for $name {
30 fn curve_id() -> u64 {
31 $id
32 }
33
34 fn curve_type() -> CurveType {
35 CurveType::$name
36 }
37
38 fn field() -> BigInt {
39 BigInt::from_str_radix($field, 10).unwrap()
40 }
41 }
42 };
43}
44
45pub mod curve {
62 use super::*;
63
64 define_curve!(
65 BN254,
66 1,
67 "21888242871839275222246405745257275088548364400416034343698204186575808495617"
68 );
69 define_curve!(
70 BLS12_381,
71 2,
72 "52435875175126190479447740508185965837690552500527637822603658699938581184513"
73 );
74 define_curve!(
75 BLS24_317,
76 3,
77 "30869589236456844204538189757527902584594726589286811523515204428962673459201"
78 );
79
80 define_curve!(
81 BLS12_377,
82 4,
83 "8444461749428370424248824938781546531375899335154063827935233455917409239041"
84 );
85 define_curve!(
86 BW6_761,
87 5,
88 "258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177"
89 );
90 define_curve!(
91 BLS24_315,
92 6,
93 "11502027791375260645628074404575422495959608200132055716665986169834464870401"
94 );
95 define_curve!(
96 BW6_633,
97 7,
98 "39705142709513438335025689890408969744933502416914749335064285505637884093126342347073617133569"
99 );
100}
101
102#[derive(Debug, Clone)]
103pub enum CurveType {
104 Mock,
105 BN254,
106 BLS12_381,
107 BLS24_317,
108 BLS12_377,
109 BW6_761,
110 BLS24_315,
111 BW6_633,
112}
113
114#[derive(Debug, Clone)]
115pub enum ProvingSystem {
116 Mock,
117 Groth16,
118 Plonk,
119}
120
121#[derive(Debug, Clone)]
122pub struct MetadataInfo {
123 pub field: BigInt,
124 pub curve: CurveType,
125 pub proving_system: ProvingSystem,
126}
127
128pub trait Metadata {
129 fn field(&self) -> &BigInt;
130
131 fn curve(&self) -> &CurveType;
132
133 fn proving_system(&self) -> &ProvingSystem;
134}
135
136impl Metadata for MetadataInfo {
137 fn field(&self) -> &BigInt {
138 &self.field
139 }
140
141 fn curve(&self) -> &CurveType {
142 &self.curve
143 }
144
145 fn proving_system(&self) -> &ProvingSystem {
146 &self.proving_system
147 }
148}