pub struct UserKeypair { /* private fields */ }Expand description
Ed25519 keypair for signing changesets and membership changes. The same seed can derive an X25519 keypair for key wrapping.
One keypair is generated per (store, device) pair: a device holds a distinct identity in each store it belongs to, so a key scoped to one store carries no authority in another, and the same device’s pubkey does not appear in more than one store’s membership chain.
Implementations§
Source§impl UserKeypair
impl UserKeypair
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generate a new random Ed25519 keypair. The unmanaged primitive behind every identity-establishing act — creating, joining, or restoring a store; also lets host code (and its tests) mint an identity directly.
Sourcepub fn from_signing_key_bytes(signing_key: &[u8; 64]) -> Result<Self, KeyError>
pub fn from_signing_key_bytes(signing_key: &[u8; 64]) -> Result<Self, KeyError>
Reconstruct a keypair from its 64-byte Ed25519 signing key (seed + public),
deriving the public key from it and validating that the bytes are a real
keypair. This is the single place stored signing-key bytes become a
UserKeypair, so a torn or corrupt signing key fails at the persistence
boundary.
pub fn public_key(&self) -> [u8; 32]
pub fn to_keypair_bytes(&self) -> [u8; 64]
Sourcepub fn sign(&self, message: &[u8]) -> [u8; 64]
pub fn sign(&self, message: &[u8]) -> [u8; 64]
Sign a message, returning a 64-byte detached signature.
Sourcepub fn to_x25519_secret_key(&self) -> [u8; 32]
pub fn to_x25519_secret_key(&self) -> [u8; 32]
Derive the X25519 secret key from this Ed25519 signing key.
Sourcepub fn to_x25519_public_key(&self) -> [u8; 32]
pub fn to_x25519_public_key(&self) -> [u8; 32]
Derive the X25519 public key from this Ed25519 public key.
Trait Implementations§
Source§impl Clone for UserKeypair
impl Clone for UserKeypair
Source§fn clone(&self) -> UserKeypair
fn clone(&self) -> UserKeypair
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more