Skip to main content

Module ecdsa

Module ecdsa 

Source
Expand description

Elliptic Curve Digital Signature Algorithm.

The module implements ECDSA for the NIST curves P-256 and P-384.

use bssl_crypto::{ecdsa, ec::P256};

let key = ecdsa::PrivateKey::<P256>::generate();
// Publish your public key.
let public_key_bytes = key.to_der_subject_public_key_info();

// Sign and publish some message.
let signed_message = b"hello world";
let mut sig = key.sign(signed_message);

// Anyone with the public key can verify it.
let public_key = ecdsa::PublicKey::<P256>::from_der_subject_public_key_info(
    public_key_bytes.as_ref()).unwrap();
assert!(public_key.verify(signed_message, sig.as_slice()).is_ok());

Structsยง

PrivateKey
An ECDH private key over the given curve.
PublicKey
An ECDSA public key over the given curve.