Skip to content

geometryxyz/semacaulk-precompute

Repository files navigation

semacaulk-precompute

semacaulk-updater is a long-running process which monitors a Semacaulk contract, precomputes witness data upon insertions, and updates a Blyss bucket.

Getting started

Clone this repository and fetch submodules:

git clone [email protected]:geometryresearch/semacaulk-precompute.git && \
cd semacaulk-precompute && \
git submodule update --init

Build the quotient-pir WASM files:

cd quotient-pir && \
cargo build --release && wasm-pack build --target nodejs

Navigate to the repository's root directory:

cd ..

Run the process:

node build/index.js -c 0x5fbdb2315678afecb367f032d93f642f64180aa3 -n 4 -m 1 -g ./config_10

In the above example, 0x5fbd... is the Semacaulk contract address, and ./config_10 is the path to a config file generated by quotient-pir-config.

Using a larger Semacaulk instance

For convenience, this repository comes with config_10, which supports Semacaulk instances of a maximum capacity of 2 ^ 10 = 1024. If you wish to instantiate a larger Semacaulk instance, you

First, clone the quotient-pir-config repository and build it.

git clone https://github.com/geometryresearch/quotient-pir-config.git && \
cd quotient-pir-config && \
cargo build --release

Run the config binary, specifying the log-2 capacity (e.g. 11 for 2048), a path to a suitable .ptau file (see snarkjs), and the path to the desired config file to be written.

cargo run --release --bin config -- -l <LOG_2 CAPACITY> --ptau <PTAU FILE> --output <CONFIG OUTPUT PATH>

You can run node build/index.js as above with the -g flag st to the path to the new config file.

Deploying and inserting leaves to a contract

Semacaulk comes with a client binary which can be used to deploy a Semacaulk instance to an Ethereum RPC.

To deploy a Semacaulk instance with a local Ethereum test chain (such as avail or Hardhat) listening at localhost:8545, run the following in a Semacaulk repository:

cargo run --release --bin client -- deploy --ptau ./11.ptau -l 10

The contract address will be printed to the console. With the default private key on a fresh RPC node, the address should be 0x5fbdb2315678afecb367f032d93f642f64180aa3.

To insert an identity commitment (e.g. from a identity nullifier set to 0x1 and an identity trapdoor set to 0x5), run:

cargo run --release --bin client -- insert --ptau 11.ptau -c 0x5fbdb2315678afecb367f032d93f642f64180aa3 -l 10 --id_nul 0x1 --id_trap 0x5

Full demo

  1. Generate config file using quotient-pir-config
git clone [email protected]:geometryresearch/quotient-pir-config.git
cd quotient-pir-config
cargo build --release
cargo run --release --bin config -- -l 10 --ptau 10.ptau --output ../config_10
cd ..
  1. Build Semacaulk
git clone [email protected]:geometryresearch/semacaulk.git
cd semacaulk
git checkout feature/client
cargo build --release
  1. Run Anvil in another terminal
anvil
  1. Deploy Semacaulk
./target/release/client deploy --ptau 11.ptau
  1. Insert an identity commitment
./target/release/client insert --ptau 11.ptau -n 0x1 -t 0x2 -l 10 -c 0x5fbdb2315678afecb367f032d93f642f64180aa3
  1. Run a local Blyss server in another terminal
git clone [email protected]:blyssprivacy/sdk.git
cd sdk/lib/server
cargo run --release --bin server
  1. Run semacaulk-precompute in another terminal
git clone [email protected]:geometryresearch/semacaulk-precompute.git
cd semacaulk-precompute
git submodule update --init
npm i
cd quotient-pir
cargo build --release && wasm-pack build --target nodejs
cd ..
npm run build
node build/index.js -c 0x5fbdb2315678afecb367f032d93f642f64180aa3 -n 4 -m 1 -g ../config_10
  1. Insert more identity commitments in the semacaulk terminal
./target/release/client insert --ptau 11.ptau -n 0x3 -t 0x4 -l 10 -c 0x5fbdb2315678afecb367f032d93f642f64180aa3
./target/release/client insert --ptau 11.ptau -n 0x5 -t 0x6 -l 10 -c 0x5fbdb2315678afecb367f032d93f642f64180aa3

You should see the semacaulk-precompute program pick up on these identity commitments, update QuotientTracker, and update the local Blyss bucket.

  1. Generate a proof and broadcast a signal
./target/release/client prove --ptau 11.ptau -c 0x5fbdb2315678afecb367f032d93f642f64180aa3 -n 0x1 -t 0x2 -l 10 -e 0x0 -s signal -i 0 --semacaulk-precompute-endpoint http://127.0.0.1:8000

Output:

Nullifier hash:
2FB6C6F0265EB4ABFEEA80E4464BA0F04226E88572DF5F3F7BF3A6CAE4ED0728
Serialised proof:
95dabfccc8c70339018bcb043ccb716c884fd16404370dc4d61de31d2c904d2e0e25bf765b1dc16019e3d655359a8d807b33e389c4d15fd53cb9beab40b53210e4161b6328752b22386c385f49b5b00bdc525f989c104957caa2ece25a5d520ae18cdbd30b317134305ab16c39e2b0028d271ae8cb6eb95f175bf3fda0775205f4cc92425fc1b3103d77d53464bbb0555606c3fb56b9e3d45e502e7fe1716e2eff7b53c03484a2473cfaf53579a26b51014ba113a78a2f999ca222ee41bb4fa26ccf8f2bbd780410827a4d1adb4feb67a063dea0630a17664e91ff8d8bd4062094866bf6baa9bef253e0d4aba68ecd27029bc5c036adeaade75278213c6ced28dea2892402af53ffb681b6d2acd066bb184c37f06e20f21b28b0c3804296921f64869f9bd0908fb79fcb9e85decfc41e48d94f68ae56a08ae987c44108ebad06c845f38496a3eb915a9eb8f1a7509f10657e9f4b9b0b37ba7362ea905165e50c0000000000000000000000000000000000000000000000000000000000000000f69f1b94a2376ee20dd3a89aee0c6cdcbee8521489ab1c126c4132f5289bbc19ab217aedc9f11827713b79120edcaf86b0d26764d17ce5e1121bd67088898e2c5bdf586a1292e393fc024881246ec2ef39a59b5463d7e571b765d1d0f3bbcc0384ef569821cf93d1cc628e2a0d528e50b5df6e52a8a62322ee53ad0735214f112ca77475f4c1140348a6583efbd2d181e4fbc7f0a821b0b4dc28f83c18337c0906aed7c7ca1b035d9bf0d33179921a64994d08d8d505c2816cf63ddb7e443e25d3493c4f7d1008f2730d1cbbb887d07a9f229d09a850eba585fce013baf6a1218edae2342a24302258b7fc8a3f2d08706437bca433b9af32fe7584353deaf10eb8b1076b8d27e584ae0755bd9a66f8aed891dfecd8037bfcff641607d94c2611b1dad3b9f9cde139bae233d3261eb7b08ca369b1b6f8377045651976d80ae701a716baf9a5a1f217eb81671ac59108302ca8ab281ec06a4221d438e3efeb3730d4460b05efff9a249f249d7e778fe5a916933b8e3f36b13541f835b16956632448fe8994be8ba1456298ab7b229be5816e46ae29eefb1f7bc037b0040b029b864a3a78fa4320e3d11e490102856ae7706e40cd9249322a7d0deb345b874cbca128d62bce93256168f75989dd182376761fe2f2a97f13ac51a9f27aa985a1ff0d22d1d074fd66d9dd3ead6f7d074356b9c8cd5b16258237a72bccdca331eb8b9ca13a306f36814da0c29bec37a07e411ff9cde1ee2da2f5414a3d3b7f412bd3a55852c0079492b1141cca3e2b56989e834d76a9ebad676c34d06dd8ad2f7802a04519c41b6062e55f526dcb34126242055673c1d2752d46d41606b3fd356ce700ee656b6bcd1e9b68cb3a14fa2130c10fdba0ccb026936e74db18515e67a0ca8b1448db1a94a41778e4cb7b1aaad627366190f4184bcd77620efe7968c77300148c3289cca702cdc0dbe6569fe21c4d0af602b8bfa98b1db9b276f5d743d7141d830e90fffe45cd4110bc94e517fc6ab5d63b4f794356fe52028fe0f72bb6cd8ac95710d59566f5fb6c11c75b883b349d8586f9c889582991372711ef1efa4789abf63fe66bd0baabd7a49a4202fd9b6b37e2615b64608cc8cb99e01280909f150d88ea7acdc16083e1547231b3f4b5f45a80f5a39f5299e53df195fadc716a86
./target/release/client broadcast-signal -c 0x5fbdb2315678afecb367f032d93f642f64180aa3 --signal signal --nul_hash 2FB6C6F0265EB4ABFEEA80E4464BA0F04226E88572DF5F3F7BF3A6CAE4ED0728 -e 0x0 --proof 95dabfccc8c70339018bcb043ccb716c884fd16404370dc4d61de31d2c904d2e0e25bf765b1dc16019e3d655359a8d807b33e389c4d15fd53cb9beab40b53210e4161b6328752b22386c385f49b5b00bdc525f989c104957caa2ece25a5d520ae18cdbd30b317134305ab16c39e2b0028d271ae8cb6eb95f175bf3fda0775205f4cc92425fc1b3103d77d53464bbb0555606c3fb56b9e3d45e502e7fe1716e2eff7b53c03484a2473cfaf53579a26b51014ba113a78a2f999ca222ee41bb4fa26ccf8f2bbd780410827a4d1adb4feb67a063dea0630a17664e91ff8d8bd4062094866bf6baa9bef253e0d4aba68ecd27029bc5c036adeaade75278213c6ced28dea2892402af53ffb681b6d2acd066bb184c37f06e20f21b28b0c3804296921f64869f9bd0908fb79fcb9e85decfc41e48d94f68ae56a08ae987c44108ebad06c845f38496a3eb915a9eb8f1a7509f10657e9f4b9b0b37ba7362ea905165e50c0000000000000000000000000000000000000000000000000000000000000000f69f1b94a2376ee20dd3a89aee0c6cdcbee8521489ab1c126c4132f5289bbc19ab217aedc9f11827713b79120edcaf86b0d26764d17ce5e1121bd67088898e2c5bdf586a1292e393fc024881246ec2ef39a59b5463d7e571b765d1d0f3bbcc0384ef569821cf93d1cc628e2a0d528e50b5df6e52a8a62322ee53ad0735214f112ca77475f4c1140348a6583efbd2d181e4fbc7f0a821b0b4dc28f83c18337c0906aed7c7ca1b035d9bf0d33179921a64994d08d8d505c2816cf63ddb7e443e25d3493c4f7d1008f2730d1cbbb887d07a9f229d09a850eba585fce013baf6a1218edae2342a24302258b7fc8a3f2d08706437bca433b9af32fe7584353deaf10eb8b1076b8d27e584ae0755bd9a66f8aed891dfecd8037bfcff641607d94c2611b1dad3b9f9cde139bae233d3261eb7b08ca369b1b6f8377045651976d80ae701a716baf9a5a1f217eb81671ac59108302ca8ab281ec06a4221d438e3efeb3730d4460b05efff9a249f249d7e778fe5a916933b8e3f36b13541f835b16956632448fe8994be8ba1456298ab7b229be5816e46ae29eefb1f7bc037b0040b029b864a3a78fa4320e3d11e490102856ae7706e40cd9249322a7d0deb345b874cbca128d62bce93256168f75989dd182376761fe2f2a97f13ac51a9f27aa985a1ff0d22d1d074fd66d9dd3ead6f7d074356b9c8cd5b16258237a72bccdca331eb8b9ca13a306f36814da0c29bec37a07e411ff9cde1ee2da2f5414a3d3b7f412bd3a55852c0079492b1141cca3e2b56989e834d76a9ebad676c34d06dd8ad2f7802a04519c41b6062e55f526dcb34126242055673c1d2752d46d41606b3fd356ce700ee656b6bcd1e9b68cb3a14fa2130c10fdba0ccb026936e74db18515e67a0ca8b1448db1a94a41778e4cb7b1aaad627366190f4184bcd77620efe7968c77300148c3289cca702cdc0dbe6569fe21c4d0af602b8bfa98b1db9b276f5d743d7141d830e90fffe45cd4110bc94e517fc6ab5d63b4f794356fe52028fe0f72bb6cd8ac95710d59566f5fb6c11c75b883b349d8586f9c889582991372711ef1efa4789abf63fe66bd0baabd7a49a4202fd9b6b37e2615b64608cc8cb99e01280909f150d88ea7acdc16083e1547231b3f4b5f45a80f5a39f5299e53df195fadc716a86

Output:

Transaction hash:
0x30e1be631f06f523cb5909829b9cd151e9c7643575e59844ed2cbb34208e69fd

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published