Struct Secp256k1
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§
§impl CurveArithmetic for Secp256k1
impl CurveArithmetic for Secp256k1
§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
§impl DecompactPoint<Secp256k1> for AffinePoint
Decompaction using Taproot conventions as described in BIP 340.
impl DecompactPoint<Secp256k1> for AffinePoint
Decompaction using Taproot conventions as described in BIP 340.
§fn decompact(
x_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>,
) -> CtOption<AffinePoint>
fn decompact( x_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>, ) -> CtOption<AffinePoint>
Attempt to decompact an elliptic curve point
§impl DecompressPoint<Secp256k1> for AffinePoint
impl DecompressPoint<Secp256k1> for AffinePoint
§fn decompress(
x_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>,
y_is_odd: Choice,
) -> CtOption<AffinePoint>
fn decompress( x_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>, y_is_odd: Choice, ) -> CtOption<AffinePoint>
Attempt to decompress an elliptic curve point.
§impl DigestPrimitive for Secp256k1
Available on crate feature sha256 only.
impl DigestPrimitive for Secp256k1
Available on crate feature
sha256 only.§impl FieldBytesEncoding<Secp256k1> for Uint<crypto_bigint::::uint::U256::{constant#0}>
impl FieldBytesEncoding<Secp256k1> for Uint<crypto_bigint::::uint::U256::{constant#0}>
§fn decode_field_bytes(
field_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>,
) -> Uint<crypto_bigint::::uint::U256::{constant#0}>
fn decode_field_bytes( field_bytes: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>, ) -> Uint<crypto_bigint::::uint::U256::{constant#0}>
Decode unsigned integer from serialized field element. Read more
§fn encode_field_bytes(
&self,
) -> GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>
fn encode_field_bytes( &self, ) -> GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>
Encode unsigned integer into serialized field element. Read more
§impl FromEncodedPoint<Secp256k1> for AffinePoint
impl FromEncodedPoint<Secp256k1> for AffinePoint
§fn from_encoded_point(
encoded_point: &EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>,
) -> CtOption<AffinePoint>
fn from_encoded_point( encoded_point: &EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>, ) -> CtOption<AffinePoint>
Attempts to parse the given EncodedPoint as an SEC1-encoded AffinePoint.
§Returns
None value if encoded_point is not on the secp256k1 curve.
§impl FromEncodedPoint<Secp256k1> for ProjectivePoint
impl FromEncodedPoint<Secp256k1> for ProjectivePoint
§fn from_encoded_point(
p: &EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>,
) -> CtOption<ProjectivePoint>
fn from_encoded_point( p: &EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>, ) -> CtOption<ProjectivePoint>
Deserialize the type this trait is impl’d on from an
EncodedPoint.§impl Ord for Secp256k1
impl Ord for Secp256k1
§impl PartialOrd for Secp256k1
impl PartialOrd for Secp256k1
§impl PointCompression for Secp256k1
impl PointCompression for Secp256k1
§const COMPRESS_POINTS: bool = true
const COMPRESS_POINTS: bool = true
secp256k1 points are typically compressed.
§impl SignPrimitive<Secp256k1> for Scalar
Available on crate feature ecdsa only.
impl SignPrimitive<Secp256k1> for Scalar
Available on crate feature
ecdsa only.§fn try_sign_prehashed<K>(
&self,
k: K,
z: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>,
) -> Result<(Signature<Secp256k1>, Option<RecoveryId>), Error>
fn try_sign_prehashed<K>( &self, k: K, z: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>, ) -> Result<(Signature<Secp256k1>, Option<RecoveryId>), Error>
Try to sign the prehashed message. Read more
§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,
§impl ToEncodedPoint<Secp256k1> for AffinePoint
impl ToEncodedPoint<Secp256k1> for AffinePoint
§fn to_encoded_point(
&self,
compress: bool,
) -> EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>
fn to_encoded_point( &self, compress: bool, ) -> EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>
Serialize this value as a SEC1
EncodedPoint, optionally applying
point compression.§impl ToEncodedPoint<Secp256k1> for ProjectivePoint
impl ToEncodedPoint<Secp256k1> for ProjectivePoint
§fn to_encoded_point(
&self,
compress: bool,
) -> EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>
fn to_encoded_point( &self, compress: bool, ) -> EncodedPoint<<Secp256k1 as Curve>::FieldBytesSize>
Serialize this value as a SEC1
EncodedPoint, optionally applying
point compression.§impl VerifyPrimitive<Secp256k1> for AffinePoint
Available on crate feature ecdsa only.
impl VerifyPrimitive<Secp256k1> for AffinePoint
Available on crate feature
ecdsa only.§fn verify_prehashed(
&self,
z: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>,
sig: &Signature<Secp256k1>,
) -> Result<(), Error>
fn verify_prehashed( &self, z: &GenericArray<u8, <Secp256k1 as Curve>::FieldBytesSize>, sig: &Signature<Secp256k1>, ) -> Result<(), Error>
Verify the prehashed message against the provided ECDSA signature. Read more
§fn verify_digest<D>(
&self,
msg_digest: D,
sig: &Signature<C>,
) -> Result<(), Error>
fn verify_digest<D>( &self, msg_digest: D, sig: &Signature<C>, ) -> Result<(), Error>
Verify message digest against the provided signature.
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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,
§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.