pub struct SecretKey { /* private fields */ }xhpke only.Expand description
SecretKey contains a private key of the type bound to the configured crypto.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn from_bytes(bin: &[u8; 32]) -> Self
pub fn from_bytes(bin: &[u8; 32]) -> Self
from_bytes converts a 32-byte seed into a private key.
Sourcepub fn from_der(der: &[u8]) -> Result<Self, Box<dyn Error>>
pub fn from_der(der: &[u8]) -> Result<Self, Box<dyn Error>>
from_der parses a DER buffer into a private key.
Sourcepub fn from_pem(pem_str: &str) -> Result<Self, Box<dyn Error>>
pub fn from_pem(pem_str: &str) -> Result<Self, Box<dyn Error>>
from_pem parses a PEM string into a private key.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
public_key retrieves the public counterpart of the secret key.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
fingerprint returns a 256bit unique identifier for this key. For HPKE, that is the SHA256 hash of the raw public key.
Sourcepub fn open(
&self,
session_key: &[u8; 1120],
msg_to_open: &[u8],
msg_to_auth: &[u8],
domain: &[u8],
) -> Result<Vec<u8>, HpkeError>
pub fn open( &self, session_key: &[u8; 1120], msg_to_open: &[u8], msg_to_auth: &[u8], domain: &[u8], ) -> Result<Vec<u8>, HpkeError>
open consumes a standalone cryptographic construct encrypted to this secret key. The method will deconstruct the given encapsulated key and ciphertext and will also verify the authenticity of the (unencrypted) message-to-auth (not included in the ciphertext).
Note: X-Wing uses Base mode (no sender authentication). The sender’s identity cannot be verified from the ciphertext alone.