crypto ed25519 module #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Module Overview
The keys module provides the foundational cryptographic infrastructure for , focusing on Ed25519 keypair generation, secure key management, and essential cryptographic utilities. This module ensures that all components can generate, store, and use cryptographic keys securely for authentication, encryption, and digital signatures throughout the ecosystem.
Functionality
Module API
Key Management
KeyPair::generate() -> Result<Self, KeyError>- Generate a new cryptographically secure Ed25519 keypair using system entropyKeyPair::from_private_hex(hex: &str) -> Result<Self, KeyError>- Restore a keypair from a hex-encoded private key stringKeyPair::from_private_bytes(bytes: &[u8]) -> Result<Self, KeyError>- Restore a keypair from raw private key bytesKeyPair::public_key_hex(&self) -> String- Export the public key as a hex-encoded string for sharing or storageKeyPair::private_key_hex(&self) -> String- Export the private key as a hex-encoded string (use with caution)KeyPair::public_key_bytes(&self) -> Vec<u8>- Export the public key as raw bytes for binary protocolsKeyPair::private_key_bytes(&self) -> Vec<u8>- Export the private key as raw bytes (handle securely)KeyPair::sign(&self, message: &[u8]) -> Signature- Create a digital signature for the given messageKeyPair::verify(&self, message: &[u8], sig: &Signature) -> bool- Verify a signature against the original messageKeyPair::to_public_key(&self) -> PublicKey- Extract just the public key portion for sharingUtilities
generate_random_bytes(size: usize) -> Vec<u8>- Generate cryptographically secure random bytes using system entropyencode_hex(data: &[u8]) -> String- Convert binary data to hexadecimal string representationdecode_hex(s: &str) -> Result<Vec<u8>, DecodeError>- Convert hex string back to binary data with validationencode_base64(data: &[u8]) -> String- Encode binary data using Base64 for text-safe transmissiondecode_base64(s: &str) -> Result<Vec<u8>, DecodeError>- Decode Base64 string back to binary datasecure_compare(a: &[u8], b: &[u8]) -> bool- Constant-time comparison to prevent timing attackssha256_digest(data: &[u8]) -> Vec<u8>- Compute SHA-256 hash for data integrity verificationverify_signature_ed25519(public_key: &[u8], message: &[u8], signature: &[u8]) -> bool- Standalone signature verification using raw bytesthere is already some in vault
requirements