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 NIST SP 800-186: Recommendations for Discrete Logarithm-based Cryptography: Elliptic Curve Domain Parameters.
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 unknown NSA-selected constant)
Trait Implementations§
Source§impl AssociatedOid for NistP256
Available on crate feature pkcs8
only.
impl AssociatedOid for NistP256
pkcs8
only.Source§const OID: ObjectIdentifier
const OID: ObjectIdentifier
Source§impl Curve for NistP256
impl Curve for NistP256
Source§impl CurveArithmetic for NistP256
Available on crate feature arithmetic
only.
impl CurveArithmetic for NistP256
arithmetic
only.Source§type AffinePoint = AffinePoint<NistP256>
type AffinePoint = AffinePoint<NistP256>
Source§type ProjectivePoint = ProjectivePoint<NistP256>
type ProjectivePoint = ProjectivePoint<NistP256>
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 FieldBytesEncoding<NistP256> for U256
impl FieldBytesEncoding<NistP256> for U256
Source§fn decode_field_bytes(field_bytes: &FieldBytes) -> Self
fn decode_field_bytes(field_bytes: &FieldBytes) -> Self
Source§fn encode_field_bytes(&self) -> FieldBytes
fn encode_field_bytes(&self) -> FieldBytes
Source§impl GroupDigest for NistP256
Available on crate features hash2curve
and arithmetic
only.
impl GroupDigest for NistP256
hash2curve
and arithmetic
only.Source§type FieldElement = FieldElement
type FieldElement = FieldElement
Source§fn hash_from_bytes<'a, X>(
msgs: &[&[u8]],
dsts: &'a [&'a [u8]],
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
fn hash_from_bytes<'a, X>(
msgs: &[&[u8]],
dsts: &'a [&'a [u8]],
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
Source§fn encode_from_bytes<'a, X>(
msgs: &[&[u8]],
dsts: &'a [&'a [u8]],
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
fn encode_from_bytes<'a, X>(
msgs: &[&[u8]],
dsts: &'a [&'a [u8]],
) -> Result<Self::ProjectivePoint, Error>where
X: ExpandMsg<'a>,
Source§fn hash_to_scalar<'a, X>(
msgs: &[&[u8]],
dsts: &'a [&'a [u8]],
) -> Result<Self::Scalar, Error>
fn hash_to_scalar<'a, X>( msgs: &[&[u8]], dsts: &'a [&'a [u8]], ) -> Result<Self::Scalar, Error>
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 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
Available on crate feature arithmetic
only.
impl PrimeCurveArithmetic for NistP256
arithmetic
only.Source§type CurveGroup = ProjectivePoint<NistP256>
type CurveGroup = ProjectivePoint<NistP256>
Source§impl PrimeCurveParams for NistP256
Available on crate feature arithmetic
only.Adapted from NIST SP 800-186 § G.1.2: Curve P-256.
impl PrimeCurveParams for NistP256
arithmetic
only.Adapted from NIST SP 800-186 § G.1.2: Curve P-256.
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 NIST SP 800-186 § G.1.2:
Gₓ = 6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296
Gᵧ = 4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5
Source§const EQUATION_B: FieldElement
const EQUATION_B: FieldElement
b
in the curve equation.Source§type FieldElement = FieldElement
type FieldElement = FieldElement
Source§type PointArithmetic = EquationAIsMinusThree
type PointArithmetic = EquationAIsMinusThree
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§fn try_sign_prehashed<K>(
&self,
k: K,
z: &GenericArray<u8, <C as Curve>::FieldBytesSize>,
) -> Result<(Signature<C>, Option<RecoveryId>), Error>
fn try_sign_prehashed<K>( &self, k: K, z: &GenericArray<u8, <C as Curve>::FieldBytesSize>, ) -> Result<(Signature<C>, Option<RecoveryId>), Error>
Source§fn try_sign_prehashed_rfc6979<D>(
&self,
z: &GenericArray<u8, <C as Curve>::FieldBytesSize>,
ad: &[u8],
) -> Result<(Signature<C>, Option<RecoveryId>), Error>where
Self: From<ScalarPrimitive<C>> + Invert<Output = CtOption<Self>>,
D: Digest<OutputSize = <C as Curve>::FieldBytesSize> + BlockSizeUser + FixedOutput + FixedOutputReset,
fn try_sign_prehashed_rfc6979<D>(
&self,
z: &GenericArray<u8, <C as Curve>::FieldBytesSize>,
ad: &[u8],
) -> Result<(Signature<C>, Option<RecoveryId>), Error>where
Self: From<ScalarPrimitive<C>> + Invert<Output = CtOption<Self>>,
D: Digest<OutputSize = <C as Curve>::FieldBytesSize> + BlockSizeUser + FixedOutput + FixedOutputReset,
rfc6979
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§fn verify_prehashed(
&self,
z: &GenericArray<u8, <C as Curve>::FieldBytesSize>,
sig: &Signature<C>,
) -> Result<(), Error>
fn verify_prehashed( &self, z: &GenericArray<u8, <C as Curve>::FieldBytesSize>, sig: &Signature<C>, ) -> Result<(), Error>
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 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,
Source§impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
impl<T> DynAssociatedOid for Twhere
T: AssociatedOid,
Source§fn oid(&self) -> ObjectIdentifier
fn oid(&self) -> ObjectIdentifier
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§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.Source§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.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.Source§impl<C> ValidatePublicKey for Cwhere
C: CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
impl<C> ValidatePublicKey for Cwhere
C: CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
Source§fn validate_public_key(
secret_key: &SecretKey<C>,
public_key: &EncodedPoint<<C as Curve>::FieldBytesSize>,
) -> Result<(), Error>
fn validate_public_key( secret_key: &SecretKey<C>, public_key: &EncodedPoint<<C as Curve>::FieldBytesSize>, ) -> Result<(), Error>
EncodedPoint
is a valid public key for the
provided secret value.