pub struct Identity {
pub public: [u8; 32],
pub secret: [u8; 32],
}Expand description
A long-lived X25519 keypair that identifies one side of a connection.
Sendspin uses the public key as the client_id or server_id and the secret key as the
static key of the Noise handshake. Both halves must match: Identity::generate and
Identity::from_secret_base64 derive the public key from the secret, so an identity built
through them always does.
Fields§
§public: [u8; 32]Public X25519 key as 32 raw bytes; 43 base64url characters once encoded.
secret: [u8; 32]Secret X25519 key as 32 raw bytes. Never log this value.
Implementations§
Source§impl Identity
impl Identity
Sourcepub fn generate() -> Identity
pub fn generate() -> Identity
Generates a fresh keypair from the operating system’s CSPRNG.
§Panics
Panics if the operating system’s CSPRNG is unavailable. That is not a recoverable condition: a silent fallback would be a weak key.
Sourcepub fn from_secret_base64(s: &str) -> Result<Identity, Error>
pub fn from_secret_base64(s: &str) -> Result<Identity, Error>
Decodes an identity from its 43-character unpadded base64url secret key.
The public key is derived from the secret. The input must be the canonical encoding of
exactly 32 bytes; a truncated, padded or non-base64url string is an error. Every 32-byte
value is a valid secret, so this cannot tell a secret key from a public key: passing a
public key such as Identity::public_base64 succeeds and silently yields a different
identity.
Sourcepub fn public_base64(&self) -> String
pub fn public_base64(&self) -> String
Returns the public key as 43-character unpadded base64url text.
This is the value to send as client_id or server_id.
Sourcepub fn secret_base64(&self) -> String
pub fn secret_base64(&self) -> String
Returns the secret key as 43-character unpadded base64url text.
The value is key material: hand it to Identity::from_secret_base64 to restore an
identity and treat the text like a password.