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
Source§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
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 DigestPrimitive for NistP256
Available on crate feature sha256 only.
impl DigestPrimitive for NistP256
sha256 only.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 PartialOrd for NistP256
impl PartialOrd for NistP256
Source§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
Source§type CurveGroup = ProjectivePoint
type CurveGroup = ProjectivePoint
Source§impl ProjectiveArithmetic for NistP256
impl ProjectiveArithmetic for NistP256
Source§type ProjectivePoint = ProjectivePoint
type ProjectivePoint = ProjectivePoint
Source§impl SignPrimitive<NistP256> for Scalar
Available on crate feature ecdsa only.
impl SignPrimitive<NistP256> for Scalar
ecdsa only.Source§fn try_sign_prehashed<K>(
&self,
k: K,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
) -> Result<(Signature<C>, Option<RecoveryId>), Error>
fn try_sign_prehashed<K>( &self, k: K, z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>, ) -> Result<(Signature<C>, Option<RecoveryId>), Error>
Source§fn try_sign_prehashed_rfc6979<D>(
&self,
z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>,
ad: &[u8],
) -> Result<(Signature<C>, Option<RecoveryId>), Error>
fn try_sign_prehashed_rfc6979<D>( &self, z: GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>, ad: &[u8], ) -> Result<(Signature<C>, Option<RecoveryId>), Error>
Source§fn try_sign_digest_rfc6979<D>(
&self,
msg_digest: D,
ad: &[u8],
) -> Result<(Signature<C>, Option<RecoveryId>), Error>
fn try_sign_digest_rfc6979<D>( &self, msg_digest: D, ad: &[u8], ) -> Result<(Signature<C>, Option<RecoveryId>), Error>
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.Source§impl VerifyPrimitive<NistP256> for AffinePoint
Available on crate feature ecdsa only.
impl VerifyPrimitive<NistP256> for AffinePoint
ecdsa only.impl Copy for NistP256
impl Eq for NistP256
impl PrimeCurve for NistP256
impl StructuralPartialEq for NistP256
Auto Trait Implementations§
impl Freeze for NistP256
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
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.