Skip to content

Commit

Permalink
p521: get rid of private MODULUS_HEX constant (#970)
Browse files Browse the repository at this point in the history
It has extra unnecessary zeros to allow decoding as a U576 which are
undesirable in a string representation.
  • Loading branch information
tarcieri authored Nov 11, 2023
1 parent 91a5b32 commit cbbf27e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions p521/src/arithmetic/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ use elliptic_curve::{
#[cfg(target_pointer_width = "32")]
use super::util;

/// Constant representing the modulus serialized as hex.
/// p = 2^{521} − 1
const MODULUS_HEX: &str = "00000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";

pub(crate) const MODULUS: U576 = U576::from_be_hex(MODULUS_HEX);
/// Field modulus: p = 2^{521} − 1
pub(crate) const MODULUS: U576 = U576::from_be_hex("00000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

/// Element of the secp521r1 base field used for curve coordinates.
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -469,7 +466,7 @@ impl Field for FieldElement {
impl PrimeField for FieldElement {
type Repr = FieldBytes;

const MODULUS: &'static str = MODULUS_HEX;
const MODULUS: &'static str = "1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
const NUM_BITS: u32 = 521;
const CAPACITY: u32 = 520;
const TWO_INV: Self = Self::from_u64(2).invert_unchecked();
Expand Down

0 comments on commit cbbf27e

Please sign in to comment.