Skip to content

Commit

Permalink
Merge pull request #18 from privacy-scaling-explorations/feat/params
Browse files Browse the repository at this point in the history
Use 6-8-2-3 params insteand of 10-2-1-2
  • Loading branch information
baumstern committed Jul 10, 2023
2 parents 99f3010 + c2c73cf commit 7f6fb79
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 42 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ jobs:
run: |
mkdir -p ./instruments
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.1-aa4ba27/10-2-1-2/ProcessMessages_10-2-1-2_test.wasm
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.1-aa4ba27/10-2-1-2/TallyVotes_10-1-2_test.wasm
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.1-aa4ba27/10-2-1-2/ProcessMessages_10-2-1-2_test.0.zkey
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.1-aa4ba27/10-2-1-2/TallyVotes_10-1-2_test.0.zkey
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/6f45848_20230309/ProcessMessages_6-8-2-3_test.wasm
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/6f45848_20230309/TallyVotes_6-2-3_test.wasm
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/6f45848_20230309/ProcessMessages_6-8-2-3_test.0.zkey
wget -q -P ./instruments https://maci-develop-fra.s3.eu-central-1.amazonaws.com/6f45848_20230309/TallyVotes_6-2-3_test.0.zkey
- name: Build
run: make docker-gen VERSION=${{ github.ref_name }}

- name: Push Docker image
run: docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}

# TODO: replace to ECS deployment
# deploy:
# needs: build-and-push-image
# name: Deploy
# runs-on: ubuntu-latest

deploy:
needs: build-and-push-image
name: Deploy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
# steps:
# - uses: actions/checkout@v3

- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# - uses: superfly/flyctl-actions/setup-flyctl@master
# - run: flyctl deploy --remote-only
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
File renamed without changes.
2 changes: 1 addition & 1 deletion demo/cli_demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ curl http://localhost:8080/api/getResult
## Generate Proof using snarkjs

```
snarkjs groth16 prove instruments/TallyVotes_10-1-2_test.0.zkey data/TallyVotes/10-1-2/witness_wasm.wtns outputs/proof_TallyVotes_10-1-2.json outputs/public_TallyVotes_10-1-2.json
snarkjs groth16 prove instruments/TallyVotes_6-2-3_test.0.zkey data/TallyVotes/6-2-3/witness_wasm.wtns outputs/proof_TallyVotes_6-2-3.json outputs/public_TallyVotes_6-2-3.json
```
22 changes: 11 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN go mod download
COPY . .

# Generate a binary -- custom name to avoid collisions with existing files/directories
RUN go build -v -o "/builds/maci-coordinator"
RUN go build -tags rapidsnark_asm -ldflags="-s -w" -trimpath -v -o "/builds/maci-coordinator"



Expand All @@ -66,20 +66,20 @@ COPY "./demo" \

# Copy instruments needed to generate proof
# Before building the image, you'll need to prepare these files
COPY "./instruments/ProcessMessages_10-2-1-2_test.0.zkey" \
"./instruments/ProcessMessages_10-2-1-2_test.0.zkey"
COPY "./instruments/ProcessMessages_6-8-2-3_test.0.zkey" \
"./instruments/ProcessMessages_6-8-2-3_test.0.zkey"

COPY "./instruments/ProcessMessages_10-2-1-2_test.wasm" \
"./instruments/ProcessMessages_10-2-1-2_test.wasm"
COPY "./instruments/ProcessMessages_6-8-2-3_test.wasm" \
"./instruments/ProcessMessages_6-8-2-3_test.wasm"

COPY "./instruments/TallyVotes_10-1-2_test.0.zkey" \
"./instruments/TallyVotes_10-1-2_test.0.zkey"
COPY "./instruments/TallyVotes_6-2-3_test.0.zkey" \
"./instruments/TallyVotes_6-2-3_test.0.zkey"

COPY "./instruments/TallyVotes_10-1-2_test.wasm" \
"./instruments/TallyVotes_10-1-2_test.wasm"
COPY "./instruments/TallyVotes_6-2-3_test.wasm" \
"./instruments/TallyVotes_6-2-3_test.wasm"

RUN mkdir -p /builds/data/ProcessMessages/10-2-1-2
RUN mkdir -p /builds/data/TallyVotes/10-1-2
RUN mkdir -p /builds/data/ProcessMessages/6-8-2-3
RUN mkdir -p /builds/data/TallyVotes/6-2-3

# Run the binary
CMD ["./maci-coordinator"]
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ go 1.18
require (
github.com/gin-gonic/gin v1.9.1
github.com/iden3/go-rapidsnark/prover v0.0.10
github.com/stretchr/testify v1.8.4
)

require (
github.com/iden3/go-rapidsnark/types v0.0.2 // indirect
github.com/iden3/wasmer-go v0.0.1 // indirect
github.com/stretchr/testify v1.8.4 // indirect
)

require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
Expand All @@ -35,7 +34,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions src/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (p *Prover) GenerateProof(c *gin.Context) {

// 1. Calculate witness
start := time.Now()
wasmBytes, err := os.ReadFile("./instruments/ProcessMessages_10-2-1-2_test.wasm")
wasmBytes, err := os.ReadFile("./instruments/ProcessMessages_6-8-2-3_test.wasm")
if err != nil {
fmt.Printf("err: %s", err)
}
Expand All @@ -97,20 +97,20 @@ func (p *Prover) GenerateProof(c *gin.Context) {
}

//nolint:gomnd // PoC skip
err = os.WriteFile("./data/ProcessMessages/10-2-1-2/witness_wasm.wtns", wtns, 0600)
err = os.WriteFile("./data/ProcessMessages/6-8-2-3/witness_wasm.wtns", wtns, 0600)
if err != nil {
fmt.Printf("err: %s", err)
}

elapsed := time.Since(start) // Calculate the elapsed time
fmt.Printf("Elapsed time for witness calculation 10-2-1-2 Processmessages: %s\n", elapsed)
fmt.Printf("Elapsed time for witness calculation 6-8-2-3 Processmessages: %s\n", elapsed)

// 2. Generate Proof
provingKey, err := os.ReadFile("./instruments/ProcessMessages_10-2-1-2_test.0.zkey")
provingKey, err := os.ReadFile("./instruments/ProcessMessages_6-8-2-3_test.0.zkey")
if err != nil {
fmt.Printf("err: %s", err)
}
witnessOutput, err := os.ReadFile("./data/ProcessMessages/10-2-1-2/witness_wasm.wtns")
witnessOutput, err := os.ReadFile("./data/ProcessMessages/6-8-2-3/witness_wasm.wtns")
if err != nil {
fmt.Printf("err: %s", err)
}
Expand All @@ -127,7 +127,7 @@ func (p *Prover) GenerateProof(c *gin.Context) {

elapsed = time.Since(start) // Calculate the elapsed time

fmt.Printf("Elapsed time for gen proof 10-2-1-2: %s\n", elapsed)
fmt.Printf("Elapsed time for gen proof 6-8-2-3: %s\n", elapsed)

p.ProcessMessagesCircuit.Status = ProofAvailable
fmt.Println("Proof available for ProcessMessages")
Expand All @@ -137,7 +137,7 @@ func (p *Prover) GenerateProof(c *gin.Context) {
p.TallyVotesCircuit.Status = GeneratingProof
// 1. Calculate witness
start := time.Now()
wasmBytes, err := os.ReadFile("./instruments/TallyVotes_10-1-2_test.wasm")
wasmBytes, err := os.ReadFile("./instruments/TallyVotes_6-2-3_test.wasm")
if err != nil {
fmt.Printf("err: %s", err)
}
Expand All @@ -158,20 +158,20 @@ func (p *Prover) GenerateProof(c *gin.Context) {
}

//nolint:gomnd // PoC skip
err = os.WriteFile("./data/TallyVotes/10-1-2/witness_wasm.wtns", wtns, 0600)
err = os.WriteFile("./data/TallyVotes/6-2-3/witness_wasm.wtns", wtns, 0600)
if err != nil {
fmt.Printf("err: %s", err)
}

elapsed := time.Since(start) // Calculate the elapsed time
fmt.Printf("Elapsed time for witness calculation 10-1-2 TallyVotes: %s\n", elapsed)
fmt.Printf("Elapsed time for witness calculation 6-2-3 TallyVotes: %s\n", elapsed)

// 2. Generate Proof
provingKey, err := os.ReadFile("./instruments/TallyVotes_10-1-2_test.0.zkey")
provingKey, err := os.ReadFile("./instruments/TallyVotes_6-2-3_test.0.zkey")
if err != nil {
fmt.Printf("err: %s", err)
}
witnessOutput, err := os.ReadFile("./data/TallyVotes/10-1-2/witness_wasm.wtns")
witnessOutput, err := os.ReadFile("./data/TallyVotes/6-2-3/witness_wasm.wtns")
if err != nil {
fmt.Printf("err: %s", err)
}
Expand All @@ -188,7 +188,7 @@ func (p *Prover) GenerateProof(c *gin.Context) {

elapsed = time.Since(start) // Calculate the elapsed time

fmt.Printf("Elapsed time for gen proof 10-1-2 TallyVotes: %s\n", elapsed)
fmt.Printf("Elapsed time for gen proof 6-2-3 TallyVotes: %s\n", elapsed)

p.TallyVotesCircuit.Status = ProofAvailable
fmt.Println("Proof available for TallyVotes")
Expand Down

0 comments on commit 7f6fb79

Please sign in to comment.