Skip to main content

miden_precompiles/math/
k1_scalar.rs

1//! secp256k1 scalar-field domain for the uint precompile.
2
3use miden_core::Felt;
4
5use crate::math::uint::{Limbs, UintSpec};
6
7/// Marker type for the secp256k1 scalar field.
8#[derive(Debug, Default, Clone, Copy)]
9pub struct K1Scalar;
10
11impl K1Scalar {
12    /// Stable local domain selector carried in uint precompile tags.
13    pub const ID: Felt = Felt::new_unchecked(2);
14
15    /// Modulus of the secp256k1 scalar field, little-endian u32 limbs.
16    pub const MODULUS: Limbs = [
17        0xd036_4141,
18        0xbfd2_5e8c,
19        0xaf48_a03b,
20        0xbaae_dce6,
21        0xffff_fffe,
22        0xffff_ffff,
23        0xffff_ffff,
24        0xffff_ffff,
25    ];
26}
27
28impl UintSpec for K1Scalar {
29    const ID: Felt = Self::ID;
30    const ENCODED_MODULUS: Limbs = Self::MODULUS;
31    const IS_PRIME_FIELD: bool = true;
32}