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() -> UserKeypair
pub fn generate() -> UserKeypair
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<UserKeypair, KeyError>
pub fn from_signing_key_bytes( signing_key: &[u8; 64], ) -> Result<UserKeypair, 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 moreAuto Trait Implementations§
impl Freeze for UserKeypair
impl RefUnwindSafe for UserKeypair
impl Send for UserKeypair
impl Sync for UserKeypair
impl Unpin for UserKeypair
impl UnsafeUnpin for UserKeypair
impl UnwindSafe for UserKeypair
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more