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.§type AffinePoint = AffinePoint
type AffinePoint = AffinePoint
Elliptic curve point in affine coordinates.
§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.
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.§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 PartialEq for Secp256k1
impl PartialEq for Secp256k1
source§impl PartialOrd for Secp256k1
impl PartialOrd for Secp256k1
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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,
Available on crate feature
rfc6979
only.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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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.