baseid-crypto
The cryptography crate providing key management and signing operations for all BaseID crates.
Installation
Section titled “Installation”[dependencies]baseid-crypto = "0.1.0-alpha.1"Key Generation
Section titled “Key Generation”use baseid_core::types::KeyType;use baseid_crypto::KeyPair;
// Ed25519 (default, recommended)let kp = KeyPair::generate(KeyType::Ed25519)?;
// NIST P-256let kp = KeyPair::generate(KeyType::P256)?;
// NIST P-384let kp = KeyPair::generate(KeyType::P384)?;
// secp256k1let kp = KeyPair::generate(KeyType::Secp256k1)?;Signing and Verification
Section titled “Signing and Verification”let message = b"hello world";
// Signlet signature = kp.sign(message)?;
// Verifykp.public.verify(message, &signature)?;Key Serialization
Section titled “Key Serialization”// Export to JWKlet jwk = kp.to_jwk()?;
// Import from JWKlet kp = KeyPair::from_jwk(&jwk)?;
// Export public key onlylet public_jwk = kp.public.to_jwk()?;Supported Algorithms
Section titled “Supported Algorithms”| Key Type | Signing Algorithm | JWT alg |
|---|---|---|
| Ed25519 | EdDSA | EdDSA |
| P-256 | ECDSA | ES256 |
| P-384 | ECDSA | ES384 |
| Secp256k1 | ECDSA | ES256K |
Security Notes
Section titled “Security Notes”- All private keys are zeroized on drop
- No software RNG — uses the OS-provided CSPRNG
- Backend:
aws-lc-rs(FIPS-capable)