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

Function le64_nonce

connectd/handshake.c:249–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249static void le64_nonce(unsigned char *npub, u64 nonce)
250{
251 /* BOLT #8:
252 *
253 * ...with nonce `n` encoded as 32 zero bits, followed by a
254 * *little-endian* 64-bit value. Note: this follows the Noise
255 * Protocol convention, rather than our normal endian
256 */
257 le64 le_nonce = cpu_to_le64(nonce);
258 const size_t zerolen = crypto_aead_chacha20poly1305_ietf_NPUBBYTES - sizeof(le_nonce);
259
260 BUILD_ASSERT(crypto_aead_chacha20poly1305_ietf_NPUBBYTES >= sizeof(le_nonce));
261 /* First part is 0, followed by nonce. */
262 memset(npub, 0, zerolen);
263 memcpy(npub + zerolen, &le_nonce, sizeof(le_nonce));
264}
265
266/* BOLT #8:
267 * * `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