Function deriveHdPublicNodeChild

  • Derive a non-hardened child HD public node from an HD public node.

    Because hardened derivation also requires knowledge of the parent private node, it's not possible to use an HD public node to derive a hardened child HD public node.

    Though private keys cannot be derived from HD public keys, sharing HD public keys still carries risk. Along with allowing an attacker to associate wallet addresses together (breaking privacy), should an attacker gain knowledge of a single child private key, it's possible to derive all parent HD private keys. See crackHdPrivateNodeFromHdPublicNodeAndChildPrivateNode for details.

    Parameters

    • node: HdPublicNode

      the HD public node from which to derive the child public node

    • index: number

      the index at which to derive the child node

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

      an optional object containing implementations of sha256, sha512, ripemd160, and secp256k1 compressed public 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: {
            addTweakPublicKeyCompressed: ((publicKey: Uint8Array, tweakValue: Uint8Array) => string | Uint8Array);
        }
        • addTweakPublicKeyCompressed: ((publicKey: Uint8Array, tweakValue: Uint8Array) => string | Uint8Array)
            • (publicKey: Uint8Array, tweakValue: Uint8Array): string | Uint8Array
            • Tweak a publicKey by adding tweakValue times the generator to it.

              Returns an error message if the provided public key could not be parsed or is not valid, or if the addition failed.

              The returned public key will be in compressed format.

              Parameters

              • publicKey: Uint8Array

                a public key.

              • tweakValue: Uint8Array

                256 bit value to tweak by (BE)

              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 HdPublicNodeKnownParent | nextChildIndexRequiresHardenedAlgorithm | hardenedDerivationRequiresPrivateNode

Generated using TypeDoc