Signing script example

Regarding with signing playload capabilities on Zymkey 4 I would like to get an example of python script using sign_digest() class.

Thanks

Regards

Here is a simple example:

#!/usr/bin/python3

import zymkey
import hashlib


if __name__ == "__main__":

    # Example of sign_digest() and verify_digest()
    hash_object = hashlib.sha256(b'hello world')

    print('Signing data with Zymkey ECDSA private key...', end='')
    signature = zymkey.client.sign_digest(hash_object, slot=0)
    print('OK')

    print('Verifying good data...', end='')
    zymkey.client.verify_digest(hash_object, signature, raise_exception=True, pubkey_slot=0)
    print('OK')

    print('Verifying bad data...', end='')
    bad_hash_object = hashlib.sha256(b'this does not match')
    try:
        zymkey.client.verify_digest(bad_hash_object, signature, raise_exception=True, pubkey_slot=0)
    except VerificationError:
        print('Verification failed (Expected)')
    else:
        raise Exception('verification should have failed, but passed')