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
sourceimpl AffineArithmetic for NistP256
impl AffineArithmetic for NistP256
type AffinePoint = AffinePoint<NistP256>
type AffinePoint = AffinePoint<NistP256>
sourceimpl AssociatedOid for NistP256
impl AssociatedOid for NistP256
sourceconst OID: ObjectIdentifier = _
const OID: ObjectIdentifier = _
sourceimpl Curve for NistP256
impl Curve for NistP256
type UInt = UInt<_>
type UInt = UInt<_>
256-bit integer type used for internally representing field elements.
sourceconst 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)
sourceimpl DigestPrimitive for NistP256
Available on crate features ecdsa-core
and sha256
only.
impl DigestPrimitive for NistP256
ecdsa-core
and sha256
only.sourceimpl GroupDigest for NistP256
impl GroupDigest for NistP256
type FieldElement = FieldElement
type FieldElement = FieldElement
sourcefn hash_from_bytes<'a, X>(
msgs: &[&[u8]],
dst: &'a [u8]
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
fn hash_from_bytes<'a, X>(
msgs: &[&[u8]],
dst: &'a [u8]
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
sourcefn encode_from_bytes<'a, X>(
msgs: &[&[u8]],
dst: &'a [u8]
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
fn encode_from_bytes<'a, X>(
msgs: &[&[u8]],
dst: &'a [u8]
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
sourceimpl JwkParameters for NistP256
Available on crate feature jwk
only.
impl JwkParameters for NistP256
jwk
only.sourceconst CRV: &'static str = "P-256"
const CRV: &'static str = "P-256"
crv
parameter which identifies a particular elliptic curve
as defined in RFC 7518 Section 6.2.1.1:
https://tools.ietf.org/html/rfc7518#section-6.2.1.1 Read moresourceimpl Ord for NistP256
impl Ord for NistP256
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialOrd<NistP256> for NistP256
impl PartialOrd<NistP256> for NistP256
sourcefn partial_cmp(&self, other: &NistP256) -> Option<Ordering>
fn partial_cmp(&self, other: &NistP256) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl PointCompaction for NistP256
impl PointCompaction for NistP256
sourceconst COMPACT_POINTS: bool = false
const COMPACT_POINTS: bool = false
NIST P-256 points are typically uncompressed.
sourceimpl PointCompression for NistP256
impl PointCompression for NistP256
sourceconst COMPRESS_POINTS: bool = false
const COMPRESS_POINTS: bool = false
NIST P-256 points are typically uncompressed.
sourceimpl PrimeCurveArithmetic for NistP256
impl PrimeCurveArithmetic for NistP256
type CurveGroup = ProjectivePoint<NistP256>
type CurveGroup = ProjectivePoint<NistP256>
sourceimpl PrimeOrderCurve for NistP256
impl PrimeOrderCurve for NistP256
sourceconst EQUATION_A: FieldElement = _
const EQUATION_A: FieldElement = _
a = -3
sourceconst GENERATOR: (FieldElement, FieldElement) = _
const GENERATOR: (FieldElement, FieldElement) = _
Base point of P-256.
Defined in FIPS 186-4 § D.1.2.3:
Gₓ = 6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296
Gᵧ = 4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5
type FieldElement = FieldElement
type FieldElement = FieldElement
sourceconst ZERO: FieldElement = FieldElement::ZERO
const ZERO: FieldElement = FieldElement::ZERO
sourceconst ONE: FieldElement = FieldElement::ONE
const ONE: FieldElement = FieldElement::ONE
sourceconst EQUATION_B: FieldElement = _
const EQUATION_B: FieldElement = _
b
in the curve equation.sourceimpl ProjectiveArithmetic for NistP256
impl ProjectiveArithmetic for NistP256
type ProjectivePoint = ProjectivePoint<NistP256>
type ProjectivePoint = ProjectivePoint<NistP256>
sourceimpl SignPrimitive<NistP256> for Scalar
Available on crate feature ecdsa-core
only.
impl SignPrimitive<NistP256> for Scalar
ecdsa-core
only.sourceimpl VerifyPrimitive<NistP256> for AffinePoint
Available on crate feature ecdsa-core
only.
impl VerifyPrimitive<NistP256> for AffinePoint
ecdsa-core
only.sourceimpl VoprfParameters for NistP256
Available on crate feature voprf
only.
impl VoprfParameters for NistP256
voprf
only.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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
self
, then passes self.deref()
into the pipe function.impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read morefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read morefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read morefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read morefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more