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

Function commit_number_obscurer

common/initial_commit_tx.c:16–30  ·  view source on GitHub ↗

BOLT #3: * * The 48-bit commitment number is obscured by `XOR` with the lower 48 bits of: * * SHA256(payment_basepoint from open_channel || payment_basepoint from accept_channel) */

Source from the content-addressed store, hash-verified

14 * SHA256(payment_basepoint from open_channel || payment_basepoint from accept_channel)
15 */
16u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint,
17 const struct pubkey *accepter_payment_basepoint)
18{
19 u8 ders[PUBKEY_CMPR_LEN * 2];
20 struct sha256 sha;
21 be64 obscurer = 0;
22
23 pubkey_to_der(ders, opener_payment_basepoint);
24 pubkey_to_der(ders + PUBKEY_CMPR_LEN, accepter_payment_basepoint);
25
26 sha256(&sha, ders, sizeof(ders));
27 /* Lower 48 bits */
28 memcpy((u8 *)&obscurer + 2, sha.u.u8 + sizeof(sha.u.u8) - 6, 6);
29 return be64_to_cpu(obscurer);
30}
31
32bool try_subtract_fee(enum side opener, enum side side,
33 struct amount_sat base_fee,

Callers 2

new_initial_channelFunction · 0.70
mainFunction · 0.50

Calls 3

be64_to_cpuFunction · 0.85
sha256Class · 0.70
pubkey_to_derFunction · 0.50

Tested by 1

mainFunction · 0.40