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
Available on crate feature arithmetic
only.
impl AffineArithmetic for NistP256
arithmetic
only.§type AffinePoint = AffinePoint<NistP256>
type AffinePoint = AffinePoint<NistP256>
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 DigestPrimitive for NistP256
Available on crate features ecdsa-core
and sha256
only.
impl DigestPrimitive for NistP256
ecdsa-core
and sha256
only.source§impl GroupDigest for NistP256
Available on crate features hash2curve
and arithmetic
only.
impl GroupDigest for NistP256
hash2curve
and arithmetic
only.§type FieldElement = FieldElement
type FieldElement = FieldElement
source§fn 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>,
source§fn 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>,
source§impl JwkParameters for NistP256
Available on crate feature jwk
only.
impl JwkParameters for NistP256
jwk
only.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
Available on crate feature arithmetic
only.
impl PrimeCurveArithmetic for NistP256
arithmetic
only.§type CurveGroup = ProjectivePoint<NistP256>
type CurveGroup = ProjectivePoint<NistP256>
source§impl PrimeCurveParams for NistP256
Available on crate feature arithmetic
only.
impl PrimeCurveParams for NistP256
arithmetic
only.source§const EQUATION_A: FieldElement = _
const EQUATION_A: FieldElement = _
a = -3
source§const 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
source§const ZERO: FieldElement = FieldElement::ZERO
const ZERO: FieldElement = FieldElement::ZERO
source§const ONE: FieldElement = FieldElement::ONE
const ONE: FieldElement = FieldElement::ONE
source§const EQUATION_B: FieldElement = _
const EQUATION_B: FieldElement = _
b
in the curve equation.source§impl ProjectiveArithmetic for NistP256
Available on crate feature arithmetic
only.
impl ProjectiveArithmetic for NistP256
arithmetic
only.§type ProjectivePoint = ProjectivePoint<NistP256>
type ProjectivePoint = ProjectivePoint<NistP256>
source§impl ScalarArithmetic for NistP256
Available on crate feature arithmetic
only.
impl ScalarArithmetic for NistP256
arithmetic
only.source§impl SignPrimitive<NistP256> for Scalar
Available on crate features ecdsa-core
and ecdsa
only.
impl SignPrimitive<NistP256> for Scalar
ecdsa-core
and ecdsa
only.source§impl VerifyPrimitive<NistP256> for AffinePoint
Available on crate features ecdsa-core
and ecdsa
only.
impl VerifyPrimitive<NistP256> for AffinePoint
ecdsa-core
and ecdsa
only.source§impl 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§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
§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,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§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 more§fn 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 more§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<'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,
self
, then passes self.as_mut()
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 more§fn 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 more§fn 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 more§fn 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 more§fn 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 more§fn 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 more§fn 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.§fn 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.§fn 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.§fn 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.§fn 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.