Ethereum Privacy : Get started now.

Guénolé de Cadoudal
Ethereum Research
Published in
4 min readApr 8, 2019

Ethereum Privacy leverage the public blockchain infrastructure while maintaining the confidentiality of your transactions

This is the first tutorial to get started with Ethereum Privacy technology.

In 10 minutes, get Ethereum Privacy running on your developer’s machine and understand

  • where the Ethereum Privacy process sits between your web3 program and your usual Ethereum client node
  • what configurations are required to have the technology ready to use
  • how to specify with whom your transaction mus be shared

1.Before we start, some requirements for your target machine

The packaging as of now (v 0.1.2) uses docker image, so you need docker and docker-compose. This has been tested on the following version but it should work with others

Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01

2. Download the get-started package

~ $ git clone --depth 1 https://gitlab.com/guenoledc-perso/offchainprivatetx/get-started.git

This will give you a folder structure with the following

docker-compose.yml: the docker services description and configuration
default-conf.json: common configuration file for all the privacy nodes
setup-env.sh: shell script to prepare the public and privacy nodes
node1/keystore: contains a standard Ethereum wallet for node1
node2/keystore: same for privacy node2
node3/keystore: same for privacy node3
client: a node js command line projet that interacts with the privacy nodes

3. Deploy the environment

~/get-started $ ./setup-env.sh
  1. Starts the public node: here a simple geth in local dev mode with PoA consensus mining when a transaction is received
  2. Launching a geth attach — exec javascript to the public node, to credit each of the wallets that will be used by the Ethereum Privacy nodes to interact with the public node.
  3. Deploying in the public node the smart contract (PrivacyTxStorage) used to store the encrypted transaction and the encrypted notifications. See the previous article. The generated contract address must be given to the privacy nodes so they know to what they should communicate with. This deployment is done using one of the privacy node command line.
  4. Starting each of the 3 Ethereum Privacy nodes (node A, node B, Node C)
  5. From each node, collect the other nodes public key (from their url) and store it in the local PKI.

Setup is now ready and operational (also look at the readme for additional details). You can test the setup by running for each url

$ geth attach http://localhost:8546
Welcome to the Geth JavaScript console!
instance: Ethereum-Standalone-Node/v0.0.1/6000
coinbase: 0x1778fef1adf67b8d904a73f64da4d29c1f13ec0b
at block: 0 (Sat, 09 Feb 2019 18:53:29 CET)
modules: admin:1.0 eth:1.0 net:1.0 parked:1.0 personal:1.0 web3:1.0
This is how the deployed environment looks like (but with a single public node)

geth public node listens for JSON RPC requests at http://localhost:8590

Privacy Node A listens for Web3 JSON RPC requests at http://localhost:8546, Node B and C at http://localhost:8547 and :8548 respectively.

4. Test the setup
with a NodeJS client using a simple key/value smart-contract.

The client test program uses the following smart contract as a mean to simulate private interactions between each other while going through the public blockchain

  • The smart contract has the following behaviour
  • Each key is globally unique, belong to the first person setting a value.
  • Only the owner can change the value.
  • An event is generated on first set and subsequent change
  • Every one can read the value

Below is the recording of a test session that you can replicate easily on your machine.

# On top left terminal
$ node main.js --smartcontract create --listen --url http://localhost:8546
# On top right terminal
$ node main.js --smartcontract auto --listen --url http://localhost:8547
# On bottom left terminal
$ node main.js --smartcontract auto --listen --url http://localhost:8548
# On bottom right terminal
$ node main.js --smartcontract auto --url http://localhost:8546 --key Hello --value World
$ node main.js --smartcontract auto --url http://localhost:8546 --key Hello2 --value World-A-And-C --target 'node C'
$ node main.js --smartcontract auto --url http://localhost:8546 --key Hello3 --value World-A-And-B --target 'node B'

5. Extracting the proof of transaction

The proof of a private transaction extract a json with all the needed elements to demonstrate that an action has been done and communicated to the participants. Read article Ethereum Privacy: Proof of transaction

You can do it in the demonstrator with the following command

# Find the transaction hash output by the commands abobe
$ node main.js --proof 0xa4c65e561cb4db45b80c07616f103872e94746014e637fa69e5dbdedb6c6935e

--

--

Guénolé de Cadoudal
Ethereum Research

Developper passionated with Blockchain. Currently Head of Digital Assets Group & Digital Factory Officer for CACIB .