interface Blockchain {
    create(
        name: string,
        type: BLOCKCHAIN_KEYS,
        exportable: boolean,
        temporary: boolean,
        version?: null | VERSION_OPTIONS,
        seed?: null | string,
        passphrase?: null | string,
    ): Promise<boolean>;
    delete(name: string): Promise<boolean>;
    block(name: string): Promise<boolean>;
    unblock(name: string): Promise<boolean>;
    createBip32ChildKeyDerivation(
        version: VERSION_OPTIONS,
        index: number,
        exportable: boolean,
        temporary: boolean,
        parentKeyName: string,
        childKeyName: string,
    ): Promise<KeyInfo>;
    hashData(
        hashMode: BLOCKCHAIN_HASH_MODE,
        data: Buffer,
    ): Promise<Buffer<ArrayBufferLike>>;
    edDsaSign(
        type: BLOCKCHAIN_EdDSA_TYPE,
        privKeyName: string,
        data: Buffer,
    ): Promise<Buffer<ArrayBufferLike>>;
    getPubKey(
        type: BLOCKCHAIN_GET_PUB_KEY_TYPE,
        privKeyName: string,
    ): Promise<Buffer<ArrayBufferLike>>;
    edDsaVerify(
        type: BLOCKCHAIN_EdDSA_TYPE,
        pubKeyType: BLOCKCHAIN_PUB_KEY_TYPE,
        pubKey: Buffer,
        signature: Buffer,
        data: Buffer,
    ): Promise<boolean>;
    getAddress(
        type: ADDRESS_TYPE,
        version: ADDRESS_VERSION,
        hrp: ADDRESS_HRP,
        pk: string,
    ): Promise<Buffer<ArrayBufferLike>>;
    sign(
        type: BLOCKCHAIN_SIG_TYPE,
        hashMode: BLOCKCHAIN_HASH_MODE,
        hash: Buffer,
        pk: string,
    ): Promise<Buffer<ArrayBufferLike>>;
    getKeyInfo(name: string): Promise<KeyInfo>;
    import(
        format: IMPORT_EXPORT_FORMAT,
        exportable: boolean,
        temporary: boolean,
        name: string,
        data: string,
    ): Promise<boolean>;
    export(
        format: IMPORT_EXPORT_FORMAT,
        version: BLOCKCHAIN_EXPORT_VERSION,
        compressed: boolean,
        name: string,
    ): Promise<Buffer<ArrayBufferLike>>;
    verify(
        sigType: BLOCKCHAIN_SIG_TYPE,
        hashMode: BLOCKCHAIN_HASH_MODE,
        hashData: Buffer,
        signature: Buffer,
        pubKeyType: BLOCKCHAIN_SIG_VERIFY_PUB_KEY_TYPE,
        pubSignature: Buffer,
    ): Promise<boolean>;
    pubKeyRecovery(
        sigType: BLOCKCHAIN_SIG_TYPE,
        hashMode: BLOCKCHAIN_HASH_MODE,
        hashData: Buffer,
        signature: Buffer,
    ): Promise<Buffer<ArrayBufferLike>>;
    abn128RndCtxGetPt(
        x: string | Buffer<ArrayBufferLike>,
        y: string | Buffer<ArrayBufferLike>,
    ): Promise<Buffer<ArrayBufferLike>>;
    abn128RndCtxMultAdd(
        keyName: string,
        scalar: string | Buffer<ArrayBufferLike>,
    ): Promise<Buffer<ArrayBufferLike>>;
    abn128RndScs(): Promise<Buffer<ArrayBufferLike>[]>;
    abn128RndSc(): Promise<Buffer<ArrayBufferLike>>;
    abn128RndCtxRefresh(
        x: string | Buffer<ArrayBufferLike>,
        y: string | Buffer<ArrayBufferLike>,
    ): Promise<Buffer<ArrayBufferLike>>;
    abn128PscMult(
        keyName: string,
        x: string | Buffer<ArrayBufferLike>,
        y: string | Buffer<ArrayBufferLike>,
        neg?: boolean,
    ): Promise<Buffer<ArrayBufferLike>>;
}

Methods

  • Creates an Extended Private Key (XPrv) for the blockchain in the BIP32 standard.

    Parameters

    • name: string

      Name of the key in the HSM.

    • type: BLOCKCHAIN_KEYS

      Type of key generation.

    • exportable: boolean

      If the key is exportable.

    • temporary: boolean

      If the key is temporary.

    • Optionalversion: null | VERSION_OPTIONS

      Key version that must be passed according to the type option

    • Optionalseed: null | string

      Buffer containing the data needed to generate the key. The input data must be passed according to the enums.BLOCKCHAIN_KEYS type option.

    • Optionalpassphrase: null | string

    Returns Promise<boolean>

    Key created.

    exceptions.HsmError If it is not possible to create the key or there is an error in the operation.

    Example code: Creating a blockchain key

  • Deletes a key stored in the HSM.

    Parameters

    • name: string

      Key name.

    Returns Promise<boolean>

    Returns true if the key was successfully deleted.

    If the key name is invalid.

    In the event of an error when deleting the key.

    Example code: Deleting a blockchain key

  • Locks a key in the HSM.

    Parameters

    • name: string

      Key name.

    Returns Promise<boolean>

    Returns true if the key was successfully locked.

    If the key name is invalid.

    In the event of an error when deleting the key.

    Example code: Locking a blockchain key

  • Unlocks a key in the HSM.

    Parameters

    • name: string

      Key name.

    Returns Promise<boolean>

    Returns true if the key was successfully unlocked.

    If the key name is invalid.

    In the event of an error when deleting the key.

    Example code: Unlocking a blockchain key

  • Performs a Child Key Derivation (CKD) operation. Derives an Extended Private Key (XPrv) for the blockchain in the BIP32 standard.

    Parameters

    • version: VERSION_OPTIONS

      Key version.

    • index: number

      Index of the key to be derived. Non-hardened keys use an index from 0 to231-1 and hardened (unrestrictedly secure) keys use indexes from231 to232-1, as specified in the BIP32 standard. It is highly recommended to generate hardened keys.

    • exportable: boolean

      If the key is exportable.

    • temporary: boolean

      If the key is temporary.

    • parentKeyName: string

      Name of the parent key in the HSM. It must be an XPrv key.

    • childKeyName: string

      Name of the key that will be derived in the HSM.

    Returns Promise<KeyInfo>

    Information on the derived key.

    exceptions.HsmError If it is not possible to derive the key or an error occurs in the operation.

  • Generates an EdDSA signature using the blockchain module.

    Parameters

    • type: BLOCKCHAIN_EdDSA_TYPE

      Type of signature to be generated.

    • privKeyName: string

      Name of the private key.

    • date: Buffer

      Data that will be signed.

    Returns Promise<Buffer<ArrayBufferLike>>

    Signature generated.

    exceptions.HsmError If it is not possible to sign the data or an error occurs in the operation.

  • Retrieves the address of a key using the blockchain module.

    Parameters

    • type: ADDRESS_TYPE

      Type of address to be generated.

    • version: ADDRESS_VERSION

      Address version.

    • hrp: ADDRESS_HRP

      HRP (Human Readable Part) of the key.

    • pk: string

      Private key from which the address or script-hash will be generated.

    Returns Promise<Buffer<ArrayBufferLike>>

    Returns the address.

    exceptions.HsmError If the address cannot be retrieved or an error occurs in the operation.

    Example code: Getting the blockchain address from the private key

    ATTENTION

    P2TR addresses (without key tweak) should only be used with BIP340/Schnorr signatures in single-key-setting scenarios.
  • Retrieves the properties of a key using the blockchain module.

    Parameters

    • name: string

      Name of the private key.

    Returns Promise<KeyInfo>

    Returns an object with the key's blockchain data.

    exceptions.HsmError If the address cannot be retrieved or an error occurs in the operation.

  • Import a private key using the blockchain_interfaces module.

    Parameters

    • format: IMPORT_EXPORT_FORMAT

      Format of the key to be imported.

    • exportable: boolean

      If the key is exportable.

    • temporary: boolean

      If the key is temporary.

    • name: string

      Name of the private key.

    • date: string

      Private key in the format specified in enums.IMPORT_EXPORT_FORMAT.

    Returns Promise<boolean>

    True if the import was carried out or an exception otherwise.

    exceptions.HsmError If an error occurs in the operation.

  • Calculates a point from another point and a random context.

    Parameters

    Returns Promise<Buffer<ArrayBufferLike>>

    Returns a buffer with the calculated point.

    If any of the parameters entered are invalid.

    exceptions.InvalidParameterError If any parameter entered is invalid.

    exceptions.HsmError If an error occurs in the operation.

  • Multiplies a scalar by the private key and adds a random scalar.

    Parameters

    Returns Promise<Buffer<ArrayBufferLike>>

    Returns a buffer with the result of the operation.

    If the key name is invalid.

    exceptions.InvalidParameterError If any parameter entered is invalid.

    exceptions.HsmError If an error occurs in the operation.

  • Returns four random scalars.

    Returns Promise<Buffer<ArrayBufferLike>[]>

    Returns an array of buffers with random scalars.

    exceptions.HsmError If an error occurs in the operation.

  • Returns a random scalar.

    Returns Promise<Buffer<ArrayBufferLike>>

    Returns a buffer with the random scalar.

    exceptions.HsmError If an error occurs in the operation.

  • Multiplies a scalar by the private key.

    Parameters

    Returns Promise<Buffer<ArrayBufferLike>>

    Returns a buffer with the calculated point.

    If any of the parameters entered are invalid.

    exceptions.InvalidParameterError If any parameter entered is invalid.

    exceptions.HsmError If an error occurs in the operation.

MMNEPVFCICPMFPCPTTAAATR