Expand description
AES-256-GCM encryption and X25519 ECDH key exchange. Wire format: base64url(nonce[12B] || ciphertext || GCM_tag[16B]).
This module is the single source of truth for client-side crypto across
the CLI and desktop. Wire format is bit-compatible with the Go relay /
cinch/internal/crypto/ Go side; do not change byte layout, HKDF info
string (cinch-key-xfer), or nonce length without coordinated updates
to all consumers and testdata/crypto-vectors.json.
Functions§
- decrypt
- Decrypt a base64url-encoded AES-256-GCM payload.
- derive_
shared_ key - Derive a 32-byte AES key from X25519 ECDH shared secret via HKDF-SHA256.
local_priv_b64andremote_pub_b64are base64url-encoded. - encrypt
- Encrypt plaintext with AES-256-GCM. Returns base64url(nonce[12] || ciphertext || tag[16]).
- generate_
aes_ key - Generate a fresh 32-byte AES-256 key. Mirrors the Go side’s
cinchcrypto.GenerateKey()used bycinch auth loginto seed the per-user clip-encryption key. - generate_
device_ keypair - Generate a static X25519 keypair for the device’s long-lived identity used in encrypted key-exchange bundles. Returns (private_b64, public_b64).
- generate_
ephemeral_ keypair - Generate an ephemeral X25519 keypair for ECDH key exchange. Returns (private_key_b64, public_key_b64).
- pub_
from_ priv - Derive the X25519 public key (base64url) from a stored private key (base64url). Used at login completion to re-register a device’s public key with the relay without needing the keypair generator’s in-memory output.