Python API Documentation
Generated from zkapputilslib version 1.2.2-1 (commit a547582).
This file contains a Python class which interfaces to the the Zymkey
Application Utilities library. Systems intending to run such applications
require that the python3-zku package be installed.
This class facilitates writing userspace applications which use Zymkey to perform cryptographic operations, such as:
- Signing of payloads using ECDSA
- Verification of payloads that were signed using Zymkey
- Exporting the public key that matches Zymkey’s private key
- “Locking” and “unlocking” data objects
- Generating random data
Additionally, there are methods for changing the i2c address (i2c units only), setting tap sensitivity, and controlling the LED.
Classes
Zymkey
class
class Zymkey()Inherits from object.
Attributes
EPHEMERAL_KEY_SLOT
attribute
EPHEMERAL_KEY_SLOT = -1Methods
__init__
method
def __init__()led_on
method
def led_on() -> NoneRaises
AssertionError- If
retis a bad return code from the Zymkey library function.
led_off
method
def led_off() -> NoneRaises
AssertionError- If
retis a bad return code from the Zymkey library function.
led_flash
method
def led_flash(on_ms: int, off_ms: int = 0, num_flashes: int = 0) -> NoneParameters
on_msint- The amount of time in milliseconds that the LED will be on for.
off_msint default0- The amount of time in milliseconds that the LED will be off for. If this parameter is set to 0 (default), the off time is the same as the on time.
num_flashesint default0- The number of on/off cycles to execute. If this parameter is set to 0 (default), the LED flashes indefinitely.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_random
method
def get_random(num_bytes: int) -> bytearrayParameters
num_bytesint- The number of random bytes to get.
Returns
- bytearray
- An array of bytes returned by the random number generator.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
create_random_file
method
def create_random_file(file_path: str, num_bytes: int) -> NoneParameters
file_pathstr- The absolute path name for the destination file.
num_bytesint- The number of random bytes to get.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
lock
method
def lock(src: t.Union[str, bytes], dst: t.Optional[str] = None, encryption_key: str = ZYMKEY_ENCRYPTION_KEY) -> t.Union[None, bytearray]This methods encrypts and signs a block of data.
The Zymkey that can be used for locking/unlocking operations
- The one-way key is meant to lock up data only on the local host computer. Data encrypted using this key cannot be exported and deciphered anywhere else.
Parameters
srct.Union[str, bytes]The source (plaintext) data to lock.
If a
stris passed to this method, the value is assumed to be the absolute path to the location of the source file. Ifbytesorbytesarrayis passed, it is assumed to contain binary data.dstt.Optional[str] defaultNoneThe destination (ciphertext) of the locked data.
If a
stris 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, ifNoneis passed to the method (the default), the locked data is returned from the method as a bytearray.encryption_keystr defaultZYMKEY_ENCRYPTION_KEY- This specifies which key will be used to lock the data. A value of ‘zymbit’ (default) specifies that the Zymkey will use the one-way key.
Returns
- t.Union[None, bytearray]
- The locked data is returned as a bytearray if no destination is
specified when this method is called. Otherwise,
Noneis returned.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
unlock
method
def unlock(src: t.Union[str, bytes], dst: t.Optional[str] = None, encryption_key: str = ZYMKEY_ENCRYPTION_KEY, raise_exception: bool = True) -> t.Union[None, bytearray, t.NoReturn]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 one-way key is meant to lock up data only on the local host computer. Data encrypted using this key cannot be exported and deciphered anywhere else.
Parameters
srct.Union[str, bytes]The source (ciphertext) data to verify and decrypt.
If a
stris passed to this method, the value is assumed to be the absolute path to the location of the source file. Ifbytesorbytesarrayis passed, it is assumed to contain binary data.dstt.Optional[str] defaultNoneThe destination of the decrypted data (plaintext).
If a
stris 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, ifNoneis passed to the method (the default), the locked data is returned from the method as a bytearray.encryption_keystr defaultZYMKEY_ENCRYPTION_KEY- This specifies which key will be used to lock the data. A value of ‘zymbit’ (default) specifies that the Zymkey will use the one-way key.
raise_exceptionbool defaultTrue- Specifies if an exception should be raised if the signature verification of the locked object fails.
Returns
- t.Union[None, bytearray, t.NoReturn]
- The locked data is returned as a bytearray if no destination is
specified when this method is called. Otherwise,
Noneis returned.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
sign
method
def sign(src: t.Union[str, bytes, bytearray], slot: int = 0, return_recid: bool = False, encoding: str = 'utf-8', digest: t.Any = None) -> bytearrayParameters
srct.Union[str, bytes, bytearray]- The SHA256 digest of the data that will be used to generate the signature.
slotint default0- The key slot used for signing. [ZYMKEY5, HSM60, HSM64, HSM6] Slot can’t contain a X25519 key pair
return_recidbool defaultFalse- This parameter asks for the y parity to be returned.
encodingstr default'utf-8'- This parameter asks for the encoding for the string source.
digest_hashlib.HASH defaultNone- This parameter asks for the type of hash. Can be None. Defaults to sha256.
Returns
- bytearray
- A bytearray of the signature.
- int
- If return_recid = True, then return the y parity of the signature (either a 1 or 0).
sign_digest
method
def sign_digest(digest: t.Any, slot: int = 0, return_recid: bool = False) -> bytearrayParameters
digest_hashlib.HASH- A encoded str instance representing the digest to be signed.
slotint default0- This parameter specifies the key slot used for signing. [ZYMKEY5, HSM60, HSM64, HSM6] Slot can’t contain a X25519 key pair
return_recidbool defaultFalse- This parameter asks for the y parity to be returned.
Returns
- bytearray
- The signature of the SHA-256 digest passed to this method.
- int
- If return_recid = True, then return the y parity of the signature (either a 1 or 0).
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
verify
method
def verify(src: t.Union[str, bytes, bytearray], sig: bytearray, raise_exception: bool = True, pubkey_slot: int = 0, foreign: bool = False, encoding: str = 'utf-8', digest: t.Any = None) -> boolParameters
srct.Union[str, bytes, bytearray]- The buffer to verify.
sigbytearray- The signature to verify against.
raise_exceptionbool defaultTrue- By default, when verification fails a
VerificationErrorwill be raised, unless this is set toFalse. pubkey_slotint default0- The key slot to use to verify the signature against. Defaults to the first key slot.
foreignbool defaultFalse- If false, the normal key store is referenced. Otherwise, the foreign public key store is referenced. Note: This parameter is only applicable for Supported Devices: ZYMKEY5, HSM60, HSM64, HSM6, Secure Compute Module.
encodingstr default'utf-8'- This parameter asks for the encoding for the string source.
digest_hashlib.HASH defaultNone- This parameter asks for the type of hash. Can be None. Defaults to sha256.
Returns
- bool
- Returns
Truefor a good verification orFalsefor a bad verification when theraise_exceptionparameters isFalse.
verify_digest
method
def verify_digest(digest: t.Any, sig: bytearray, raise_exception: bool = True, pubkey_slot: int = 0, foreign: bool = False) -> boolParameters
digest_hashlib.HASH- A hashlib instance that will be used to generate the signature.
sigbytearray- The signature to verify.
raise_exceptionbool defaultTrue- By default, when verification fails, a
VerificationErrorwill be raised, unless this is set toFalse. pubkey_slotint default0- The key slot to use to verify the signature against. Defaults to the first key slot.
foreignbool defaultFalse- If false, the normal key store is referenced. Otherwise, the foreign public key store is referenced. Note: This parameter is only applicable for Supported Devices: ZYMKEY5, HSM60, HSM64, HSM6, Secure Compute Module.
Returns
- bool
- Returns
Truefor a good verification orFalsefor a bad verification whenraise_exceptionisFalse.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
ecdh
method
def ecdh(local_slot: int, peer_pubkey: t.Union[t.List[bytes], int], kdf_func_type: str = 'none', salt: t.Optional[t.List[bytes]] = [], info: t.Optional[t.List[bytes]] = [], num_iterations: int = 1, peer_pubkey_slot_is_foreign: bool = True, derived_key_size: bool = 32) -> bytearrayParameters
local_slotint- The local key slot to use.
peer_pubkeyt.Union[t.List[bytes], int]- The public key of the peer used to generate the pre-master secret
against the private key located in
local_slot. This parameter can be a list ofbytesif the key is provided explicitly or anintif it refers to a key slot. kdf_func_typestr default'none'Specifies the KDF (Key Derivation Function) to use for the returned derived key. Valid values are:
"none": just return the pre-master secret. NOTE: The raw pre-master secret should not be used as a derived key should be put through a suitable KDF. Use ’none’ when it is desired to use a different KDF than what is offered by this method."rfc5869-sha256": RFC5869 with SHA256"rfc5869-sha512": RFC5869 with SHA512"pbkdf2-sha256": PBKDF2 with SHA256"pbkdf2-sha512": PBKDF2 with SHA512
saltt.Optional[t.List[bytes]] default[]- A unique identifier for KDF. Ignored for
kdf_func_type='none'. infot.Optional[t.List[bytes]] default[]- A unique field for rfc5869. Ignore for other KDF types.
num_iterationsint default1- The number of iterations that the KDF should complete.
peer_pubkey_slot_is_foreignbool defaultTrue- TODO_DESCRIPTION
derived_key_sizebool default32- TODO_DESCRIPTION
Returns
- bytearray
- The computed signature.
create_ecdsa_public_key_file
method
def create_ecdsa_public_key_file(filename: str, slot: int = 0) -> None[DEPRECATED]: Use create_public_key_file instead.
This method is useful for generating a Certificate Signing Request.
Parameters
filenamestr- The absolute file path where the public key will be stored in PEM format.
slotint default0- The key slot for the public key.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
create_public_key_file
method
def create_public_key_file(filename: str, slot: int = 0, foreign: bool = False) -> NoneParameters
filenamestr- The absolute file path where the public key will be stored in PEM format.
slotint default0- The key slot for the public key.
foreignbool defaultFalse- If
True, designates the pubkey slot to come from the foreign keystore (Supported Devices: ZYMKEY5, HSM60, HSM64, HSM6, Secure Compute Module).
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_ecdsa_public_key
method
def get_ecdsa_public_key(slot: int = 0) -> bytearray[DEPRECATED]: Use get_public_key instead.
This method is used to retrieve the public key in binary form.
Parameters
slotint default0- The key slot for the public key.
Returns
- bytearray
- The public key in binary form.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_public_key
method
def get_public_key(slot: int = 0, foreign: bool = False)Parameters
slotint default0- The key slot for the public key. Zymkey and HSM4 have slots 0, 1, and 2.
foreignbool defaultFalse- If
True, designates the pubkey slot to come from the foreign keystore (Supported Devices: ZYMKEY5, HSM60, HSM64, HSM6, Secure Compute Module).
Returns
- bytearray
- The public key in binary form.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_slot_alloc_list
method
def get_slot_alloc_list(foreign: bool = False) -> t.Tuple[list, int]Parameters
foreignbool defaultFalse- If
True, designates the pubkey slot to come from the foreign keystore (Supported Devices: ZYMKEY5, HSM60, HSM64, HSM6, Secure Compute Module).
Returns
- t.Tuple[list, int]
- The allocation list and the maximum number of keys
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
store_foreign_public_key
method
def store_foreign_public_key(key_type: str, pubkey: bytearray) -> intParameters
key_typestr- The EC curve type that should be associated with the public key.
pubkeybytearray- The public key binary data.
Returns
- int
- The slot allocated to the key, or less than one for failure.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
disable_public_key_export
method
def disable_public_key_export(slot=0, foreign=False)Parameters
slotdefault0- This parameter specifies the key slot for the public key.
foreigndefaultFalse- If true, the slot refers to the foreign public keyring.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
gen_key_pair
method
def gen_key_pair(key_type)Parameters
key_type- This parameter indicates the EC curve type that should be associated with the new key pair.
Returns
- int
- The slot the new key pair was allocated to.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
gen_ephemeral_key_pair
method
def gen_ephemeral_key_pair(key_type)Parameters
key_type- This parameter indicates the EC curve type that should be associated with the new key pair.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
remove_key
method
def remove_key(slot, foreign=False)Parameters
slot- This parameter specifies the key slot for the key.
foreigndefaultFalse- If true, a public key in the foreign keyring will be deleted.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
invalidate_ephemeral_key
method
def invalidate_ephemeral_key() -> intReturns
- int
- 0 for success.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
gen_wallet_master_seed
method
def gen_wallet_master_seed(key_type, master_gen_key, wallet_name, recovery_strategy=RecoveryStrategy())Parameters
key_type- This parameter indicates the EC curve type that should be associated with the new key pair.
master_gen_key- The master generator key (bytearray) used in the derivation of the child key.
wallet_name- The name of the wallet (string) that this master seed is attached to.
recovery_strategydefaultRecoveryStrategy()- RecoveryStrategy() class that defines what strategy to be used {None, BIP39, SLIP39} are currently supported. RecoveryStrategy->passphrase must be b64 encoded.
Returns
- int or tuple of (int, str)
- The slot the master seed was generated in. With a BIP39 recovery strategy, a tuple of that slot and the BIP39 mnemonic sentence. 0 for starting SLIP39 sessions.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_gen_SLIP39_group_info
method
def set_gen_SLIP39_group_info(group_index, member_count, member_threshold)Parameters
group_index- This parameter indicates the index of the group share to set the amount of member count/threshold for.
member_count- The total number of members (mnemonics) in this group share.
member_threshold- The number of members (mnemonics) needed to reconstruct the group share.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
add_gen_SLIP39_member_pwd
method
def add_gen_SLIP39_member_pwd(passphrase='')Parameters
passphrasedefault''- This parameter indicates the passphrase of the SLIP39 member and is associated with the mnemonic string generated. Can be empty string for no passphrase.
Returns
- tuple of (int, str)
- The return code from the Zymkey library, and the member’s 24-word recovery phrase (mnemonic sentence).
Raises
AssertionError- If the library returned no mnemonic sentence.
cancel_SLIP39_session
method
def cancel_SLIP39_session()Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
gen_oversight_wallet
method
def gen_oversight_wallet(key_type, pub_key, chain_code, node_addr, wallet_name, variant='')Parameters
key_type- This parameter indicates the EC curve type that should be associated with the new key pair.
pub_key- The public key (bytearray) of the last hardened node of the node address.
chain_code- The chain code (bytearray) of the last hardened node of the node address.
node_addr- The bip32 node address used. (EX: “m/1852’/1815’/0’”).
wallet_name- The name of the wallet (string) that this master seed is attached to.
variantdefault''- Key type variant to generate from. Currently only “cardano” is supported for “ed25519”.
Returns
- int
- the slot the oversight wallet was generated in.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
gen_wallet_child_key
method
def gen_wallet_child_key(parent_key_slot, index, hardened, return_chain_code=False)Parameters
parent_key_slot- This parameter specifies the parent key slot. This key must already be part of a wallet.
index- This parameter represents the index for the child key derivation which becomes part of the node address.
hardened- If true, the key is a hardened key.
return_chain_codedefaultFalse- If true, returns the chain code for the key as well. (Must be from a hardened key).
Returns
- int or tuple of (int, bytearray)
- The allocated slot. If
return_chain_codeis true, a tuple of the slot and the 32-byte chain code.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
restore_wallet_master_seed
method
def restore_wallet_master_seed(key_type, master_gen_key, wallet_name, recovery_strategy, mnemonics=None)Parameters
key_type- This parameter indicates the EC curve type that should be associated with the new key pair.
master_gen_key- The master generator key used in the derivation of the child key.
wallet_name- Name of the new wallet to be generated.
recovery_strategy- RecoveryStategy class object that provides the type of recovery and key variant required for restoration.
mnemonicsdefaultNone- Mnemonic sentences required for restoration, number of mnemonics dependant on recovery strategy used. This field is not used for SLIP39.
Returns
- int
- the allocated slot on success
Raises
AssertionError- If
retis a bad return code from the Zymkey library function (BIP39), ifmnemonicsis not given for BIP39, or if the recovery strategy is not BIP39 or SLIP39.
add_restore_SLIP39_mnemonic
method
def add_restore_SLIP39_mnemonic(mnemonic_sentence, passphrase='')Parameters
mnemonic_sentence- 24-word recovery phrase associated with the SLIP39 member.
passphrasedefault''- This parameter indicates the passphrase of the SLIP39 member and is associated with the mnemonic string generated. Can be empty string for no passphrase.
Returns
- int
- A -1 for no change in status. Otherwise returns the slot of the master seed successfully reconstructed from the last shard passed in.
get_wallet_node_addr
method
def get_wallet_node_addr(slot)Parameters
slot- The key slot assignment.
Returns
- tuple of (str, str, int)
- the node address, wallet name and master seed key slot.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_wallet_key_slot
method
def get_wallet_key_slot(node_addr, wallet_name=None, master_seed_slot=None)Parameters
node_addr- The desired node address to look up
wallet_namedefaultNone- The name of the wallet that the node address belongs to. Either this parameter or master_seed_slot must be specified or this function will fail.
master_seed_slotdefaultNone- The master seed slot that the node address belongs to. Either this parameter or wallet_name must be specified or this function will fail.
Returns
- int
- the key slot.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_i2c_address
method
def set_i2c_address(address: int) -> NoneNote: 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.
Parameters
addressint- The i2c address that the Zymkey will set itself to.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_tap_sensitivity
method
def set_tap_sensitivity(axis='all', pct=50.0)Parameters
axisdefault'all'The axis to configure. Valid values include:
- ‘all’: Configure all axes with the specified sensitivity value.
- ‘x’ or ‘X’: Configure only the x-axis
- ‘y’ or ‘Y’: Configure only the y-axis
- ‘z’ or ‘Z’: Configure only the z-axis
pctdefault50.0The sensitivity expressed as percentage.
- 0% = Shut down: Tap detection should not occur along the axis.
- 100% = Maximum sensitivity.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
wait_for_tap
method
def wait_for_tap(timeout_ms=-1)Parameters
timeout_msdefault-1- The maximum amount of time in milliseconds to wait for a tap event to arrive.
get_accelerometer_data
method
def get_accelerometer_data()Returns
- An array of accelerometer readings in units of g-force.
- array index 0 = x axis 1 = y axis 2 = z axis A value of -1 indicates that the tap event was detected in a negative direction for the axis, +1 for a positive direction and 0 for stationary.
get_time
method
def get_time(precise=False)Parameters
precisedefaultFalse- 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.
Returns
- Time in epoch seconds.
lock_binding
method
def lock_binding()Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_current_binding_info
method
def get_current_binding_info()Returns
- binding_is_locked
- Binary value which expresses the current binding lock state.
- is_bound
- Binary value which expresses the current bind state.
set_perimeter_event_actions
method
def set_perimeter_event_actions(channel, action_notify=True, action_self_destruct=False)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
Parameters
channel- The channel (0 or 1) that the action flags will be applied to
action_notifydefaultTrue- Set a perimeter breach to notify. (default = True)
action_self_destructdefaultFalse- Set a perimeter breach to self destruct. (default = False)
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_digital_perimeter_lp_period
method
def set_digital_perimeter_lp_period(lp_period)Parameters
lp_period- The perimeter detect low power period in microseconds.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_digital_perimeter_lp_max_bits
method
def set_digital_perimeter_lp_max_bits(max_num_bits)Parameters
max_num_bits- The perimeter detect low power max number of bits
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_digital_perimeter_delays
method
def set_digital_perimeter_delays(min_delay_ns, max_delay_ns)Parameters
min_delay_ns- The minimum delay in nanoseconds.
max_delay_ns- The maximum delay in nanoseconds.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
wait_for_perimeter_event
method
def wait_for_perimeter_event(timeout_ms=-1)Parameters
timeout_msdefault-1- (input) The maximum amount of time in milliseconds to wait for a perimeter breach event to arrive.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function. ZymkeyTimeoutError- If no perimeter event arrives within
timeout_ms.
get_perimeter_detect_info
method
def get_perimeter_detect_info()Returns
- list of int
- The array of timestamps for each channel for the first detected event in epoch seconds
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
clear_perimeter_detect_info
method
def clear_perimeter_detect_info()Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_cpu_temp
method
def get_cpu_temp()Returns
- float
- The CPU temperature in celsius as a float
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_aux_temp
method
def get_aux_temp(index=0)THIS FUNCTION IS FOR INTERNAL ZYMBIT USE ONLY.
This function gets the current aux temperature. (defaults to 0)
Parameters
indexdefault0- (input) The index id of the processor.
Returns
- float
- The temperature in celsius as a float
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_rtc_drift
method
def get_rtc_drift()Returns
- float
- The RTC drift as a float
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_batt_volt
method
def get_batt_volt()Returns
- float
- The battery voltage as a float
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_model_number
method
def get_model_number()Returns
- str
- The model number as a string.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_firmware_version
method
def get_firmware_version()Returns
- str
- The firmware version as a string.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_serial_number
method
def get_serial_number()Returns
- str
- The serial number as a string.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_battery_voltage_action
method
def set_battery_voltage_action(sleep=False, self_destruct=False)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.
Parameters
sleepdefaultFalse- Set the sleep action.
self_destructdefaultFalse- Set the self_destruct action.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_battery_voltage_threshold
method
def set_battery_voltage_threshold(threshold)Parameters
threshold- The threshold in Volts.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_cpu_temp_action
method
def set_cpu_temp_action(self_destruct=False)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.
Parameters
self_destructdefaultFalse- Set the self_destruct action.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_cpu_low_temp_threshold
method
def set_cpu_low_temp_threshold(threshold)Parameters
threshold- The threshold in celsius.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_cpu_high_temp_threshold
method
def set_cpu_high_temp_threshold(threshold)Parameters
threshold- The threshold in celsius.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
set_supervised_boot_policy
method
def set_supervised_boot_policy(policy_id: int = 0)Parameters
policy_idint default0The actions to apply to the Supervised boot process:
- 0 Do Nothing
- 1 Self-Destruct
- 2 Hold Chip in Reset
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
add_or_update_supervised_boot_file
method
def add_or_update_supervised_boot_file(filepath: str = '', slot: int = 15)Parameters
filepathstr default''- The file to be signed and checked by Supervised boot.
slotint default15- The slot to sign the file with.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
remove_supervised_boot_file
method
def remove_supervised_boot_file(filepath: str = '')Parameters
filepathstr default''- The file to be removed from the manifest.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
get_supervised_boot_file_manifest
method
def get_supervised_boot_file_manifest()Returns
- str
- File manifest to be checked by Supervised boot.
Raises
AssertionError- If
retis a bad return code from the Zymkey library function.
Classes
ZymkeyAccelAxisData
class
class ZymkeyAccelAxisData(g_force, tap_dir)Inherits from object.
Methods
__init__
method
def __init__(g_force, tap_dir)Parameters
g_forcetap_dir
RecoveryStrategy
class
class RecoveryStrategy(variant='')Methods
__init__
method
def __init__(variant='')Parameters
variantdefault''- Variant of the key type. Currently only “cardano” for ed25519 is supported.
RecoveryStrategyBIP39
class
class RecoveryStrategyBIP39(variant='', passphrase='')Inherits from RecoveryStrategy.
Methods
__init__
method
def __init__(variant='', passphrase='')Parameters
variantdefault''- Variant of the key type. Currently only “cardano” for ed25519 is supported.
passphrasedefault''- Passphrase used for BIP39 generation. Can be empty string. Must be b64 encoded.
RecoveryStrategySLIP39
class
class RecoveryStrategySLIP39(group_count, group_threshold, iteration_exponent, variant='', passphrase='')Inherits from RecoveryStrategy.
Methods
__init__
method
def __init__(group_count, group_threshold, iteration_exponent, variant='', passphrase='')Parameters
group_count- Total number of group shares to generate [Max: 14 Groups].
group_threshold- Number of groups needed to restore a master seed with [threshold <= group_count].
iteration_exponent- The higher the exponent the more PBKDF2 hashing is done. [Exponent: 0-5]
variantdefault''- Variant of the key type. Currently only “cardano” for ed25519 is supported.
passphrasedefault''- Passphrase used for BIP39 generation. Can be empty string. Must be b64 encoded.
Attributes
client
attribute
client: t.Optional[Zymkey] = Zymkey()