salsaBoxSeal static method
NaCl crypto_box seal quick call for TON Connect, routed through the
active backend: X25519 + XSalsa20-Poly1305, returning
NONCE || TAG || CIPHERTEXT. Generates a fresh random 24-byte nonce
(web-safe Fortuna PRNG) when nonce is omitted; pass an explicit
nonce for deterministic vectors/tests.
Implementation
static BuBytes salsaBoxSeal({
required List<int> peerPublicKey,
required List<int> secretKey,
required List<int> plainText,
List<int>? nonce,
}) {
final n = nonce ?? generateRandom(length: xsalsa20Poly1305NonceSize);
try {
return blockchainUtils.api.aed.salsaBoxSeal(
n,
plainText,
peerPublicKey: peerPublicKey,
secretKey: secretKey,
);
} finally {
if (nonce == null) {
BinaryOps.zero(n);
}
}
}