Skip to content

Instantly share code, notes, and snippets.

Last active February 16, 2020 14:02
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Key generation

To communicate securely Bob and Alice need to generate the following key combinations:

  • Kyber PK and SK
  • Dilithium PK and SK


qrl-cli create-wallet --file wallet_bob.json
qrl-cli create-lattice -f wallet_bob.json -e ephemeral_bob.json -i 0

Generates the following output:


qrl-cli create-wallet --file wallet_alice.json
qrl-cli create-lattice -f wallet_alice.json -e ephemeral_alice.json -i 0

Generates the following output:

EMS communication

  • send-initial-message
  • receive-initial-message
  • send-next-message
  • receive-next-message

1. Bob sends initial message

The sender user the following command to send the initial message (channel opening). Local private keys are used (ephemeral_bob.json) and associated public keys are retrieved from corresponding lattice transaction for the sender and for the receiver.

To create the initial message to send to Alice, Bob needs

  1. Bob's own private keys file (ephemeral_bob.json)
  2. Alice's lattice tx hash to use
qrl-cli send-initial-message ephemeral_bob.json -h bd2691cf8940569cc28aac2c8fc6c208dd4b11a89299cff5f23e832f28746df0

This commans generates 3 outputs:

  1. encCypherText.txt: ecnrypted cypher text
  2. signedMessage.txt containing the secret seed encrypted with the shared key
  3. List of the next 1000 keys (saved as keyListSender.txt, but should be saved in the localStorage)

The encrypted cypher text (1) and the signed message (2) are sent over to Alice as the channel opening message.

2. Alice receives initial message

Alice receives the channel opening message and needs to :

  1. extract the shared key from the encrypted cypher text
  2. decrypt the shared seed with the shared key (1)
  3. generates the list of the next 1000 keys (saved as keyListReceiver.txt, but should be saved in the localStorage)
qrl-cli receive-initial-message ephemeral_alice.json -h d45de896fe45ae443ccf887ae069ee6655a6dc5c5beda8ae70b610e05c57e02a

3. Send next message

To encrypt following messages, receiver needs to define the key index (position in keyList, this should be tracked to increase automatically) and input the message to encrypt.

qrl-cli send-next-message 1 "test"

The output of the send-next-message is encrypted(test) and is sent over (also saved as encryptedMessage{$index}.txt)

4. Receive next message

To decrypt following messages, the receive only need to know its index (which can be deducted if we keep a counter for each message received)

qrl-cli receive-next-message 1

The decrypted message is currently also saved as decryptedMessage{$index}.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment