1pub mod genesis;
17pub use genesis::*;
18
19pub mod powers;
20pub use powers::*;
21
22pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json");
24
25const REMOTE_URLS: [&str; 2] =
26 ["https://parameters.provable.com/mainnet", "https://s3.us-west-1.amazonaws.com/mainnet.parameters"];
27
28impl_local!(Degree15, "resources/", "powers-of-beta-15", "usrs");
30impl_remote!(Degree16, REMOTE_URLS, "resources/", "powers-of-beta-16", "usrs");
31impl_remote!(Degree17, REMOTE_URLS, "resources/", "powers-of-beta-17", "usrs");
32impl_remote!(Degree18, REMOTE_URLS, "resources/", "powers-of-beta-18", "usrs");
33impl_remote!(Degree19, REMOTE_URLS, "resources/", "powers-of-beta-19", "usrs");
34impl_remote!(Degree20, REMOTE_URLS, "resources/", "powers-of-beta-20", "usrs");
35impl_remote!(Degree21, REMOTE_URLS, "resources/", "powers-of-beta-21", "usrs");
36impl_remote!(Degree22, REMOTE_URLS, "resources/", "powers-of-beta-22", "usrs");
37impl_remote!(Degree23, REMOTE_URLS, "resources/", "powers-of-beta-23", "usrs");
38impl_remote!(Degree24, REMOTE_URLS, "resources/", "powers-of-beta-24", "usrs");
39impl_remote!(Degree25, REMOTE_URLS, "resources/", "powers-of-beta-25", "usrs");
40#[cfg(feature = "large_params")]
46impl_remote!(Degree26, REMOTE_URLS, "resources/", "powers-of-beta-26", "usrs");
47#[cfg(feature = "large_params")]
48impl_remote!(Degree27, REMOTE_URLS, "resources/", "powers-of-beta-27", "usrs");
49#[cfg(feature = "large_params")]
50impl_remote!(Degree28, REMOTE_URLS, "resources/", "powers-of-beta-28", "usrs");
51
52impl_local!(ShiftedDegree15, "resources/", "shifted-powers-of-beta-15", "usrs");
54impl_local!(ShiftedDegree16, "resources/", "shifted-powers-of-beta-16", "usrs");
55impl_remote!(ShiftedDegree17, REMOTE_URLS, "resources/", "shifted-powers-of-beta-17", "usrs");
56impl_remote!(ShiftedDegree18, REMOTE_URLS, "resources/", "shifted-powers-of-beta-18", "usrs");
57impl_remote!(ShiftedDegree19, REMOTE_URLS, "resources/", "shifted-powers-of-beta-19", "usrs");
58impl_remote!(ShiftedDegree20, REMOTE_URLS, "resources/", "shifted-powers-of-beta-20", "usrs");
59impl_remote!(ShiftedDegree21, REMOTE_URLS, "resources/", "shifted-powers-of-beta-21", "usrs");
60impl_remote!(ShiftedDegree22, REMOTE_URLS, "resources/", "shifted-powers-of-beta-22", "usrs");
61impl_remote!(ShiftedDegree23, REMOTE_URLS, "resources/", "shifted-powers-of-beta-23", "usrs");
62impl_remote!(ShiftedDegree24, REMOTE_URLS, "resources/", "shifted-powers-of-beta-24", "usrs");
63impl_remote!(ShiftedDegree25, REMOTE_URLS, "resources/", "shifted-powers-of-beta-25", "usrs");
64#[cfg(feature = "large_params")]
67impl_remote!(ShiftedDegree26, REMOTE_URLS, "resources/", "shifted-powers-of-beta-26", "usrs");
68#[cfg(feature = "large_params")]
69impl_remote!(ShiftedDegree27, REMOTE_URLS, "resources/", "shifted-powers-of-beta-27", "usrs");
70
71impl_local!(Gamma, "resources/", "powers-of-beta-gamma", "usrs");
73impl_local!(NegBeta, "resources/", "neg-powers-of-beta", "usrs");
75impl_local!(BetaH, "resources/", "beta-h", "usrs");
77
78impl_remote!(BondPublicProver, REMOTE_URLS, "resources/", "bond_public", "prover", "credits");
80impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier", "credits");
81impl_remote!(BondValidatorProver, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits");
83impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier", "credits");
84impl_remote!(UnbondPublicProver, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits");
86impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier", "credits");
87impl_remote!(ClaimUnbondPublicProver, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits");
89impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier", "credits");
90impl_remote!(SetValidatorStateProver, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits");
92impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier", "credits");
93impl_remote!(TransferPrivateProver, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits");
95impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier", "credits");
96impl_remote!(TransferPublicProver, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits");
98impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier", "credits");
99impl_remote!(TransferPublicAsSignerProver, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits");
101impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier", "credits");
102impl_remote!(TransferPrivateToPublicProver, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits");
104impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier", "credits");
105impl_remote!(TransferPublicToPrivateProver, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits");
107impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier", "credits");
108impl_remote!(JoinProver, REMOTE_URLS, "resources/", "join", "prover", "credits");
110impl_local!(JoinVerifier, "resources/", "join", "verifier", "credits");
111impl_remote!(SplitProver, REMOTE_URLS, "resources/", "split", "prover", "credits");
113impl_local!(SplitVerifier, "resources/", "split", "verifier", "credits");
114impl_remote!(FeePrivateProver, REMOTE_URLS, "resources/", "fee_private", "prover", "credits");
116impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier", "credits");
117impl_remote!(FeePublicProver, REMOTE_URLS, "resources/", "fee_public", "prover", "credits");
119impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier", "credits");
120impl_remote!(UpgradeProver, REMOTE_URLS, "resources/", "upgrade", "prover", "credits");
122impl_local!(UpgradeVerifier, "resources/", "upgrade", "verifier", "credits");
123
124impl_remote!(BondPublicV0Prover, REMOTE_URLS, "resources/", "bond_public", "prover", "credits_v0");
128impl_local!(BondPublicV0Verifier, "resources/", "bond_public", "verifier", "credits_v0");
129impl_remote!(BondValidatorV0Prover, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits_v0");
131impl_local!(BondValidatorV0Verifier, "resources/", "bond_validator", "verifier", "credits_v0");
132impl_remote!(UnbondPublicV0Prover, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits_v0");
134impl_local!(UnbondPublicV0Verifier, "resources/", "unbond_public", "verifier", "credits_v0");
135impl_remote!(ClaimUnbondPublicV0Prover, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits_v0");
137impl_local!(ClaimUnbondPublicV0Verifier, "resources/", "claim_unbond_public", "verifier", "credits_v0");
138impl_remote!(SetValidatorStateV0Prover, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits_v0");
140impl_local!(SetValidatorStateV0Verifier, "resources/", "set_validator_state", "verifier", "credits_v0");
141impl_remote!(TransferPrivateV0Prover, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits_v0");
143impl_local!(TransferPrivateV0Verifier, "resources/", "transfer_private", "verifier", "credits_v0");
144impl_remote!(TransferPublicV0Prover, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits_v0");
146impl_local!(TransferPublicV0Verifier, "resources/", "transfer_public", "verifier", "credits_v0");
147impl_remote!(TransferPublicAsSignerV0Prover, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits_v0");
149impl_local!(TransferPublicAsSignerV0Verifier, "resources/", "transfer_public_as_signer", "verifier", "credits_v0");
150impl_remote!(TransferPrivateToPublicV0Prover, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits_v0");
152impl_local!(TransferPrivateToPublicV0Verifier, "resources/", "transfer_private_to_public", "verifier", "credits_v0");
153impl_remote!(TransferPublicToPrivateV0Prover, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits_v0");
155impl_local!(TransferPublicToPrivateV0Verifier, "resources/", "transfer_public_to_private", "verifier", "credits_v0");
156impl_remote!(JoinV0Prover, REMOTE_URLS, "resources/", "join", "prover", "credits_v0");
158impl_local!(JoinV0Verifier, "resources/", "join", "verifier", "credits_v0");
159impl_remote!(SplitV0Prover, REMOTE_URLS, "resources/", "split", "prover", "credits_v0");
161impl_local!(SplitV0Verifier, "resources/", "split", "verifier", "credits_v0");
162impl_remote!(FeePrivateV0Prover, REMOTE_URLS, "resources/", "fee_private", "prover", "credits_v0");
164impl_local!(FeePrivateV0Verifier, "resources/", "fee_private", "verifier", "credits_v0");
165impl_remote!(FeePublicV0Prover, REMOTE_URLS, "resources/", "fee_public", "prover", "credits_v0");
167impl_local!(FeePublicV0Verifier, "resources/", "fee_public", "verifier", "credits_v0");
168impl_remote!(UpgradeV0Prover, REMOTE_URLS, "resources/", "upgrade", "prover", "credits_v0");
170impl_local!(UpgradeV0Verifier, "resources/", "upgrade", "verifier", "credits_v0");
171
172#[macro_export]
173macro_rules! insert_credit_keys {
174 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
175 paste::paste! {
176 let string = stringify!([<$variant:lower>]);
177 $crate::insert_key!($map, string, $type<$network>, ("bond_public", $crate::mainnet::[<BondPublic $variant>]::load_bytes()));
178 $crate::insert_key!($map, string, $type<$network>, ("bond_validator", $crate::mainnet::[<BondValidator $variant>]::load_bytes()));
179 $crate::insert_key!($map, string, $type<$network>, ("unbond_public", $crate::mainnet::[<UnbondPublic $variant>]::load_bytes()));
180 $crate::insert_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::mainnet::[<ClaimUnbondPublic $variant>]::load_bytes()));
181 $crate::insert_key!($map, string, $type<$network>, ("set_validator_state", $crate::mainnet::[<SetValidatorState $variant>]::load_bytes()));
182 $crate::insert_key!($map, string, $type<$network>, ("transfer_private", $crate::mainnet::[<TransferPrivate $variant>]::load_bytes()));
183 $crate::insert_key!($map, string, $type<$network>, ("transfer_public", $crate::mainnet::[<TransferPublic $variant>]::load_bytes()));
184 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::mainnet::[<TransferPublicAsSigner $variant>]::load_bytes()));
185 $crate::insert_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::mainnet::[<TransferPrivateToPublic $variant>]::load_bytes()));
186 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::mainnet::[<TransferPublicToPrivate $variant>]::load_bytes()));
187 $crate::insert_key!($map, string, $type<$network>, ("join", $crate::mainnet::[<Join $variant>]::load_bytes()));
188 $crate::insert_key!($map, string, $type<$network>, ("split", $crate::mainnet::[<Split $variant>]::load_bytes()));
189 $crate::insert_key!($map, string, $type<$network>, ("fee_private", $crate::mainnet::[<FeePrivate $variant>]::load_bytes()));
190 $crate::insert_key!($map, string, $type<$network>, ("fee_public", $crate::mainnet::[<FeePublic $variant>]::load_bytes()));
191 $crate::insert_key!($map, string, $type<$network>, ("upgrade", $crate::mainnet::[<Upgrade $variant>]::load_bytes()));
192 }
193 }};
194}
195
196#[macro_export]
197macro_rules! insert_credit_v0_keys {
198 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
199 paste::paste! {
200 let string = stringify!([<$variant:lower>]);
201 $crate::insert_key!($map, string, $type<$network>, ("bond_public", $crate::mainnet::[<BondPublicV0 $variant>]::load_bytes()));
202 $crate::insert_key!($map, string, $type<$network>, ("bond_validator", $crate::mainnet::[<BondValidatorV0 $variant>]::load_bytes()));
203 $crate::insert_key!($map, string, $type<$network>, ("unbond_public", $crate::mainnet::[<UnbondPublicV0 $variant>]::load_bytes()));
204 $crate::insert_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::mainnet::[<ClaimUnbondPublicV0 $variant>]::load_bytes()));
205 $crate::insert_key!($map, string, $type<$network>, ("set_validator_state", $crate::mainnet::[<SetValidatorStateV0 $variant>]::load_bytes()));
206 $crate::insert_key!($map, string, $type<$network>, ("transfer_private", $crate::mainnet::[<TransferPrivateV0 $variant>]::load_bytes()));
207 $crate::insert_key!($map, string, $type<$network>, ("transfer_public", $crate::mainnet::[<TransferPublicV0 $variant>]::load_bytes()));
208 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::mainnet::[<TransferPublicAsSignerV0 $variant>]::load_bytes()));
209 $crate::insert_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::mainnet::[<TransferPrivateToPublicV0 $variant>]::load_bytes()));
210 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::mainnet::[<TransferPublicToPrivateV0 $variant>]::load_bytes()));
211 $crate::insert_key!($map, string, $type<$network>, ("join", $crate::mainnet::[<JoinV0 $variant>]::load_bytes()));
212 $crate::insert_key!($map, string, $type<$network>, ("split", $crate::mainnet::[<SplitV0 $variant>]::load_bytes()));
213 $crate::insert_key!($map, string, $type<$network>, ("fee_private", $crate::mainnet::[<FeePrivateV0 $variant>]::load_bytes()));
214 $crate::insert_key!($map, string, $type<$network>, ("fee_public", $crate::mainnet::[<FeePublicV0 $variant>]::load_bytes()));
215 $crate::insert_key!($map, string, $type<$network>, ("upgrade", $crate::mainnet::[<UpgradeV0 $variant>]::load_bytes()));
216 }
217 }};
218}
219
220#[macro_export]
221macro_rules! insert_key {
222 ($map:ident, $string:tt, $type:ident<$network:ident>, ($name:tt, $circuit_key:expr)) => {{
223 let key_bytes: Vec<u8> = $circuit_key.expect(&format!("Failed to load {} bytes", $string));
225 let key = $type::<$network>::from_bytes_le(&key_bytes[1..]).expect(&format!("Failed to recover {}", $string));
227 $map.insert($name.to_string(), std::sync::Arc::new(key));
229 }};
230}
231
232impl_remote!(InclusionV0Prover, REMOTE_URLS, "resources/", "inclusion", "prover", "credits_v0");
234impl_local!(InclusionV0Verifier, "resources/", "inclusion", "verifier", "credits_v0");
235impl_remote!(InclusionProver, REMOTE_URLS, "resources/", "inclusion", "prover", "credits");
236impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier", "credits");
237
238pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
240
241lazy_static! {
242 pub static ref INCLUSION_V0_PROVING_KEY: Vec<u8> =
243 InclusionV0Prover::load_bytes().expect("Failed to load inclusion_v0 proving key");
244 pub static ref INCLUSION_V0_VERIFYING_KEY: Vec<u8> =
245 InclusionV0Verifier::load_bytes().expect("Failed to load inclusion_v0 verifying key");
246 pub static ref INCLUSION_PROVING_KEY: Vec<u8> = InclusionProver::load_bytes().expect("Failed to load inclusion proving key");
247 pub static ref INCLUSION_VERIFYING_KEY: Vec<u8> =
248 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifying key");
249}
250
251#[cfg(test)]
252mod tests {
253 use super::*;
254 use wasm_bindgen_test::*;
255 wasm_bindgen_test_configure!(run_in_browser);
256
257 #[ignore]
258 #[test]
259 fn test_load_bytes_mini() {
260 Degree16::load_bytes().expect("Failed to load degree 16");
261 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
262 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
263 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
264 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
265 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
266 }
267
268 #[allow(dead_code)]
269 #[wasm_bindgen_test]
270 fn test_load_bytes() {
271 Degree16::load_bytes().expect("Failed to load degree 16");
272 Degree17::load_bytes().expect("Failed to load degree 17");
273 Degree18::load_bytes().expect("Failed to load degree 18");
274 Degree19::load_bytes().expect("Failed to load degree 19");
275 Degree20::load_bytes().expect("Failed to load degree 20");
276 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
277 BondValidatorVerifier::load_bytes().expect("Failed to load bond_validator verifier");
278 UnbondPublicVerifier::load_bytes().expect("Failed to load unbond_public verifier");
279 ClaimUnbondPublicVerifier::load_bytes().expect("Failed to load claim_unbond_public verifier");
280 SetValidatorStateVerifier::load_bytes().expect("Failed to load set_validator_state verifier");
281 TransferPrivateVerifier::load_bytes().expect("Failed to load transfer_private verifier");
282 TransferPublicVerifier::load_bytes().expect("Failed to load transfer_public verifier");
283 TransferPublicAsSignerVerifier::load_bytes().expect("Failed to load transfer_public_as_signer verifier");
284 TransferPrivateToPublicVerifier::load_bytes().expect("Failed to load transfer_private_to_public verifier");
285 TransferPublicToPrivateVerifier::load_bytes().expect("Failed to load transfer_public_to_private verifier");
286 FeePrivateProver::load_bytes().expect("Failed to load fee_private prover");
287 FeePrivateVerifier::load_bytes().expect("Failed to load fee_private verifier");
288 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
289 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
290 UpgradeProver::load_bytes().expect("Failed to load upgrade prover");
291 UpgradeVerifier::load_bytes().expect("Failed to load upgrade verifier");
292 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
293 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
294 }
295}