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_URL: &str = "https://parameters.aleo.org/mainnet";
26
27#[cfg(not(feature = "wasm"))]
29impl_local!(Degree15, "resources/", "powers-of-beta-15", "usrs");
30#[cfg(feature = "wasm")]
31impl_remote!(Degree15, REMOTE_URL, "resources/", "powers-of-beta-15", "usrs");
32impl_remote!(Degree16, REMOTE_URL, "resources/", "powers-of-beta-16", "usrs");
33impl_remote!(Degree17, REMOTE_URL, "resources/", "powers-of-beta-17", "usrs");
34impl_remote!(Degree18, REMOTE_URL, "resources/", "powers-of-beta-18", "usrs");
35impl_remote!(Degree19, REMOTE_URL, "resources/", "powers-of-beta-19", "usrs");
36impl_remote!(Degree20, REMOTE_URL, "resources/", "powers-of-beta-20", "usrs");
37impl_remote!(Degree21, REMOTE_URL, "resources/", "powers-of-beta-21", "usrs");
38impl_remote!(Degree22, REMOTE_URL, "resources/", "powers-of-beta-22", "usrs");
39impl_remote!(Degree23, REMOTE_URL, "resources/", "powers-of-beta-23", "usrs");
40impl_remote!(Degree24, REMOTE_URL, "resources/", "powers-of-beta-24", "usrs");
41impl_remote!(Degree25, REMOTE_URL, "resources/", "powers-of-beta-25", "usrs");
42#[cfg(feature = "large_params")]
48impl_remote!(Degree26, REMOTE_URL, "resources/", "powers-of-beta-26", "usrs");
49#[cfg(feature = "large_params")]
50impl_remote!(Degree27, REMOTE_URL, "resources/", "powers-of-beta-27", "usrs");
51#[cfg(feature = "large_params")]
52impl_remote!(Degree28, REMOTE_URL, "resources/", "powers-of-beta-28", "usrs");
53
54#[cfg(not(feature = "wasm"))]
56impl_local!(ShiftedDegree15, "resources/", "shifted-powers-of-beta-15", "usrs");
57#[cfg(feature = "wasm")]
58impl_remote!(ShiftedDegree15, REMOTE_URL, "resources/", "shifted-powers-of-beta-15", "usrs");
59#[cfg(not(feature = "wasm"))]
60impl_local!(ShiftedDegree16, "resources/", "shifted-powers-of-beta-16", "usrs");
61#[cfg(feature = "wasm")]
62impl_remote!(ShiftedDegree16, REMOTE_URL, "resources/", "shifted-powers-of-beta-16", "usrs");
63impl_remote!(ShiftedDegree17, REMOTE_URL, "resources/", "shifted-powers-of-beta-17", "usrs");
64impl_remote!(ShiftedDegree18, REMOTE_URL, "resources/", "shifted-powers-of-beta-18", "usrs");
65impl_remote!(ShiftedDegree19, REMOTE_URL, "resources/", "shifted-powers-of-beta-19", "usrs");
66impl_remote!(ShiftedDegree20, REMOTE_URL, "resources/", "shifted-powers-of-beta-20", "usrs");
67impl_remote!(ShiftedDegree21, REMOTE_URL, "resources/", "shifted-powers-of-beta-21", "usrs");
68impl_remote!(ShiftedDegree22, REMOTE_URL, "resources/", "shifted-powers-of-beta-22", "usrs");
69impl_remote!(ShiftedDegree23, REMOTE_URL, "resources/", "shifted-powers-of-beta-23", "usrs");
70impl_remote!(ShiftedDegree24, REMOTE_URL, "resources/", "shifted-powers-of-beta-24", "usrs");
71impl_remote!(ShiftedDegree25, REMOTE_URL, "resources/", "shifted-powers-of-beta-25", "usrs");
72#[cfg(feature = "large_params")]
75impl_remote!(ShiftedDegree26, REMOTE_URL, "resources/", "shifted-powers-of-beta-26", "usrs");
76#[cfg(feature = "large_params")]
77impl_remote!(ShiftedDegree27, REMOTE_URL, "resources/", "shifted-powers-of-beta-27", "usrs");
78
79impl_local!(Gamma, "resources/", "powers-of-beta-gamma", "usrs");
81impl_local!(NegBeta, "resources/", "neg-powers-of-beta", "usrs");
83impl_local!(BetaH, "resources/", "beta-h", "usrs");
85
86impl_remote!(BondPublicProver, REMOTE_URL, "resources/", "bond_public", "prover");
88impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier");
89impl_remote!(BondValidatorProver, REMOTE_URL, "resources/", "bond_validator", "prover");
91impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier");
92impl_remote!(UnbondPublicProver, REMOTE_URL, "resources/", "unbond_public", "prover");
94impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier");
95impl_remote!(ClaimUnbondPublicProver, REMOTE_URL, "resources/", "claim_unbond_public", "prover");
97impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier");
98impl_remote!(SetValidatorStateProver, REMOTE_URL, "resources/", "set_validator_state", "prover");
100impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier");
101impl_remote!(TransferPrivateProver, REMOTE_URL, "resources/", "transfer_private", "prover");
103impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier");
104impl_remote!(TransferPublicProver, REMOTE_URL, "resources/", "transfer_public", "prover");
106impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier");
107impl_remote!(TransferPublicAsSignerProver, REMOTE_URL, "resources/", "transfer_public_as_signer", "prover");
109impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier");
110impl_remote!(TransferPrivateToPublicProver, REMOTE_URL, "resources/", "transfer_private_to_public", "prover");
112impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier");
113impl_remote!(TransferPublicToPrivateProver, REMOTE_URL, "resources/", "transfer_public_to_private", "prover");
115impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier");
116impl_remote!(JoinProver, REMOTE_URL, "resources/", "join", "prover");
118impl_local!(JoinVerifier, "resources/", "join", "verifier");
119impl_remote!(SplitProver, REMOTE_URL, "resources/", "split", "prover");
121impl_local!(SplitVerifier, "resources/", "split", "verifier");
122impl_remote!(FeePrivateProver, REMOTE_URL, "resources/", "fee_private", "prover");
124impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier");
125impl_remote!(FeePublicProver, REMOTE_URL, "resources/", "fee_public", "prover");
127impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier");
128
129#[macro_export]
130macro_rules! insert_credit_keys {
131 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
132 paste::paste! {
133 let string = stringify!([<$variant:lower>]);
134 $crate::insert_key!($map, string, $type<$network>, ("bond_public", $crate::mainnet::[<BondPublic $variant>]::load_bytes()));
135 $crate::insert_key!($map, string, $type<$network>, ("bond_validator", $crate::mainnet::[<BondValidator $variant>]::load_bytes()));
136 $crate::insert_key!($map, string, $type<$network>, ("unbond_public", $crate::mainnet::[<UnbondPublic $variant>]::load_bytes()));
137 $crate::insert_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::mainnet::[<ClaimUnbondPublic $variant>]::load_bytes()));
138 $crate::insert_key!($map, string, $type<$network>, ("set_validator_state", $crate::mainnet::[<SetValidatorState $variant>]::load_bytes()));
139 $crate::insert_key!($map, string, $type<$network>, ("transfer_private", $crate::mainnet::[<TransferPrivate $variant>]::load_bytes()));
140 $crate::insert_key!($map, string, $type<$network>, ("transfer_public", $crate::mainnet::[<TransferPublic $variant>]::load_bytes()));
141 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::mainnet::[<TransferPublicAsSigner $variant>]::load_bytes()));
142 $crate::insert_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::mainnet::[<TransferPrivateToPublic $variant>]::load_bytes()));
143 $crate::insert_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::mainnet::[<TransferPublicToPrivate $variant>]::load_bytes()));
144 $crate::insert_key!($map, string, $type<$network>, ("join", $crate::mainnet::[<Join $variant>]::load_bytes()));
145 $crate::insert_key!($map, string, $type<$network>, ("split", $crate::mainnet::[<Split $variant>]::load_bytes()));
146 $crate::insert_key!($map, string, $type<$network>, ("fee_private", $crate::mainnet::[<FeePrivate $variant>]::load_bytes()));
147 $crate::insert_key!($map, string, $type<$network>, ("fee_public", $crate::mainnet::[<FeePublic $variant>]::load_bytes()));
148 }
149 }};
150}
151
152#[macro_export]
153macro_rules! insert_key {
154 ($map:ident, $string:tt, $type:ident<$network:ident>, ($name:tt, $circuit_key:expr)) => {{
155 let key_bytes: Vec<u8> = $circuit_key.expect(&format!("Failed to load {} bytes", $string));
157 let key = $type::<$network>::from_bytes_le(&key_bytes[1..]).expect(&format!("Failed to recover {}", $string));
159 $map.insert($name.to_string(), std::sync::Arc::new(key));
161 }};
162}
163
164impl_remote!(InclusionProver, REMOTE_URL, "resources/", "inclusion", "prover");
166impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier");
167
168pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
170
171lazy_static! {
172 pub static ref INCLUSION_PROVING_KEY: Vec<u8> =
173 InclusionProver::load_bytes().expect("Failed to load inclusion proving key");
174 pub static ref INCLUSION_VERIFYING_KEY: Vec<u8> =
175 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifying key");
176}
177
178#[cfg(test)]
179mod tests {
180 use super::*;
181 use wasm_bindgen_test::*;
182 wasm_bindgen_test_configure!(run_in_browser);
183
184 #[ignore]
185 #[test]
186 fn test_load_bytes_mini() {
187 Degree16::load_bytes().expect("Failed to load degree 16");
188 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
189 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
190 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
191 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
192 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
193 }
194
195 #[allow(dead_code)]
196 #[wasm_bindgen_test]
197 fn test_load_bytes() {
198 Degree16::load_bytes().expect("Failed to load degree 16");
199 Degree17::load_bytes().expect("Failed to load degree 17");
200 Degree18::load_bytes().expect("Failed to load degree 18");
201 Degree19::load_bytes().expect("Failed to load degree 19");
202 Degree20::load_bytes().expect("Failed to load degree 20");
203 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
204 BondValidatorVerifier::load_bytes().expect("Failed to load bond_validator verifier");
205 UnbondPublicVerifier::load_bytes().expect("Failed to load unbond_public verifier");
206 ClaimUnbondPublicVerifier::load_bytes().expect("Failed to load claim_unbond_public verifier");
207 SetValidatorStateVerifier::load_bytes().expect("Failed to load set_validator_state verifier");
208 TransferPrivateVerifier::load_bytes().expect("Failed to load transfer_private verifier");
209 TransferPublicVerifier::load_bytes().expect("Failed to load transfer_public verifier");
210 TransferPublicAsSignerVerifier::load_bytes().expect("Failed to load transfer_public_as_signer verifier");
211 TransferPrivateToPublicVerifier::load_bytes().expect("Failed to load transfer_private_to_public verifier");
212 TransferPublicToPrivateVerifier::load_bytes().expect("Failed to load transfer_public_to_private verifier");
213 FeePrivateProver::load_bytes().expect("Failed to load fee_private prover");
214 FeePrivateVerifier::load_bytes().expect("Failed to load fee_private verifier");
215 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
216 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
217 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
218 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
219 }
220}