Sealed box encrypt: uses an ephemeral keypair so the recipient cannot identify the sender.
Output format: ephemeralPubKey(32) || nonce(24) || ciphertext. The ciphertext includes the 16-byte Poly1305 authentication tag.
ephemeralPubKey(32) || nonce(24) || ciphertext
The plaintext bytes to encrypt.
The recipient's 32-byte Curve25519 public key.
A single Uint8Array containing the sealed message.
Uint8Array
If encryption fails (e.g. invalid public key).
import { sealedBoxEncrypt, sealedBoxDecrypt } from "@polkadot-apps/crypto";import nacl from "tweetnacl";const recipient = nacl.box.keyPair();const sealed = sealedBoxEncrypt(message, recipient.publicKey);const plaintext = sealedBoxDecrypt(sealed, recipient.secretKey); Copy
import { sealedBoxEncrypt, sealedBoxDecrypt } from "@polkadot-apps/crypto";import nacl from "tweetnacl";const recipient = nacl.box.keyPair();const sealed = sealedBoxEncrypt(message, recipient.publicKey);const plaintext = sealedBoxDecrypt(sealed, recipient.secretKey);
Sealed box encrypt: uses an ephemeral keypair so the recipient cannot identify the sender.
Output format:
ephemeralPubKey(32) || nonce(24) || ciphertext. The ciphertext includes the 16-byte Poly1305 authentication tag.