Skip to main content

snarkvm_parameters/mainnet/
mod.rs

1// Copyright (c) 2019-2026 Provable Inc.
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16pub mod genesis;
17pub use genesis::*;
18
19pub mod powers;
20pub use powers::*;
21
22/// The restrictions list as a JSON-compatible string.
23pub 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
28// Degrees
29#[cfg(not(feature = "no-embedded-srs"))]
30impl_local!(Degree15, "resources/", "powers-of-beta-15", "usrs");
31#[cfg(feature = "no-embedded-srs")]
32impl_remote!(Degree15, REMOTE_URLS, "resources/", "powers-of-beta-15", "usrs");
33impl_remote!(Degree16, REMOTE_URLS, "resources/", "powers-of-beta-16", "usrs");
34impl_remote!(Degree17, REMOTE_URLS, "resources/", "powers-of-beta-17", "usrs");
35impl_remote!(Degree18, REMOTE_URLS, "resources/", "powers-of-beta-18", "usrs");
36impl_remote!(Degree19, REMOTE_URLS, "resources/", "powers-of-beta-19", "usrs");
37impl_remote!(Degree20, REMOTE_URLS, "resources/", "powers-of-beta-20", "usrs");
38impl_remote!(Degree21, REMOTE_URLS, "resources/", "powers-of-beta-21", "usrs");
39impl_remote!(Degree22, REMOTE_URLS, "resources/", "powers-of-beta-22", "usrs");
40impl_remote!(Degree23, REMOTE_URLS, "resources/", "powers-of-beta-23", "usrs");
41impl_remote!(Degree24, REMOTE_URLS, "resources/", "powers-of-beta-24", "usrs");
42impl_remote!(Degree25, REMOTE_URLS, "resources/", "powers-of-beta-25", "usrs");
43// TODO (nkls): restore on CI.
44// The SRS is only used for proving and we don't currently support provers of
45// this size. When a users wants to create a proof, they load the appropriate
46// powers for the circuit in `batch_circuit_setup` which calls `max_degree`
47// based on the domain size.
48#[cfg(feature = "large_params")]
49impl_remote!(Degree26, REMOTE_URLS, "resources/", "powers-of-beta-26", "usrs");
50#[cfg(feature = "large_params")]
51impl_remote!(Degree27, REMOTE_URLS, "resources/", "powers-of-beta-27", "usrs");
52#[cfg(feature = "large_params")]
53impl_remote!(Degree28, REMOTE_URLS, "resources/", "powers-of-beta-28", "usrs");
54
55// Shifted Degrees
56#[cfg(not(feature = "no-embedded-srs"))]
57impl_local!(ShiftedDegree15, "resources/", "shifted-powers-of-beta-15", "usrs");
58#[cfg(feature = "no-embedded-srs")]
59impl_remote!(ShiftedDegree15, REMOTE_URLS, "resources/", "shifted-powers-of-beta-15", "usrs");
60#[cfg(not(feature = "no-embedded-srs"))]
61impl_local!(ShiftedDegree16, "resources/", "shifted-powers-of-beta-16", "usrs");
62#[cfg(feature = "no-embedded-srs")]
63impl_remote!(ShiftedDegree16, REMOTE_URLS, "resources/", "shifted-powers-of-beta-16", "usrs");
64impl_remote!(ShiftedDegree17, REMOTE_URLS, "resources/", "shifted-powers-of-beta-17", "usrs");
65impl_remote!(ShiftedDegree18, REMOTE_URLS, "resources/", "shifted-powers-of-beta-18", "usrs");
66impl_remote!(ShiftedDegree19, REMOTE_URLS, "resources/", "shifted-powers-of-beta-19", "usrs");
67impl_remote!(ShiftedDegree20, REMOTE_URLS, "resources/", "shifted-powers-of-beta-20", "usrs");
68impl_remote!(ShiftedDegree21, REMOTE_URLS, "resources/", "shifted-powers-of-beta-21", "usrs");
69impl_remote!(ShiftedDegree22, REMOTE_URLS, "resources/", "shifted-powers-of-beta-22", "usrs");
70impl_remote!(ShiftedDegree23, REMOTE_URLS, "resources/", "shifted-powers-of-beta-23", "usrs");
71impl_remote!(ShiftedDegree24, REMOTE_URLS, "resources/", "shifted-powers-of-beta-24", "usrs");
72impl_remote!(ShiftedDegree25, REMOTE_URLS, "resources/", "shifted-powers-of-beta-25", "usrs");
73// TODO (nkls): restore on CI.
74// See `Degree28` above for context.
75#[cfg(feature = "large_params")]
76impl_remote!(ShiftedDegree26, REMOTE_URLS, "resources/", "shifted-powers-of-beta-26", "usrs");
77#[cfg(feature = "large_params")]
78impl_remote!(ShiftedDegree27, REMOTE_URLS, "resources/", "shifted-powers-of-beta-27", "usrs");
79
80// Powers of Beta Times Gamma * G
81impl_local!(Gamma, "resources/", "powers-of-beta-gamma", "usrs");
82// Negative Powers of Beta in G2
83impl_local!(NegBeta, "resources/", "neg-powers-of-beta", "usrs");
84// Negative Powers of Beta in G2
85impl_local!(BetaH, "resources/", "beta-h", "usrs");
86
87// BondPublic
88impl_remote!(BondPublicProver, REMOTE_URLS, "resources/", "bond_public", "prover", "credits");
89impl_local!(BondPublicVerifier, "resources/", "bond_public", "verifier", "credits");
90// BondValidator
91impl_remote!(BondValidatorProver, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits");
92impl_local!(BondValidatorVerifier, "resources/", "bond_validator", "verifier", "credits");
93// UnbondPublic
94impl_remote!(UnbondPublicProver, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits");
95impl_local!(UnbondPublicVerifier, "resources/", "unbond_public", "verifier", "credits");
96// ClaimUnbondPublic
97impl_remote!(ClaimUnbondPublicProver, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits");
98impl_local!(ClaimUnbondPublicVerifier, "resources/", "claim_unbond_public", "verifier", "credits");
99// SetValidatorState
100impl_remote!(SetValidatorStateProver, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits");
101impl_local!(SetValidatorStateVerifier, "resources/", "set_validator_state", "verifier", "credits");
102// TransferPrivate
103impl_remote!(TransferPrivateProver, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits");
104impl_local!(TransferPrivateVerifier, "resources/", "transfer_private", "verifier", "credits");
105// TransferPublic
106impl_remote!(TransferPublicProver, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits");
107impl_local!(TransferPublicVerifier, "resources/", "transfer_public", "verifier", "credits");
108// TransferPublicAsSigner
109impl_remote!(TransferPublicAsSignerProver, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits");
110impl_local!(TransferPublicAsSignerVerifier, "resources/", "transfer_public_as_signer", "verifier", "credits");
111// TransferPrivateToPublic
112impl_remote!(TransferPrivateToPublicProver, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits");
113impl_local!(TransferPrivateToPublicVerifier, "resources/", "transfer_private_to_public", "verifier", "credits");
114// TransferPublicToPrivate
115impl_remote!(TransferPublicToPrivateProver, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits");
116impl_local!(TransferPublicToPrivateVerifier, "resources/", "transfer_public_to_private", "verifier", "credits");
117// Join
118impl_remote!(JoinProver, REMOTE_URLS, "resources/", "join", "prover", "credits");
119impl_local!(JoinVerifier, "resources/", "join", "verifier", "credits");
120// Split
121impl_remote!(SplitProver, REMOTE_URLS, "resources/", "split", "prover", "credits");
122impl_local!(SplitVerifier, "resources/", "split", "verifier", "credits");
123// FeePrivate
124impl_remote!(FeePrivateProver, REMOTE_URLS, "resources/", "fee_private", "prover", "credits");
125impl_local!(FeePrivateVerifier, "resources/", "fee_private", "verifier", "credits");
126// FeePublic
127impl_remote!(FeePublicProver, REMOTE_URLS, "resources/", "fee_public", "prover", "credits");
128impl_local!(FeePublicVerifier, "resources/", "fee_public", "verifier", "credits");
129// Upgrade
130impl_remote!(UpgradeProver, REMOTE_URLS, "resources/", "upgrade", "prover", "credits");
131impl_local!(UpgradeVerifier, "resources/", "upgrade", "verifier", "credits");
132
133// V0 Credits Keys
134
135// BondPublic
136impl_remote!(BondPublicV0Prover, REMOTE_URLS, "resources/", "bond_public", "prover", "credits_v0");
137impl_local!(BondPublicV0Verifier, "resources/", "bond_public", "verifier", "credits_v0");
138// BondValidator
139impl_remote!(BondValidatorV0Prover, REMOTE_URLS, "resources/", "bond_validator", "prover", "credits_v0");
140impl_local!(BondValidatorV0Verifier, "resources/", "bond_validator", "verifier", "credits_v0");
141// UnbondPublic
142impl_remote!(UnbondPublicV0Prover, REMOTE_URLS, "resources/", "unbond_public", "prover", "credits_v0");
143impl_local!(UnbondPublicV0Verifier, "resources/", "unbond_public", "verifier", "credits_v0");
144// ClaimUnbondPublic
145impl_remote!(ClaimUnbondPublicV0Prover, REMOTE_URLS, "resources/", "claim_unbond_public", "prover", "credits_v0");
146impl_local!(ClaimUnbondPublicV0Verifier, "resources/", "claim_unbond_public", "verifier", "credits_v0");
147// SetValidatorState
148impl_remote!(SetValidatorStateV0Prover, REMOTE_URLS, "resources/", "set_validator_state", "prover", "credits_v0");
149impl_local!(SetValidatorStateV0Verifier, "resources/", "set_validator_state", "verifier", "credits_v0");
150// TransferPrivate
151impl_remote!(TransferPrivateV0Prover, REMOTE_URLS, "resources/", "transfer_private", "prover", "credits_v0");
152impl_local!(TransferPrivateV0Verifier, "resources/", "transfer_private", "verifier", "credits_v0");
153// TransferPublic
154impl_remote!(TransferPublicV0Prover, REMOTE_URLS, "resources/", "transfer_public", "prover", "credits_v0");
155impl_local!(TransferPublicV0Verifier, "resources/", "transfer_public", "verifier", "credits_v0");
156// TransferPublicAsSigner
157impl_remote!(TransferPublicAsSignerV0Prover, REMOTE_URLS, "resources/", "transfer_public_as_signer", "prover", "credits_v0");
158impl_local!(TransferPublicAsSignerV0Verifier, "resources/", "transfer_public_as_signer", "verifier", "credits_v0");
159// TransferPrivateToPublic
160impl_remote!(TransferPrivateToPublicV0Prover, REMOTE_URLS, "resources/", "transfer_private_to_public", "prover", "credits_v0");
161impl_local!(TransferPrivateToPublicV0Verifier, "resources/", "transfer_private_to_public", "verifier", "credits_v0");
162// TransferPublicToPrivate
163impl_remote!(TransferPublicToPrivateV0Prover, REMOTE_URLS, "resources/", "transfer_public_to_private", "prover", "credits_v0");
164impl_local!(TransferPublicToPrivateV0Verifier, "resources/", "transfer_public_to_private", "verifier", "credits_v0");
165// Join
166impl_remote!(JoinV0Prover, REMOTE_URLS, "resources/", "join", "prover", "credits_v0");
167impl_local!(JoinV0Verifier, "resources/", "join", "verifier", "credits_v0");
168// Split
169impl_remote!(SplitV0Prover, REMOTE_URLS, "resources/", "split", "prover", "credits_v0");
170impl_local!(SplitV0Verifier, "resources/", "split", "verifier", "credits_v0");
171// FeePrivate
172impl_remote!(FeePrivateV0Prover, REMOTE_URLS, "resources/", "fee_private", "prover", "credits_v0");
173impl_local!(FeePrivateV0Verifier, "resources/", "fee_private", "verifier", "credits_v0");
174// FeePublic
175impl_remote!(FeePublicV0Prover, REMOTE_URLS, "resources/", "fee_public", "prover", "credits_v0");
176impl_local!(FeePublicV0Verifier, "resources/", "fee_public", "verifier", "credits_v0");
177// Upgrade
178impl_remote!(UpgradeV0Prover, REMOTE_URLS, "resources/", "upgrade", "prover", "credits_v0");
179impl_local!(UpgradeV0Verifier, "resources/", "upgrade", "verifier", "credits_v0");
180
181#[macro_export]
182macro_rules! insert_credit_keys {
183    ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
184        paste::paste! {
185            let string = stringify!([<$variant:lower>]);
186            $crate::insert_key!($map, string, $type<$network>, ("bond_public", $crate::mainnet::[<BondPublic $variant>]::load_bytes()));
187            $crate::insert_key!($map, string, $type<$network>, ("bond_validator", $crate::mainnet::[<BondValidator $variant>]::load_bytes()));
188            $crate::insert_key!($map, string, $type<$network>, ("unbond_public", $crate::mainnet::[<UnbondPublic $variant>]::load_bytes()));
189            $crate::insert_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::mainnet::[<ClaimUnbondPublic $variant>]::load_bytes()));
190            $crate::insert_key!($map, string, $type<$network>, ("set_validator_state", $crate::mainnet::[<SetValidatorState $variant>]::load_bytes()));
191            $crate::insert_key!($map, string, $type<$network>, ("transfer_private", $crate::mainnet::[<TransferPrivate $variant>]::load_bytes()));
192            $crate::insert_key!($map, string, $type<$network>, ("transfer_public", $crate::mainnet::[<TransferPublic $variant>]::load_bytes()));
193            $crate::insert_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::mainnet::[<TransferPublicAsSigner $variant>]::load_bytes()));
194            $crate::insert_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::mainnet::[<TransferPrivateToPublic $variant>]::load_bytes()));
195            $crate::insert_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::mainnet::[<TransferPublicToPrivate $variant>]::load_bytes()));
196            $crate::insert_key!($map, string, $type<$network>, ("join", $crate::mainnet::[<Join $variant>]::load_bytes()));
197            $crate::insert_key!($map, string, $type<$network>, ("split", $crate::mainnet::[<Split $variant>]::load_bytes()));
198            $crate::insert_key!($map, string, $type<$network>, ("fee_private", $crate::mainnet::[<FeePrivate $variant>]::load_bytes()));
199            $crate::insert_key!($map, string, $type<$network>, ("fee_public", $crate::mainnet::[<FeePublic $variant>]::load_bytes()));
200            $crate::insert_key!($map, string, $type<$network>, ("upgrade", $crate::mainnet::[<Upgrade $variant>]::load_bytes()));
201        }
202    }};
203}
204
205#[macro_export]
206macro_rules! insert_credit_v0_keys {
207    ($map:ident, $type:ident<$network:ident>, $variant:ident) => {{
208        paste::paste! {
209            let string = stringify!([<$variant:lower>]);
210            $crate::insert_key!($map, string, $type<$network>, ("bond_public", $crate::mainnet::[<BondPublicV0 $variant>]::load_bytes()));
211            $crate::insert_key!($map, string, $type<$network>, ("bond_validator", $crate::mainnet::[<BondValidatorV0 $variant>]::load_bytes()));
212            $crate::insert_key!($map, string, $type<$network>, ("unbond_public", $crate::mainnet::[<UnbondPublicV0 $variant>]::load_bytes()));
213            $crate::insert_key!($map, string, $type<$network>, ("claim_unbond_public", $crate::mainnet::[<ClaimUnbondPublicV0 $variant>]::load_bytes()));
214            $crate::insert_key!($map, string, $type<$network>, ("set_validator_state", $crate::mainnet::[<SetValidatorStateV0 $variant>]::load_bytes()));
215            $crate::insert_key!($map, string, $type<$network>, ("transfer_private", $crate::mainnet::[<TransferPrivateV0 $variant>]::load_bytes()));
216            $crate::insert_key!($map, string, $type<$network>, ("transfer_public", $crate::mainnet::[<TransferPublicV0 $variant>]::load_bytes()));
217            $crate::insert_key!($map, string, $type<$network>, ("transfer_public_as_signer", $crate::mainnet::[<TransferPublicAsSignerV0 $variant>]::load_bytes()));
218            $crate::insert_key!($map, string, $type<$network>, ("transfer_private_to_public", $crate::mainnet::[<TransferPrivateToPublicV0 $variant>]::load_bytes()));
219            $crate::insert_key!($map, string, $type<$network>, ("transfer_public_to_private", $crate::mainnet::[<TransferPublicToPrivateV0 $variant>]::load_bytes()));
220            $crate::insert_key!($map, string, $type<$network>, ("join", $crate::mainnet::[<JoinV0 $variant>]::load_bytes()));
221            $crate::insert_key!($map, string, $type<$network>, ("split", $crate::mainnet::[<SplitV0 $variant>]::load_bytes()));
222            $crate::insert_key!($map, string, $type<$network>, ("fee_private", $crate::mainnet::[<FeePrivateV0 $variant>]::load_bytes()));
223            $crate::insert_key!($map, string, $type<$network>, ("fee_public", $crate::mainnet::[<FeePublicV0 $variant>]::load_bytes()));
224            $crate::insert_key!($map, string, $type<$network>, ("upgrade", $crate::mainnet::[<UpgradeV0 $variant>]::load_bytes()));
225        }
226    }};
227}
228
229#[macro_export]
230macro_rules! insert_key {
231    ($map:ident, $string:tt, $type:ident<$network:ident>, ($name:tt, $circuit_key:expr)) => {{
232        // Load the circuit key bytes.
233        let key_bytes: Vec<u8> = $circuit_key.expect(&format!("Failed to load {} bytes", $string));
234        // Recover the circuit key.
235        let key = $type::<$network>::from_bytes_le(&key_bytes[1..]).expect(&format!("Failed to recover {}", $string));
236        // Insert the circuit key.
237        $map.insert($name.to_string(), std::sync::Arc::new(key));
238    }};
239}
240
241// Inclusion
242impl_remote!(InclusionV0Prover, REMOTE_URLS, "resources/", "inclusion", "prover", "credits_v0");
243impl_local!(InclusionV0Verifier, "resources/", "inclusion", "verifier", "credits_v0");
244impl_remote!(InclusionProver, REMOTE_URLS, "resources/", "inclusion", "prover", "credits");
245impl_local!(InclusionVerifier, "resources/", "inclusion", "verifier", "credits");
246
247/// The function name for the inclusion circuit.
248pub const NETWORK_INCLUSION_FUNCTION_NAME: &str = "inclusion";
249
250lazy_static! {
251    pub static ref INCLUSION_V0_PROVING_KEY: Vec<u8> =
252        InclusionV0Prover::load_bytes().expect("Failed to load inclusion_v0 proving key");
253    pub static ref INCLUSION_V0_VERIFYING_KEY: Vec<u8> =
254        InclusionV0Verifier::load_bytes().expect("Failed to load inclusion_v0 verifying key");
255    pub static ref INCLUSION_PROVING_KEY: Vec<u8> = InclusionProver::load_bytes().expect("Failed to load inclusion proving key");
256    pub static ref INCLUSION_VERIFYING_KEY: Vec<u8> =
257        InclusionVerifier::load_bytes().expect("Failed to load inclusion verifying key");
258}
259
260// Translation
261impl_remote!(TranslationCreditsProver, REMOTE_URLS, "resources/", "translation_credits", "prover", "credits");
262impl_local!(TranslationCreditsVerifier, "resources/", "translation_credits", "verifier", "credits");
263
264lazy_static! {
265    pub static ref TRANSLATION_CREDITS_PROVING_KEY: Vec<u8> =
266        TranslationCreditsProver::load_bytes().expect("Failed to load translation proving key");
267    pub static ref TRANSLATION_CREDITS_VERIFYING_KEY: Vec<u8> =
268        TranslationCreditsVerifier::load_bytes().expect("Failed to load translation verifying key");
269}
270
271#[cfg(test)]
272mod tests {
273    use super::*;
274    use wasm_bindgen_test::*;
275    wasm_bindgen_test_configure!(run_in_browser);
276
277    #[ignore]
278    #[test]
279    fn test_load_bytes_mini() {
280        Degree16::load_bytes().expect("Failed to load degree 16");
281        BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
282        FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
283        FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
284        InclusionProver::load_bytes().expect("Failed to load inclusion prover");
285        InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
286    }
287
288    #[allow(dead_code)]
289    #[wasm_bindgen_test]
290    fn test_load_bytes() {
291        Degree16::load_bytes().expect("Failed to load degree 16");
292        Degree17::load_bytes().expect("Failed to load degree 17");
293        Degree18::load_bytes().expect("Failed to load degree 18");
294        Degree19::load_bytes().expect("Failed to load degree 19");
295        Degree20::load_bytes().expect("Failed to load degree 20");
296        BondPublicVerifier::load_bytes().expect("Failed to load bond_public verifier");
297        BondValidatorVerifier::load_bytes().expect("Failed to load bond_validator verifier");
298        UnbondPublicVerifier::load_bytes().expect("Failed to load unbond_public verifier");
299        ClaimUnbondPublicVerifier::load_bytes().expect("Failed to load claim_unbond_public verifier");
300        SetValidatorStateVerifier::load_bytes().expect("Failed to load set_validator_state verifier");
301        TransferPrivateVerifier::load_bytes().expect("Failed to load transfer_private verifier");
302        TransferPublicVerifier::load_bytes().expect("Failed to load transfer_public verifier");
303        TransferPublicAsSignerVerifier::load_bytes().expect("Failed to load transfer_public_as_signer verifier");
304        TransferPrivateToPublicVerifier::load_bytes().expect("Failed to load transfer_private_to_public verifier");
305        TransferPublicToPrivateVerifier::load_bytes().expect("Failed to load transfer_public_to_private verifier");
306        FeePrivateProver::load_bytes().expect("Failed to load fee_private prover");
307        FeePrivateVerifier::load_bytes().expect("Failed to load fee_private verifier");
308        FeePublicProver::load_bytes().expect("Failed to load fee_public prover");
309        FeePublicVerifier::load_bytes().expect("Failed to load fee_public verifier");
310        UpgradeProver::load_bytes().expect("Failed to load upgrade prover");
311        UpgradeVerifier::load_bytes().expect("Failed to load upgrade verifier");
312        InclusionProver::load_bytes().expect("Failed to load inclusion prover");
313        InclusionVerifier::load_bytes().expect("Failed to load inclusion verifier");
314    }
315}