[−][src]Struct ecdsa_fun::ECDSA
An instance of the ECDSA signature scheme.
Fields
nonce_gen: NG
An instance of NonceGen
to produce nonces.
enforce_low_s: bool
enforce_low_s
: Whether the verify algorithm should enforce that the s
component of the signature is low (see BIP-146).
Implementations
impl ECDSA<()>
[src]
pub fn verify_only() -> Self
[src]
Creates an ECDSA
instance that cannot be used to sign messages but can
verify signatures.
impl<NG> ECDSA<NG>
[src]
pub fn enforce_low_s(self) -> Self
[src]
Transforms the ECDSA instance into one which enforces the BIP-146 low s constraint.
impl<NG> ECDSA<NG>
[src]
pub fn verify(
&self,
verification_key: &Point<impl PointType, Public, NonZero>,
message: &[u8; 32],
signature: &Signature<impl Secrecy>
) -> bool
[src]
&self,
verification_key: &Point<impl PointType, Public, NonZero>,
message: &[u8; 32],
signature: &Signature<impl Secrecy>
) -> bool
Verify an ECDSA signature.
impl<NG: NonceGen> ECDSA<NG>
[src]
pub fn new(nonce_gen: NG) -> Self
[src]
Creates a ECDSA instance.
The caller chooses how nonces are generated by providing a NonceGen
.
Example
use ecdsa_fun::{nonce, ECDSA}; use rand::rngs::ThreadRng; use sha2::Sha256; let nonce_gen = nonce::from_global_rng::<Sha256, ThreadRng>(); let ecdsa = ECDSA::new(nonce_gen);
pub fn sign(&self, secret_key: &Scalar, message_hash: &[u8; 32]) -> Signature
[src]
Deterministically produce a ECDSA signature on a message hash.
Examples
use ecdsa_fun::{ fun::{digest::Digest, g, marker::*, Scalar, G}, nonce, ECDSA, }; use rand::rngs::ThreadRng; use sha2::Sha256; let secret_key = Scalar::random(&mut rand::thread_rng()); let public_key = g!(secret_key * G).mark::<Normal>(); let ecdsa = ECDSA::new(nonce::from_global_rng::<Sha256, ThreadRng>()); let message = b"Attack at dawn"; let message_hash = { let mut message_hash = [0u8; 32]; let hash = Sha256::default().chain(message); message_hash.copy_from_slice(hash.finalize().as_ref()); message_hash }; let signature = ecdsa.sign(&secret_key, &message_hash); assert!(ecdsa.verify(&public_key, &message_hash, &signature));
Trait Implementations
Auto Trait Implementations
impl<NG> RefUnwindSafe for ECDSA<NG> where
NG: RefUnwindSafe,
NG: RefUnwindSafe,
impl<NG> Send for ECDSA<NG> where
NG: Send,
NG: Send,
impl<NG> Sync for ECDSA<NG> where
NG: Sync,
NG: Sync,
impl<NG> Unpin for ECDSA<NG> where
NG: Unpin,
NG: Unpin,
impl<NG> UnwindSafe for ECDSA<NG> where
NG: UnwindSafe,
NG: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Mark for T
[src]
#[must_use]fn mark<M>(self) -> <M as ChangeMark<T>>::Out where
M: ChangeMark<T>,
[src]
M: ChangeMark<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,