Phoenix Computational Layer 2 Testnet Release

Phoenix
5 min readSep 23, 2022

--

Dear Phoenix Community/Partners/Devs:

We are glad to announce that Testnet 1.0 for Phoenix Layer 2 has just been released! Phoenix Layer 2 is a computation layer and infrastructure for on-chain data-related applications and AI, enabling Web3 applications to scale privacy-enabled computations and AI capabilities on-chain.

The significance of this is often overlooked, but the development of data computation scaling and AI support is crucial for the future development of Web3. While it is well known that blockchain technology is capable now of handling large amounts of transactions, performing data analytics and computation on large datasets on-chain is impractical and at times impossible. This makes highly-intelligent, data-driven, and machine learning-driven applications very difficult in a blockchain dApp setting. Another problem is that blockchain technology actually can add value and facilitate a decentralized privacy-layer for multi-party data analytics (MPC) and AI (federated learning), but currently there is no infrastructure that serves as the bridge to gap on-chain protocols and off-chain data and AI models — hence a missed potential for a bridge between blockchain and AI.

Enter Phoenix Layer 2 — as an extension of Phoenix Layer 1 blockchain, is the first infrastructure platform integrated with a public blockchain that serves as 1) an efficient computation layer for privacy-enabled data analytics and AI 2) a protocol-level bridge that can bridge a blockchain with mainstream AI frameworks.

Phoenix is currently the only public blockchain with a Layer 2 and integrates with open source AI frameworks such as Google’s TensorFlow (see below).

The full spectrum of use cases have the ability to transform Web3 applications:

  • Multi-Party Computation (MPC)
  • Federated Learning (Decentralized AI)
  • On-Chain Data Analytics
  • Reinforcement Learning in Web3
  • Random Variable Functions (ie. VRF)

The steps below provide instructions on how to use and test the Phoenix Computational Layer 2 (intermediate know-how required).

How to Use and Test Phoenix Computational Layer 2

System requirements

Currently, Only Ubuntu 18.04 is supported. We will strive to support various systems in the near future after thorough testing.

Ubuntu (18.04=)

Python3 (3.6+)Pip3 (19.0+)

Openssl (1.1.1+)

TensorFlow (1.14.0=, cpu-only)

CMake (3.10+)

Installation

Python3 / Pip3 / Openssl / CMake

Check your versions:

python3 — version # e.g. Python 3.6.9

pip3 — version # e.g. pip 20.0.2

apt show libssl-dev # e.g. Version: 1.1.1–1ubuntu2.1~18.04.5

cmake — version # e.g. cmake version 3.15.2

If the above software versions are not met, you may install or upgrade them as follows:

# install python3, pip3, openssl

sudo apt update

sudo apt install python3-dev python3-pip libssl-dev cmake

# upgrade pip3 to latest

sudo pip3 install — upgrade pip

TensorFlow — https://www.tensorflow.org/

The TensorFlow binary installation uses the binary .whl package that TensorFlow officially uploads to pypi.

# Optional, to depress the warning of tensorflow

pip3 install numpy==1.16.4 — user

# install tensorflow

pip3 install tensorflow==1.14.0 — user

After installation, check TensorFlow availability.

python3 -c ‘import tensorflow as tf;print(tf.__version__)’

Output: v1.14.0 indicates successful installation.

Rosetta

# clone git repository

git clone https://github.com/PhoenixGlobal/Phoenix-Privacy-Computation.git — recursive

# compile, install.

cd Phoenix-Privacy-Computation/Rosetta && ./rosetta.sh compile — enable-protocol-mpc-securenn && ./rosetta.sh install

If you encounter some problems for installation, you can also build docker image by using the Dockerfile.

Usage

First, deploy a privacy computation contract (the source file is in contract/Privacy.sol ) on Phoenix Chain by using Remix. You can refer to “How to Deploy Smart Contract on Phoenix using Remix”.

Then, change the contractAddress in chain.py.

Create separate directories for three computing nodes P0, P1, P2, e.g. millionaire0, millionaire1, millionaire2.

mkdir millionaire0 millionaire1 millionaire2

Next, copy chain.py, log.py, millionaire.py,log to millionaire0, millionaire1, millionaire2, and set three parties address in chain.py, then set three parties address to PhoenixChain by calling setPartyAddresses of the privacy computation contract.

Generate server key and certificate

P0, P1, P2 nodes need generate their separate ssl server certificate and private key respectively, execute the command below:

mkdir certs

# generate private key

openssl genrsa -out certs/server-prikey 4096

# if ~/.rnd not exists, generate it with `openssl rand`

if [ ! -f “${HOME}/.rnd” ]; then openssl rand -writerand ${HOME}/.rnd; fi

# generate sign request

openssl req -new -subj ‘/C=BY/ST=Belarus/L=Minsk/O=Rosetta SSL IO server/OU=Rosetta server unit/CN=server’ -key certs/server-prikey -out certs/cert.req

# sign certificate with cert.req

openssl x509 -req -days 365 -in certs/cert.req -signkey certs/server-prikey -out certs/server-nopass.cert

Configuration

Write a configuration file CONFIG.json with the following template:

{

“PARTY_ID”: 0,

“MPC”: {

“FLOAT_PRECISION”: 16,

“P0”: {

“NAME”: “PartyA(P0)”,

“HOST”: “127.0.0.1”,

“PORT”: 11121

},

“P1”: {

“NAME”: “PartyB(P1)”,

“HOST”: “127.0.0.1”,

“PORT”: 12144

},

“P2”: {

“NAME”: “PartyC(P2)”,

“HOST”: “127.0.0.1”,

“PORT”: 13169

},

“SAVER_MODE”: 7,

“SERVER_CERT”: “certs/server-nopass.cert”,

“SERVER_PRIKEY”: “certs/server-prikey”,

“SERVER_PRIKEY_PASSWORD”: “”

}

}

Field Description:

  • PARTY_ID: role of Secure Multipart Computation, the valid values are 0,1,2, corresponding to P0, P1, P2 respectively
  • MPC: specify the protocol of Secure Multipart Computation
  • FLOAT_PRECISION: the float-point precision of Secure Multipart Computation
  • P0, P1, P2: Three-Parties-MPC players P0, P1, P2
  • NAME: MPC player name tag
  • HOST: host address
  • PORT: communication port
  • SERVER_CERT: server-side signature certificate
  • SERVER_PRIKEY: server private key
  • SERVER_PRIKEY_PASSWORD: server private key password (empty string if not set)
  • SAVER_MODE: this indicates how the output checkpoint files are saved. Please refer to MpcSaveV2 in our API document for details.

Run — Stand-alone MODE

Perform stand-alone mode in the Millionaire directory. First, configure the configuration file using the template and save it as CONFIG.json.

Run the Millionaire Problem example:

Note: The console will be prompted for your private inputs at the beginning.

· P2 node

# MPC player 2

python3 millionaire.py — party_id=2

· P1 node

# MPC player 1

python3 millionaire.py — party_id=1

· P0 node

# MPC player 0

python3 millionaire.py –party_id=0

After execution, output should be like this:

ret: [b’1.000000'] # or ret: [b’0.000000']

Transaction successful with hash: 0x81e727f0fe6c2f7aa03ed28f59c69efbeb35e779254e89fff21cfefbbd34e8ac

It means that it has run smoothly and the standalone deployment test has passed, otherwise the test has failed, and please check the above deployment steps.

Multi-machine MODE

Multi-machine MODE is similar to stand-alone mode, with the difference that the configuration file needs to be set to a different HOST field corresponding to the IP address.

Query result on PhoenixChain

You can query the result of every round by querying the getResult of the privacy computation contract.

https://explorer.phoenix.global/

Did you enjoy this update from the Devs? Have you tried the steps above? Share your feedback with the community in our Telegram channel! https://t.me/APEXcommunity

--

--

Phoenix
Phoenix

Written by Phoenix

Phoenix is an L1 and L2 blockchain infrastructure, empowering intelligent Web3 applications, focusing on the next generation of AI & Privacy-Enabled Web3 Apps.

No responses yet