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

Function le64_nonce

common/cryptomsg.c:71–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71static void le64_nonce(unsigned char *npub, u64 nonce)
72{
73 /* BOLT #8:
74 *
75 * with nonce `n` encoded as 32 zero bits, followed by a
76 * *little-endian* 64-bit value. Note: this follows the Noise
77 * Protocol convention, rather than our normal endian.
78 */
79 le64 le_nonce = cpu_to_le64(nonce);
80 const size_t zerolen = crypto_aead_chacha20poly1305_ietf_NPUBBYTES - sizeof(le_nonce);
81
82 BUILD_ASSERT(crypto_aead_chacha20poly1305_ietf_NPUBBYTES >= sizeof(le_nonce));
83 /* First part is 0, followed by nonce. */
84 memset(npub, 0, zerolen);
85 memcpy(npub + zerolen, &le_nonce, sizeof(le_nonce));
86}
87
88u8 *cryptomsg_decrypt_body(const tal_t *ctx,
89 struct crypto_state *cs, const u8 *in)

Callers 3

cryptomsg_decrypt_bodyFunction · 0.70
cryptomsg_decrypt_headerFunction · 0.70
cryptomsg_encrypt_msgFunction · 0.70

Calls 1

cpu_to_le64Function · 0.85

Tested by

no test coverage detected