pub enum SignatureScheme {
Schnorr,
Ecdsa,
Ed25519,
MLDSA44,
MLDSA65,
MLDSA87,
SshEd25519,
SshDsa,
SshEcdsaP256,
SshEcdsaP384,
}Expand description
Supported digital signature schemes.
This enum represents the various signature schemes supported in this crate, including elliptic curve schemes (ECDSA, Schnorr), Edwards curve schemes (Ed25519), post-quantum schemes (ML-DSA), and SSH-specific algorithms.
§Examples
use bc_components::SignatureScheme;
// Use the default signature scheme (Schnorr)
let scheme = SignatureScheme::default();
let (private_key, public_key) = scheme.keypair();// Create a key pair using a specific signature scheme
let (mldsa_private, mldsa_public) = SignatureScheme::MLDSA65.keypair();Variants§
Schnorr
BIP-340 Schnorr signature scheme, used in Bitcoin Taproot (default)
Ecdsa
ECDSA signature scheme using the secp256k1 curve
Ed25519
Ed25519 signature scheme (RFC 8032)
MLDSA44
ML-DSA44 post-quantum signature scheme (NIST level 2)
MLDSA65
ML-DSA65 post-quantum signature scheme (NIST level 3)
MLDSA87
ML-DSA87 post-quantum signature scheme (NIST level 5)
SshEd25519
Ed25519 signature scheme for SSH
SshDsa
DSA signature scheme for SSH
SshEcdsaP256
ECDSA signature scheme with NIST P-256 curve for SSH
SshEcdsaP384
ECDSA signature scheme with NIST P-384 curve for SSH
Implementations§
Source§impl SignatureScheme
impl SignatureScheme
Sourcepub fn keypair(&self) -> (SigningPrivateKey, SigningPublicKey)
pub fn keypair(&self) -> (SigningPrivateKey, SigningPublicKey)
Creates a new key pair for the signature scheme using the system’s secure random number generator.
This is a convenience method that calls keypair_opt with an empty
comment.
§Returns
A tuple containing a signing private key and its corresponding public key.
§Examples
use bc_components::SignatureScheme;
// Generate a Schnorr key pair
let (private_key, public_key) = SignatureScheme::Schnorr.keypair();
// Use the default scheme (also Schnorr)
let (default_private, default_public) =
SignatureScheme::default().keypair();Sourcepub fn keypair_opt(
&self,
comment: impl Into<String>,
) -> (SigningPrivateKey, SigningPublicKey)
pub fn keypair_opt( &self, comment: impl Into<String>, ) -> (SigningPrivateKey, SigningPublicKey)
Creates a new key pair for the signature scheme with an optional comment.
The comment is only used for SSH keys and is ignored for other schemes.
§Arguments
comment- A string comment to include with SSH keys
§Returns
A tuple containing a signing private key and its corresponding public key.
§Examples
use bc_components::SignatureScheme;
// Generate an SSH Ed25519 key pair with a comment
let (ssh_private, ssh_public) =
SignatureScheme::SshEd25519.keypair_opt("user@example.com");Sourcepub fn keypair_using(
&self,
_rng: &mut impl RandomNumberGenerator,
comment: impl Into<String>,
) -> Result<(SigningPrivateKey, SigningPublicKey)>
pub fn keypair_using( &self, _rng: &mut impl RandomNumberGenerator, comment: impl Into<String>, ) -> Result<(SigningPrivateKey, SigningPublicKey)>
Creates a key pair for the signature scheme using a provided random number generator.
This allows for deterministic key generation when using a seeded RNG. Note that not all signature schemes support deterministic generation.
§Arguments
rng- A mutable reference to a random number generatorcomment- A string comment to include with SSH keys
§Returns
A Result containing a tuple of signing private key and public key, or
an error if the signature scheme doesn’t support deterministic
generation.
§Examples
use bc_components::SignatureScheme;
use bc_rand::SecureRandomNumberGenerator;
let mut rng = SecureRandomNumberGenerator;
// Generate an ECDSA key pair with a specific RNG
let result = SignatureScheme::Ecdsa.keypair_using(&mut rng, "");
assert!(result.is_ok());Trait Implementations§
Source§impl Clone for SignatureScheme
impl Clone for SignatureScheme
Source§fn clone(&self) -> SignatureScheme
fn clone(&self) -> SignatureScheme
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more