Get Started

Run W3bstream Locally

The W3bstream GitHub repository includes a developer-friendly setup to facilitate DePIN builders building W3bstream provers for their verifiable off-chain computing.

The setup includes the following services:

  • A reference implementation for a DePIN data sequencer

  • A Postgres DB as the Data Availability service

  • A W3bstream coordinator and a prover as a single-node W3bstream configuration

Download demo provers

Let's start by first downloading some ready-made W3bstream project files that implement a basic "range prover" using different ZK technologies:

mkdir w3bstream && cd w3bstream
mkdir -p test/project

# Fetch the latest W3bstream release number
export RELEASE=$(curl --silent "https://api.github.com/repos/iotexproject/w3bstream/releases/latest" | jq -r .tag_name)

# Download the Risc Zero demo prover
curl -L -o test/project/10000 https://raw.githubusercontent.com/iotexproject/w3bstream/$RELEASE/test/project/10000
# Download the Halo2 demo prover
curl -L -o test/project/10001 https://raw.githubusercontent.com/iotexproject/w3bstream/$RELEASE/test/project/10001
# Download the zkWASM demo prover
curl -L -o test/project/10002 https://raw.githubusercontent.com/iotexproject/w3bstream/$RELEASE/test/project/10002
Learn more about the examples

Let's quickly describe the demo projects:

Risc0 "Range Prover"

Proves that a certain integer is in a certain range.

→ Source code

  • private_input: string The value we want to prove is within the range, e.g. "7"

  • public_input: string Comma separated range endpoints, e.g. "3,9"

Halo2 "Proof of Multiplication"

Given two input aa and bb, compute the result 4a2b24*a^2*b^2 and provide the proof.

→ Source code

  • private_a: integer The first value

  • private_b: integer The second value

zkWASM "Proof of Addition"

Given three input a,ba, b and cc, compute the result a+ba+b and provide the proof that a+b=ca+b=c

→ Source code

Inputs:

  • private_input: integer[] The first value

  • public_input: integer[] The second value

With the demo projects in place, we can proceed by fetching the docker-compose.yaml file and running W3bstream locally:

Start the W3bstream Dev Setup

# Fetch the latest docker-compose.yaml
curl https://raw.githubusercontent.com/iotexproject/w3bstream/$RELEASE/docker-compose.yaml > docker-compose.yaml

# Run the configuration
docker compose up -d 

# Log the sequencer, coordinator, and prover
docker compose logs -f sequencer coordinator prover

Test the setup

Now that we have a basic DePIN stack running, including a data sequencer, a data availability service, and a minimal W3bstream network, let's test the setup by sending a data message targeting one of the three demo projects.

In a new terminal, type the following command to send a data message to the sequencer targeting one of the example projects:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "projectID": 10000,
    "projectVersion": "0.1",
    "data": "{\"private_input\":\"14\", \"public_input\":\"3,34\", \"receipt_type\":\"Snark\"}"
  }' \
  localhost:9000/message

After some time, the log in the first terminal should look like similar to the one below:

w3bstream-sequencer    | 200 |   42.968375ms |    192.168.65.1 | POST     "/message"
w3bstream-coordinator  | msg="dispatched a task" project_id=10000 task_id=27
w3bstream-prover       | msg="get a new task" project_id=10000 task_id=27
w3bstream-prover       | msg="acquire vm instance success" vm_type=risc0
w3bstream-coordinator  | msg=stdout proof="{\"Snark\":{\"snark\":{\"a\":[[13,51,248,201,29,8,75,18,133,175,224,43,153,182,18,76,116,108,72,18,95,83,150,181,238,149,60,82,162,242,202,144],[12,175,37,4,26,25,67,209,3,240,63,121,58,84,186,151,17,115,150,37,124,105,91,165,42,121,183,217,131,16,203,210]],\"b\":[[[34,33,95,242,250,124,78,175,229,146,174,12,184,28,240,133,228,90,88,209,196,2,235,47,121,225,159,104,237,152,210,182],[29,175,79,126,19,96,201,151,4,181,4,238,150,139,165,172,133,237,156,92,223,86,25,143,46,208,51,188,171,20,76,62]],[[12,87,52,171,230,179,182,56,194,172,191,150,227,40,164,204,200,238,82,222,83,112,138,149,134,56,14,178,165,237,81,137],[44,149,186,174,109,232,219,73,234,193,62,238,165,249,132,201,206,217,68,57,151,45,105,165,154,60,111,134,31,62,25,253]]],\"c\":[[7,96,9,209,79,91,0,232,113,87,32,163,146,113,134,97,216,33,194,78,150,160,222,150,123,88,202,228,236,171,207,84],[24,35,80,218,45,162,14,142,79,158,53,50,121,190,131,213,93,167,137,57,199,76,147,158,230,19,101,211,85,123,193,94]]},\"post_state_digest\":[163,172,194,113,23,65,137,150,52,11,132,229,169,15,62,244,196,157,34,199,158,68,170,216,34,236,156,49,62,30,184,226],\"journal\":[81,0,0,0,73,32,107,110,111,119,32,121,111,117,114,32,112,114,105,118,97,116,101,32,105,110,112,117,116,32,105,115,32,103,114,101,97,116,101,114,32,116,104,97,110,32,51,32,97,110,100,32,108,101,115,115,32,116,104,97,110,32,51,52,44,32,97,110,100,32,73,32,99,97,110,32,112,114,111,118,101,32,105,116,33,0,0,0]}}"
w3bstream-coordinator  | time=2024-06-25T17:14:58.088Z level=INFO msg="task finished" project_id=10000 task_id=27

Last updated

Logo

This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.

.

2024 | IoTeX