C++ interface to Zymkey Application Utilities Library.
This file contains the C API to the the Zymkey Application Utilities library. This API facilitates writing user space applications which use Zymkey to perform cryptographic operations, such as:
Typedef for a simple unsigned bytes container.
Typedef for a simple integer container.
Structure typedef used for retrieval of accelerometer data.
Class used for retrieval of recovery mnemonic for Bip32 wallet.
Subclassed by
Class used for BIP39 recovery strategy. User can set b64 encoded passphrase and key variant (only “cardano” is supported for ed25519 currently) for bip32 seed generation. It can also hold the mnemonic sentence from master seed generation.
The main class.
Constructor: a Zymkey context is opened.
Destructor: the Zymkey context is closed.
Write random data to a file.
A string containing the absolute path to the file where random data is written.
The number of random bytes to generate.
Generate a block of random data.
The number of random bytes to generate.
A pointer to container with the random bytes.
Locks data from a plaintext source file and stores locked data object to a destination file.
Absolute path to source plaintext file.
Absolute path to destination file which will contain locked data object.
Determines whether one-way or shared key is used for locking. Default = false.
Locks data from a plaintext source byte container and stores locked data object to a destination file.
Unsigned byte container which holds source plaintext data.
Absolute path to destination file which will contain locked data object.
Determines whether one-way or shared key is used for locking. Default = false.
Locks data from a plaintext source file and stores locked data object in a container of unsigned bytes.
Absolute path to source plaintext file.
Determines whether one-way or shared key is used for locking. Default = false.
Byte container with locked data.
Locks data from a plaintext source byte container and stores locked data object in a container of unsigned bytes.
Unsigned byte container which holds source plaintext data.
Determines whether one-way or shared key is used for locking. Default = false.
Byte container with locked data.
Unocks a locked data object from source file and stores unlocked data object to a destination file.
Absolute path to source file which contains locked data object.
Absolute path to destination file which will contain unlocked plaintext data.
Determines whether one-way or shared key is used for locking. Default = false.
Unlocks a locked data object contained in an unsigned byte container and stores plaintext data to a destination file.
Unsigned byte container which holds locked data object.
Absolute path to destination file which will contain unlocked plaintext data.
Determines whether one-way or shared key is used for locking. Default = false.
Unlocks a locked data object from a plaintext source file and stores plaintext data in a container of unsigned bytes.
Absolute path to source file which contains locked data object.
Determines whether one-way or shared key is used for locking. Default = false.
Byte container with plaintext data.
Unlocks a locked data object contained in an unsigned byte container and stores plaintext data in a container of unsigned bytes.
Unsigned byte container which holds locked data object.
Determines whether one-way or shared key is used for locking. Default = false.
Byte container with plaintext data.
Generate a signature from a data digest using the Zymkey’s private key.
Currently, this should be a SHA256 digest.
The key slot to use for verification.
Byte container with binary signature.
Generate a signature from a data digest using the Zymkey’s private key.
Currently, this should be a SHA256 digest.
The key slot to use for verification.
[Output]Returns recovery id value needed for ethereum key recovery.
Byte container with binary signature.
Verify a signature from a data digest using the Zymkey’s public key. The public key is not given as an input. Rather, the Zymkey uses its own copy of the private key. This insures that the public key that matches the private key is used.
Currently, this should be a SHA256 digest.
The signature to verify.
The key slot to use for verification.
If false, the normal key store is referenced. Otherwise, the foreign public key store is referenced.
If false, the normal key store is referenced. Otherwise, the foreign public key store is referenced.
true = signature verification passed, false = signature verification failed.
Perform a raw ECDH operation. (Supported Devices: HSM6, Secure Compute Module).
Perform an ECDH operation with no Key Derivation Function (KDF). The raw pre-master secret is returned in the response. The peer public key is presented in the call.
The key slot to use for the local key. If this parameter is -1, the ephemeral key is used.
The peer public key.
Byte container with pre master secret.
Perform a raw ECDH operation. (Supported Devices: HSM6, Secure Compute Module).
Perform an ECDH operation with no Key Derivation Function (KDF). The raw pre-master secret is returned in the response. The peer public key is referenced from the zymkey internal key store.
The key slot to use for the local key. If this parameter is -1, the ephemeral key is used.
The peer public key slot where the peer public key is to be found.
If true, the peer public key slot is found in the foreign public keyring.
Byte container with pre master secret.
Perform an ECDH operation plus Key Derivation Function. (Supported Devices: HSM6, Secure Compute Module).
Perform an ECDH operation with Key Derivation Function (KDF). The derived key is returned in the response. The peer public key is presented in the call.
The key slot to use for the local key. If this parameter is -1, the ephemeral key is used.
The peer public key.
The salt to use for the selected KDF.
The info field to use for RFC 5869. Ignored for PBKDF2.
Number of iterations to carry out (PBKDF only).
The desired number of bytes to return for the KDF. For RFC 5869, this value must be less than 8160 bytes (SHA256) or 16320 (SHA512).
Byte container with pre master secret.
Perform an ECDH operation plus Key Derivation Function. (Supported Devices: HSM6, Secure Compute Module).
Perform an ECDH operation with Key Derivation Function (KDF). The derived key is returned in the response. The peer public key is referenced from the zymkey internal key store.
The key slot to use for the local key. If this parameter is -1, the ephemeral key is used.
The peer public key slot where the peer public key is to be found.
If true, the peer public key slot is found in the foreign public keyring.
The salt to use for the selected KDF.
The info field to use for RFC 5869. Ignored for PBKDF2.
Number of iterations to carry out (PBKDF only).
The desired number of bytes to return for the KDF. For RFC 5869, this value must be less than 8160 bytes (SHA256) or 16320 (SHA512).
Byte container with pre master secret.
[DEPRECATED] Use exportPubKey2File. Save the public key that matches the Zymkey’s private key into a PEM formatted file. Mainly used for Certificate Signing Request (CSR) generation.
Absolute location where the PEM formatted file is to be stored.
Reserved for future use.
Store the public key to a host file in PEM format.
This function is useful for generating Certificate Signing Requests (CSR).
Filename where PEM formatted public key is to be stored.
The key slot to retrieve. Zymkey and HSM4 have slots 0, 1, and 2.
If true, designates the pubkey slot to come from the foreign keystore. (Supported Devices: HSM6, Secure Compute Module).
[DEPRECATED] Use exportPubKey. Get a container of bytes which contains the ECDSA public key.
Reserved for future use.
Byte container with binary public key.
Gets the public key and stores in a byte array created by this function.
The key slot to retrieve. Zymkey and HSM4 have slots 0, 1, and 2.
If true, designates the pubkey slot to come from the foreign keystore. (Supported Devices: HSM6, Secure Compute Module).
Get the list of allocated keys. (Supported Devices: HSM6, Secure Compute Module).
This function returns a list of all allocated key slots.
(input) if true, retrieve allocation list of the foreign keys.
Array of the allocated keys.
Store a new foreign public key in Zymkey. (Supported Devices: HSM6, Secure Compute Module).
This function stores a new foreign public key in the Zymkey public key ring. This public key can be used for signature verification in use cases where it is desirable to hide the public key.
The type of the public key. {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1}.
Public key to store.
Allocated slot number in foreign key store, less than 0 for failure.
Prevent a public key from being exported to the host. (Supported Devices: HSM6, Secure Compute Module).
This function prevents the public key at the specified slot from being exported to the host using the API zkExportPubKey.
The key slot to disable pubkey export on.
The slot parameter refers to a slot in the foreign keyring.
Generate a new persistent key pair. (Supported Devices: HSM6, Secure Compute Module).
This function generates a new key pair of the specified type and store it persistently. This key pair cannot be used as part of the zymkey’s digital wallet operations.
The type of key to generate (ZK_EC_KEY_TYPE). {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1}.
Allocated slot number if successful, less than 0 for failure.
Generate an ephemeral key pair. (Supported Devices: HSM6, Secure Compute Module).
This function generates an ephemeral key pair of the specified type. Ephemeral key pairs are useful when performing ECDH for time-of-flight encryption. Only one ephemeral key slot is available and is not persistent between reboots.
The type of key to generate (ZK_EC_KEY_TYPE). {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1}.
Remove a key pair or a foreign public key. (Supported Devices: HSM6, Secure Compute Module).
This function deletes a key pair or a foreign public key from persistent storage.
The slot.
The slot parameter refers to a slot in the foreign keyring.
Invalidate the ephemeral key. (Supported Devices: HSM6, Secure Compute Module).
This function invalidates the ephemeral key.
Generate a BIP32 master seed to start a new blockchain wallet. (Supported Devices: HSM6, Secure Compute Module).
This function generates a new blockchain master seed for creating a new wallet per BIP32.
The type of key to generate (ZK_EC_KEY_TYPE). {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1, ZK_ED25519, ZK_X25519}.
An ASCII string which contains the name of the wallet.
Allocated mnemonics if it was asked for, based on recovery strategy used.
The master generator key used to help generate the master seed (bip32). Defaults to empty string.
The recovery strategy object for returning BIP39 or SLIP39 (starts a SLIP39 session instead of a one shot). Also contains key variants and passphrases. Defaults to no recovery strategy.
The slot the master seed was allocated to.
Set the active SLIP39 group and the amount of members needed. (Supported Devices: HSM6, Secure Compute Module).
This function configures the active group to generate the number of shards requested for the active group.
The index of the group to generate shards from. Index starts at 0.
The total amount of member shards in this group to generate.
The number of member shards needed to recreate this group in recovery.
0 if successful on configuring the active group, less than 0 for failure.
Generate a new SLIP39 member shard. (Supported Devices: HSM6, Secure Compute Module).
This function generates a new SLIP39 member shard. The shard can optionally have a password attached to it.
Password for the shard. Can be empty string.
(output) The mnemonic sentence of the shard.
0 if successful on configuring the active group, less than 0 for failure.
Cancels the current active SLIP39 session (Supported Devices: HSM6, Secure Compute Module).
This function cancels open active SLIP39 sessions. For both generation and restore SLIP39 sessions.
0 if successful on configuring the active group, less than 0 for failure.
Generate a oversight wallet from the last hardened node of a wallet node address (Supported Devices: HSM6, Secure Compute Module).
This function generates a new oversight wallet and are used to generate public keys in a deterministic way.
The type of key to generate (ZK_EC_KEY_TYPE). {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1, ZK_ED25519, ZK_X25519}.
The public_key of the last hardened node of the address.
The chain_code of the last hardened node of the address.
The node_address being derived from.
An ASCII string which contains the name of the wallet.
The key type variant to generate. Currently only “cardano” for ed25519 is supported.
The slot the oversight wallet was allocated to.
Generate child key from a parent key in a wallet (Supported Devices: HSM6, Secure Compute Module).
This function generates a new child key descendent from a specified parent key in a wallet.
The parent key slot to base the child key derivation on.
The index of the child seed. This determines the node address as well as the outcome of the key generation.
If true, a hardened key is generated.
If true, exports the chain code. Must be exported from a hardened node.
Allocated chain_code if it was asked for.
Allocated slot number if successful, less than 0 for failure.
Restore a master seed from a BIP39 mnemonic and a master generator key. (Supported Devices: HSM6, Secure Compute Module).
This function restores a wallet master seed from a supplied BIP39 mnemonic string and a master generator key.
The type of key to generate (ZK_KEY_TYPE). {ZK_NISTP256, ZK_SECP256R1 = ZK_NISTP256, ZK_SECP256K1}.
An ASCII string which contains the name of the wallet.
The master generator key used to help generate the master seed.
The recovery strategy used. Contains the passphrases and key variant to recover from.
The mnemonic sentence to recover the master seed with. (Not used for SLIP39).
Allocated slot number if successful, less than 0 for failure.
Feed a SLIP39 shard to restore a master seed (Supported Devices: HSM6, Secure Compute Module).
This function will feed a shard to the module until the conditions are met and a master seed is generated.
The passphrase that was attached to the shard.
(output) The twenty-four word sentence mnemonic shard.
allocated slot number when all shards required are fed in, less than 0 for no change.
Derive the node address from a key slot number. (Supported Devices: HSM6, Secure Compute Module).
This function derives a node address from an input key slot number.
(input) A key slot number that is part of a digital wallet.
(output) A pointer to a string which will contain the node address in ASCII.
(output) A pointer to a string which will contain the wallet name in ASCII. If NULL, this parameter will not be retrieved.
The master seed key slot.
Derive the slot address from a node address. (Supported Devices: HSM6, Secure Compute Module).
This function returns the slot number associated with a given node address.
(input) A pointer which contains the node address in ASCII.
(input) A pointer which contains the wallet name in ASCII, used to identify the wallet identity. If desired, this parameter can be NULL and the master_seed_slot parameter can be specified instead.
(input) The master seed slot. Can be used to specify the wallet identity instead of the wallet name.
The associated key slot.
Turn LED off.
Turn LED on.
Flash LED a certain number of times.
Number of milliseconds that the LED will be on during a flash cycle.
Number of milliseconds that the LED will be off during a flash cycle.
Number of flash cycles to execute. 0 = infinite.
Sets the i2c address (i2c versions only). Used in case of i2c bus device address conflict.
The i2c address to set. Upon successful change, the Zymkey will reset itself. However, if the address is the same as the current setting, the Zymkey will not reset. Valid address ranges are 0x30 - 0x37 and 0x60 - 0x67.
Get current GMT time.
This method is called to get the time directly from a Zymkey’s Real Time Clock (RTC).
(input) If true, this API returns the time after the next second falls. This means that the caller could be blocked up to one second. If false, the API returns immediately with the current time reading.
The time in seconds from the epoch (Jan. 1, 1970).
Sets the sensitivity of the tap detection as a percentage for an individual axis or all axes.
Sensitivity expressed in percentage. 0% = off, 100% = maximum.
X, Y, Z or all (default).
Wait for a tap event to be detected.
This function is called in order to wait for a tap event to occur. This function blocks the calling thread unless called with a timeout of zero.
(input) The maximum amount of time in milliseconds to wait for a tap event to arrive.
Get current accelerometer data and tap info.
This function gets the most recent accelerometer data in units of g forces plus the tap direction per axis. Array index 0 = x 1 = y 2 = z.
(output) The current accelerometer data and tap information.
Set soft binding lock.
This function locks the binding for a specific HSM. This API is only valid for HSM series products.
Get current binding info.
This function gets the current binding lock state as well as the current binding state. This API is only valid for devices in the HSM family.
(output) Binary value which expresses the current binding lock state. is_bound (output) Binary value which expresses the current bind state.
Set perimeter breach action.
This function specifies the action to take when a perimeter breach event occurs. The possible actions are any combination of:
(input) The channel (0 or 1) that the action flags will be applied to.
(input) The actions to apply to the perimeter event channel:
Set the low power period (Supported Devices: HSM6, Secure Compute Module).
This function sets low power period on the digital perimeter detect.
(input) low power period in microseconds.
void.
Set the low power max number of bits (Supported Devices: HSM6, Secure Compute Module).
This function sets low power max number of bits on the digital perimeter detect.
(input) max number of bits.
void.
Set the delays (Supported Devices: HSM6, Secure Compute Module).
This function sets delays on the digital perimeter detect.
(input) minimum delay in nanoseconds.
(input) maximum delay in nanoseconds.
void.
Wait for a perimeter breach event to be detected.
This function is called in order to wait for a perimeter breach event to occur. This function blocks the calling thread unless called with a timeout of zero. Note that, in order to receive perimeter events, the zymkey must have been configured to notify the host on either or both of the perimeter detect channels via a call to “zkSetPerimeterEventAction”.
(input) The maximum amount of time in milliseconds to wait for a perimeter event to arrive.
Get current perimeter detect info.
This function gets the timestamp of the first perimeter detect event for the given channel.
(output) The timestamps for when any events occurred. The index in this array corresponds to the channel number used by zkSetPerimeterEventAction. A 0 value means no breach has occurred on this channel. This array is allocated by this routine and so it must be freed by the caller.
(output) The number of timestamps in the returned array.
Clear perimeter detect info.
This function clears all perimeter detect info and rearms all perimeter detect channels.
Get Zymkey model number.
This function retrieves the model number of the zymkey referred to in a specified context.
A pointer to a string containing the Zymkey model number.
Get Zymkey firmware version.
This function retrieves the firmware version of the zymkey referred to in a specified context.
A pointer to a string containing the Zymkey firmware version.
Get Zymkey serial number.
This function retrieves the serial number of the zymkey referred to in a specified context.
A pointer to a string containing the Zymkey serial number.
Get the CPU Temp. (Supported Devices: HSM6, Secure Compute Module).
This function gets the current HSM CPU temp.
The CPU temp as a float.
Get the AUX Temp. (Secure Compute Modules Only).
This function gets the current temp of an aux processor. (defaults to 0). THIS FUNCTION IS FOR INTERNAL ZYMBIT USE ONLY.
The CPU temp as a float.
Get the RTC drift. (Supported Devices: HSM6, Secure Compute Module).
This function gets the current RTC drift.
The RTC drift as a float.
Get the battery voltage(Supported Devices: HSM6, Secure Compute Module).
This function gets the current battery voltage.
the battery voltage as a float.
Set battery voltage threshold action. (Supported Devices: HSM6, Secure Compute Module).
This function specifies the action to take when the battery voltage falls below the threshold set by zkSetBatteryVoltageThreshold. If this function is never called, do nothing is default. There are three actions:
(input) The action to apply, specify one of the ZK_THRESHOLD_ACTION_TYPE:
Sets the battery voltage threshold. (Supported Devices: HSM6, Secure Compute Module).
This function sets the threshold at which if the battery voltage falls bellow, the action set by zkSetBatteryVoltageAction will be carried out. The recommended threshold is 2.3V is assumed by default. Threshold must be below 2.5V.
(input) The threshold in Volts.
Set HSM CPU temperature threshold action. (Supported Devices: HSM6, Secure Compute Module).
This function specifies the action to take when the HSM CPU temperature falls below the threshold set by zkSetCPULowTempThreshold, or rises above the threshold set by zkSetCPUHighTempThreshold. There are two actions to apply:
(input) The action to apply, used it’s named constant from ZK_THRESHOLD_ACTION_TYPE:
Sets the HSM CPU low temperature threshold. (Supported Devices: HSM6, Secure Compute Module).
This function sets the threshold at which if the on-board HSM CPU’s tempreature falls below, the action set by zkSetCPUTempAction will be carried out. WARNING: You can lock yourself out in dev mode if you set a threshold above the CPU’s ambient temperature. The recommended setting is no more than 20C. If no threshold is set, -10 degrees Celsius is set as default.
(input) The threshold in celsius.
Sets the HSM CPU high temperature threshold. (Supported Devices: HSM6, Secure Compute Module).
This function sets the threshold at which if the on-board HSM CPU’s tempreature rises above, the action set by zkSetCPUTempAction will be carried out. WARNING: You can lock yourself out in dev mode if you set a threshold below the CPU’s ambient temperature. The recommended setting is no less than 40C. If no threshold is set, 65 degrees celsius is set as default.
(input) The threshold in celsius.
0 for success, less than 0 for failure.
Sets the Supervised boot policy. (Supported Devices: Secure Compute Module).
This function specifies the action to take when Supervised boot event triggers based on a file change.
(input) The actions to apply to the Supervised boot process:
0 for success, less than 0 for failure.
Update file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function adds or updates files to be checked by Supervised boot.
(input) The file to be signed and checked by Supervised boot.
(input) The slot to sign the file with. Defaults to 15, if no slot 15, defaults to 0.
0 for success, less than 0 for failure.
Remove a file from file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function removes a file to be checked by Supervised boot.
(input) The file to be removed from the Supervised boot manifest.
0 for success, less than 0 for failure.
Get file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function gets the list of files to be checked by Supervised boot.
(output) The file manifest that is checked by Supervised boot.
a string for the list of files in the manifest.