Expand description
Prism standard-library numerics sub-crate.
prism-numerics realizes the numerics Layer-3 of the standard
library named in Wiki ADR-031: it declares the
arithmetic-domain axis traits (BigIntAxis, FixedPointAxis,
FieldAxis, RingAxis) through the axis! SDK
macro and supplies parametric reference impls plus matching
ConstrainedTypeShape carriers per the wiki’s ADR-031 roster.
§Scope
Every axis kernel takes (input: &[u8], out: &mut [u8]) per
ADR-030’s signature contract. Axis impls are generic in their
natural axis (byte-width, Q-format split) so applications can
instantiate the impl their model needs without re-rolling the
kernel body.
BigIntAxis—(a + b) / (a - b) / (a * b) mod 2^(8*N). Parametric:BigIntModularNumeric<BYTES>withBYTESin[1, MAX_BIG_INT_BYTES]. Aliases:BigInt64Numeric,BigInt128Numeric,BigInt256Numeric,BigInt512Numeric. Shape:BigIntShape<BYTES>.FixedPointAxis— Q-format arithmetic on a 64-bit container. Parametric:FixedPointQNumeric<INT_BITS, FRAC_BITS>. Aliases:FixedPointQ16_16Numeric,FixedPointQ32_32Numeric,FixedPointQ1_31Numeric,FixedPointQ48_16Numeric. Shape:FixedPointShape<I, F>.FieldAxis— prime-field arithmetic. The reference implPrimeFieldNumericSecp256k1fixes the modulus atp = 2^256 - 2^32 - 977; alternative primes are operational policy per ADR-031. Shape:FieldElementShape<BYTES>.RingAxis— finite-ring arithmetic. Parametric:Gf2NumericAxisN<BYTES>for GF(2) overNbytes (bitwise XOR / AND). Aliases:Gf2NumericAxis,Gf2NumericAxis128,Gf2NumericAxis512. Shape:Gf2RingShape<BYTES>.
§ConstrainedTypeShape declarations
Per ADR-031’s shape-declaration commitment (BigInt<MaxBits>,
FixedPoint<I, F>, FieldElement<P>, …), each axis has a
matching ConstrainedTypeShape carrier so downstream
prism_model! invocations can use the shape as Input / Output
through the SDK macros. Every shape is GroundedShape + IntoBindingValue-bound for use as a model Output per ADR-027.
Per ADR-017’s closure rule, shape identity flows through
(SITE_COUNT, CONSTRAINTS) — distinct parametric instantiations
with the same site count content-address identically.
§Closure under uor-foundation (ADR-013)
Every axis trait has ::uor_foundation::pipeline::AxisExtension as
a supertrait (enforced by axis!). Parametric axis impls
hand-write their AxisExtension impl since the axis!-emitted
companion macro takes :ident and cannot apply to generic types
(the hand-written impls replicate the companion macro’s dispatch
arms verbatim).
§See also
Re-exports§
pub use bigint::BigInt128Numeric;pub use bigint::BigInt256Numeric;pub use bigint::BigInt512Numeric;pub use bigint::BigInt64Numeric;pub use bigint::BigIntAxis;pub use bigint::BigIntModularNumeric;pub use bigint::BigIntShape;pub use bigint::MAX_BIG_INT_BYTES;pub use field::FieldAxis;pub use field::FieldElementShape;pub use field::PrimeFieldNumericSecp256k1;pub use fixed_point::FixedPointAxis;pub use fixed_point::FixedPointQ16_16Numeric;pub use fixed_point::FixedPointQ1_31Numeric;pub use fixed_point::FixedPointQ32_32Numeric;pub use fixed_point::FixedPointQ48_16Numeric;pub use fixed_point::FixedPointQNumeric;pub use fixed_point::FixedPointShape;pub use polynomial::Polynomial15Mod256;pub use polynomial::Polynomial7Mod256;pub use polynomial::PolynomialShape;pub use ring::Gf2NumericAxis;pub use ring::Gf2NumericAxis128;pub use ring::Gf2NumericAxis512;pub use ring::Gf2NumericAxisN;pub use ring::Gf2RingShape;pub use ring::RingAxis;pub use ring::MAX_GF2_BYTES;
Modules§
- bigint
BigIntAxisdeclaration + parametric modular-arithmetic impls + shape.- field
FieldAxisdeclaration, secp256k1 base-field reference impl, and parametricFieldElementShape<BYTES>.- fixed_
point FixedPointAxisdeclaration + parametric Q-format impl + shape.- polynomial
PolynomialShape<MAX_DEGREE, COEFF_BYTES>— ADR-031 named numerics shape carrier.- ring
RingAxisdeclaration + parametric GF(2)-over-N-bytes impl + shape.- verbs
- Layer-3 substrate-Term verb bodies per Wiki ADR-024 + Wiki ADR-031 + Wiki ADR-055 (universal substrate-Term verb body discipline, supersedes ADR-054 RA2).
Macros§
- axis_
extension_ impl_ for_ big_ int_ axis - Wiki ADR-030 companion macro: instantiate
AxisExtensionfor a concrete struct implementing this axis trait. The macro emits animpl AxisExtension for <StructIdent>block that delegatesdispatch_kernelto the axis-trait methods perKERNEL_*id. The orphan-rule-conformant per-struct impl mechanism replacing the blanketimpl<T: <axis>> AxisExtension for T(which would violate Rust’s orphan rule from any crate that does not defineAxisExtension). - axis_
extension_ impl_ for_ field_ axis - Wiki ADR-030 companion macro: instantiate
AxisExtensionfor a concrete struct implementing this axis trait. The macro emits animpl AxisExtension for <StructIdent>block that delegatesdispatch_kernelto the axis-trait methods perKERNEL_*id. The orphan-rule-conformant per-struct impl mechanism replacing the blanketimpl<T: <axis>> AxisExtension for T(which would violate Rust’s orphan rule from any crate that does not defineAxisExtension). - axis_
extension_ impl_ for_ fixed_ point_ axis - Wiki ADR-030 companion macro: instantiate
AxisExtensionfor a concrete struct implementing this axis trait. The macro emits animpl AxisExtension for <StructIdent>block that delegatesdispatch_kernelto the axis-trait methods perKERNEL_*id. The orphan-rule-conformant per-struct impl mechanism replacing the blanketimpl<T: <axis>> AxisExtension for T(which would violate Rust’s orphan rule from any crate that does not defineAxisExtension). - axis_
extension_ impl_ for_ ring_ axis - Wiki ADR-030 companion macro: instantiate
AxisExtensionfor a concrete struct implementing this axis trait. The macro emits animpl AxisExtension for <StructIdent>block that delegatesdispatch_kernelto the axis-trait methods perKERNEL_*id. The orphan-rule-conformant per-struct impl mechanism replacing the blanketimpl<T: <axis>> AxisExtension for T(which would violate Rust’s orphan rule from any crate that does not defineAxisExtension).
Constants§
- STANDARD_
LIBRARY_ VERSION - Wiki ADR-031 standard-library version banner.