Sharing public keys
To make the use of the libraries easier, there are some functions to export only the publicTable
and publicKeys
, which have to be accessible from both the sender and the receiver. Here's how to export and import a PublicKyber
object.
Exporting
To export the PublicKyber
object, you first create it from a Kyber object and then transform it to a JSON string:
import nim_kyber/big
var k: Kyber = createRandomKyber(); # Create the kyber object
var public = k.public() # Get the public object
var str: string = public.toString(); # Transform the public object to a JSON string
# You can also use "k.public().toString()" directly
Now share the str
variable, which can be imported as done in the next example.
Importing
To import the PublicKyber
object from a string, use importPublicKyber
.
import nim_kyber/big
var str = "..." # The exported JSON string
var k: PublicKyber = importPublicKyber(str);
Now you can use k.publicTable
and k.publicKeys
to create a KyberSender
as in this page.
Last updated