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 Curve for NistP256
impl Curve for NistP256
source§impl CurveArithmetic for NistP256
Available on crate feature arithmetic only.
impl CurveArithmetic for NistP256
arithmetic only.§type AffinePoint = AffinePoint<NistP256>
type AffinePoint = AffinePoint<NistP256>
§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.§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>where
X: ExpandMsg<'a>,
Self::Scalar: FromOkm,
fn hash_to_scalar<'a, X>( msgs: &[&[u8]], dsts: &'a [&'a [u8]] ) -> Result<Self::Scalar, Error>where X: ExpandMsg<'a>, Self::Scalar: FromOkm,
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.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
§type FieldElement = FieldElement
type FieldElement = FieldElement
§type PointArithmetic = EquationAIsMinusThree
type PointArithmetic = EquationAIsMinusThree
source§const EQUATION_B: FieldElement = _
const EQUATION_B: FieldElement = _
b in the curve equation.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>where
K: AsRef<Self> + Invert<Output = CtOption<Self>>,
fn try_sign_prehashed<K>( &self, k: K, z: &GenericArray<u8, <C as Curve>::FieldBytesSize> ) -> Result<(Signature<C>, Option<RecoveryId>), Error>where K: AsRef<Self> + Invert<Output = CtOption<Self>>,
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§fn verify_digest<D>(
&self,
msg_digest: D,
sig: &Signature<C>
) -> Result<(), Error>where
D: FixedOutput<OutputSize = <C as Curve>::FieldBytesSize>,
fn verify_digest<D>( &self, msg_digest: D, sig: &Signature<C> ) -> Result<(), Error>where D: FixedOutput<OutputSize = <C as Curve>::FieldBytesSize>,
digest 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.§impl<T> TryConv for T
impl<T> TryConv for T
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.