| | | 1 | | namespace NLightning.Domain.Channels.ValueObjects; |
| | | 2 | | |
| | | 3 | | using NLightning.Domain.Crypto.ValueObjects; |
| | | 4 | | |
| | | 5 | | public record struct CommitmentKeys |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// The localpubkey from the commitment owner's perspective. |
| | | 9 | | /// Derived as: payment_basepoint + SHA256(per_commitment_point || payment_basepoint) * G |
| | | 10 | | /// Used for to_remote outputs (the other party can spend immediately). |
| | | 11 | | /// </summary> |
| | 64 | 12 | | public CompactPubKey LocalPubKey { get; init; } |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// The local_delayedpubkey from the commitment owner's perspective. |
| | | 16 | | /// Derived as: delayed_payment_basepoint + SHA256(per_commitment_point || delayed_payment_basepoint) * G |
| | | 17 | | /// Used for to_local outputs (the commitment owner can spend after a delay). |
| | | 18 | | /// </summary> |
| | 124 | 19 | | public CompactPubKey LocalDelayedPubKey { get; init; } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// The revocationpubkey that allows the other party to revoke this commitment. |
| | | 23 | | /// Complex derivation involving both parties' keys to ensure neither can compute the private key alone. |
| | | 24 | | /// </summary> |
| | 256 | 25 | | public CompactPubKey RevocationPubKey { get; init; } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// The local_htlcpubkey from the commitment owner's perspective. |
| | | 29 | | /// Derived as: htlc_basepoint + SHA256(per_commitment_point || htlc_basepoint) * G |
| | | 30 | | /// Used for HTLC outputs owned by the commitment owner. |
| | | 31 | | /// </summary> |
| | 196 | 32 | | public CompactPubKey LocalHtlcPubKey { get; init; } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// The remote_htlcpubkey from the commitment owner's perspective. |
| | | 36 | | /// Derived as: remote_htlc_basepoint + SHA256(per_commitment_point || remote_htlc_basepoint) * G |
| | | 37 | | /// Used for HTLC outputs owned by the other party. |
| | | 38 | | /// </summary> |
| | 196 | 39 | | public CompactPubKey RemoteHtlcPubKey { get; init; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// The per-commitment point used to derive all the above keys. |
| | | 43 | | /// Generated as: per_commitment_secret * G |
| | | 44 | | /// </summary> |
| | 64 | 45 | | public CompactPubKey PerCommitmentPoint { get; init; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// The per-commitment secret used to generate the per-commitment point. |
| | | 49 | | /// Only available for our own commitments, not for remote commitments. |
| | | 50 | | /// </summary> |
| | 64 | 51 | | public Secret? PerCommitmentSecret { get; init; } |
| | | 52 | | |
| | | 53 | | public CommitmentKeys(CompactPubKey localPubKey, CompactPubKey localDelayedPubKey, |
| | | 54 | | CompactPubKey revocationPubKey, CompactPubKey localHtlcPubKey, |
| | | 55 | | CompactPubKey remoteHtlcPubKey, CompactPubKey perCommitmentPoint, |
| | | 56 | | Secret? perCommitmentSecret) |
| | | 57 | | { |
| | 64 | 58 | | LocalPubKey = localPubKey; |
| | 64 | 59 | | LocalDelayedPubKey = localDelayedPubKey; |
| | 64 | 60 | | RevocationPubKey = revocationPubKey; |
| | 64 | 61 | | LocalHtlcPubKey = localHtlcPubKey; |
| | 64 | 62 | | RemoteHtlcPubKey = remoteHtlcPubKey; |
| | 64 | 63 | | PerCommitmentPoint = perCommitmentPoint; |
| | 64 | 64 | | PerCommitmentSecret = perCommitmentSecret; |
| | 64 | 65 | | } |
| | | 66 | | } |