project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5

I spy (fhe / fhim)

Cypherpunk exploration of Fully Homomorphic Encryption that compares dev experience on Inco and Fhenix. See README on GH.

I spy (fhe / fhim)

Created At

ETHGlobal Bangkok

Winner of

Fhenix - Best use of Fhenix Stack 3rd place

Project Description

It's night in unnamed cypherpunk city and an undercover spy meets an informant in the corp district. Police checkpoints are on high alert as usual, but they will let the spy go through.

Each policeman chooses a predefined condition for a spy to satisfy to pass, their decisions are private and completly independent. Checkpoint can decide to let everybody in red jackets to pass (but not green), or only let motorcyclists by. Policemen are free to update their requirements at any moment. Only the spy knows all conditions set at checkpoints so he can find his way in unnamed cypherpunk city.

==========================================================

See README on GH. I programmed a smart contract and verified the correctness by running tests with deployments on corresponding testnets.

State:

  • Encrypted uint32 secretRequirements encodes 4 bytes.
  • Array of 4 addresses checkpointAddresses can modify the corresponding byte of secret requirements (starting from least significant).
  • Address spyAddress can view secretRequirements offchain.

Functions:

  • Constructor sets all address from parameters and initializes secret state to zero.
  • Function setSecretRequirement allows checkpoint address to set their byte to any value. It checks that the value fits in a byte and updates the encrypted state using bit operations.
  • Function getSecretRequirements allows spy to view the encrypted state.

Tests:

  • Check that not a checkpoint address can not set an encrypted byte.
  • Check that only spy address can decrypt the private state.
  • Check that 0th checkpoint address can set an encrypted byte and it is correctly viewed by the spy address.
  • Check that 3rd checkpoint address can set an encrypted byte and it is correctly viewed by the spy address.
  • Check that if the encrypted byte is bigger than 255, it is truncated to fit in a byte.
  • Check that all checkpoint address separately set their encrypted bytes and the total result is correctly viewed by the spy address.

How it's Made

See README on GH. Was hacking solo so no UI. Using FHE stacks Inco and Fhenix to develop, deploy and test private smart contracts. Everything done with hardhat based on the template repos of Inco and Fhenix. Was testing Inco locally in a GitHub codespace before full deployment on the testnet. All test transactions can be seen on thestnet explorers.

background image mobile

Join the mailing list

Get the latest news and updates