Curve Cryptography
Curve.generateKeyPair
Generates a new Curve25519 key pair for Signal protocol.A new cryptographic key pair
Curve.sharedKey
Computes a shared secret using ECDH (Elliptic Curve Diffie-Hellman).Your private key
Other party’s public key
Shared secret derived from the key agreement
Curve.sign
Creates a cryptographic signature for data.Private key for signing
Data to sign
Cryptographic signature
Curve.verify
Verifies a cryptographic signature.Public key of the signer
Original message that was signed
Signature to verify
True if signature is valid, false otherwise
AES Encryption
aesEncryptGCM
Encrypts data using AES-256-GCM with authentication.Data to encrypt
256-bit encryption key (32 bytes)
Initialization vector (16 bytes)
Additional authenticated data (not encrypted but authenticated)
Encrypted ciphertext with authentication tag appended
The authentication tag (16 bytes) is automatically appended to the ciphertext.
aesDecryptGCM
Decrypts AES-256-GCM encrypted data and verifies authentication.Encrypted data with authentication tag appended
256-bit decryption key (32 bytes)
Initialization vector (16 bytes)
Additional authenticated data used during encryption
Decrypted plaintext
aesEncryptCTR
Encrypts data using AES-256-CTR mode.Data to encrypt
256-bit encryption key
Counter initialization vector
Encrypted ciphertext
aesDecryptCTR
Decrypts AES-256-CTR encrypted data.aesEncrypt
Encrypts data using AES-256-CBC with a random IV prepended.Data to encrypt
256-bit encryption key
Random IV (16 bytes) prepended to the ciphertext
aesDecrypt
Decrypts AES-256-CBC encrypted data where IV is prepended.IV-prepended ciphertext (first 16 bytes are IV)
256-bit decryption key
Decrypted plaintext
aesEncryptWithIV
Encrypts data using AES-256-CBC with a provided IV.aesDecryptWithIV
Decrypts AES-256-CBC encrypted data with a provided IV.Hashing & HMAC
sha256
Computes SHA-256 hash of data.Data to hash
SHA-256 hash (32 bytes)
hmacSign
Creates HMAC signature using SHA-256 or SHA-512.Data to sign
HMAC key
Hash algorithm to use (default: ‘sha256’)
HMAC signature
hkdf
HMAC-based Key Derivation Function for deriving keys.Input key material
Desired output length in bytes
HKDF options
Derived key material of specified length
Media Encryption
getMediaKeys
Generates all keys required for media encryption/decryption.Media key (base64 string or bytes)
Type of media: ‘image’, ‘video’, ‘audio’, ‘document’, ‘sticker’, etc.
Derived encryption keys
encryptedStream
Encrypts a media stream for WhatsApp upload.Media to encrypt - can be Buffer, stream, or file path/URL
Type of media being encrypted
Encryption options
Encryption result with all necessary metadata
downloadContentFromMessage
Downloads and decrypts media from a WhatsApp message.Message containing media keys and URL
Type of media being downloaded
Download options including byte range
Readable stream of decrypted media data
Signal Protocol
signedKeyPair
Generates a signed pre-key pair for Signal protocol.Identity key pair for signing
ID number for this signed pre-key
Signed pre-key with signature
generateSignalPubKey
Prefixes version byte to public keys for Signal protocol compatibility.Public key (32 or 33 bytes)
Public key with version byte prefix (33 bytes total)
derivePairingCodeKey
Derives encryption key from pairing code using PBKDF2.8-digit pairing code
Salt for key derivation
Derived 32-byte encryption key
Uses 131,072 iterations of PBKDF2 with SHA-256.
Utility Functions
md5
Computes MD5 hash (imported from whatsapp-rust-bridge).Data to hash
MD5 hash (16 bytes)
Related
Auth Utilities
Authentication and key management
Media Operations
Complete media handling guide