MCPcopy Create free account
hub / github.com/ElementsProject/lightning / le64_nonce

Function le64_nonce

connectd/handshake.c:257–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static void le64_nonce(unsigned char *npub, u64 nonce)
258{
259 /* BOLT #8:
260 *
261 * with nonce `n` encoded as 32 zero bits, followed by a
262 * *little-endian* 64-bit value. Note: this follows the Noise
263 * Protocol convention, rather than our normal endian.
264 */
265 le64 le_nonce = cpu_to_le64(nonce);
266 const size_t zerolen = crypto_aead_chacha20poly1305_ietf_NPUBBYTES - sizeof(le_nonce);
267
268 BUILD_ASSERT(crypto_aead_chacha20poly1305_ietf_NPUBBYTES >= sizeof(le_nonce));
269 /* First part is 0, followed by nonce. */
270 memset(npub, 0, zerolen);
271 memcpy(npub + zerolen, &le_nonce, sizeof(le_nonce));
272}
273
274/* BOLT #8:
275 * * `encryptWithAD(k, n, ad, plaintext)`: outputs `encrypt(k, n, ad,

Callers 2

encrypt_adFunction · 0.70
decryptFunction · 0.70

Calls 1

cpu_to_le64Function · 0.85

Tested by

no test coverage detected