Skip to main content

miden_precompiles/
lib.rs

1#![no_std]
2
3extern crate alloc;
4
5#[cfg(feature = "std")]
6extern crate std;
7
8use miden_core::deferred::PrecompileRegistry;
9
10mod codec;
11mod hash;
12mod math;
13
14pub use codec::{chunks_to_bytes_exact, n_chunks};
15pub use hash::{HashAssertNode, HashFunction, HashPrecompile, keccak256::Keccak256Precompile};
16pub use math::{
17    curve::{
18        CurveCoefficient, CurveId, CurveNodeRef, CurvePoint, CurvePrecompile, CurveSpec, K1_A_PTR,
19        K1_B_PTR, K1_GROUP_PTR, SECP256K1_GENERATOR_X, SECP256K1_GENERATOR_Y, SECP256K1_ID,
20        ShortWeierstrassSpec, curve_coefficients,
21    },
22    k1_base::K1Base,
23    k1_scalar::K1Scalar,
24    u256::U256,
25    uint::{
26        K1_BASE_BOUND_PTR, K1_SCALAR_BOUND_PTR, Limbs, ONE_LIMBS, TWO_LIMBS, U256_BOUND_PTR,
27        UintDomain, UintNodeRef, UintPrecompile, UintSpec, ZERO_LIMBS,
28    },
29};
30
31// REGISTRY
32// ================================================================================================
33
34/// Returns a [`PrecompileRegistry`] containing the precompiles provided by this crate.
35///
36/// TODO: If constructing the official registry becomes measurable overhead, consider a
37/// cached/shared registry for default processor initialization.
38pub fn registry() -> PrecompileRegistry {
39    PrecompileRegistry::new()
40        .with_precompile(Keccak256Precompile::default())
41        .with_precompile(UintPrecompile)
42        .with_precompile(CurvePrecompile)
43}