OpenAgentID documentation
Source referencesRust module referencearsenal-crypto

arsenal-crypto · keys

Declared module signatures, types, configuration, and source documentation.

Source: arsenal/crates/arsenal-crypto/src/keys.rs. SHA-256: 87bca94390697ce74aa11e8bb88dd167369ac7e478da8c748f6295524ae8d684.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

keys::KeyId

Key identifier for key management

#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct KeyId(String);

Source line: 19.

keys::KeyId::new

Create a new key ID

Errors

Returns an error if the ID is invalid

pub fn new(id: impl Into<String>) -> ArsenalResult<Self>;

Source line: 26.

keys::KeyId::generate

Generate a new random key ID

#[must_use]
pub fn generate() -> Self;

Source line: 36.

keys::KeyId::as_str

Get the inner string

#[must_use]
pub fn as_str(&self) -> &str;

Source line: 42.

keys::SigningKeyPair

Ed25519 signing key pair

pub struct SigningKeyPair {

}

Source line: 60.

keys::SigningKeyPair::generate

Generate a new random key pair

Errors

Returns an error if random generation fails

pub fn generate() -> ArsenalResult<Self>;

Source line: 72.

keys::SigningKeyPair::from_seed

Create from existing seed bytes

Errors

Returns an error if the seed is invalid

pub fn from_seed(seed: &[u8; 32]) -> ArsenalResult<Self>;

Source line: 88.

keys::SigningKeyPair::from_seed_with_id

Create from existing seed with a specific key ID

Errors

Returns an error if the seed is invalid

pub fn from_seed_with_id(seed: &[u8; 32], key_id: KeyId) -> ArsenalResult<Self>;

Source line: 100.

keys::SigningKeyPair::verifying_key

Get the public verifying key

#[must_use]
pub fn verifying_key(&self) -> VerifyingKey;

Source line: 110.

keys::SigningKeyPair::public_key_bytes

Get the public key bytes

#[must_use]
pub fn public_key_bytes(&self) -> [u8; 32];

Source line: 116.

keys::SigningKeyPair::fingerprint

Get the key fingerprint

#[must_use]
pub fn fingerprint(&self) -> KeyFingerprint;

Source line: 122.

keys::SigningKeyPair::key_id

Get the key ID

#[must_use]
pub fn key_id(&self) -> &KeyId;

Source line: 128.

keys::SigningKeyPair::sign

Sign a message

#[must_use]
pub fn sign(&self, message: &[u8]) -> [u8; 64];

Source line: 134.

keys::SigningKeyPair::export_seed

Export the seed (use with extreme caution)

This returns the private key material. Handle with care!

#[must_use]
pub fn export_seed(&self) -> [u8; 32];

Source line: 143.

keys::PublicSigningKey

Public key for signature verification

#[derive(Clone, Serialize, Deserialize)]
pub struct PublicSigningKey {

}

Source line: 159.

keys::PublicSigningKey::from_bytes

Create from bytes

Errors

Returns an error if the bytes are invalid

pub fn from_bytes(bytes: [u8; 32], key_id: KeyId) -> ArsenalResult<Self>;

Source line: 171.

keys::PublicSigningKey::from_signing_key

Create from a signing key pair

#[must_use]
pub fn from_signing_key(key_pair: &SigningKeyPair) -> Self;

Source line: 180.

keys::PublicSigningKey::as_bytes

Get the key bytes

#[must_use]
pub fn as_bytes(&self) -> &[u8; 32];

Source line: 189.

keys::PublicSigningKey::key_id

Get the key ID

#[must_use]
pub fn key_id(&self) -> &KeyId;

Source line: 195.

keys::PublicSigningKey::fingerprint

Get the fingerprint

#[must_use]
pub fn fingerprint(&self) -> KeyFingerprint;

Source line: 201.

keys::PublicSigningKey::verify

Verify a signature

Errors

Returns an error if verification fails

pub fn verify(&self, message: &[u8], signature: &[u8; 64]) -> ArsenalResult<()>;

Source line: 209.

keys::EncryptionKeyPair

X25519 key pair for key exchange and encryption

pub struct EncryptionKeyPair {

}

Source line: 233.

keys::EncryptionKeyPair::generate

Generate a new random key pair

Errors

Returns an error if random generation fails

pub fn generate() -> ArsenalResult<Self>;

Source line: 247.

keys::EncryptionKeyPair::from_seed

Create from existing seed bytes

Errors

Returns an error if the seed is invalid

pub fn from_seed(seed: &[u8; 32]) -> ArsenalResult<Self>;

Source line: 265.

keys::EncryptionKeyPair::public_key

Get the public key

#[must_use]
pub fn public_key(&self) -> &X25519PublicKey;

Source line: 278.

keys::EncryptionKeyPair::public_key_bytes

Get the public key bytes

#[must_use]
pub fn public_key_bytes(&self) -> [u8; 32];

Source line: 284.

keys::EncryptionKeyPair::fingerprint

Get the key fingerprint

#[must_use]
pub fn fingerprint(&self) -> KeyFingerprint;

Source line: 290.

keys::EncryptionKeyPair::key_id

Get the key ID

#[must_use]
pub fn key_id(&self) -> &KeyId;

Source line: 296.

keys::EncryptionKeyPair::diffie_hellman

Perform Diffie-Hellman key exchange

#[must_use]
pub fn diffie_hellman(&self, their_public: &X25519PublicKey) -> [u8; 32];

Source line: 302.

keys::EncryptionKeyPair::diffie_hellman_bytes

Perform Diffie-Hellman with public key bytes

Errors

Returns an error if the public key is invalid

pub fn diffie_hellman_bytes(&self, their_public: &[u8; 32]) -> ArsenalResult<[u8; 32]>;

Source line: 310.

keys::PublicEncryptionKey

Public encryption key

#[derive(Clone, Serialize, Deserialize)]
pub struct PublicEncryptionKey {

}

Source line: 327.

keys::PublicEncryptionKey::from_bytes

Create from bytes

#[must_use]
pub fn from_bytes(bytes: [u8; 32], key_id: KeyId) -> Self;

Source line: 337.

keys::PublicEncryptionKey::from_key_pair

Create from an encryption key pair

#[must_use]
pub fn from_key_pair(key_pair: &EncryptionKeyPair) -> Self;

Source line: 343.

keys::PublicEncryptionKey::as_bytes

Get the key bytes

#[must_use]
pub fn as_bytes(&self) -> &[u8; 32];

Source line: 352.

keys::PublicEncryptionKey::key_id

Get the key ID

#[must_use]
pub fn key_id(&self) -> &KeyId;

Source line: 358.

keys::PublicEncryptionKey::fingerprint

Get the fingerprint

#[must_use]
pub fn fingerprint(&self) -> KeyFingerprint;

Source line: 364.

keys::PublicEncryptionKey::to_x25519

Convert to X25519 public key

#[must_use]
pub fn to_x25519(&self) -> X25519PublicKey;

Source line: 370.

keys::KeyUsage

Key usage restrictions

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum KeyUsage {
    /// Key can be used for signing
    Sign,
    /// Key can be used for verification
    Verify,
    /// Key can be used for encryption
    Encrypt,
    /// Key can be used for decryption
    Decrypt,
    /// Key can be used for key wrapping
    WrapKey,
    /// Key can be used for key unwrapping
    UnwrapKey,
    /// Key can be used for key derivation
    DeriveKey,
}

Source line: 387.

keys::KeyMetadata

Key metadata

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KeyMetadata {
/// Key ID

pub key_id: KeyId,
/// Key algorithm

pub algorithm: KeyAlgorithm,
/// Allowed usages

pub usages: Vec<KeyUsage>,
/// When the key was created

pub created_at: chrono::DateTime<chrono::Utc>,
/// When the key expires (if ever)

pub expires_at: Option<chrono::DateTime<chrono::Utc>>,
/// Whether the key is currently active

pub is_active: bool
}

Source line: 406.

keys::KeyAlgorithm

Key algorithm

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum KeyAlgorithm {
    /// Ed25519 signing
    Ed25519,
    /// X25519 key exchange
    X25519,
    /// AES-256-GCM encryption
    Aes256Gcm,
    /// XChaCha20-Poly1305 encryption
    XChaCha20Poly1305,
}

Source line: 424.

On this page