pub struct NodeIdentity { /* private fields */ }Expand description
Core node identity with cryptographic keys
Debug is manually implemented to redact secret key material.
Implementations§
Source§impl NodeIdentity
impl NodeIdentity
Sourcepub fn public_key(&self) -> &MlDsaPublicKey
pub fn public_key(&self) -> &MlDsaPublicKey
Get public key
Sourcepub fn secret_key_bytes(&self) -> &[u8] ⓘ
pub fn secret_key_bytes(&self) -> &[u8] ⓘ
Get secret key bytes (for raw key authentication)
Sourcepub fn secret_key(&self) -> &MlDsaSecretKey
pub fn secret_key(&self) -> &MlDsaSecretKey
Get the ML-DSA-65 secret key.
Used to seed the transport endpoint’s TLS identity so a node presents its persistent fingerprint across restarts (ADR-011), rather than a fresh per-process key.
Sourcepub fn sign(&self, message: &[u8]) -> Result<MlDsaSignature, P2PError>
pub fn sign(&self, message: &[u8]) -> Result<MlDsaSignature, P2PError>
Sign a message
Sourcepub fn verify(
&self,
message: &[u8],
signature: &MlDsaSignature,
) -> Result<bool, P2PError>
pub fn verify( &self, message: &[u8], signature: &MlDsaSignature, ) -> Result<bool, P2PError>
Verify a signature
Sourcepub fn to_public(&self) -> PublicNodeIdentity
pub fn to_public(&self) -> PublicNodeIdentity
Create a public version of this identity (safe to clone)
Source§impl NodeIdentity
impl NodeIdentity
Sourcepub fn from_secret_key(_secret_key: MlDsaSecretKey) -> Result<Self, P2PError>
pub fn from_secret_key(_secret_key: MlDsaSecretKey) -> Result<Self, P2PError>
Create an identity from an existing secret key Note: Currently not supported as saorsa-transport doesn’t provide public key derivation from secret key This would require storing both keys together
Source§impl NodeIdentity
impl NodeIdentity
Sourcepub async fn save_to_file(&self, path: &Path) -> Result<(), P2PError>
pub async fn save_to_file(&self, path: &Path) -> Result<(), P2PError>
Save identity to a JSON file (async)
Sourcepub async fn load_from_file(path: &Path) -> Result<Self, P2PError>
pub async fn load_from_file(path: &Path) -> Result<Self, P2PError>
Load identity from a JSON file (async)
Source§impl NodeIdentity
impl NodeIdentity
Sourcepub fn export(&self) -> IdentityData
pub fn export(&self) -> IdentityData
Export identity for persistence
Sourcepub fn import(data: &IdentityData) -> Result<Self, P2PError>
pub fn import(data: &IdentityData) -> Result<Self, P2PError>
Import identity from persisted data