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

Function hkdf_two_keys

connectd/handshake.c:224–247  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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