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

Function le64_nonce

common/cryptomsg.c:69–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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