Skip to content

Testing Milestone 2

Isaac Adams edited this page Feb 24, 2022 · 31 revisions

Verifying Features

First, run Fennel Protocol as a dev node:

$ ./scripts/setup.sh
$ ./scripts/build-run.sh

Extrinsics are available by navigating to Polkadot.js and entering the Developer > Extrinsics menu.

The following represent the features outlined as the deliverables outlined for Milestone 2:

Keypair Creation

Given key and location, the Key Announcement extrinsic will insert a Storage entry announcing the existence of a Key to the Issued Key's list of keys.

AES

Fennel provides support in our integration libraries for AES encryption and the generation of AES keys (source). A light wrapper around the OpenSSL implementation of AES is used for both key generation and encryption/decryption. An AES key will be generated based on the shared secret for each communication channel established and be used for encrypting the messages exchanged within it.

  • AESCipher::new generates an AES cipher instance based on a randomly generated secret
  • AESCipher::from_file generates an AES cipher instance based on a secret stored in a file
  • AESCipher::new_from_shared_secret generates an AES cipher instance based on a given secret
  • generate_keys using a given secret, this method will return an AES encryption and decryption keys for the OpenSSL implementation
  • aes_encrypt encrypts the given plain text using the given AES Key and a randomly generated IV. It returns the cipher text appended to the randomly generated IV
  • aes_decrypt decrypts the given cipher text using the given AES Key and the appended random IV that was generated for it, returning the original plain text

RSA

Fennel provides support in our integration libraries for RSA encryption and the generation of RSA keys. A light wrapper around the RSA

Public Key Transmission

Having the capability to map public keys to accounts is critical to offering cryptographically secure avenues for Fennel protocol users to request and establish communication channels between each other. By storing the public keys on-chain in connection with user accounts, blockchain level security is achieved for the connection between the public key and the account that claims it. It also ensures that when an account retires a public key, it occurs on-chain so that others are made aware it is no longer active.

You can announce a new RSA public key to the network by calling the issue_key extrinsic (source) with a key fingerprint and a link to a public key storage location.

Any existing RSA public key on-chain can also be revoked by calling the revoke_key extrinsic (source) by supplying the fingerprint.

A Diffie-Hellman encryption key can be announced through the issue_encryption_key extrinsic (source) by simply providing the public key data.

Public Key Retrieval

Public Key Retrieval is implemented as a storage handler around a StorageDoubleMap, mapping accounts to key fingerprints to storage locations. You can find an example of a Rust function to call against this storage endpoint in fennel-lib.

Encrypted Communication Channel Negotiation

The changes in this milestone include both a library used to integrate key management and encryption negotiation features into Rust-based applications through a new fennel-lib implementation, and a Fennel Protocol pallet used to announce both Diffie-Hellman public keys and RSA public keys to the network. In the next milestone, we'll complete a client/server pair targeting easy deployment with this library integrated.

Diffie-Hellman

Fennel utilizes the Diffie-Hellman (DH) algorithm for establishing secure communication channels. A light wrapper around the x25519_dalek crate provides the functions Fennel will use for the communication channel handshake between two accounts (source).

  • get_session_secret this function generates a secret for a user to be used for DH
  • get_session_public_key this function returns the public key derived from the given DH secret, which is exchanged with another user's public key for DH
  • get_shared_secret when a user receives another user's public key, they can combine it with their DH secret to create the DH shared secret

Clone this wiki locally