Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DeterministicKey describes hierarchical deterministic keys that are compatible with the bitcoinjs/bip32 implementation.

This class is used to provide with compatibility for both schemes: BIP32 and NIP6.

see

https://github.com/nemtech/NIP/issues/12

since

0.2.0

Hierarchy

Implements

Index

Constructors

constructor

  • new DeterministicKey(__D: undefined | Buffer, __Q: undefined | Buffer, chainCode: Buffer, network: Network, __DEPTH?: number, __INDEX?: number, __PARENT_FINGERPRINT?: number): DeterministicKey
  • Construct a NodeEd25519 object.

    Parameters

    • __D: undefined | Buffer
    • __Q: undefined | Buffer
    • chainCode: Buffer

      The chain code of the node (32 bytes).

    • network: Network

      The network of the node

    • __DEPTH: number = 0
    • __INDEX: number = 0
    • __PARENT_FINGERPRINT: number = 0x00000000

    Returns DeterministicKey

Properties

Readonly chainCode

chainCode: Buffer

Readonly network

network: Network

Accessors

Private depth

  • get depth(): number

fingerprint

  • get fingerprint(): Buffer
  • Getter for the fingerprint of the key.

    The fingerprint are the first 4 bytes of the identifier of the key.

    access

    public

    Returns Buffer

identifier

  • get identifier(): Buffer
  • Getter for the identifier of the key.

    The identifier is build as follows:

    • Step 1: Sha3-256 of the public key
    • Step 2: RIPEMD160 of the sha3 hash
    access

    public

    Returns Buffer

Private index

  • get index(): number

Private parentFingerprint

  • get parentFingerprint(): number

privateKey

  • get privateKey(): Buffer

Abstract publicKey

  • get publicKey(): Buffer

Methods

Abstract derive

Abstract deriveHardened

Abstract derivePath

  • Generic child derivation.

    This method reads the derivation paths and uses derive and deriveHardened accordingly.

    Derivation paths starting with m/ are only possible with master nodes (for example created from seed).

    abstract
    access

    public

    Parameters

    • path: string

    Returns NodeInterface

getD

  • getD(): undefined | Buffer
  • Getter for private field __D.

    This method is added to explicitely expose the __D field to allow sub-classes to make use of it.

    The __D field represents the private key.

    access

    public

    Returns undefined | Buffer

getDepth

  • getDepth(): number

getIndex

  • getIndex(): number

getParentFingerprint

  • getParentFingerprint(): number

getQ

  • getQ(): undefined | Buffer
  • Getter for private field __Q.

    This method is added to explicitely expose the __Q field to allow sub-classes to make use of it.

    The __Q field represents the public key.

    access

    public

    Returns undefined | Buffer

isNeutered

  • isNeutered(): boolean

Abstract neutered

Abstract sign

  • sign(hash: Buffer): Buffer

toBase58

  • toBase58(): string
  • Get the Base58 representation of said key.

    This method is modified to use the Network class to determine privateKey and publicKey prefixes (version field).

    The Base58 representation is laid on 78 bytes with following specification (with || concatenation operator) :

    version || depth || parent || index || chain code || priv/pub

    Private keys are prepended with 0x00, public keys are encoded in X9.62 format.

    see

    https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js#L73

    access

    public

    Returns string

toWIF

  • toWIF(): string

Abstract verify

  • verify(hash: Buffer, signature: Buffer): boolean
  • Verify a signature signature for data hash with the current node.

    Overloads the bitcoinjs/bip32 method named verify in order to be ED25519 compliant and use tweetnacl with ed25519 instead of secp256k1.

    see

    https://github.com/bitcoinjs/bip32/blob/master/ts-src/bip32.ts#L281

    abstract
    access

    publics

    Parameters

    • hash: Buffer

      The binary data that was supposedly signed.

    • signature: Buffer

      The signature binary data that needs to be verified.

    Returns boolean

    Returns true for a valid signature, false otherwise.

Generated using TypeDoc