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

Function hkdf_two_keys

connectd/handshake.c:232–255  ·  view source on GitHub ↗

out1, out2 = HKDF(in1, in2)` */

Source from the content-addressed store, hash-verified

230
231/* out1, out2 = HKDF(in1, in2)` */
232static void hkdf_two_keys(struct secret *out1, struct secret *out2,
233 const struct secret *in1,
234 const void *in2, size_t in2_size)
235{
236 /* BOLT #8:
237 *
238 * * `HKDF(salt,ikm)`: a function defined in `RFC 5869`<sup>[3](#reference-3)</sup>,
239 * evaluated with a zero-length `info` field
240 * * All invocations of `HKDF` implicitly return 64 bytes
241 * of cryptographic randomness using the extract-and-expand
242 * component of the `HKDF`.
243 */
244 struct secret okm[2];
245
246 SUPERVERBOSE("# HKDF(0x%s,%s%s)",
247 tal_hexstr(tmpctx, in1, sizeof(*in1)),
248 in2_size ? "0x" : "zero",
249 tal_hexstr(tmpctx, in2, in2_size));
250 BUILD_ASSERT(sizeof(okm) == 64);
251 hkdf_sha256(okm, sizeof(okm), in1, sizeof(*in1), in2, in2_size,
252 NULL, 0);
253 *out1 = okm[0];
254 *out2 = okm[1];
255}
256
257static void le64_nonce(unsigned char *npub, u64 nonce)
258{

Callers 7

handshake_succeededFunction · 0.70
act_three_initiatorFunction · 0.70
act_two_initiator2Function · 0.70
act_one_initiatorFunction · 0.70
act_three_responder2Function · 0.70
act_two_responderFunction · 0.70
act_one_responder2Function · 0.70

Calls 2

tal_hexstrFunction · 0.85
hkdf_sha256Function · 0.85

Tested by

no test coverage detected