pub struct Secp256k1;Expand description
secp256k1 (K-256) elliptic curve.
Specified in Certicom’s SECG in “SEC 2: Recommended Elliptic Curve Domain Parameters”:
https://www.secg.org/sec2-v2.pdf
The curve’s equation is y² = x³ + 7 over a ~256-bit prime field.
It’s primarily notable for usage in Bitcoin and other cryptocurrencies, particularly in conjunction with the Elliptic Curve Digital Signature Algorithm (ECDSA).
Trait Implementations§
Source§impl AssociatedOid for Secp256k1
Available on crate feature pkcs8 only.
impl AssociatedOid for Secp256k1
Available on crate feature
pkcs8 only.Source§const OID: ObjectIdentifier
const OID: ObjectIdentifier
The OID associated with this type.
Source§impl CurveArithmetic for Secp256k1
Available on crate feature arithmetic only.
impl CurveArithmetic for Secp256k1
Available on crate feature
arithmetic only.Source§type AffinePoint = AffinePoint
type AffinePoint = AffinePoint
Elliptic curve point in affine coordinates.
Source§type ProjectivePoint = ProjectivePoint
type ProjectivePoint = ProjectivePoint
Elliptic curve point in projective coordinates. Read more
Source§impl DecompactPoint<Secp256k1> for AffinePoint
Available on crate feature arithmetic only.Decompaction using Taproot conventions as described in BIP 340.
impl DecompactPoint<Secp256k1> for AffinePoint
Available on crate feature
arithmetic only.Decompaction using Taproot conventions as described in BIP 340.
Source§fn decompact(x_bytes: &FieldBytes) -> CtOption<Self>
fn decompact(x_bytes: &FieldBytes) -> CtOption<Self>
Attempt to decompact an elliptic curve point
Source§impl DecompressPoint<Secp256k1> for AffinePoint
Available on crate feature arithmetic only.
impl DecompressPoint<Secp256k1> for AffinePoint
Available on crate feature
arithmetic only.Source§fn decompress(x_bytes: &FieldBytes, y_is_odd: Choice) -> CtOption<Self>
fn decompress(x_bytes: &FieldBytes, y_is_odd: Choice) -> CtOption<Self>
Attempt to decompress an elliptic curve point.
Source§impl DigestPrimitive for Secp256k1
Available on crate features ecdsa-core and sha256 only.
impl DigestPrimitive for Secp256k1
Available on crate features
ecdsa-core and sha256 only.Source§impl FieldBytesEncoding<Secp256k1> for U256
impl FieldBytesEncoding<Secp256k1> for U256
Source§fn decode_field_bytes(field_bytes: &FieldBytes) -> Self
fn decode_field_bytes(field_bytes: &FieldBytes) -> Self
Decode unsigned integer from serialized field element. Read more
Source§fn encode_field_bytes(&self) -> FieldBytes
fn encode_field_bytes(&self) -> FieldBytes
Encode unsigned integer into serialized field element. Read more
Source§impl FromEncodedPoint<Secp256k1> for AffinePoint
Available on crate feature arithmetic only.
impl FromEncodedPoint<Secp256k1> for AffinePoint
Available on crate feature
arithmetic only.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 secp256k1 curve.
Source§impl FromEncodedPoint<Secp256k1> for ProjectivePoint
Available on crate feature arithmetic only.
impl FromEncodedPoint<Secp256k1> for ProjectivePoint
Available on crate feature
arithmetic only.Source§fn from_encoded_point(p: &EncodedPoint) -> CtOption<Self>
fn from_encoded_point(p: &EncodedPoint) -> CtOption<Self>
Deserialize the type this trait is impl’d on from an
EncodedPoint.Source§impl GroupDigest for Secp256k1
Available on crate features hash2curve and arithmetic only.
impl GroupDigest for Secp256k1
Available on crate features
hash2curve and arithmetic only.Source§type FieldElement = FieldElement
type FieldElement = FieldElement
The field element representation for a group value with multiple elements
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>,
Computes the hash to curve routine. Read more
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>,
Computes the encode to curve routine. Read more
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>
Computes the hash to field routine according to
https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-13.html#section-5
and returns a scalar. Read more
Source§impl Ord for Secp256k1
impl Ord for Secp256k1
Source§impl PartialOrd for Secp256k1
impl PartialOrd for Secp256k1
Source§impl PointCompression for Secp256k1
impl PointCompression for Secp256k1
Source§const COMPRESS_POINTS: bool = true
const COMPRESS_POINTS: bool = true
secp256k1 points are typically compressed.
Source§impl SignPrimitive<Secp256k1> for Scalar
Available on crate features ecdsa-core and ecdsa only.
impl SignPrimitive<Secp256k1> for Scalar
Available on crate features
ecdsa-core and ecdsa only.Source§fn try_sign_prehashed<K>(
&self,
k: K,
z: &FieldBytes,
) -> Result<(Signature, Option<RecoveryId>), Error>
fn try_sign_prehashed<K>( &self, k: K, z: &FieldBytes, ) -> Result<(Signature, Option<RecoveryId>), Error>
Try to sign the prehashed message. Read more
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,
Source§impl ToEncodedPoint<Secp256k1> for AffinePoint
Available on crate feature arithmetic only.
impl ToEncodedPoint<Secp256k1> for AffinePoint
Available on crate feature
arithmetic only.Source§fn to_encoded_point(&self, compress: bool) -> EncodedPoint
fn to_encoded_point(&self, compress: bool) -> EncodedPoint
Serialize this value as a SEC1
EncodedPoint, optionally applying
point compression.Source§impl ToEncodedPoint<Secp256k1> for ProjectivePoint
Available on crate feature arithmetic only.
impl ToEncodedPoint<Secp256k1> for ProjectivePoint
Available on crate feature
arithmetic only.Source§fn to_encoded_point(&self, compress: bool) -> EncodedPoint
fn to_encoded_point(&self, compress: bool) -> EncodedPoint
Serialize this value as a SEC1
EncodedPoint, optionally applying
point compression.Source§impl VerifyPrimitive<Secp256k1> for AffinePoint
Available on crate features ecdsa-core and ecdsa only.
impl VerifyPrimitive<Secp256k1> for AffinePoint
Available on crate features
ecdsa-core and ecdsa only.Source§fn verify_prehashed(&self, z: &FieldBytes, sig: &Signature) -> Result<(), Error>
fn verify_prehashed(&self, z: &FieldBytes, sig: &Signature) -> Result<(), Error>
Verify the prehashed message against the provided ECDSA signature. Read more
impl Copy for Secp256k1
impl Eq for Secp256k1
impl PrimeCurve for Secp256k1
impl StructuralPartialEq for Secp256k1
Auto Trait Implementations§
impl Freeze for Secp256k1
impl RefUnwindSafe for Secp256k1
impl Send for Secp256k1
impl Sync for Secp256k1
impl Unpin for Secp256k1
impl UnwindSafe for Secp256k1
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
Mutably borrows from an owned value. Read more
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
Get the OID associated with this value.
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Pipes by value. This is generally the method you want to use. Read more
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,
Borrows
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,
Mutably borrows
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
Borrows
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
Mutably borrows
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
Borrows
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
Immutable access to the
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
Mutable access to the
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
Immutable access to the
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
Mutable access to the
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
Immutable access to the
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
Mutable access to the
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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.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>
Validate that the given
EncodedPoint is a valid public key for the
provided secret value.