Skip to main content

monty_field_params

Macro monty_field_params 

Source
macro_rules! monty_field_params {
    (
        name: $name:ident,
        modulus: $modulus_hex:expr,
        uint: $uint:ty,
        byte_order: $byte_order:expr,
        multiplicative_generator: $multiplicative_generator:expr,
        doc: $doc:expr
    ) => { ... };
}
Expand description

Creates a ZST representing the Montgomery parameters for a given field modulus.

Accepts the following parameters:

  • name of the ZST representing the field modulus
  • hex serialization of the modulus
  • crypto-bigint unsigned integer type (e.g. U256)
  • number of bytes in an encoded field element
  • byte order to use when encoding/decoding field elements
  • documentation string for the field modulus type
use primefield::{ByteOrder, bigint::U256, consts::U32};

primefield::monty_field_params!(
    name: FieldParams,
    modulus: "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
    uint: U256,
    byte_order: ByteOrder::BigEndian,
    multiplicative_generator: 6,
    doc: "P-256 field modulus"
);