Table of Contents

Class KeyDerivationService

Namespace
NLightning.Infrastructure.Bitcoin.Services
Assembly
NLightning.Infrastructure.Bitcoin.dll
public class KeyDerivationService : IKeyDerivationService
Inheritance
KeyDerivationService
Implements
Inherited Members

Methods

DerivePrivateKey(PrivKey, CompactPubKey)

Derives a private key using the formula: basepoint_secret + SHA256(per_commitment_point || basepoint)

public PrivKey DerivePrivateKey(PrivKey basepointSecretPriv, CompactPubKey compactPerCommitmentPoint)

Parameters

basepointSecretPriv PrivKey
compactPerCommitmentPoint CompactPubKey

Returns

PrivKey

DerivePublicKey(CompactPubKey, CompactPubKey)

Derives a public key using the formula: basepoint + SHA256(per_commitment_point || basepoint) * G

public CompactPubKey DerivePublicKey(CompactPubKey compactBasepoint, CompactPubKey compactPerCommitmentPoint)

Parameters

compactBasepoint CompactPubKey
compactPerCommitmentPoint CompactPubKey

Returns

CompactPubKey

DeriveRevocationPrivKey(PrivKey, PrivKey)

Derives the revocation private key when both secrets are known

public PrivKey DeriveRevocationPrivKey(PrivKey revocationBasepointSecretPriv, PrivKey perCommitmentSecretPriv)

Parameters

revocationBasepointSecretPriv PrivKey
perCommitmentSecretPriv PrivKey

Returns

PrivKey

DeriveRevocationPubKey(CompactPubKey, CompactPubKey)

Derives the revocation public key

public CompactPubKey DeriveRevocationPubKey(CompactPubKey compactRevocationBasepoint, CompactPubKey compactPerCommitmentPoint)

Parameters

compactRevocationBasepoint CompactPubKey
compactPerCommitmentPoint CompactPubKey

Returns

CompactPubKey

GeneratePerCommitmentSecret(Secret, ulong)

Generates per-commitment secret from seed and index

public Secret GeneratePerCommitmentSecret(Secret seed, ulong index)

Parameters

seed Secret
index ulong

Returns

Secret