Class SecureKeyManager
- Namespace
- NLightning.Infrastructure.Bitcoin.Managers
- Assembly
- NLightning.Infrastructure.Bitcoin.dll
Manages a securely stored private key using protected memory allocation. This class ensures that the private key remains inaccessible from regular memory and is securely wiped when no longer needed.
public class SecureKeyManager : ISecureKeyManager, IDisposable
- Inheritance
-
SecureKeyManager
- Implements
- Inherited Members
Constructors
SecureKeyManager(byte[], BitcoinNetwork, string)
Manages secure key operations for generating and managing cryptographic keys. Provides functionality to safely store, load, and derive secure keys protected in memory.
public SecureKeyManager(byte[] privateKey, BitcoinNetwork network, string filePath)
Parameters
privateKey
byte[]The private key to be managed.
network
BitcoinNetworkThe network associated with the private key.
filePath
stringThe file path for storing the key data.
Properties
KeyPath
public BitcoinKeyPath KeyPath { get; }
Property Value
OutputDescriptor
public string OutputDescriptor { get; init; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
~SecureKeyManager()
protected ~SecureKeyManager()
FromFilePath(string, BitcoinNetwork, string)
public static SecureKeyManager FromFilePath(string filePath, BitcoinNetwork expectedNetwork, string password)
Parameters
filePath
stringexpectedNetwork
BitcoinNetworkpassword
string
Returns
FromMnemonic(string, string, BitcoinNetwork, string?)
public static SecureKeyManager FromMnemonic(string mnemonic, string passphrase, BitcoinNetwork network, string? filePath = null)
Parameters
mnemonic
stringpassphrase
stringnetwork
BitcoinNetworkfilePath
string
Returns
GetKeyAtIndex(uint)
public ExtPrivKey GetKeyAtIndex(uint index)
Parameters
index
uint
Returns
GetKeyFilePath(string)
Gets the path for the Key file
public static string GetKeyFilePath(string network)
Parameters
network
string
Returns
GetNextKey(out uint)
public ExtPrivKey GetNextKey(out uint index)
Parameters
index
uint
Returns
GetNodeKeyPair()
public CryptoKeyPair GetNodeKeyPair()
Returns
GetNodePubKey()
public CompactPubKey GetNodePubKey()
Returns
SaveToFile(string)
public void SaveToFile(string password)
Parameters
password
string
UpdateLastUsedIndexOnFile()
public Task UpdateLastUsedIndexOnFile()