Quickstart: Distributed Key Generation

Sample Code

Find the finalized code for this quickstart on GitHub.

Prerequisites

Setup

  1. Clone the repo containing this quickstart to a local folder on a Linux, Mac or Windows platform.

  2. Retrieve a token from the Qrypt Portal.

  3. (Optional) Create an environment variable QRYPT_TOKEN for it. For simplicity, the commands below will be referencing a QRYPT_TOKEN environment variable but you can also just use the token directly in the commands below.

  4. Download the Qrypt Security SDK for your platform.

  5. Create a lib folder and extract the Qrypt Security SDK into it.

Expected Folder structure

KeyGenDistributed
   /lib
       /QryptSecurity
           /bin (Windows)
           /include
           /lib
           /res (Windows)

Macos Security Warning

Mac users will need to allow use of the library in the Security & Privacy settings. This will be fixed in a future release.

Reference

https://support.apple.com/en-us/HT202491

Build

To change to the KeyGenDistributed folder:

cd KeyGenDistributed

To make a (debug) build:

./build.sh --build_type=Debug

To find the build folder (if it built successfully):

For linux/mac

ls -d build

For windows

ls -d build/Debug/

To see more build options:

./build.sh --help

Run

Run as Alice

To change to the KeyGenDistributed build folder:

For linux/mac

cd KeyGenDistributed/build

for windows

cd KeyGenDistributed/build/Debug

To run as Alice:

./KeyGenDistributed --user=alice --token=${QRYPT_TOKEN} --key-type=aes --metadata-filename=metadata.bin

Run as Bob

To change to the KeyGenDistributed build folder:

For linux/mac

cd KeyGenDistributed/build

for windows

cd KeyGenDistributed/build/Debug

To run as Alice:

./KeyGenDistributed --user=bob --token=${QRYPT_TOKEN} --metadata-filename=metadata.bin

Debug

If you open the folder KeyGenDistributed In Visual Studio Code, you will find debug setups for running as Alice and Bob.