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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PrivateKeys
impl Debug for PrivateKeys
Source§impl Decrypter for PrivateKeys
impl Decrypter for PrivateKeys
Source§fn encapsulation_private_key(&self) -> EncapsulationPrivateKey
fn encapsulation_private_key(&self) -> EncapsulationPrivateKey
Source§impl Display for PrivateKeys
impl Display for PrivateKeys
Source§impl From<PrivateKeys> for CBOR
impl From<PrivateKeys> for CBOR
Source§fn from(value: PrivateKeys) -> Self
fn from(value: PrivateKeys) -> Self
Source§impl Hash for PrivateKeys
impl Hash for PrivateKeys
Source§impl PartialEq for PrivateKeys
impl PartialEq for PrivateKeys
Source§impl PrivateKeysProvider for PrivateKeys
impl PrivateKeysProvider for PrivateKeys
Source§fn private_keys(&self) -> PrivateKeys
fn private_keys(&self) -> PrivateKeys
Source§impl ReferenceProvider for PrivateKeys
impl ReferenceProvider for PrivateKeys
Source§fn reference(&self) -> Reference
fn reference(&self) -> Reference
Source§fn ref_hex_short(&self) -> String
fn ref_hex_short(&self) -> String
Source§impl Signer for PrivateKeys
impl Signer for PrivateKeys
Source§fn sign_with_options(
&self,
message: &dyn AsRef<[u8]>,
options: Option<SigningOptions>,
) -> Result<Signature>
fn sign_with_options( &self, message: &dyn AsRef<[u8]>, options: Option<SigningOptions>, ) -> Result<Signature>
Source§impl TryFrom<CBOR> for PrivateKeys
impl TryFrom<CBOR> for PrivateKeys
impl Eq for PrivateKeys
impl StructuralPartialEq for PrivateKeys
Auto Trait Implementations§
impl Freeze for PrivateKeys
impl RefUnwindSafe for PrivateKeys
impl Send for PrivateKeys
impl Sync for PrivateKeys
impl Unpin for PrivateKeys
impl UnwindSafe for PrivateKeys
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CBORDecodable for T
impl<T> CBORDecodable for T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)