ark_test_curves::fp

Macro MontFp

Source
macro_rules! MontFp {
    ($c0:expr) => { ... };
}
Expand description

Construct a Fp<MontBackend<T, N>, N> element from a literal string. This should be used primarily for constructing constant field elements; in a non-const context, Fp::from_str is preferable.

§Panics

If the integer represented by the string cannot fit in the number of limbs of the Fp, this macro results in a

  • compile-time error if used in a const context
  • run-time error otherwise.

§Usage

use ark_bls12_381::Fq;
const ONE: Fq = MontFp!("1");
const NEG_ONE: Fq = MontFp!("-1");

fn check_correctness() {
    assert_eq!(ONE, Fq::one());
    assert_eq!(Fq::from_str("1").unwrap(), ONE);
    assert_eq!(NEG_ONE, -Fq::one());
}