A Python wrapper for the libntruprime microlibrary
pyntruprime depends only on libntruprime (which also depends on libcpucycles and librandombytes), available here
The API follows the libntruprime API. It implements the following parameter sets:
- sntrup761
More parameter sets may be added later
Each has the following constants defined:
- sntrup761.PUBLICKEYBYTES Length of the public key
- sntrup761.SECRETKEYBYTES Length of the private key
- sntrup761.CIPHERTEXTBYTES Length of the ciphertext
- sntrup761.BYTES Length of the session key
For each instantiation the following functions are available:
Randomly generates a NTRUprime secret key and its corresponding public key.
Example:
>>> from pyntruprime import sntrup761
>>> pk, sk = sntrup761.keypair()
Randomly generates a ciphertext and the corresponding session key given a public key pk.
Example:
>>> from pyntruprime import sntrup761
>>> pk, _ = sntrup761.keypair()
>>> c, k = sntrup761.enc(pk)
Given a NTRUprime secret key sk and a ciphertext c encapsulated to sk's corresponding public key pk, computes the session key k.
Example:
>>> from pyntruprime import sntrup761
>>> pk, sk = sntrup761.keypair()
>>> c, k = sntrup761.enc(pk)
>>> sntrup761.dec(c, sk) == k
True