Function deriveHdPrivateNodeChild

  • Derive a child HD private node from an HD private node.

    To derive a child HD public node, use deriveHdPublicNode on the result of this method. If the child uses a non-hardened index, it's also possible to use deriveHdPublicNodeChild.

    Parameters

    • node: HdPrivateNodeValid

      the valid HD private node from which to derive the child node

    • index: number

      the index at which to derive the child node - indexes greater than or equal to the hardened index offset (0x80000000/2147483648) are derived using the "hardened" derivation algorithm

    • crypto: {
          ripemd160: {
              hash: ((input: Uint8Array) => Uint8Array);
          };
          secp256k1: {
              addTweakPrivateKey: ((privateKey: Uint8Array, tweakValue: Uint8Array) => string | Uint8Array);
              derivePublicKeyCompressed: ((privateKey: Uint8Array) => string | Uint8Array);
          };
          sha256: {
              hash: ((input: Uint8Array) => Uint8Array);
          };
          sha512: {
              hash: ((input: Uint8Array) => Uint8Array);
          };
      } = ...

      an optional object containing implementations of sha256, ripemd160, secp256k1 compressed public key derivation, and secp256k1 private key "tweak addition" (application of the EC group operation)

      • ripemd160: {
            hash: ((input: Uint8Array) => Uint8Array);
        }
        • hash: ((input: Uint8Array) => Uint8Array)
            • (input: Uint8Array): Uint8Array
            • Returns the ripemd160 hash of the provided input.

              To incrementally construct a ripemd160 hash (e.g. for streaming), use init, update, and final.

              Parameters

              • input: Uint8Array

                a Uint8Array to be hashed using ripemd160

              Returns Uint8Array

      • secp256k1: {
            addTweakPrivateKey: ((privateKey: Uint8Array, tweakValue: Uint8Array) => string | Uint8Array);
            derivePublicKeyCompressed: ((privateKey: Uint8Array) => string | Uint8Array);
        }
        • addTweakPrivateKey: ((privateKey: Uint8Array, tweakValue: Uint8Array) => string | Uint8Array)
            • (privateKey: Uint8Array, tweakValue: Uint8Array): string | Uint8Array
            • Tweak a privateKey by adding tweakValue to it.

              Returns an error message if the private key is invalid or if the addition fails.

              Parameters

              • privateKey: Uint8Array

                a valid secp256k1 private key

              • tweakValue: Uint8Array

                256 bit value to tweak by (BE)

              Returns string | Uint8Array

        • derivePublicKeyCompressed: ((privateKey: Uint8Array) => string | Uint8Array)
            • (privateKey: Uint8Array): string | Uint8Array
            • Derive a compressed public key from a valid secp256k1 private key.

              Returns an error message if the provided private key is too large (see validatePrivateKey).

              Parameters

              • privateKey: Uint8Array

                a valid secp256k1, 32-byte private key

              Returns string | Uint8Array

      • sha256: {
            hash: ((input: Uint8Array) => Uint8Array);
        }
        • hash: ((input: Uint8Array) => Uint8Array)
            • (input: Uint8Array): Uint8Array
            • Returns the sha256 hash of the provided input.

              To incrementally construct a sha256 hash (e.g. for streaming), use init, update, and final.

              Parameters

              • input: Uint8Array

                a Uint8Array to be hashed using sha256

              Returns Uint8Array

      • sha512: {
            hash: ((input: Uint8Array) => Uint8Array);
        }
        • hash: ((input: Uint8Array) => Uint8Array)
            • (input: Uint8Array): Uint8Array
            • Returns the sha512 hash of the provided input.

              To incrementally construct a sha512 hash (e.g. for streaming), use init, update, and final.

              Parameters

              • input: Uint8Array

                a Uint8Array to be hashed using sha512

              Returns Uint8Array

    Returns HdPrivateNodeKnownParent | childIndexExceedsMaximum | nextChildIndexRequiresHardenedAlgorithm

Generated using TypeDoc