pub struct P256;Expand description
NIST P-256 (secp256r1).
Trait Implementations§
Source§impl Curve for P256
impl Curve for P256
Source§fn keygen(rng: &mut dyn CryptoRng) -> (PublicKey, SecretKey)
fn keygen(rng: &mut dyn CryptoRng) -> (PublicKey, SecretKey)
Generate a key pair on this curve.
Source§fn ecdh(sk: &SecretKey, peer_pk: &PublicKey) -> Option<Vec<u8>>
fn ecdh(sk: &SecretKey, peer_pk: &PublicKey) -> Option<Vec<u8>>
ECDH key agreement: derive the shared secret from our secret
key and the peer’s SEC1 uncompressed public key. Read more
Source§fn compress_pubkey(pk: &PublicKey) -> Option<Vec<u8>>
fn compress_pubkey(pk: &PublicKey) -> Option<Vec<u8>>
Compress a public key from SEC1 uncompressed (
0x04 || X || Y)
to SEC1 compressed (0x02/0x03 || X). If the input is already
compressed, returns a validated clone. Returns None for
malformed or off-curve input.Source§fn decompress_pubkey(compressed: &[u8]) -> Option<PublicKey>
fn decompress_pubkey(compressed: &[u8]) -> Option<PublicKey>
Decompress a SEC1 compressed public key (
0x02/0x03 || X) to
uncompressed form (0x04 || X || Y), recovering Y via the
field square-root. If the input is already uncompressed, acts
as a validate-and-clone. Returns None if the input is
malformed, if X is not a valid x-coordinate on the curve, or
if the decompressed point fails the on-curve check.Source§fn sign_rfc6979<H: Hasher>(sk: &SecretKey, digest: &[u8]) -> Signature
fn sign_rfc6979<H: Hasher>(sk: &SecretKey, digest: &[u8]) -> Signature
Sign a precomputed digest with the deterministic RFC 6979 nonce. Read more
Source§fn sign_random(
sk: &SecretKey,
digest: &[u8],
rng: &mut dyn CryptoRng,
) -> Signature
fn sign_random( sk: &SecretKey, digest: &[u8], rng: &mut dyn CryptoRng, ) -> Signature
Sign a precomputed digest with a uniformly random nonce drawn from
rng. The hash function is irrelevant – only the digest bytes are
consumed (via bits2int). Each call must consume fresh entropy;
reusing k across two signatures with the same key recovers the
secret key.Source§fn verify(pk: &PublicKey, digest: &[u8], sig: &Signature) -> bool
fn verify(pk: &PublicKey, digest: &[u8], sig: &Signature) -> bool
Verify a signature against a precomputed digest.
Source§fn sign_random_msg<H: Hasher>(
sk: &SecretKey,
msg: &[u8],
rng: &mut dyn CryptoRng,
) -> Signature
fn sign_random_msg<H: Hasher>( sk: &SecretKey, msg: &[u8], rng: &mut dyn CryptoRng, ) -> Signature
Auto Trait Implementations§
impl Freeze for P256
impl RefUnwindSafe for P256
impl Send for P256
impl Sync for P256
impl Unpin for P256
impl UnsafeUnpin for P256
impl UnwindSafe for P256
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