C/C++ API
HSM Dinamo
Loading...
Looking for...
No entries found
Blockchain

Detailed description

Operations to support the security of Blockchain-based structures.

The Blockchain module APIs are aimed at specific operations for processing blockchain network cryptography and BIP, EIP and SLIP specifications.

The ECDSA signature, for example, is specialized to avoid signature malleabilitywith the restriction of LOW-S.

Examples of operations available in the Blockchain module:

  1. Extended Private Key (XPrv) generation in the BIP32 standard.
  1. Child Key Derivation in the BIP32 and SLIP10 standards.
  1. Address recovery.
  1. ECDSA digital signatures, in SECG strict DER standards (BIP62/66 and BIP 146) and Schnorr in BIP340 standard;
  1. Digital signatures EdDSA curve 25519.
  1. Signature verification.
  1. Import and export of keys via various formats (WIF, Hex, Sec1, Xpriv etc).
  1. Recovery of the public key with different formats (BIP32 Xpub, Sec1 with and without compression, Schnorr BIP340 etc).
  1. Split and Recover secrets with M from N scheme using SSS (Shamir's Secret Sharing).
  1. Operations with the curve alt_bn128according to EIP-196.
Attention
The blockchain module does not handle or assemble the transaction details for each particular network; this must be left to the application. The function of the HSM is to protect the private key in a secure environment, generate and return a signature according to the parameters passed by the calling application.

Compatible networks

Below is the list of networks whose encryption is compatible with HSM:

Observation
The algorithms listed are those currently implemented in the HSM that allow transactions to be signed on the network and do not necessarily cover all the options defined in the network specification. If you have any questions, feel free to contact Dinamo Networks support and ask them.
Then Name Symbol Alg. Signature in HSM Curve Obs
Bitcoin BTC ECDSA secp256k1
Ethereum ETH ECDSA secp256k1
Tether USDT ECDSA secp256k1 token on various networks (e.g. Ethereum, Algorand)
Binance Coin BNB ECDSA secp256k1
image USD Coin USDC ECDSA secp256k1 token
Solana SUN EdDSA edwards25519
XRP XRP ECDSA, EdDSA secp256k1, edwards25519
Terra Classic LUNC ECDSA secp256k1
Cardano ADA EdDSA edwards25519
Avalanche AVAX ECDSA secp256k1
image Dogecoin DOGE ECDSA secp256k1
image Binance USD BUSD ECDSA secp256k1 token
Polkadot DOT ECDSA, EdDSA secp256k1, edwards25519
Shiba Inu SHIB ECDSA secp256k1 token
Wrapped Bitcoin WBTC ECDSA, EdDSA secp256k1, edwards25519 token
Polygon MATIC ECDSA secp256k1
Cronos CRO ECDSA secp256k1
Dai DAI ECDSA secp256k1 token
NEAR Protocol NEAR ECDSA secp256k1
Litecoin LTC ECDSA secp256k1
TRON TRX ECDSA secp256k1
image ApeCoin EPA ECDSA secp256k1 token
Cosmos ATOM ECDSA secp256k1
Bitcoin Cash BCH ECDSA secp256k1
Algorand SOMETHING EdDSA edwards25519
Brazilian Digital Token BRZ ECDSA secp256k1 token
Celo Brazilian Real CREAL ECDSA secp256k1 token
Celo Dollar CUSD ECDSA secp256k1 token
Axie Infinity AXS ECDSA secp256k1 token/coin
Fantom FTM ECDSA secp256k1
Uniswap UNI ECDSA secp256k1 token
Stellar XLM EdDSA edwards25519
Tezos XTZ ECDSA, EdDSA secp256k1, edwards25519
CELO CELO ECDSA secp256k1 token/coin
image Toncoin TON EdDSA edwards25519
Chainlink LINK ECDSA secp256k1 token

The HSM implementation complies with the standards defined in the documentation listed below:

Operations to support the security of Blockchain-based structures. More...

Functions

int AAP_API DBchainCreateXPrv(HSESSIONCTX hSession, BYTE bType, DWORD dwAttributes, const char *szId, const BYTE *pcbData, DWORD dwDataLen, DWORD dwReserved)
 
int AAP_API DBchainCreateBip32Ckd(HSESSIONCTX hSession, BYTE bVersion, DWORD dwIndex, DWORD dwAttributes, const char *cszPar, const char *cszDst, DN_BCHAIN_KEY_INFO *pKeyInfo, DWORD dwReserved)
 
int AAP_API DBchainGetAddress(HSESSIONCTX hSession, BYTE bType, BYTE bVer, const char *cszHrp, const char *cszPk, BYTE *pbAddress, DWORD *pdwAddressLen, DWORD dwReserved)
 
int AAP_API DBchainSignHash(HSESSIONCTX hSession, BYTE bType, BYTE bHashMode, BYTE *pbHash, DWORD dwHashLen, const char *cszPk, BYTE *pbSig, DWORD *pdwSigLen, DWORD dwReserved)
 
int AAP_API DBchainVerify(HSESSIONCTX hSession, BYTE bSigType, BYTE bHashMode, const BYTE *pbHash, DWORD dwHashLen, const BYTE *pbSig, DWORD dwSigLen, BYTE bInPbkType, const BYTE *pbInPbk, BYTE bInPbkLen, DWORD dwReserved)
 
int AAP_API DBchainEdDsaSign(HSESSIONCTX hSession, BYTE bType, const char *cszCtxStr, BYTE *pbData, DWORD dwDataLen, const char *cszPk, BYTE *pbSig, DWORD *pdwSigLen, DWORD dwReserved)
 
int AAP_API DBchainEdDsaVerify(HSESSIONCTX hSession, BYTE bType, const char *cszCtxStr, BYTE *pbData, DWORD dwDataLen, BYTE bPbkType, BYTE *pbPbk, DWORD dwPbkLen, BYTE *pbSig, DWORD dwSigLen, DWORD dwReserved)
 
int AAP_API DBchainPkImport(HSESSIONCTX hSession, BYTE bFormat, DWORD dwAttributes, const char *cszId, const BYTE *pcbData, DWORD dwDataLen, DWORD dwReserved)
 
int AAP_API DBchainPkExport(HSESSIONCTX hSession, BYTE bFormat, BYTE bVersion, BYTE bCompressed, const char *cszId, BYTE **ppbData, DWORD *pdwDataLen, DWORD dwReserved)
 
int AAP_API DBchainGetPubKey(HSESSIONCTX hSession, BYTE bType, const char *cszId, BYTE *pbData, DWORD *pdwDataLen, DWORD dwReserved)
 
int AAP_API DBchainRecoverPbkFromSignature(HSESSIONCTX hSession, BYTE bSigType, BYTE bHashMode, const BYTE *pbHash, DWORD dwHashLen, const BYTE *pbSig, DWORD dwSigLen, DN_BCHAIN_PBK *pPbk, DWORD dwReserved)
 
int AAP_API DBchainGetKeyInfo(HSESSIONCTX hSession, DWORD dwReserved, const char *cszId, void *pvData, DWORD *pdwDataLen)
 
int AAP_API DBchainHashData(HSESSIONCTX hSession, BYTE bMode, BYTE *pbData, DWORD dwDataLen, BYTE *pbHash, DWORD *pdwHashLen, DWORD dwReserved)
 
int AAP_API DBchainEd2X(HSESSIONCTX hSession, const char *cszPk, const char *cszTo, DWORD dwAttr, DWORD dwReserved)
 

Functions

DBchainCreateXPrv()

int AAP_API DBchainCreateXPrv ( HSESSIONCTX hSession,
BYTE bType,
DWORD dwAttributes,
const char * szId,
const BYTE * pcbData,
DWORD dwDataLen,
DWORD dwReserved )

#include <dinamo.h>

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

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeType of key generation.
Value Meaning
DN_BCHAIN_BTC_MINIKEY Bitcoin minikey. pcbData must be NULL and dwDataLen should be 0.
DN_BCHAIN_BIP32_SEED_XPRV BIP32 seed XPrv. pcbData must contain the structure DN_BCHAIN_BIP32_SEED_XPRV_DATA filled.
DN_BCHAIN_BIP39_SEED_XPRV BIP39 seed XPrv. pcbData must contain the structure DN_BCHAIN_BIP39_SEED_XPRV_DATA filled.
DN_BCHAIN_BIP32_XPRV BIP32 XPrv. dwDataLen must be a BYTE containing the version of the key. See annotations for more details.
DN_BCHAIN_BIP32_ED25519_XPRV BIP32 Ed25519 XPrv. dwDataLen must be a BYTE containing the version of the key. See annotations for more details.
[in]dwAttributesAdditional key parameters. See the options in the DGenerateKey() function. This API automatically includes the BCHAIN_KEY flag, which is required for blockchain operations.
[in]szIdName of the key in the HSM. Must have a maximum length of MAX_OBJ_ID_FQN_LEN.
[in]pcbDataBuffer containing the data needed to generate the key. The input data must be passed according to the option bType and the size of the data passed here must be specified in dwDataLen.
[in]dwDataLenSize of data passed in pcbData.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Notes
Table of version options for the XPrv key.
Value Meaning
DN_BCHAIN_VER_BIP32_MAINNET Mainnet BIP32.
DN_BCHAIN_VER_BIP32_TESTNET Testnet BIP32.
DN_BCHAIN_VER_BIP32_HTR_MAINNET Mainnet BIP32 Hathor.
DN_BCHAIN_VER_BIP32_HTR_TESTNET Testnet BIP32 Hathor.
Examples
ckd_bchain.c, get_key_info_bchain.c, get_pub_key_bchain.c, import_export_bchain.c and sign_verify_bchain.c.

DBchainCreateBip32Ckd()

int AAP_API DBchainCreateBip32Ckd ( HSESSIONCTX hSession,
BYTE bVersion,
DWORD dwIndex,
DWORD dwAttributes,
const char * cszPar,
const char * cszDst,
DN_BCHAIN_KEY_INFO * pKeyInfo,
DWORD dwReserved )

#include <dinamo.h>

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

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bVersionKey version.
Value Meaning
DN_BCHAIN_VER_BIP32_MAINNET Mainnet BIP32.
DN_BCHAIN_VER_BIP32_TESTNET Testnet BIP32.
DN_BCHAIN_VER_BIP32_HTR_MAINNET Mainnet BIP32 Hathor.
DN_BCHAIN_VER_BIP32_HTR_TESTNET Testnet BIP32 Hathor.
[in]dwIndexIndex of the key to be derived. Keys non hardened use the 0 a 231-1 and keys hardened (unrestrictedly secure) use indices of 231 a 232-1as specified in the standard BIP32. It is highly recommended to generate hardened keys. Use DN_BCHAIN_SECURE_BIP32_INDEX_BASE as a basis for generating indexes hardened (Ex. DN_BCHAIN_SECURE_BIP32_INDEX_BASE + 1 ...).
[in]dwAttributesAdditional key parameters. See the options in the DGenerateKey() function. This API automatically includes the BCHAIN_KEY flag, which is required for blockchain operations.
[in]cszParName of the parent key in the HSM. Must have a maximum size of MAX_OBJ_ID_FQN_LEN. Must be an XPrv key(DN_BCHAIN_BIP32_XPRV etc.). See DBchainCreateXPrv().
[in]cszDstName of the key that will be derived in the HSM. It must have a maximum size of MAX_OBJ_ID_FQN_LEN.
[out]pKeyInfoPointer to the DN_BCHAIN_KEY_INFO structure that will contain the information of the generated key.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
ckd_bchain.c.

DBchainGetAddress()

int AAP_API DBchainGetAddress ( HSESSIONCTX hSession,
BYTE bType,
BYTE bView,
const char * cszHrp,
const char * cszPk,
BYTE * pbAddress,
DWORD * pdwAddressLen,
DWORD dwReserved )

#include <dinamo.h>

Retrieves the address of a key using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeType of address to be generated. It can be one of the values below.
Value Meaning
DN_BCHAIN_AT_BTC_P2PKH P2PKH address.

bView should be DN_BCHAIN_VER_BTC_A1_MAIN_NET, DN_BCHAIN_VER_BTC_A3_MAIN_NET, DN_BCHAIN_VER_BTC_AMN_TEST_NET, DN_BCHAIN_VER_HTR_MAINNET or DN_BCHAIN_VER_HTR_TESTNET.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_BTC_P2SH Address P2SH BIP13.

bView should be DN_BCHAIN_VER_BTC_A1_MAIN_NET, DN_BCHAIN_VER_BTC_A3_MAIN_NET, DN_BCHAIN_VER_BTC_AMN_TEST_NET, DN_BCHAIN_VER_HTR_MAINNET or DN_BCHAIN_VER_HTR_TESTNET.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
cszPk should be the script-hash.
DN_BCHAIN_AT_BTC_B32_PKH Address BIP32 P2PKH BIP173.

bView should be DN_BCHAIN_VER_BTC_B32_WITVER.
cszHrp can be DN_BCHAIN_HRP_BTC_MAIN_NET or DN_BCHAIN_HRP_BTC_TEST_NET.
DN_BCHAIN_AT_BTC_B32_SH BIP32 P2SH address.

bView should be DN_BCHAIN_VER_BTC_A1_MAIN_NET, DN_BCHAIN_VER_BTC_A3_MAIN_NET, DN_BCHAIN_VER_BTC_AMN_TEST_NET, DN_BCHAIN_VER_HTR_MAINNET or DN_BCHAIN_VER_HTR_TESTNET.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
cszPk should be the script-hash.
DN_BCHAIN_AT_ETH_EOA Address ETH EOA.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_ETH_EOA_MC_CKS Address ETH EOA MC CKS. EIP55.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_ETH_EOA_ICAP Address ETH EOA ICAP.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_ALGORAND Address Algorand.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_TRON_HEX Hexadecimal TRON address.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_TRON_B58 Address TRON Base 58.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_XRP XRP Ledger/Ripple address.

bView should be DN_BCHAIN_VER_XRP_CLASSIC.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
DN_BCHAIN_AT_SOL Address Solana.

bView should be DN_BCHAIN_VER_UNUSED.
cszHrp should be DN_BCHAIN_HRP_UNUSED.
[in]bViewAddress version.
Value Meaning
DN_BCHAIN_VER_UNUSED Parameter not used.
DN_BCHAIN_VER_BTC_A1_MAIN_NET Bitcoin A1 mainnet.
DN_BCHAIN_VER_XRP_CLASSIC XRP Ledger/Ripple Classic.
DN_BCHAIN_VER_BTC_AMN_TEST_NET Bitcoin P2PKH testnet.
DN_BCHAIN_VER_BTC_A3_MAIN_NET Bitcoin A3 mainnet.
DN_BCHAIN_VER_BTC_B32_WITVER Bitcoin B32 witver.
DN_BCHAIN_VER_HTR_MAINNET Hathor mainnet.
DN_BCHAIN_VER_HTR_TESTNET Hathor testnet.
DN_BCHAIN_VER_HTR_P2SH_MAINNET Hathor P2SH mainnet.
DN_BCHAIN_VER_HTR_P2SH_TESTNET Hathor P2SH testnet.
[in]cszHrpHRP (Human Readable Part) of the key. The values in the table are accepted. It must have a maximum size of DN_BCHAIN_MAX_HRP.
Value Meaning
DN_BCHAIN_HRP_UNUSED Parameter not used.
DN_BCHAIN_HRP_BTC_MAIN_NET Bitcoin mainnet.
DN_BCHAIN_HRP_BTC_TEST_NET Bitcoin testnet.
[in]cszPkPrivate key that will generate the address or the script-hash. If using script-hash pass a buffer of size MAX_OBJ_ID_FQN_LEN with script-hash with zero padding.
[in,out]pbAddressBuffer that will receive the address. It can be NULL to obtain the required size. It is recommended to use the maximum size of DN_BCHAIN_MAX_ADDR_LEN.
[in,out]pdwAddressLenBuffer size pbAddress. If the buffer pbAddress is NULL, this parameter will be assigned the required size.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
ckd_bchain.c.

DBchainSignHash()

int AAP_API DBchainSignHash ( HSESSIONCTX hSession,
BYTE bType,
BYTE bHashMode,
BYTE * pbHash,
DWORD dwHashLen,
const char * cszPk,
BYTE * pbSig,
DWORD * pdwSigLen,
DWORD dwReserved )

#include <dinamo.h>

Sign a hash using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeType of subscription to be generated. It can be one of the values below.
Value Meaning
DN_BCHAIN_SIG_DER_ECDSA DER signature, in the format v || DER. SECG!SEC1 strict DER with low S as described in BIP62/66, BIP146, EIP2. With 'v' having a size of 1 byte. 'v' is the parity bit of 'r' and can have the values 0 or 1.
DN_BCHAIN_SIG_RAW_ECDSA RAW signature, in the format v || r || s. With 'v' having a size of 1 byte and 'r' and 's' each having a size of 32 bytes. 'v' is the parity bit of 'r' and can have the values 0 or 1.
DN_BCHAIN_SIG_BIP340 Signature BIP340 - Schnorr 64 bytes.
DN_BCHAIN_DER_RFC_6979_ECDSA RFC-6979 standard deterministic ECDSA signature. DER type in the format v || DER, with 'v' having a size of 1 byte. 'v' is the parity bit of 'r' and can have the values 0 or 1
DN_BCHAIN_RAW_RFC_6979_ECDSA RFC-6979 standard deterministic ECDSA signature. RAW type in the format v || r || s, with 'v' having a size of 1 byte and 'r' and 's' each having a size of 32 bytes. 'v' is the parity bit of 'r' and can have the values 0 or 1.
[in]bHashModeHash type.
Value Meaning
DN_BCHAIN_HASH_BTC_H160 Bitcoin H160.
DN_BCHAIN_HASH_RIPEMD160 RIPEMD160.
DN_BCHAIN_HASH_SHA256 SHA256
DN_BCHAIN_HASH_BTC_SHA256_2X Bitcoin SHA256 2x.
DN_BCHAIN_HASH_KECCAK256 KECCAK256.
[in]pbHashHash calculated according to bHashMode.
[in]dwHashLenHash size entered in pbHash.
[in]cszPkName of the private key.
[in,out]pbSigBuffer that will receive the signature.Can be NULL to obtain the required size.It is recommended to use the maximum size of DN_BCHAIN_MAX_SIG_LEN.
[in,out]pdwSigLenBuffer size pbSig.Case the buffer pbSig is NULL, this parameter will be assigned the required size.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
sign_verify_bchain.c.

DBchainVerify()

int AAP_API DBchainVerify ( HSESSIONCTX hSession,
BYTE bSigType,
BYTE bHashMode,
const BYTE * pbHash,
DWORD dwHashLen,
const BYTE * pbSig,
DWORD dwSigLen,
BYTE bInPbkType,
const BYTE * pbInPbk,
BYTE bInPbkLen,
DWORD dwReserved )

#include <dinamo.h>

Verifies a signature using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bSigTypeType of subscription to be generated. It can be one of the values below.
Value Meaning
DN_BCHAIN_SIG_DER_ECDSA DER signature, in the format v || DER. SECG!SEC1 strict DER with low S as described in BIP62/66, BIP146, EIP2. With 'v' having a size of 1 byte. 'v' is the parity bit of 'r' and can have the values 0 or 1.
DN_BCHAIN_SIG_RAW_ECDSA RAW signature, in the format v || r || s. With 'v' having a size of 1 byte and 'r' and 's' each having a size of 32 bytes. 'v' is the parity bit of 'r' and can have the values 0 or 1.
DN_BCHAIN_SIG_BIP340 Signature BIP340 - Schnorr 64 bytes.
[in]bHashModeHash type.
Value Meaning
DN_BCHAIN_HASH_BTC_H160 Bitcoin H160.
DN_BCHAIN_HASH_RIPEMD160 RIPEMD160.
DN_BCHAIN_HASH_SHA256 SHA256
DN_BCHAIN_HASH_BTC_SHA256_2X Bitcoin SHA256 2x.
DN_BCHAIN_HASH_KECCAK256 KECCAK256.
[in]pbHashHash calculated according to bHashMode.
[in]dwHashLenHash size entered in pbHash.
[in]pbSigSignature according to bSigType.
[in]dwSigLenSignature size entered in pbSig.
[in]bInPbkTypePublic key format. Can be one of the values below.
Value Meaning
DN_BCHAIN_PBK_SEC1_UNCOMP ECDSA SEC1 uncompressed.
DN_BCHAIN_PBK_SEC1_COMP ECDSA SEC1 compressed.
DN_BCHAIN_PBK_BIP340 Schnorr, BIP-340.
DN_BCHAIN_PBK_ED25519 Ed25519.
[in]pbInPbkSignature according to bInPbkType.
[in]bInPbkLenSignature size entered in pbInPbk.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
sign_verify_bchain.c.

DBchainEdDsaSign()

int AAP_API DBchainEdDsaSign ( HSESSIONCTX hSession,
BYTE bType,
const char * cszCtxStr,
BYTE * pbData,
DWORD dwDataLen,
const char * cszPk,
BYTE * pbSig,
DWORD * pdwSigLen,
DWORD dwReserved )

#include <dinamo.h>

Generates an EdDsa signature using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeType of subscription to be generated. It can be one of the values below.
Value Meaning
DN_BCHAIN_EDDSA_SIG_PURE EdDsa Pure Signature.
DN_BCHAIN_EDDSA_SIG_ALGORAND EdDsa Algorand Signature.
DN_BCHAIN_EDDSA_SIG_XRP EdDsa XRP subscription.
DN_BCHAIN_EDDSA_SIG_SOL Signature EdDsa Solana.
[in]cszCtxStrContext string as defined in RFC-8032 . Can be passed DN_BCHAIN_EDDSA_CSTR_UNUSED.
[in]pbDataData to be signed.
[in]dwDataLenSize of the data to be signed.
[in]cszPkName of the private key.
[in,out]pbSigBuffer that will receive the signature. It can be NULL to obtain the required size. It is recommended to use the maximum size of DN_BCHAIN_MAX_SIG_LEN.
[in,out]pdwSigLenBuffer size pbSig. If the buffer pbSig is NULL, this parameter will be assigned the required size.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.

DBchainEdDsaVerify()

int AAP_API DBchainEdDsaVerify ( HSESSIONCTX hSession,
BYTE bType,
const char * cszCtxStr,
BYTE * pbData,
DWORD dwDataLen,
BYTE bPbkType,
BYTE * pbPbk,
DWORD dwPbkLen,
BYTE * pbSig,
DWORD dwSigLen,
DWORD dwReserved )

#include <dinamo.h>

Verifies an EdDsa signature using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeType of signature to be verified. It can be one of the values below.
Value Meaning
DN_BCHAIN_EDDSA_SIG_PURE EdDsa Pure Signature.
DN_BCHAIN_EDDSA_SIG_ALGORAND EdDsa Algorand Signature.
DN_BCHAIN_EDDSA_SIG_XRP EdDsa XRP subscription.
DN_BCHAIN_EDDSA_SIG_SOL Signature EdDsa Solana.
[in]cszCtxStrContext string as defined in RFC-8032 of maximum length DN_BCHAIN_EDDSA_MAX_CSTRL. Can be passed DN_BCHAIN_EDDSA_CSTR_UNUSED.
[in]pbDataData to be verified.
[in]dwDataLenSize of the data to be checked.
[in]bPbkTypePublic key format. Can be one of the values below.
Value Meaning
DN_BCHAIN_PBK_ED25519 Ed25519.
DN_BCHAIN_PBK_AT_ALGORAND Algorand.
DN_BCHAIN_PBK_BIP32_XPUB BIP32 XPub.
DN_BCHAIN_PBK_AT_SOL Solana.
[in]pbPbkPublic key used for verification.
[in]dwPbkLenSize of the public key.
[in]pbSigSignature to be verified.
[in]dwSigLenSignature size.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.

DBchainPkImport()

int AAP_API DBchainPkImport ( HSESSIONCTX hSession,
BYTE bFormat,
DWORD dwAttributes,
const char * cszId,
const BYTE * pcbData,
DWORD dwDataLen,
DWORD dwReserved )

#include <dinamo.h>

Import a private key using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bFormatFormat of the key to be imported. Can be one of the values below.
Value Meaning
DN_BCHAIN_KEY_WIF Wallet Import Format (WIF).
DN_BCHAIN_KEY_MINI Bitcoin minikey.
DN_BCHAIN_KEY_HEX Private key scale in hexadecimal. Imported as a key of type ALG_ECC_SECP256K1.
DN_BCHAIN_KEY_SEC1 SEC1.
DN_BCHAIN_KEY_XPRIV XPriv.
DN_BCHAIN_KEY_ED25519_B64 Ed25519 in Base 64 format.
DN_BCHAIN_KEY_ED25519_XPRIV Ed25519 in XPriv format.
[in]dwAttributesAdditional key parameters. See the options in the DGenerateKey() function. This API automatically includes the BCHAIN_KEY flag, which is required for blockchain operations.
[in]cszIdName of the private key.
[in]pcbDataPrivate key in the format specified in bFormat. The size of this buffer must be entered in dwDataLen.
[in]dwDataLenBuffer size pcbData.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
import_export_bchain.c.

DBchainPkExport()

int AAP_API DBchainPkExport ( HSESSIONCTX hSession,
BYTE bFormat,
BYTE bVersion,
BYTE bCompressed,
const char * cszId,
BYTE ** ppbData,
DWORD * pdwDataLen,
DWORD dwReserved )

#include <dinamo.h>

Export a private key using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bFormatFormat of the key to be exported. Can be one of the values below.
Value Meaning
DN_BCHAIN_KEY_WIF Wallet Import Format (WIF). bVersion can be DN_BCHAIN_VER_WIF_MAIN_NET or DN_BCHAIN_VER_WIF_TEST_NET.
DN_BCHAIN_KEY_MINI Bitcoin minikey. bVersion should be DN_BCHAIN_VER_UNUSED.
DN_BCHAIN_KEY_HEX Scalar of the private key in hexadecimal. bVersion should be DN_BCHAIN_VER_UNUSED.
DN_BCHAIN_KEY_SEC1 SEC1. bVersion should be DN_BCHAIN_VER_UNUSED.
DN_BCHAIN_KEY_XPRIV XPriv. bVersion should be DN_BCHAIN_VER_UNUSED.
DN_BCHAIN_KEY_ED25519_B64 Ed25519 in Base 64 format. bVersion should be DN_BCHAIN_VER_UNUSED and the parameter bCompressed is ignored.
DN_BCHAIN_KEY_ED25519_XPRIV Ed25519 in XPriv format. bVersion should be DN_BCHAIN_VER_UNUSED and the parameter bCompressed is ignored.
[in]bVersionKey version.
Value Meaning
DN_BCHAIN_VER_UNUSED Parameter not used.
DN_BCHAIN_VER_WIF_MAIN_NET WIF main net.
DN_BCHAIN_VER_WIF_TEST_NET WIF test net.
[in]bCompressed0 to export the key in uncompressed format and 1 for compressed format.
[in]cszIdName of the private key.
[out]ppbDataPrivate key. The size of this buffer will be entered in pdwDataLen. This buffer must be released with the API DFree().
[out]pdwDataLenBuffer size ppcbData.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
import_export_bchain.c.

DBchainGetPubKey()

int AAP_API DBchainGetPubKey ( HSESSIONCTX hSession,
BYTE bType,
const char * cszId,
BYTE * pbData,
DWORD * pdwDataLen,
DWORD dwReserved )

#include <dinamo.h>

Recover a public key from a private key using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bTypeFormat of the public key to be exported. Can be one of the values below.
Value Meaning
DN_BCHAIN_PBK_SEC1_UNCOMP ECDSA SEC1 uncompressed.
DN_BCHAIN_PBK_SEC1_COMP ECDSA SEC1 compressed.
DN_BCHAIN_PBK_BIP340 Schnorr, BIP-340.
DN_BCHAIN_PBK_ED25519 Ed25519.
DN_BCHAIN_PBK_AT_ALGORAND Algorand.
DN_BCHAIN_PBK_BIP32_XPUB BIP32 XPub.
DN_BCHAIN_PBK_AT_SOL Solana.
[in]cszIdName of the private key.
[out]pbDataPublic key. Can be passed NULL to receive the expected size in pdwDataLen. The maximum size of this buffer is DN_BCHAIN_MAX_PBK_LEN.
[in,out]pdwDataLenBuffer size pcbData. It will contain, at the end of the call, the amount of data written to pcbData.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
get_pub_key_bchain.c.

DBchainRecoverPbkFromSignature()

int AAP_API DBchainRecoverPbkFromSignature ( HSESSIONCTX hSession,
BYTE bSigType,
BYTE bHashMode,
const BYTE * pbHash,
DWORD dwHashLen,
const BYTE * pbSig,
DWORD dwSigLen,
DN_BCHAIN_PBK * pPbk,
DWORD dwReserved )

#include <dinamo.h>

Retrieves a public key (PBK) from an ECDSA-type signature.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bSigTypeType of subscription to be generated. It can be one of the values below.
Value Meaning
DN_BCHAIN_SIG_DER_ECDSA DER signature, in the format v || DER. SECG!SEC1 strict DER with low S as described in BIP62/66, BIP146, EIP2. With 'v' having a size of 1 byte. 'v' is the parity bit of 'r' and can have the values 0 or 1.
DN_BCHAIN_SIG_RAW_ECDSA RAW signature, in the format v || r || s. With 'v' having a size of 1 byte and 'r' and 's' each having a size of 32 bytes. 'v' is the parity bit of 'r' and can have the values 0 or 1.
[in]bHashModeHash type.
Value Meaning
DN_BCHAIN_HASH_BTC_H160 Bitcoin H160.
DN_BCHAIN_HASH_RIPEMD160 RIPEMD160.
DN_BCHAIN_HASH_SHA256 SHA256
DN_BCHAIN_HASH_BTC_SHA256_2X Bitcoin SHA256 2x.
DN_BCHAIN_HASH_KECCAK256 KECCAK256.
[in]pbHashHash calculated according to bHashMode.
[in]dwHashLenHash size entered in pbHash.
[in]pbSigSignature according to bSigType.
[in]dwSigLenSignature size entered in pbSig.
[out]pPbkPublic key to be retrieved. Enter a structure of type DN_BCHAIN_PBK.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
sign_verify_bchain.c.

DBchainGetKeyInfo()

int AAP_API DBchainGetKeyInfo ( HSESSIONCTX hSession,
DWORD dwReserved,
const char * cszId,
void * pvData,
DWORD * pdwDataLen )

#include <dinamo.h>

Retrieves the properties of a key using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]dwReservedReserved for future use (must be 0).
[in]cszIdName of the private key.
[out]pvDataKey properties. Receives a structure DN_BCHAIN_KEY_INFO. NULL can be passed to receive the expected size in pdwDataLen.
[in,out]pdwDataLenBuffer size pcbData. It will contain, at the end of the call, the amount of data written to pcbData.
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Examples
get_key_info_bchain.c.

DBchainHashData()

int AAP_API DBchainHashData ( HSESSIONCTX hSession,
BYTE bMode,
BYTE * pbData,
DWORD dwDataLen,
BYTE * pbHash,
DWORD * pdwHashLen,
DWORD dwReserved )

#include <dinamo.h>

Calculates a hash using the blockchain module.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]bModeHash type.
Value Meaning
DN_BCHAIN_HASH_BTC_H160 Bitcoin H160.
DN_BCHAIN_HASH_RIPEMD160 RIPEMD160.
DN_BCHAIN_HASH_SHA256 SHA256
DN_BCHAIN_HASH_BTC_SHA256_2X Bitcoin SHA256 2x.
DN_BCHAIN_HASH_KECCAK256 KECCAK256.
[in]pbDataData to be processed. The size of this buffer must be entered in dwDataLen. Maximum size of DN_BCHAIN_MAX_HDATA_LEN.
[in]dwDataLenBuffer size pbData.
[out]pbHashReceives the calculated hash. Can be passed NULL to receive the expected size in pdwHashLen.
[in,out]pdwHashLenBuffer size pbHash. It will contain, at the end of the call, the amount of data written to pbHash.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Notes
This API is available for implementation validation. We recommend generating the hash by software for better performance and better use of HSM resources.
Examples
sign_verify_bchain.c.

DBchainEd2X()

int AAP_API DBchainEd2X ( HSESSIONCTX hSession,
const char * cszPk,
const char * cszTo,
DWORD dwAttr,
DWORD dwReserved )

#include <dinamo.h>

Converts an Edwards (Ed) key to Montgomery (x) format. Currently converts Ed25519 keys to X25519.

Parameters
[in]hSessionContext acquired through the DOpenSession() function.
[in]cszPkName of the private key in Edwards format that exists in the HSM.
[in]cszToName of the private key in Montgomery format that will be created in the HSM.
[in]dwAttrKey attributes. See dwAttr in DGenerateKey() for details on the key attributes. The attributes are added to the current attributes of the source key cszPk.
[in]dwReservedReserved for future use (must be 0).
Return
0 (ZERO) if the function is successful.
See the Return Codes section for other values.
Observation
Keys must be marked with the BCHAIN_KEY flag to be converted.