snarkvm_console_network/
lib.rs

1// Copyright (c) 2019-2025 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
16#![forbid(unsafe_code)]
17#![allow(clippy::too_many_arguments)]
18#![warn(clippy::cast_possible_truncation)]
19
20#[macro_use]
21extern crate lazy_static;
22
23pub use snarkvm_console_network_environment as environment;
24pub use snarkvm_console_network_environment::*;
25
26mod helpers;
27pub use helpers::*;
28
29mod canary_v0;
30pub use canary_v0::*;
31
32mod consensus_heights;
33pub use consensus_heights::*;
34
35mod mainnet_v0;
36pub use mainnet_v0::*;
37
38mod testnet_v0;
39
40pub use testnet_v0::*;
41
42pub mod prelude {
43    pub use crate::{
44        CANARY_V0_CONSENSUS_VERSION_HEIGHTS,
45        ConsensusVersion,
46        MAINNET_V0_CONSENSUS_VERSION_HEIGHTS,
47        Network,
48        TEST_CONSENSUS_VERSION_HEIGHTS,
49        TESTNET_V0_CONSENSUS_VERSION_HEIGHTS,
50        consensus_config_value,
51        environment::prelude::*,
52    };
53}
54
55use crate::environment::prelude::*;
56use snarkvm_algorithms::{
57    AlgebraicSponge,
58    crypto_hash::PoseidonSponge,
59    snark::varuna::{CircuitProvingKey, CircuitVerifyingKey, VarunaHidingMode},
60    srs::{UniversalProver, UniversalVerifier},
61};
62use snarkvm_console_algorithms::{BHP512, BHP1024, Poseidon2, Poseidon4};
63use snarkvm_console_collections::merkle_tree::{MerklePath, MerkleTree};
64use snarkvm_console_types::{Field, Group, Scalar};
65use snarkvm_curves::PairingEngine;
66
67use indexmap::IndexMap;
68use std::sync::{Arc, OnceLock};
69
70/// A helper type for the BHP Merkle tree.
71pub type BHPMerkleTree<N, const DEPTH: u8> = MerkleTree<N, BHP1024<N>, BHP512<N>, DEPTH>;
72/// A helper type for the Poseidon Merkle tree.
73pub type PoseidonMerkleTree<N, const DEPTH: u8> = MerkleTree<N, Poseidon4<N>, Poseidon2<N>, DEPTH>;
74
75/// Helper types for the Varuna parameters.
76type Fq<N> = <<N as Environment>::PairingCurve as PairingEngine>::Fq;
77pub type FiatShamir<N> = PoseidonSponge<Fq<N>, 2, 1>;
78pub type FiatShamirParameters<N> = <FiatShamir<N> as AlgebraicSponge<Fq<N>, 2>>::Parameters;
79
80/// Helper types for the Varuna proving and verifying key.
81pub(crate) type VarunaProvingKey<N> = CircuitProvingKey<<N as Environment>::PairingCurve, VarunaHidingMode>;
82pub(crate) type VarunaVerifyingKey<N> = CircuitVerifyingKey<<N as Environment>::PairingCurve>;
83
84/// A list of consensus versions and their corresponding block heights.
85static CONSENSUS_VERSION_HEIGHTS: OnceLock<[(ConsensusVersion, u32); NUM_CONSENSUS_VERSIONS]> = OnceLock::new();
86
87pub trait Network:
88    'static
89    + Environment
90    + Copy
91    + Clone
92    + Debug
93    + Eq
94    + PartialEq
95    + core::hash::Hash
96    + Serialize
97    + DeserializeOwned
98    + for<'a> Deserialize<'a>
99    + Send
100    + Sync
101{
102    /// The network ID.
103    const ID: u16;
104    /// The (long) network name.
105    const NAME: &'static str;
106    /// The short network name (used, for example, in query URLs).
107    const SHORT_NAME: &'static str;
108
109    /// The function name for the inclusion circuit.
110    const INCLUSION_FUNCTION_NAME: &'static str;
111
112    /// The fixed timestamp of the genesis block.
113    const GENESIS_TIMESTAMP: i64;
114    /// The genesis block coinbase target.
115    const GENESIS_COINBASE_TARGET: u64;
116    /// The genesis block proof target.
117    const GENESIS_PROOF_TARGET: u64;
118    /// The maximum number of solutions that can be included per block as a power of 2.
119    const MAX_SOLUTIONS_AS_POWER_OF_TWO: u8 = 2; // 4 solutions
120    /// The maximum number of solutions that can be included per block.
121    const MAX_SOLUTIONS: usize = 1 << Self::MAX_SOLUTIONS_AS_POWER_OF_TWO; // 4 solutions
122
123    /// The starting supply of Aleo credits.
124    const STARTING_SUPPLY: u64 = 1_500_000_000_000_000; // 1.5B credits
125    /// The cost in microcredits per byte for the deployment transaction.
126    const DEPLOYMENT_FEE_MULTIPLIER: u64 = 1_000; // 1 millicredit per byte
127    /// The multiplier in microcredits for each command in the constructor.
128    const CONSTRUCTOR_FEE_MULTIPLIER: u64 = 100; // 100x per command
129    /// The constant that divides the storage polynomial.
130    const EXECUTION_STORAGE_FEE_SCALING_FACTOR: u64 = 5000;
131    /// The maximum size execution transactions can be before a quadratic storage penalty applies.
132    const EXECUTION_STORAGE_PENALTY_THRESHOLD: u64 = 5000;
133    /// The cost in microcredits per constraint for the deployment transaction.
134    const SYNTHESIS_FEE_MULTIPLIER: u64 = 25; // 25 microcredits per constraint
135    /// The maximum number of variables in a deployment.
136    const MAX_DEPLOYMENT_VARIABLES: u64 = 1 << 21; // 2,097,152 variables
137    /// The maximum number of constraints in a deployment.
138    const MAX_DEPLOYMENT_CONSTRAINTS: u64 = 1 << 21; // 2,097,152 constraints
139    /// The maximum number of microcredits that can be spent as a fee.
140    const MAX_FEE: u64 = 1_000_000_000_000_000;
141    /// A list of consensus versions and their corresponding transaction spend limits in microcredits.
142    //  Note: This value must **not** decrease without considering the impact on transaction validity.
143    const TRANSACTION_SPEND_LIMIT: [(ConsensusVersion, u64); 2] =
144        [(ConsensusVersion::V1, 100_000_000), (ConsensusVersion::V10, 4_000_000)];
145    /// The compute discount approved by ARC 0005.
146    const ARC_0005_COMPUTE_DISCOUNT: u64 = 25;
147
148    /// The anchor height, defined as the expected number of blocks to reach the coinbase target.
149    const ANCHOR_HEIGHT: u32 = Self::ANCHOR_TIME as u32 / Self::BLOCK_TIME as u32;
150    /// The anchor time in seconds.
151    const ANCHOR_TIME: u16 = 25;
152    /// The expected time per block in seconds.
153    const BLOCK_TIME: u16 = 10;
154    /// The number of blocks per epoch.
155    const NUM_BLOCKS_PER_EPOCH: u32 = 3600 / Self::BLOCK_TIME as u32; // 360 blocks == ~1 hour
156
157    /// The maximum number of entries in data.
158    const MAX_DATA_ENTRIES: usize = 32;
159    /// The maximum recursive depth of an entry.
160    /// Note: This value must be strictly less than u8::MAX.
161    const MAX_DATA_DEPTH: usize = 32;
162    /// The maximum number of fields in data (must not exceed u16::MAX).
163    #[allow(clippy::cast_possible_truncation)]
164    const MAX_DATA_SIZE_IN_FIELDS: u32 = ((128 * 1024 * 8) / Field::<Self>::SIZE_IN_DATA_BITS) as u32;
165
166    /// The minimum number of entries in a struct.
167    const MIN_STRUCT_ENTRIES: usize = 1; // This ensures the struct is not empty.
168    /// The maximum number of entries in a struct.
169    const MAX_STRUCT_ENTRIES: usize = Self::MAX_DATA_ENTRIES;
170
171    /// The minimum number of elements in an array.
172    const MIN_ARRAY_ELEMENTS: usize = 1; // This ensures the array is not empty.
173    /// The maximum number of elements in an array.
174    const MAX_ARRAY_ELEMENTS: usize = Self::MAX_DATA_ENTRIES;
175
176    /// The minimum number of entries in a record.
177    const MIN_RECORD_ENTRIES: usize = 1; // This accounts for 'record.owner'.
178    /// The maximum number of entries in a record.
179    const MAX_RECORD_ENTRIES: usize = Self::MIN_RECORD_ENTRIES.saturating_add(Self::MAX_DATA_ENTRIES);
180
181    /// The maximum program size by number of characters.
182    const MAX_PROGRAM_SIZE: usize = 100_000; // 100 KB
183
184    /// The maximum number of mappings in a program.
185    const MAX_MAPPINGS: usize = 31;
186    /// The maximum number of functions in a program.
187    const MAX_FUNCTIONS: usize = 31;
188    /// The maximum number of structs in a program.
189    const MAX_STRUCTS: usize = 10 * Self::MAX_FUNCTIONS;
190    /// The maximum number of records in a program.
191    const MAX_RECORDS: usize = 10 * Self::MAX_FUNCTIONS;
192    /// The maximum number of closures in a program.
193    const MAX_CLOSURES: usize = 2 * Self::MAX_FUNCTIONS;
194    /// The maximum number of operands in an instruction.
195    const MAX_OPERANDS: usize = Self::MAX_INPUTS;
196    /// The maximum number of instructions in a closure or function.
197    const MAX_INSTRUCTIONS: usize = u16::MAX as usize;
198    /// The maximum number of commands in finalize.
199    const MAX_COMMANDS: usize = u16::MAX as usize;
200    /// The maximum number of write commands in finalize.
201    const MAX_WRITES: u16 = 16;
202    /// The maximum number of `position` commands in finalize.
203    const MAX_POSITIONS: usize = u8::MAX as usize;
204
205    /// The maximum number of inputs per transition.
206    const MAX_INPUTS: usize = 16;
207    /// The maximum number of outputs per transition.
208    const MAX_OUTPUTS: usize = 16;
209
210    /// The maximum number of imports.
211    const MAX_IMPORTS: usize = 64;
212
213    /// The maximum number of bytes in a transaction.
214    // Note: This value must **not** be decreased as it would invalidate existing transactions.
215    const MAX_TRANSACTION_SIZE: usize = 128_000; // 128 kB
216
217    /// The state root type.
218    type StateRoot: Bech32ID<Field<Self>>;
219    /// The block hash type.
220    type BlockHash: Bech32ID<Field<Self>>;
221    /// The ratification ID type.
222    type RatificationID: Bech32ID<Field<Self>>;
223    /// The transaction ID type.
224    type TransactionID: Bech32ID<Field<Self>>;
225    /// The transition ID type.
226    type TransitionID: Bech32ID<Field<Self>>;
227    /// The transmission checksum type.
228    type TransmissionChecksum: IntegerType;
229
230    /// A list of (consensus_version, block_height) pairs indicating when each consensus version takes effect.
231    /// Documentation for what is changed at each version can be found in `N::CONSENSUS_VERSION`
232    /// Do not read this directly outside of tests, use `N::CONSENSUS_VERSION_HEIGHTS()` instead.
233    const _CONSENSUS_VERSION_HEIGHTS: [(ConsensusVersion, u32); NUM_CONSENSUS_VERSIONS];
234
235    ///  A list of (consensus_version, size) pairs indicating the maximum number of validators in a committee.
236    //  Note: This value must **not** decrease without considering the impact on serialization.
237    //  Decreasing this value will break backwards compatibility of serialization without explicit
238    //  declaration of migration based on round number rather than block height.
239    //  Increasing this value will require a migration to prevent forking during network upgrades.
240    const MAX_CERTIFICATES: [(ConsensusVersion, u16); 5];
241
242    /// Returns the list of consensus versions.
243    #[allow(non_snake_case)]
244    #[cfg(not(any(test, feature = "test", feature = "test_consensus_heights")))]
245    fn CONSENSUS_VERSION_HEIGHTS() -> &'static [(ConsensusVersion, u32); NUM_CONSENSUS_VERSIONS] {
246        // Initialize the consensus version heights directly from the constant.
247        CONSENSUS_VERSION_HEIGHTS.get_or_init(|| Self::_CONSENSUS_VERSION_HEIGHTS)
248    }
249    /// Returns the list of test consensus versions.
250    #[allow(non_snake_case)]
251    #[cfg(any(test, feature = "test", feature = "test_consensus_heights"))]
252    fn CONSENSUS_VERSION_HEIGHTS() -> &'static [(ConsensusVersion, u32); NUM_CONSENSUS_VERSIONS] {
253        // NOTE: this function may panic, as it is only called during startup.
254        CONSENSUS_VERSION_HEIGHTS.get_or_init(load_test_consensus_heights)
255    }
256
257    /// A set of incrementing consensus version heights used for tests.
258    #[allow(non_snake_case)]
259    #[cfg(any(test, feature = "test", feature = "test_consensus_heights"))]
260    const TEST_CONSENSUS_VERSION_HEIGHTS: [(ConsensusVersion, u32); NUM_CONSENSUS_VERSIONS] =
261        TEST_CONSENSUS_VERSION_HEIGHTS;
262    /// Returns the consensus version which is active at the given height.
263    #[allow(non_snake_case)]
264    fn CONSENSUS_VERSION(seek_height: u32) -> anyhow::Result<ConsensusVersion> {
265        match Self::CONSENSUS_VERSION_HEIGHTS().binary_search_by(|(_, height)| height.cmp(&seek_height)) {
266            // If a consensus version was found at this height, return it.
267            Ok(index) => Ok(Self::CONSENSUS_VERSION_HEIGHTS()[index].0),
268            // If the specified height was not found, determine whether to return an appropriate version.
269            Err(index) => {
270                if index == 0 {
271                    Err(anyhow!("Expected consensus version 1 to exist at height 0."))
272                } else {
273                    // Return the appropriate version belonging to the height *lower* than the sought height.
274                    Ok(Self::CONSENSUS_VERSION_HEIGHTS()[index - 1].0)
275                }
276            }
277        }
278    }
279    /// Returns the height at which a specified consensus version becomes active.
280    #[allow(non_snake_case)]
281    fn CONSENSUS_HEIGHT(version: ConsensusVersion) -> Result<u32> {
282        Ok(Self::CONSENSUS_VERSION_HEIGHTS().get(version as usize - 1).ok_or(anyhow!("Invalid consensus version"))?.1)
283    }
284    /// Returns the last `MAX_CERTIFICATES` value.
285    #[allow(non_snake_case)]
286    fn LATEST_MAX_CERTIFICATES() -> Result<u16> {
287        Self::MAX_CERTIFICATES.last().map_or(Err(anyhow!("No MAX_CERTIFICATES defined.")), |(_, value)| Ok(*value))
288    }
289
290    /// Returns the block height where the the inclusion proof will be updated.
291    #[allow(non_snake_case)]
292    fn INCLUSION_UPGRADE_HEIGHT() -> Result<u32>;
293
294    /// Returns the genesis block bytes.
295    fn genesis_bytes() -> &'static [u8];
296
297    /// Returns the restrictions list as a JSON-compatible string.
298    fn restrictions_list_as_str() -> &'static str;
299
300    /// Returns the proving key for the given function name in the v0 version of `credits.aleo`.
301    fn get_credits_v0_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>>;
302
303    /// Returns the verifying key for the given function name in the v0 version of `credits.aleo`.
304    fn get_credits_v0_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>>;
305
306    /// Returns the proving key for the given function name in `credits.aleo`.
307    fn get_credits_proving_key(function_name: String) -> Result<&'static Arc<VarunaProvingKey<Self>>>;
308
309    /// Returns the verifying key for the given function name in `credits.aleo`.
310    fn get_credits_verifying_key(function_name: String) -> Result<&'static Arc<VarunaVerifyingKey<Self>>>;
311
312    /// Returns the `proving key` for the inclusion_v0 circuit.
313    fn inclusion_v0_proving_key() -> &'static Arc<VarunaProvingKey<Self>>;
314
315    /// Returns the `verifying key` for the inclusion_v0 circuit.
316    fn inclusion_v0_verifying_key() -> &'static Arc<VarunaVerifyingKey<Self>>;
317
318    /// Returns the `proving key` for the inclusion circuit.
319    fn inclusion_proving_key() -> &'static Arc<VarunaProvingKey<Self>>;
320
321    /// Returns the `verifying key` for the inclusion circuit.
322    fn inclusion_verifying_key() -> &'static Arc<VarunaVerifyingKey<Self>>;
323
324    /// Returns the powers of `G`.
325    fn g_powers() -> &'static Vec<Group<Self>>;
326
327    /// Returns the scalar multiplication on the generator `G`.
328    fn g_scalar_multiply(scalar: &Scalar<Self>) -> Group<Self>;
329
330    /// Returns the Varuna universal prover.
331    fn varuna_universal_prover() -> &'static UniversalProver<Self::PairingCurve>;
332
333    /// Returns the Varuna universal verifier.
334    fn varuna_universal_verifier() -> &'static UniversalVerifier<Self::PairingCurve>;
335
336    /// Returns the sponge parameters for Varuna.
337    fn varuna_fs_parameters() -> &'static FiatShamirParameters<Self>;
338
339    /// Returns the commitment domain as a constant field element.
340    fn commitment_domain() -> Field<Self>;
341
342    /// Returns the encryption domain as a constant field element.
343    fn encryption_domain() -> Field<Self>;
344
345    /// Returns the graph key domain as a constant field element.
346    fn graph_key_domain() -> Field<Self>;
347
348    /// Returns the serial number domain as a constant field element.
349    fn serial_number_domain() -> Field<Self>;
350
351    /// Returns a BHP commitment with an input hasher of 256-bits and randomizer.
352    fn commit_bhp256(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
353
354    /// Returns a BHP commitment with an input hasher of 512-bits and randomizer.
355    fn commit_bhp512(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
356
357    /// Returns a BHP commitment with an input hasher of 768-bits and randomizer.
358    fn commit_bhp768(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
359
360    /// Returns a BHP commitment with an input hasher of 1024-bits and randomizer.
361    fn commit_bhp1024(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
362
363    /// Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
364    fn commit_ped64(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
365
366    /// Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
367    fn commit_ped128(input: &[bool], randomizer: &Scalar<Self>) -> Result<Field<Self>>;
368
369    /// Returns a BHP commitment with an input hasher of 256-bits and randomizer.
370    fn commit_to_group_bhp256(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
371
372    /// Returns a BHP commitment with an input hasher of 512-bits and randomizer.
373    fn commit_to_group_bhp512(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
374
375    /// Returns a BHP commitment with an input hasher of 768-bits and randomizer.
376    fn commit_to_group_bhp768(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
377
378    /// Returns a BHP commitment with an input hasher of 1024-bits and randomizer.
379    fn commit_to_group_bhp1024(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
380
381    /// Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
382    fn commit_to_group_ped64(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
383
384    /// Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
385    fn commit_to_group_ped128(input: &[bool], randomizer: &Scalar<Self>) -> Result<Group<Self>>;
386
387    /// Returns the BHP hash with an input hasher of 256-bits.
388    fn hash_bhp256(input: &[bool]) -> Result<Field<Self>>;
389
390    /// Returns the BHP hash with an input hasher of 512-bits.
391    fn hash_bhp512(input: &[bool]) -> Result<Field<Self>>;
392
393    /// Returns the BHP hash with an input hasher of 768-bits.
394    fn hash_bhp768(input: &[bool]) -> Result<Field<Self>>;
395
396    /// Returns the BHP hash with an input hasher of 1024-bits.
397    fn hash_bhp1024(input: &[bool]) -> Result<Field<Self>>;
398
399    /// Returns the Keccak hash with a 256-bit output.
400    fn hash_keccak256(input: &[bool]) -> Result<Vec<bool>>;
401
402    /// Returns the Keccak hash with a 384-bit output.
403    fn hash_keccak384(input: &[bool]) -> Result<Vec<bool>>;
404
405    /// Returns the Keccak hash with a 512-bit output.
406    fn hash_keccak512(input: &[bool]) -> Result<Vec<bool>>;
407
408    /// Returns the Pedersen hash for a given (up to) 64-bit input.
409    fn hash_ped64(input: &[bool]) -> Result<Field<Self>>;
410
411    /// Returns the Pedersen hash for a given (up to) 128-bit input.
412    fn hash_ped128(input: &[bool]) -> Result<Field<Self>>;
413
414    /// Returns the Poseidon hash with an input rate of 2.
415    fn hash_psd2(input: &[Field<Self>]) -> Result<Field<Self>>;
416
417    /// Returns the Poseidon hash with an input rate of 4.
418    fn hash_psd4(input: &[Field<Self>]) -> Result<Field<Self>>;
419
420    /// Returns the Poseidon hash with an input rate of 8.
421    fn hash_psd8(input: &[Field<Self>]) -> Result<Field<Self>>;
422
423    /// Returns the SHA-3 hash with a 256-bit output.
424    fn hash_sha3_256(input: &[bool]) -> Result<Vec<bool>>;
425
426    /// Returns the SHA-3 hash with a 384-bit output.
427    fn hash_sha3_384(input: &[bool]) -> Result<Vec<bool>>;
428
429    /// Returns the SHA-3 hash with a 512-bit output.
430    fn hash_sha3_512(input: &[bool]) -> Result<Vec<bool>>;
431
432    /// Returns the extended Poseidon hash with an input rate of 2.
433    fn hash_many_psd2(input: &[Field<Self>], num_outputs: u16) -> Vec<Field<Self>>;
434
435    /// Returns the extended Poseidon hash with an input rate of 4.
436    fn hash_many_psd4(input: &[Field<Self>], num_outputs: u16) -> Vec<Field<Self>>;
437
438    /// Returns the extended Poseidon hash with an input rate of 8.
439    fn hash_many_psd8(input: &[Field<Self>], num_outputs: u16) -> Vec<Field<Self>>;
440
441    /// Returns the BHP hash with an input hasher of 256-bits.
442    fn hash_to_group_bhp256(input: &[bool]) -> Result<Group<Self>>;
443
444    /// Returns the BHP hash with an input hasher of 512-bits.
445    fn hash_to_group_bhp512(input: &[bool]) -> Result<Group<Self>>;
446
447    /// Returns the BHP hash with an input hasher of 768-bits.
448    fn hash_to_group_bhp768(input: &[bool]) -> Result<Group<Self>>;
449
450    /// Returns the BHP hash with an input hasher of 1024-bits.
451    fn hash_to_group_bhp1024(input: &[bool]) -> Result<Group<Self>>;
452
453    /// Returns the Pedersen hash for a given (up to) 64-bit input.
454    fn hash_to_group_ped64(input: &[bool]) -> Result<Group<Self>>;
455
456    /// Returns the Pedersen hash for a given (up to) 128-bit input.
457    fn hash_to_group_ped128(input: &[bool]) -> Result<Group<Self>>;
458
459    /// Returns the Poseidon hash with an input rate of 2 on the affine curve.
460    fn hash_to_group_psd2(input: &[Field<Self>]) -> Result<Group<Self>>;
461
462    /// Returns the Poseidon hash with an input rate of 4 on the affine curve.
463    fn hash_to_group_psd4(input: &[Field<Self>]) -> Result<Group<Self>>;
464
465    /// Returns the Poseidon hash with an input rate of 8 on the affine curve.
466    fn hash_to_group_psd8(input: &[Field<Self>]) -> Result<Group<Self>>;
467
468    /// Returns the Poseidon hash with an input rate of 2 on the scalar field.
469    fn hash_to_scalar_psd2(input: &[Field<Self>]) -> Result<Scalar<Self>>;
470
471    /// Returns the Poseidon hash with an input rate of 4 on the scalar field.
472    fn hash_to_scalar_psd4(input: &[Field<Self>]) -> Result<Scalar<Self>>;
473
474    /// Returns the Poseidon hash with an input rate of 8 on the scalar field.
475    fn hash_to_scalar_psd8(input: &[Field<Self>]) -> Result<Scalar<Self>>;
476
477    /// Returns a Merkle tree with a BHP leaf hasher of 1024-bits and a BHP path hasher of 512-bits.
478    fn merkle_tree_bhp<const DEPTH: u8>(leaves: &[Vec<bool>]) -> Result<BHPMerkleTree<Self, DEPTH>>;
479
480    /// Returns a Merkle tree with a Poseidon leaf hasher with input rate of 4 and a Poseidon path hasher with input rate of 2.
481    fn merkle_tree_psd<const DEPTH: u8>(leaves: &[Vec<Field<Self>>]) -> Result<PoseidonMerkleTree<Self, DEPTH>>;
482
483    /// Returns `true` if the given Merkle path is valid for the given root and leaf.
484    #[allow(clippy::ptr_arg)]
485    fn verify_merkle_path_bhp<const DEPTH: u8>(
486        path: &MerklePath<Self, DEPTH>,
487        root: &Field<Self>,
488        leaf: &Vec<bool>,
489    ) -> bool;
490
491    /// Returns `true` if the given Merkle path is valid for the given root and leaf.
492    #[allow(clippy::ptr_arg)]
493    fn verify_merkle_path_psd<const DEPTH: u8>(
494        path: &MerklePath<Self, DEPTH>,
495        root: &Field<Self>,
496        leaf: &Vec<Field<Self>>,
497    ) -> bool;
498}