pub trait ECSignature {
type r: AsRef<[u8]>;
type s: AsRef<[u8]>;
type sbytes: AsRef<[u8]>;
// Required methods
fn generate_keypair(&mut self, seed: [u8; 32]);
fn sign(&self, data: &[u8]) -> Result<Self::sbytes>;
fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool>;
fn r(s: Self::sbytes) -> Self::r;
fn s(s: Self::sbytes) -> Self::s;
}Expand description
A trait to implement ECDSA signatures for any curve type.
As RustCrypto is yet to support (i.e. no Projective arithmetic yet) curves P384, p521 or Brainpool
I put together my own affine-point arithemtic impls leveraging types SecretKey, PublicKey, EncodedPoint
from the elliptic-curve crate.
For now - all methods in this trait return byte-arrays (this is just a stop-gap solution)
Required Associated Types§
Required Methods§
Sourcefn generate_keypair(&mut self, seed: [u8; 32])
fn generate_keypair(&mut self, seed: [u8; 32])
Generate a ECDSA keypair.
- This function borrows
SigningKeyandVerifyingKeytypes from the p256 impl to compute ECDSASHA256 Signatures
For other impls, we use a mix of SecretKey, PublicKey, EncodedPoint types.
borrowed from the elliptic-curve crate.
Sourcefn sign(&self, data: &[u8]) -> Result<Self::sbytes>
fn sign(&self, data: &[u8]) -> Result<Self::sbytes>
Function to sign messages of arbitrary length.
- Returns the
signature as byte-arrayor an Error.
Note - we use affine point arithmetic of ECDSA calculation for curves other than p256
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.