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

Function derive_simple_pubkey

tests/test_opening.py:81–90  ·  view source on GitHub ↗

BOLT #3: pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G Both args and the result are 33-byte compressed pubkeys.

(basepoint, per_commitment_point)

Source from the content-addressed store, hash-verified

79
80
81def derive_simple_pubkey(basepoint, per_commitment_point):
82 """BOLT #3: pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G
83
84 Both args and the result are 33-byte compressed pubkeys.
85 """
86 tweak = _sha256(per_commitment_point, basepoint)
87 tweak_g = coincurve.PublicKey.from_valid_secret(tweak)
88 combined = coincurve.PublicKey.combine_keys([coincurve.PublicKey(basepoint),
89 tweak_g])
90 return combined.format(compressed=True)
91
92
93def derive_revocation_pubkey(revocation_basepoint, per_commitment_point):

Calls 1

_sha256Function · 0.85

Tested by

no test coverage detected