Class HDKey
Extended (hierarchical deterministic) private key
Inheritance
Namespace: Netmavryk.Keys
Assembly: Netmavryk.dll
Syntax
public class HDKey : object
Constructors
| Improve this Doc View SourceHDKey(ECKind)
Generates a new extended (hierarchical deterministic) private key
Declaration
public HDKey(ECKind kind = default(ECKind))
Parameters
| Type | Name | Description |
|---|---|---|
| ECKind | kind | Elliptic curve kind |
Properties
| Improve this Doc View SourceAddress
Public key hash
Declaration
public string Address { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
ChainCode
32 bytes of entropy added to the private key to enable deriving secure child keys
Declaration
public byte[] ChainCode { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte[] |
HDPubKey
Extended (hierarchical deterministic) public key
Declaration
public HDPubKey HDPubKey { get; }
Property Value
| Type | Description |
|---|---|
| HDPubKey |
Key
Private key
Declaration
public Key Key { get; }
Property Value
| Type | Description |
|---|---|
| Key |
PubKey
Public key
Declaration
public PubKey PubKey { get; }
Property Value
| Type | Description |
|---|---|
| PubKey |
Methods
| Improve this Doc View SourceDerive(HDPath)
Derives an extended child key at the given path relative to the current key
Declaration
public HDKey Derive(HDPath path)
Parameters
| Type | Name | Description |
|---|---|---|
| HDPath | path | HD key path |
Returns
| Type | Description |
|---|---|
| HDKey | Derived extended child key |
Derive(Int32, Boolean)
Derives an extended child key at the given index
Declaration
public HDKey Derive(int index, bool hardened = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Index of the child key, starting from zero |
| System.Boolean | hardened | If true, hardened derivation will be performed |
Returns
| Type | Description |
|---|---|
| HDKey | Derived extended child key |
Derive(String)
Derives an extended child key at the given path relative to the current key
Declaration
public HDKey Derive(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | HD key path string, formatted like m/44'/1729'/0/0' |
Returns
| Type | Description |
|---|---|
| HDKey | Derived extended child key |
FromKey(Key, Byte[])
Creates an extended (hierarchical deterministic) private key from the given private key and chain code
Declaration
public static HDKey FromKey(Key key, byte[] chainCode)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | key | Private key |
| System.Byte[] | chainCode | 32 bytes of entropy to be added to the private key |
Returns
| Type | Description |
|---|---|
| HDKey | Extended private key |
FromMnemonic(Mnemonic, String, ECKind)
Creates an extended (hierarchical deterministic) private key from the given BIP-39 mnemonic
Declaration
public static HDKey FromMnemonic(Mnemonic mnemonic, string passphrase = "", ECKind kind = default(ECKind))
Parameters
| Type | Name | Description |
|---|---|---|
| Mnemonic | mnemonic | BIP-39 mnemonic sentence |
| System.String | passphrase | Passphrase. If not present, an empty string "" is used instead, according to the standard. |
| ECKind | kind | Elliptic curve kind |
Returns
| Type | Description |
|---|---|
| HDKey | Extended private key |
FromSeed(Byte[], ECKind)
Creates an extended (hierarchical deterministic) private key from the given seed bytes
Declaration
public static HDKey FromSeed(byte[] seed, ECKind kind = default(ECKind))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | seed | Seed bytes |
| ECKind | kind | Elliptic curve kind |
Returns
| Type | Description |
|---|---|
| HDKey | Extended private key |
Sign(Byte[])
Signs an array of bytes
Declaration
public Signature Sign(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | bytes | Array of bytes to sign |
Returns
| Type | Description |
|---|---|
| Signature | Signature object |
Sign(String)
Signs a UTF-8 encoded string
Declaration
public Signature Sign(string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | String to sign |
Returns
| Type | Description |
|---|---|
| Signature | Signature object |
SignOperation(Byte[])
Signs forged operation bytes with 0x03 prefix added
Declaration
public Signature SignOperation(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | bytes | Forged operation bytes |
Returns
| Type | Description |
|---|---|
| Signature | Signature object |
Verify(Byte[], Byte[])
Verifies a signature of the given array of bytes
Declaration
public bool Verify(byte[] data, byte[] signature)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | Original data bytes |
| System.Byte[] | signature | Signature to verify |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the signature is valid, otherwise false |
Verify(String, String)
Verifies a signature of the given message string
Declaration
public bool Verify(string message, string signature)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | Original message string |
| System.String | signature | Signature to verify |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the signature is valid, otherwise false |