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

Function commit_number_obscurer

common/initial_commit_tx.c:15–29  ·  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

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

Callers 2

new_initial_channelFunction · 0.70
mainFunction · 0.50

Calls 3

pubkey_to_derFunction · 0.85
be64_to_cpuFunction · 0.85
sha256Class · 0.70

Tested by 1

mainFunction · 0.40