1pub mod genesis;
17pub use genesis::*;
18
19pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json");
21
22const REMOTE_URL: &str = "https://parameters.provable.com/testnet";
23
24impl_remote!(BondPublicProver, REMOTE_URL, "resources/", "bond_public", "prover", "credits");
26impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier", "credits");
27impl_remote!(BondValidatorProver, REMOTE_URL, "resources/", "bond_validator", "prover", "credits");
29impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier", "credits");
30impl_remote!(UnbondPublicProver, REMOTE_URL, "resources/", "unbond_public", "prover", "credits");
32impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier", "credits");
33impl_remote!(ClaimUnbondPublicProver, REMOTE_URL, "resources/", "claim_unbond_public", "prover", "credits");
35impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier", "credits");
36impl_remote!(SetValidatorStateProver, REMOTE_URL, "resources/", "set_validator_state", "prover", "credits");
38impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier", "credits");
39impl_remote!(TransferPrivateProver, REMOTE_URL, "resources/", "transfer_private", "prover", "credits");
41impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier", "credits");
42impl_remote!(TransferPublicProver, REMOTE_URL, "resources/", "transfer_public", "prover", "credits");
44impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier", "credits");
45impl_remote!(TransferPublicAsSignerProver, REMOTE_URL, "resources/", "transfer_public_as_signer", "prover", "credits");
47impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier", "credits");
48impl_remote!(TransferPrivateToPublicProver, REMOTE_URL, "resources/", "transfer_private_to_public", "prover", "credits");
50impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier", "credits");
51impl_remote!(TransferPublicToPrivateProver, REMOTE_URL, "resources/", "transfer_public_to_private", "prover", "credits");
53impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier", "credits");
54impl_remote!(JoinProver, REMOTE_URL, "resources/", "join", "prover", "credits");
56impl_local!(JoinVerifier, "resources/", "join", "verifier", "credits");
57impl_remote!(SplitProver, REMOTE_URL, "resources/", "split", "prover", "credits");
59impl_local!(SplitVerifier, "resources/", "split", "verifier", "credits");
60impl_remote!(FeePrivateProver, REMOTE_URL, "resources/", "fee_private", "prover", "credits");
62impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier", "credits");
63impl_remote!(FeePublicProver, REMOTE_URL, "resources/", "fee_public", "prover", "credits");
65impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier", "credits");
66impl_remote!(UpgradeProver, REMOTE_URL, "resources/", "upgrade", "prover", "credits");
68impl_local!(UpgradeVerifier, "resources/", "upgrade", "verifier", "credits");
69
70impl_remote!(BondPublicV0Prover, REMOTE_URL, "resources/", "bond_public", "prover", "credits_v0");
74impl_local!(BondPublicV0Verifier, "resources/", "bond_public", "verifier", "credits_v0");
75impl_remote!(BondValidatorV0Prover, REMOTE_URL, "resources/", "bond_validator", "prover", "credits_v0");
77impl_local!(BondValidatorV0Verifier, "resources/", "bond_validator", "verifier", "credits_v0");
78impl_remote!(UnbondPublicV0Prover, REMOTE_URL, "resources/", "unbond_public", "prover", "credits_v0");
80impl_local!(UnbondPublicV0Verifier, "resources/", "unbond_public", "verifier", "credits_v0");
81impl_remote!(ClaimUnbondPublicV0Prover, REMOTE_URL, "resources/", "claim_unbond_public", "prover", "credits_v0");
83impl_local!(ClaimUnbondPublicV0Verifier, "resources/", "claim_unbond_public", "verifier", "credits_v0");
84impl_remote!(SetValidatorStateV0Prover, REMOTE_URL, "resources/", "set_validator_state", "prover", "credits_v0");
86impl_local!(SetValidatorStateV0Verifier, "resources/", "set_validator_state", "verifier", "credits_v0");
87impl_remote!(TransferPrivateV0Prover, REMOTE_URL, "resources/", "transfer_private", "prover", "credits_v0");
89impl_local!(TransferPrivateV0Verifier, "resources/", "transfer_private", "verifier", "credits_v0");
90impl_remote!(TransferPublicV0Prover, REMOTE_URL, "resources/", "transfer_public", "prover", "credits_v0");
92impl_local!(TransferPublicV0Verifier, "resources/", "transfer_public", "verifier", "credits_v0");
93impl_remote!(TransferPublicAsSignerV0Prover, REMOTE_URL, "resources/", "transfer_public_as_signer", "prover", "credits_v0");
95impl_local!(TransferPublicAsSignerV0Verifier, "resources/", "transfer_public_as_signer", "verifier", "credits_v0");
96impl_remote!(TransferPrivateToPublicV0Prover, REMOTE_URL, "resources/", "transfer_private_to_public", "prover", "credits_v0");
98impl_local!(TransferPrivateToPublicV0Verifier, "resources/", "transfer_private_to_public", "verifier", "credits_v0");
99impl_remote!(TransferPublicToPrivateV0Prover, REMOTE_URL, "resources/", "transfer_public_to_private", "prover", "credits_v0");
101impl_local!(TransferPublicToPrivateV0Verifier, "resources/", "transfer_public_to_private", "verifier", "credits_v0");
102impl_remote!(JoinV0Prover, REMOTE_URL, "resources/", "join", "prover", "credits_v0");
104impl_local!(JoinV0Verifier, "resources/", "join", "verifier", "credits_v0");
105impl_remote!(SplitV0Prover, REMOTE_URL, "resources/", "split", "prover", "credits_v0");
107impl_local!(SplitV0Verifier, "resources/", "split", "verifier", "credits_v0");
108impl_remote!(FeePrivateV0Prover, REMOTE_URL, "resources/", "fee_private", "prover", "credits_v0");
110impl_local!(FeePrivateV0Verifier, "resources/", "fee_private", "verifier", "credits_v0");
111impl_remote!(FeePublicV0Prover, REMOTE_URL, "resources/", "fee_public", "prover", "credits_v0");
113impl_local!(FeePublicV0Verifier, "resources/", "fee_public", "verifier", "credits_v0");
114impl_remote!(UpgradeV0Prover, REMOTE_URL, "resources/", "upgrade", "prover", "credits_v0");
116impl_local!(UpgradeV0Verifier, "resources/", "upgrade", "verifier", "credits_v0");
117
118#[macro_export]
119macro_rules! insert_testnet_credit_keys {
120 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
121 paste::paste! {
122 let string = stringify!([<$variant:lower>]);
123 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_public", $crate::testnet::[<BondPublic $variant>]::load_bytes()));
124 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_validator", $crate::testnet::[<BondValidator $variant>]::load_bytes()));
125 $crate::insert_testnet_key!($map, string, $type<$network>, ("unbond_public", $crate::testnet::[<UnbondPublic $variant>]::load_bytes()));
126 $crate::insert_testnet_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::testnet::[<ClaimUnbondPublic $variant>]::load_bytes()));
127 $crate::insert_testnet_key!($map, string, $type<$network>, ("set_validator_state", $crate::testnet::[<SetValidatorState $variant>]::load_bytes()));
128 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private", $crate::testnet::[<TransferPrivate $variant>]::load_bytes()));
129 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public", $crate::testnet::[<TransferPublic $variant>]::load_bytes()));
130 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::testnet::[<TransferPublicAsSigner $variant>]::load_bytes()));
131 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::testnet::[<TransferPrivateToPublic $variant>]::load_bytes()));
132 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::testnet::[<TransferPublicToPrivate $variant>]::load_bytes()));
133 $crate::insert_testnet_key!($map, string, $type<$network>, ("join", $crate::testnet::[<Join $variant>]::load_bytes()));
134 $crate::insert_testnet_key!($map, string, $type<$network>, ("split", $crate::testnet::[<Split $variant>]::load_bytes()));
135 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_private", $crate::testnet::[<FeePrivate $variant>]::load_bytes()));
136 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_public", $crate::testnet::[<FeePublic $variant>]::load_bytes()));
137 $crate::insert_testnet_key!($map, string, $type<$network>, ("upgrade", $crate::testnet::[<Upgrade $variant>]::load_bytes()));
138 }
139 }};
140}
141
142#[macro_export]
143macro_rules! insert_testnet_credit_v0_keys {
144 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
145 paste::paste! {
146 let string = stringify!([<$variant:lower>]);
147 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_public", $crate::testnet::[<BondPublicV0 $variant>]::load_bytes()));
148 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_validator", $crate::testnet::[<BondValidatorV0 $variant>]::load_bytes()));
149 $crate::insert_testnet_key!($map, string, $type<$network>, ("unbond_public", $crate::testnet::[<UnbondPublicV0 $variant>]::load_bytes()));
150 $crate::insert_testnet_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::testnet::[<ClaimUnbondPublicV0 $variant>]::load_bytes()));
151 $crate::insert_testnet_key!($map, string, $type<$network>, ("set_validator_state", $crate::testnet::[<SetValidatorStateV0 $variant>]::load_bytes()));
152 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private", $crate::testnet::[<TransferPrivateV0 $variant>]::load_bytes()));
153 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public", $crate::testnet::[<TransferPublicV0 $variant>]::load_bytes()));
154 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::testnet::[<TransferPublicAsSignerV0 $variant>]::load_bytes()));
155 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::testnet::[<TransferPrivateToPublicV0 $variant>]::load_bytes()));
156 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::testnet::[<TransferPublicToPrivateV0 $variant>]::load_bytes()));
157 $crate::insert_testnet_key!($map, string, $type<$network>, ("join", $crate::testnet::[<JoinV0 $variant>]::load_bytes()));
158 $crate::insert_testnet_key!($map, string, $type<$network>, ("split", $crate::testnet::[<SplitV0 $variant>]::load_bytes()));
159 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_private", $crate::testnet::[<FeePrivateV0 $variant>]::load_bytes()));
160 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_public", $crate::testnet::[<FeePublicV0 $variant>]::load_bytes()));
161 $crate::insert_testnet_key!($map, string, $type<$network>, ("upgrade", $crate::testnet::[<UpgradeV0 $variant>]::load_bytes()));
162 }
163 }};
164}
165
166#[macro_export]
167macro_rules! insert_testnet_key {
168 ($map:ident, $string:tt, $type:ident<$network:ident>, ($name:tt, $circuit_key:expr)) => {{
169 let key_bytes: Vec<u8> = $circuit_key.expect(&format!("Failed to load {} bytes", $string));
171 let key = $type::<$network>::from_bytes_le(&key_bytes[1..]).expect(&format!("Failed to recover {}", $string));
173 $map.insert($name.to_string(), std::sync::Arc::new(key));
175 }};
176}
177
178impl_remote!(InclusionV0Prover, REMOTE_URL, "resources/", "inclusion", "prover", "credits_v0");
180impl_local!(InclusionV0Verifier, "resources/", "inclusion", "verifier", "credits_v0");
181impl_remote!(InclusionProver, REMOTE_URL, "resources/", "inclusion", "prover", "credits");
182impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier", "credits");
183
184pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
186
187lazy_static! {
188 pub static ref INCLUSION_V0_PROVING_KEY: Vec<u8> =
189 InclusionV0Prover::load_bytes().expect("Failed to load inclusion_v0 proving key");
190 pub static ref INCLUSION_V0_VERIFYING_KEY: Vec<u8> =
191 InclusionV0Verifier::load_bytes().expect("Failed to load inclusion_v0 verifying key");
192 pub static ref INCLUSION_PROVING_KEY: Vec<u8> = InclusionProver::load_bytes().expect("Failed to load inclusion proving key");
193 pub static ref INCLUSION_VERIFYING_KEY: Vec<u8> =
194 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifying key");
195}
196
197#[cfg(test)]
198mod tests {
199 use super::*;
200 use wasm_bindgen_test::*;
201 wasm_bindgen_test_configure!(run_in_browser);
202
203 #[allow(dead_code)]
204 #[wasm_bindgen_test]
205 fn test_load_bytes() {
206 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
207 BondValidatorVerifier::load_bytes().expect("Failed to load bond_validator verifier");
208 UnbondPublicVerifier::load_bytes().expect("Failed to load unbond_public verifier");
209 ClaimUnbondPublicVerifier::load_bytes().expect("Failed to load claim_unbond_public verifier");
210 SetValidatorStateVerifier::load_bytes().expect("Failed to load set_validator_state verifier");
211 TransferPrivateVerifier::load_bytes().expect("Failed to load transfer_private verifier");
212 TransferPublicVerifier::load_bytes().expect("Failed to load transfer_public verifier");
213 TransferPublicAsSignerVerifier::load_bytes().expect("Failed to load transfer_public_as_signer verifier");
214 TransferPrivateToPublicVerifier::load_bytes().expect("Failed to load transfer_private_to_public verifier");
215 TransferPublicToPrivateVerifier::load_bytes().expect("Failed to load transfer_public_to_private verifier");
216 FeePrivateProver::load_bytes().expect("Failed to load fee_private prover");
217 FeePrivateVerifier::load_bytes().expect("Failed to load fee_private verifier");
218 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
219 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
220 UpgradeProver::load_bytes().expect("Failed to load upgrade prover");
221 UpgradeVerifier::load_bytes().expect("Failed to load upgrade verifier");
222 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
223 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
224 }
225}