lightning community – LND per-commitment-secret derivation


For studying functions I am attempting to recreate all keys in LND channel.

I may reproduce MultiSigKey, RevocationBasePoint, PaymentBasePoint, DelayBasePoint, HtlcBasePoint. The workflow to breed them was to create HD node root key with azeed from 24 phrases after which use HD Pockets BIP44 specification to calculate these keys with outlined paths.

My HD node root key (base58): vprv9DMUxX4ShgxMLHkP4A7EPJr52LoHYn5jD6vn3UfQnf6Tv1uA7mw3RozDzwD2vMxs5MWLAPENaxYvrDERFdARSQLa6RXWBih5bjRqh5hsfJr

(derived from:
words_local=”above tomato swarm sq. ski body stay buffalo cardio ginger cut back insect kiwi kitchen antenna elevator century courageous boil gospel gasoline picnic climate basket”)

For instance I can efficiently derive RevocationBasePoint with path “m/1017’/1’/1’/0/0”
032a1e4b9ba2db7bcdee19cfb6cd9b285af0b99723f401e72990e278ea029a07e3
(the actual keys I acquired studying channel information with chantools from guggero).

Nonetheless I can not derive the Per-commitment-point, which must be:
0346d482f460d2a2e53db6c1f2cf06cfcf2d2151088787a4a7637ed35552a22767

I’ve applied per-commitment-secret as in BOLT 03 and examined it with efficiently with check vectors, however nonetheless can’t derive the ‘0346d4..’ key.

generate_from_seed(seed, I):
    P = seed
    for B in 47 all the way down to 0:
        if B set in I:
            flip(B) in P
            P = SHA256(P)
    return P

I exploit for seed the decoded prolonged non-public key:

extended_private_key = "vprv9DMUxX4ShgxMLHkP4A7EPJr52LoHYn5jD6vn3UfQnf6Tv1uA7mw3RozDzwD2vMxs5MWLAPENaxYvrDERFdARSQLa6RXWBih5bjRqh5hsfJr"
decoded_key = base58.b58decode(extended_private_key)
seed = decoded_key[46:78]

index = 0xFFFFFFFFFFFF # 281474976710655 (first channel).

I imagine I am not utilizing the best seed…May somebody please assist how one can derive the per-commitment-secret?

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top