1pub mod genesis;
17pub use genesis::*;
18
19pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json");
21
22const REMOTE_URL: &str = "https://parameters.aleo.org/testnet";
23
24impl_remote!(BondPublicProver, REMOTE_URL, "resources/", "bond_public", "prover");
26impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier");
27impl_remote!(BondValidatorProver, REMOTE_URL, "resources/", "bond_validator", "prover");
29impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier");
30impl_remote!(UnbondPublicProver, REMOTE_URL, "resources/", "unbond_public", "prover");
32impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier");
33impl_remote!(ClaimUnbondPublicProver, REMOTE_URL, "resources/", "claim_unbond_public", "prover");
35impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier");
36impl_remote!(SetValidatorStateProver, REMOTE_URL, "resources/", "set_validator_state", "prover");
38impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier");
39impl_remote!(TransferPrivateProver, REMOTE_URL, "resources/", "transfer_private", "prover");
41impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier");
42impl_remote!(TransferPublicProver, REMOTE_URL, "resources/", "transfer_public", "prover");
44impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier");
45impl_remote!(TransferPublicAsSignerProver, REMOTE_URL, "resources/", "transfer_public_as_signer", "prover");
47impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier");
48impl_remote!(TransferPrivateToPublicProver, REMOTE_URL, "resources/", "transfer_private_to_public", "prover");
50impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier");
51impl_remote!(TransferPublicToPrivateProver, REMOTE_URL, "resources/", "transfer_public_to_private", "prover");
53impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier");
54impl_remote!(JoinProver, REMOTE_URL, "resources/", "join", "prover");
56impl_local!(JoinVerifier, "resources/", "join", "verifier");
57impl_remote!(SplitProver, REMOTE_URL, "resources/", "split", "prover");
59impl_local!(SplitVerifier, "resources/", "split", "verifier");
60impl_remote!(FeePrivateProver, REMOTE_URL, "resources/", "fee_private", "prover");
62impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier");
63impl_remote!(FeePublicProver, REMOTE_URL, "resources/", "fee_public", "prover");
65impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier");
66
67#[macro_export]
68macro_rules! insert_testnet_credit_keys {
69 ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
70 paste::paste! {
71 let string = stringify!([<$variant:lower>]);
72 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_public", $crate::testnet::[<BondPublic $variant>]::load_bytes()));
73 $crate::insert_testnet_key!($map, string, $type<$network>, ("bond_validator", $crate::testnet::[<BondValidator $variant>]::load_bytes()));
74 $crate::insert_testnet_key!($map, string, $type<$network>, ("unbond_public", $crate::testnet::[<UnbondPublic $variant>]::load_bytes()));
75 $crate::insert_testnet_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::testnet::[<ClaimUnbondPublic $variant>]::load_bytes()));
76 $crate::insert_testnet_key!($map, string, $type<$network>, ("set_validator_state", $crate::testnet::[<SetValidatorState $variant>]::load_bytes()));
77 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private", $crate::testnet::[<TransferPrivate $variant>]::load_bytes()));
78 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public", $crate::testnet::[<TransferPublic $variant>]::load_bytes()));
79 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::testnet::[<TransferPublicAsSigner $variant>]::load_bytes()));
80 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::testnet::[<TransferPrivateToPublic $variant>]::load_bytes()));
81 $crate::insert_testnet_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::testnet::[<TransferPublicToPrivate $variant>]::load_bytes()));
82 $crate::insert_testnet_key!($map, string, $type<$network>, ("join", $crate::testnet::[<Join $variant>]::load_bytes()));
83 $crate::insert_testnet_key!($map, string, $type<$network>, ("split", $crate::testnet::[<Split $variant>]::load_bytes()));
84 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_private", $crate::testnet::[<FeePrivate $variant>]::load_bytes()));
85 $crate::insert_testnet_key!($map, string, $type<$network>, ("fee_public", $crate::testnet::[<FeePublic $variant>]::load_bytes()));
86 }
87 }};
88}
89
90#[macro_export]
91macro_rules! insert_testnet_key {
92 ($map:ident, $string:tt, $type:ident<$network:ident>, ($name:tt, $circuit_key:expr)) => {{
93 let key_bytes: Vec<u8> = $circuit_key.expect(&format!("Failed to load {} bytes", $string));
95 let key = $type::<$network>::from_bytes_le(&key_bytes[1..]).expect(&format!("Failed to recover {}", $string));
97 $map.insert($name.to_string(), std::sync::Arc::new(key));
99 }};
100}
101
102impl_remote!(InclusionProver, REMOTE_URL, "resources/", "inclusion", "prover");
104impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier");
105
106pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
108
109lazy_static! {
110 pub static ref INCLUSION_PROVING_KEY: Vec<u8> =
111 InclusionProver::load_bytes().expect("Failed to load inclusion proving key");
112 pub static ref INCLUSION_VERIFYING_KEY: Vec<u8> =
113 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifying key");
114}
115
116#[cfg(test)]
117mod tests {
118 use super::*;
119 use wasm_bindgen_test::*;
120 wasm_bindgen_test_configure!(run_in_browser);
121
122 #[allow(dead_code)]
123 #[wasm_bindgen_test]
124 fn test_load_bytes() {
125 BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
126 BondValidatorVerifier::load_bytes().expect("Failed to load bond_validator verifier");
127 UnbondPublicVerifier::load_bytes().expect("Failed to load unbond_public verifier");
128 ClaimUnbondPublicVerifier::load_bytes().expect("Failed to load claim_unbond_public verifier");
129 SetValidatorStateVerifier::load_bytes().expect("Failed to load set_validator_state verifier");
130 TransferPrivateVerifier::load_bytes().expect("Failed to load transfer_private verifier");
131 TransferPublicVerifier::load_bytes().expect("Failed to load transfer_public verifier");
132 TransferPublicAsSignerVerifier::load_bytes().expect("Failed to load transfer_public_as_signer verifier");
133 TransferPrivateToPublicVerifier::load_bytes().expect("Failed to load transfer_private_to_public verifier");
134 TransferPublicToPrivateVerifier::load_bytes().expect("Failed to load transfer_public_to_private verifier");
135 FeePrivateProver::load_bytes().expect("Failed to load fee_private prover");
136 FeePrivateVerifier::load_bytes().expect("Failed to load fee_private verifier");
137 FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
138 FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
139 InclusionProver::load_bytes().expect("Failed to load inclusion prover");
140 InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
141 }
142}