Python interface module to Zymkey Application Utilities Library.
This file contains a Python class which interfaces to the the Zymkey Application Utilities library. This class facilitates writing user space applications which use Zymkey to perform cryptographic operations, such as:
Additionally, there are methods for changing the i2c address (i2c units only), setting tap sensitivity, and controlling the LED.
The Zymkey class definition.
This class provides access to the Zymkey within Python.
Initialize an instance of a Zymkey context.
Turn the LED on.
Turn the LED off.
Flash the LED.
Get some random bytes.
Deposit random data in a file.
Lock up source (plaintext) data.
This methods encrypts and signs a block of data.
The Zymkey that can be used for locking/unlocking operations.
The source (plaintext) data to lock.
If a str is passed to this method, the value is assumed to be the absolute path to the location of the source file. If bytes or bytesarray is passed, it is assumed to contain binary data.
The destination (ciphertext) of the locked data.
If a str is passed to this method, the value is assumed to be the absolute path to the location of the file where the destination data is meant to be written. Otherwise, if None is passed to the method (the default), the locked data is returned from the method as a bytearray.
None is returned.
Unlock source (ciphertext) data.
This method verifies a locked object signature and decrypts the associated ciphertext data.
The Zymkey has two keys that can be used for locking/unlocking operations.
The source (ciphertext) data to verify and decrypt.
If a str is passed to this method, the value is assumed to be the absolute path to the location of the source file. If bytes or bytesarray is passed, it is assumed to contain binary data.
The destination of the decrypted data (plaintext).
If a str is passed to this method, the value is assumed to be the absolute path to the location of the file where the destination data is meant to be written. Otherwise, if None is passed to the method (the default), the locked data is returned from the method as a bytearray.
None is returned.
Generate a signature using the Zymkey’s ECDSA private key.
Generate a signature using the Zymkey’s ECDSA private key.
Verify data against a signature.
The public key is not specified in the parameter list to ensure that the public key that matches the Zymkey’s ECDSA private key is used.
True for a good verification or False for a bad verification when the raise_exception parameters is False.
Verify a signature using the Zymkey’s ECDSA public key.
The public key is not specified in the parameter list to ensure that the public key that matches the Zymkey’s ECDSA private key is used.
True for a good verification or False for a bad verification when raise_exception is False.
Derive a key or a pre-master secret from an ECDH operation. (Supported Devices: HSM6, Secure Compute Module).
Specifies the KDF (Key Derivation Function) to use for the returned derived key. Valid values are:
Create a file with the PEM-formatted ECDSA public key.
[DEPRECATED]: Use create_public_key_file instead.
This method is useful for generating a Certificate Signing Request.
Create a file with the PEM-formatted public key.
This method is useful for generating a Certificate Signing Request.
Retrieves the ECDSA public key as a binary bytearray.
[DEPRECATED]: Use get_public_key instead.
This method is used to retrieve the public key in binary form.
Retrieves a public key as a binary bytearray.
This method is used to retrieve the public key in binary form.
Get a list of the allocated slots in the key store (Supported Devices: HSM6, Secure Compute Module).
This method gets a list of the allocated slots in the key store.
Stores a foreign public key on the Zymkey foreign keyring (Supported Devices: HSM6, Secure Compute Module).
This method stores a foreign public key onto the Zymkey foreign public keyring.
Disable exporting of a public key at a given slot (Supported Devices: HSM6, Secure Compute Module).
This method permanently disables exporting a public key from a given slot.
Generate a new key pair (Supported Devices: HSM6, Secure Compute Module).
This method generates a new key pair of the specified type.
Generate a new ephemeral key pair (Supported Devices: HSM6, Secure Compute Module).
This method generates a new ephemeral key pair of the specified type, overwriting the previous ephemeral key pair.
Remove a key at the designated slot (Supported Devices: HSM6, Secure Compute Module).
This method removes a key at the designated slot in either the standard key store or the foreign public keyring.
Invalidate the ephemeral key (Supported Devices: HSM6, Secure Compute Module).
This method invalidates the ephemeral key, effectively removing it from service until a new key is generated.
Generates a new master seed for creating a new BIP32 wallet (Supported Devices: HSM6, Secure Compute Module).
This method generates a new master seed for creating a new BIP32 wallet.
Configures the number of members and threshold for the group shares (Supported Devices: HSM6, Secure Compute Module).
This method sets the number of members required for a group share once a SLIP39 session was opened via gen_wallet_master_seed().
Generates a new mnemonic_str tied to a SLIP39 member (Supported Devices: HSM6, Secure Compute Module).
This method generates a new member of a group share. Members can also be passphrase protected. Passphrases are not required to be unique. This function is meant to be called after configuring a group via set_gen_SLIP39_group_info().
Cancels an active SLIP39 session (Supported Devices: HSM6, Secure Compute Module).
This method cancels an ongoing SLIP39 session for both master seed generation and recovery.
Generates a supervisory bip32 wallet. (Supported Devices: HSM6, Secure Compute Module).
This method generates a new supervisory Bip32 wallet. Meant for read-only transactions and supervising history.
Generates a child key based on a parent key that is in a wallet (Supported Devices: HSM6, Secure Compute Module).
This method generates a child key based on a parent key that is in a wallet.
Restore a wallet’s master seed based on the recovery strategy object (Supported Devices: HSM6, Secure Compute Module).
This method restores a wallet’s master seed based on a mnemonic string and a master generator key. This method can be used in the process of wallet duplication.
Feed a mnemonic string and the passphrase associated with it (Supported Devices: HSM6, Secure Compute Module).
This method feeds in mnemonic sentences (shards) into the module. Meant to be called after starting a restore_wallet_master_seed() SLIP39 session. Will return -1 until the master seed is reconstructed properly.
Get a wallet node address from a key slot (Supported Devices: HSM6, Secure Compute Module).
This method gets a wallet entry’s node address from its key slot assignment. The wallet name and master seed slot are also returned.
Look up a wallet key slot number from a node address (Supported Devices: HSM6, Secure Compute Module).
This method gets a wallet key slot number from its node address and wallet name or master seed key slot. Either the wallet name or the master seed slot must be present.
Set the i2c address of the Zymkey.
Note: This is only applicable to versions of the Zymkey with i2c.
This method should be called if the i2c address of the Zymkey is shared with another i2c device on the same i2c bus. The default i2c address for Zymkey units is 0x30. Currently, the address may be set in the ranges of 0x30 - 0x37 and 0x60 - 0x67.
After successful completion of this command, the Zymkey will reboot itself.
Set the sensitivity of tap operations.
This method permits setting the sensitivity of the tap detection feature. Each axis may be individually configured or all at once.
Wait for tap event.
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.
Initialize self. See help(type(self)) for accurate signature.
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.
Get current GMT time.
This function is called to get the time directly from a Zymkey’s Real Time Clock (RTC).
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.
Set perimeter breach action.
This function specifies the action to take when a perimeter breach event occurs. The possible actions are any combination of:
- Notify host.
- Zymkey self-destruct.
Set the digital perimeter detect low power period (Supported Devices: HSM6, Secure Compute Module).
This function sets the digital perimeter detect low power period (microseconds).
Set the low power max number of bits (Supported Devices: HSM6, Secure Compute Module).
This function sets the digital perimeter detect low power max number of bits.
Set the digital perimeter detect delays (Supported Devices: HSM6, Secure Compute Module).
This function sets the digital perimeter detect delay values.
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.
Get current perimeter detect info.
This function gets the timestamp of the first perimeter detect event for the given channel. The index corresponds to the channel specified in set_perimeter_event_actions.
Clear perimeter detect info.
This function clears all perimeter detect info and rearms all perimeter detect channels.
Get current CPU temperature (Supported Devices: HSM6, Secure Compute Module).
This function gets the current HSM CPU temperature.
Get current aux temperature (Secure Compute Modules only).
THIS FUNCTION IS FOR INTERNAL ZYMBIT USE ONLY.
This function gets the current aux temperature. (defaults to 0).
Get RTC drift (Supported Devices: HSM6, Secure Compute Module).
This function gets the current RTC drift.
Get current battery voltage (Supported Devices: HSM6, Secure Compute Module).
This function gets the current battery voltage.
Get Zymkey model number.
This function gets the Zymkey model number.
Get Zymkey firmware version.
This function gets the Zymkey firmware version.
Get Zymkey serial number.
This function gets the Zymkey serial number.
Set battery voltage action. (Supported Devices: HSM6, Secure Compute Module).
This function specifies the action to take when the battery voltage falls below the threshold set by set_battery_voltage_threshold. If this function is never called, do nothing is default. There are three actions:
- Do nothing.
- Go to sleep until battery is replaced.
- Self-destruct.
With sleep and self_destruct set to False, it removes a previously set sleep or self_destruct action.
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 set_battery_voltage_action will be carried out. The recommended threshold is 2.3V is assumed by default. Threshold must be below 2.5V.
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 set_cpu_low_temp_threshold, or rises above the threshold set by set_cpu_high_temp_threshold. There are two actions to apply:
- Do nothing.
- Self-destruct.
To remove a previously set self-destruct action, call this function with self_destruct=False.
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 set_cpu_temp_action 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 this function is never called, -10 degrees celsius is assumed.
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 set_cpu_temp_action 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 this function is never called, 65 degrees celsius is assumed.
Sets the Supervised boot policy. (Supported Devices: Secure Compute Module).
This function sets the action policy to take when Supervised boot detects a file change during the boot process.
Update file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function adds or updates a file in the file manifest to be checked by Supervised during the boot process.
Remove a file from file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function removes a file in the file manifest to be checked by Supervised boot during the boot process.
Get the file manifest for Supervised boot to check. (Supported Devices: Secure Compute Module).
This function gets a list of the files that are checked by Supervised boot during the boot process.
The RecoveryStrategy class definition.
This class specifies the recovery strategy used for wallet generation within Python. Base class strategy is to do no recovery.
Initialize an instance of RecoveryStrategy.
The RecoveryStrategyBIP39 class definition.
This class specifies the BIP39 recovery strategy used for wallet generation within Python. Derived from RecoveryStrategy class.
Initialize an instance of RecoveryStrategyBIP39.
The RecoveryStrategySLIP39 class definition.
This class specifies the SLIP39 recovery strategy used for wallet generation within Python. Derived from RecoveryStrategy class.
Initialize an instance of RecoveryStrategySLIP39.