pub struct NistP256;
Expand description
NIST P-256 elliptic curve.
This curve is also known as prime256v1 (ANSI X9.62) and secp256r1 (SECG) and is specified in FIPS 186-4: Digital Signature Standard (DSS):
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
It’s included in the US National Security Agency’s “Suite B” and is widely used in protocols like TLS and the associated X.509 PKI.
Its equation is y² = x³ - 3x + b
over a ~256-bit prime field where b
is
the “verifiably random”† constant:
b = 41058363725152142129326129780047268409114441015993725554835256314039467401291
† NOTE: the specific origins of this constant have never been fully disclosed (it is the SHA-1 digest of an inexplicable NSA-selected constant)
Trait Implementations§
source§impl AffineArithmetic for NistP256
impl AffineArithmetic for NistP256
§type AffinePoint = AffinePoint
type AffinePoint = AffinePoint
source§impl AffineXCoordinate<NistP256> for AffinePoint
impl AffineXCoordinate<NistP256> for AffinePoint
source§fn x(&self) -> FieldBytes
fn x(&self) -> FieldBytes
source§impl Curve for NistP256
impl Curve for NistP256
§type UInt = UInt<crypto_bigint::::uint::U256::{constant#0}>
type UInt = UInt<crypto_bigint::::uint::U256::{constant#0}>
256-bit integer type used for internally representing field elements.
source§const ORDER: U256 = _
const ORDER: U256 = _
Order of NIST P-256’s elliptic curve group (i.e. scalar modulus).
n = FFFFFFFF 00000000 FFFFFFFF FFFFFFFF BCE6FAAD A7179E84 F3B9CAC2 FC632551
Calculating the order
One way to calculate the order is with GP/PARI
:
p = (2^224) * (2^32 - 1) + 2^192 + 2^96 - 1
b = 41058363725152142129326129780047268409114441015993725554835256314039467401291
E = ellinit([Mod(-3, p), Mod(b, p)])
default(parisize, 120000000)
n = ellsea(E)
isprime(n)
source§impl DecompactPoint<NistP256> for AffinePoint
impl DecompactPoint<NistP256> for AffinePoint
source§fn decompact(x_bytes: &FieldBytes) -> CtOption<Self>
fn decompact(x_bytes: &FieldBytes) -> CtOption<Self>
source§impl DecompressPoint<NistP256> for AffinePoint
impl DecompressPoint<NistP256> for AffinePoint
source§fn decompress(x_bytes: &FieldBytes, y_is_odd: Choice) -> CtOption<Self>
fn decompress(x_bytes: &FieldBytes, y_is_odd: Choice) -> CtOption<Self>
source§impl FromEncodedPoint<NistP256> for AffinePoint
impl FromEncodedPoint<NistP256> for AffinePoint
source§fn from_encoded_point(encoded_point: &EncodedPoint) -> CtOption<Self>
fn from_encoded_point(encoded_point: &EncodedPoint) -> CtOption<Self>
Attempts to parse the given EncodedPoint
as an SEC1-encoded AffinePoint
.
Returns
None
value if encoded_point
is not on the secp256r1 curve.
source§impl FromEncodedPoint<NistP256> for ProjectivePoint
impl FromEncodedPoint<NistP256> for ProjectivePoint
source§fn from_encoded_point(p: &EncodedPoint) -> CtOption<Self>
fn from_encoded_point(p: &EncodedPoint) -> CtOption<Self>
EncodedPoint
.source§impl Ord for NistP256
impl Ord for NistP256
source§impl PartialEq<NistP256> for NistP256
impl PartialEq<NistP256> for NistP256
source§impl PartialOrd<NistP256> for NistP256
impl PartialOrd<NistP256> for NistP256
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PointCompaction for NistP256
impl PointCompaction for NistP256
source§const COMPACT_POINTS: bool = false
const COMPACT_POINTS: bool = false
NIST P-256 points are typically uncompressed.
source§impl PointCompression for NistP256
impl PointCompression for NistP256
source§const COMPRESS_POINTS: bool = false
const COMPRESS_POINTS: bool = false
NIST P-256 points are typically uncompressed.
source§impl PrimeCurveArithmetic for NistP256
impl PrimeCurveArithmetic for NistP256
§type CurveGroup = ProjectivePoint
type CurveGroup = ProjectivePoint
source§impl ProjectiveArithmetic for NistP256
impl ProjectiveArithmetic for NistP256
§type ProjectivePoint = ProjectivePoint
type ProjectivePoint = ProjectivePoint
source§impl ToCompactEncodedPoint<NistP256> for AffinePoint
impl ToCompactEncodedPoint<NistP256> for AffinePoint
source§fn to_compact_encoded_point(&self) -> CtOption<EncodedPoint>
fn to_compact_encoded_point(&self) -> CtOption<EncodedPoint>
Serialize this value as a SEC1 compact EncodedPoint
source§impl ToEncodedPoint<NistP256> for AffinePoint
impl ToEncodedPoint<NistP256> for AffinePoint
source§fn to_encoded_point(&self, compress: bool) -> EncodedPoint
fn to_encoded_point(&self, compress: bool) -> EncodedPoint
EncodedPoint
, optionally applying
point compression.source§impl ToEncodedPoint<NistP256> for ProjectivePoint
impl ToEncodedPoint<NistP256> for ProjectivePoint
source§fn to_encoded_point(&self, compress: bool) -> EncodedPoint
fn to_encoded_point(&self, compress: bool) -> EncodedPoint
EncodedPoint
, optionally applying
point compression.impl Copy for NistP256
impl Eq for NistP256
impl PrimeCurve for NistP256
impl StructuralEq for NistP256
impl StructuralPartialEq for NistP256
Auto Trait Implementations§
impl RefUnwindSafe for NistP256
impl Send for NistP256
impl Sync for NistP256
impl Unpin for NistP256
impl UnwindSafe for NistP256
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<C> ValidatePublicKey for Cwhere
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<<C as Curve>::UInt as ArrayEncoding>::ByteSize: ModulusSize,
impl<C> ValidatePublicKey for Cwhere C: Curve + ProjectiveArithmetic, <C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>, <<C as Curve>::UInt as ArrayEncoding>::ByteSize: ModulusSize,
source§fn validate_public_key(
secret_key: &SecretKey<C>,
public_key: &EncodedPoint<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>
) -> Result<(), Error>
fn validate_public_key( secret_key: &SecretKey<C>, public_key: &EncodedPoint<<<C as Curve>::UInt as ArrayEncoding>::ByteSize> ) -> Result<(), Error>
EncodedPoint
is a valid public key for the
provided secret value.