:py:mod:`cryptnoxpy.card.nft` ============================= .. py:module:: cryptnoxpy.card.nft .. autoapi-nested-parse:: Module containing class for NFT card Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cryptnoxpy.card.nft.Nft .. py:class:: Nft(*args, **kwargs) Bases: :py:obj:`cryptnoxpy.card.basic_g1.BasicG1` Class containing functionality for NFT card which has limited capabilities .. py:attribute:: type .. py:attribute:: _type :annotation: = NFT .. py:method:: derive(self, key_type: cryptnoxpy.enums.KeyType = KeyType.K1, path: str = '') :abstractmethod: Derive key on path and make it the current key in the card :requires: - PIN code or challenge-response validated - Seed must exist :param KeyType key_type: Key type to do derive on :param str path: Path on which to do derivation .. py:method:: get_public_key(self, derivation: cryptnoxpy.enums.Derivation = Derivation.CURRENT_KEY, key_type: cryptnoxpy.enums.KeyType = KeyType.K1, path: str = '', compressed: bool = False) -> str Get the public key from the card. :requires: - PIN code or challenge-response validated, except for PIN-less path - Seed must exist :param Derivation derivation: Derivation to use. :param KeyType key_type: Key type to use :param str path: :param bool compressed: The returned value is in compressed format. :return: The public key for the given path in hexadecimal string format :rtype: str :raises DerivationSelectionException: Card is not initialized with seed :raises ReadPublicKeyException: Invalid data received from card .. py:method:: generate_random_number(self, size: int) -> bytes :abstractmethod: Generate random number on the car and return it. :param int size: Output data size in bytes (between 16 and 64, mod 4) :return: Random number generated by the chip :rtype: bytes :raises DataValidationException: size in not a number between 16 and 64 or is not divisible by 4 .. py:method:: load_seed(self, seed: bytes, pin: str = '') -> None :abstractmethod: Load the given seed into the Cryptnox card. :requires: - PIN code or challenge-response validated :param bytes seed: Seed to initialize the card with :param pin: PIN code of the card. Can be empty if card is opened with challenge-response validation :type pin: str, optional :raises KeyGenerationException: Data is not correct .. py:method:: set_pin_authentication(self, status: bool, puk: str) -> None :abstractmethod: Turn on/off authentication with the PIN code. Other methods can still be used. :param bool status: Status of PIN authentication :param str puk: PUK code associated with the card :raises DataValidationException: input data is not valid :raises PukException: PUK code is not valid .. py:method:: set_pinless_path(self, path: str, puk: str) -> None :abstractmethod: Enable working with the card without a PIN on path. :param str path: Path to be available without a PIN code :param str puk: PUK code of the card :raises DataValidationException: input data is not valid :raises PukException: PUK code is not valid .. py:method:: user_key_add(self, slot: cryptnoxpy.enums.SlotIndex, data_info: str, public_key: bytes, puk_code: str, cred_id: bytes = b'') -> None :abstractmethod: Add user public key into the card for user authentication :param int slot: Slot to write the public key to 1 - EC256R1 2 - RSA key, 2048 bits, public exponent must be 65537 3 - FIDO key :param bytes data_info: 64 bytes of user data :param bytes public_key: Public key of the secure element to be used for authentication :param str puk_code: PUK code of the card :param cred_id: Cred id. Used for FIDO2 authentication :type cred_id: bytes, optional :raises DataValidationException: Invalid input data .. py:method:: user_key_delete(self, slot: cryptnoxpy.enums.SlotIndex, puk_code: str) -> None :abstractmethod: Delete the user key from slot and free up for insertion :param SlotIndex slot: Slot to remove the key from :param str puk_code: PUK code of the card :raises DataValidationException: Invalid input data .. py:method:: user_key_info(self, slot: cryptnoxpy.enums.SlotIndex) -> Tuple[str, str] :abstractmethod: Get the description and public key of the user key :requires: - PIN code or challenge-response validated :param SlotIndex slot: Index of slot for which to fetch the description :return: Description and public key in slot :rtype: tuple[str, str] .. py:method:: user_key_enabled(self, slot_index: cryptnoxpy.enums.SlotIndex) Check if user key is present in given slot :param SlotIndex slot_index: Slot index to check for :return: Whether the user key for slot is present :rtype: bool .. py:method:: user_key_challenge_response_nonce(self) -> bytes :abstractmethod: Get 32 bytes random value from the card that is used to open the card with a user key Take nonce value from the card. Sign it with a third party application, like TPM. Send the signature back into the card using :func:`~cryptnoxpy.card.base.Base.user_key_challenge_response_open` :return: 32 bytes random value used as nonce :rtype: bytes .. py:method:: user_key_challenge_response_open(self, slot: cryptnoxpy.enums.SlotIndex, signature: bytes) -> bool :abstractmethod: Send the nonce signature to the card to open it for operations, like it was opened by a PIN code :param SlotIndex slot: Slot to use to open the card :param bytes signature: Signature generated by a third party like TPM. :return: Whether the challenge response authentication succeeded :rtype: bool :raises DataValidationException: invalid input data .. py:method:: user_key_signature_open(self, slot: cryptnoxpy.enums.SlotIndex, message: bytes, signature: bytes) -> bool :abstractmethod: Used for opening the card to sign the given message :param SlotIndex slot: Slot to use to open the card :param bytes message: Message that will be sent to sign operation :param bytes signature: Signature generated by a third party, like TPM, on the same message :return: Whether the challenge response authentication succeeded :rtype: bool :raises DataValidationException: invalid input data .. py:method:: signature_check(self, nonce: bytes) -> cryptnoxpy.card.base.SignatureCheckResult Sign random 32 bytes for validation that private key of public key is on the card. This call doesn't increase signature counter and doesn't go into signature history. :param bytes nonce: random 16 bytes that will be used to sign :return: Message that was signed and the signature :rtype: SignatureCheckResult :raises DataValidationException: Nonce has to be 16 bytes :raises SeedException: There is no seed on the card :raises DataException: Data returned from the card is not valid .. py:method:: _init_data(self, name: str, email: str, pin: str, puk: str, pairing_secret: bytes = base.BASIC_PAIRING_SECRET, nfc_sign: bool = False)