pub struct PrivateKeys { /* private fields */ }Expand description
A container for an entity’s private cryptographic keys.
PrivateKeys combines a signing key for creating digital signatures with an
encapsulation key for decrypting messages, providing a complete private key
package for cryptographic operations.
This type is typically used in conjunction with its public counterpart,
PublicKeys, to enable secure communication between entities. The private
keys remain with the owner, while the corresponding public keys can be
freely shared.
§Components
-
signing_private_key- A private key used for creating digital signatures. Can be Schnorr, ECDSA, Ed25519, or SSH-based, depending on the security needs. -
encapsulation_private_key- A private key used for decrypting messages that were encrypted using the corresponding public key. Can be X25519 or ML-KEM based.
§Security
This struct contains highly sensitive cryptographic material and should be handled with appropriate security measures:
- Minimize serialization and storage of private keys
- Ensure secure memory handling and proper zeroization
- Apply access controls and encryption when at rest
- Consider using hardware security modules for production systems
§Examples
use bc_components::{Signer, Verifier, keypair};
// Generate a new key pair with default schemes
let (private_keys, public_keys) = keypair();
// Sign a message using the private keys
let message = b"Hello, world!";
let signature = private_keys.sign(message).unwrap();
// Verify the signature using the corresponding public keys
assert!(public_keys.verify(&signature, message));Implementations§
Source§impl PrivateKeys
impl PrivateKeys
Sourcepub fn with_keys(
signing_private_key: SigningPrivateKey,
encapsulation_private_key: EncapsulationPrivateKey,
) -> Self
pub fn with_keys( signing_private_key: SigningPrivateKey, encapsulation_private_key: EncapsulationPrivateKey, ) -> Self
Restores a PrivateKeys from a SigningPrivateKey and an
EncapsulationPrivateKey.
Sourcepub fn signing_private_key(&self) -> &SigningPrivateKey
pub fn signing_private_key(&self) -> &SigningPrivateKey
Returns the SigningPrivateKey of this PrivateKeys.
Sourcepub fn enapsulation_private_key(&self) -> &EncapsulationPrivateKey
pub fn enapsulation_private_key(&self) -> &EncapsulationPrivateKey
Returns the EncapsulationPrivateKey of this PrivateKeys.
pub fn public_keys(&self) -> Result<PublicKeys>
Trait Implementations§
Source§impl AsRef<EncapsulationPrivateKey> for PrivateKeys
impl AsRef<EncapsulationPrivateKey> for PrivateKeys
Source§fn as_ref(&self) -> &EncapsulationPrivateKey
fn as_ref(&self) -> &EncapsulationPrivateKey
Source§impl AsRef<PrivateKeys> for PrivateKeys
impl AsRef<PrivateKeys> for PrivateKeys
Source§fn as_ref(&self) -> &PrivateKeys
fn as_ref(&self) -> &PrivateKeys
Source§impl AsRef<SigningPrivateKey> for PrivateKeys
impl AsRef<SigningPrivateKey> for PrivateKeys
Source§fn as_ref(&self) -> &SigningPrivateKey
fn as_ref(&self) -> &SigningPrivateKey
Source§impl CBORTagged for PrivateKeys
impl CBORTagged for PrivateKeys
Source§impl CBORTaggedDecodable for PrivateKeys
impl CBORTaggedDecodable for PrivateKeys
Source§fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
Source§fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
Source§impl CBORTaggedEncodable for PrivateKeys
impl CBORTaggedEncodable for PrivateKeys
Source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Source§impl Clone for PrivateKeys
impl Clone for PrivateKeys
Source§fn clone(&self) -> PrivateKeys
fn clone(&self) -> PrivateKeys
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more