This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
actions.go
178 lines (160 loc) · 4.14 KB
/
actions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package main
import (
"errors"
"strconv"
"github.com/bnb-chain/zkbnb-setup/keys"
"github.com/bnb-chain/zkbnb-setup/phase1"
"github.com/bnb-chain/zkbnb-setup/phase2"
"github.com/urfave/cli/v2"
)
func p1t(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 4 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
outputPath := cCtx.Args().Get(1)
inPowStr := cCtx.Args().Get(2)
inPower, err := strconv.Atoi(inPowStr)
if err != nil {
return err
}
outPowStr := cCtx.Args().Get(3)
outPower, err := strconv.Atoi(outPowStr)
if err != nil {
return err
}
if inPower < outPower {
return errors.New("cannot transform to a higher power")
}
err = phase1.Transform(inputPath, outputPath, byte(inPower), byte(outPower))
return err
}
func p1n(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
powerStr := cCtx.Args().Get(0)
power, err := strconv.Atoi(powerStr)
if err != nil {
return err
}
if power > 26 {
return errors.New("can't support powers larger than 26")
}
outputPath := cCtx.Args().Get(1)
err = phase1.Initialize(byte(power), outputPath)
return err
}
func p1c(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
outputPath := cCtx.Args().Get(1)
err := phase1.Contribute(inputPath, outputPath)
return err
}
func p1v(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 1 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
err := phase1.Verify(inputPath, "")
return err
}
func p1vt(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
transformedPath :=cCtx.Args().Get(1)
err := phase1.Verify(inputPath, transformedPath)
return err
}
func p2n(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 3 {
return errors.New("please provide the correct arguments")
}
phase1Path := cCtx.Args().Get(0)
r1csPath := cCtx.Args().Get(1)
phase2Path := cCtx.Args().Get(2)
err := phase2.Initialize(phase1Path, r1csPath, phase2Path)
return err
}
func p2np(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 6 {
return errors.New("please provide the correct arguments")
}
phase1Path := cCtx.Args().Get(0)
r1csPath := cCtx.Args().Get(1)
phase2Path := cCtx.Args().Get(2)
nbCons, err := strconv.Atoi(cCtx.Args().Get(3))
if err != nil {
return err
}
nbR1C, err := strconv.Atoi(cCtx.Args().Get(4))
if err != nil {
return err
}
batchSize, err := strconv.Atoi(cCtx.Args().Get(5))
if err != nil {
return err
}
err = phase2.InitializeFromPartedR1CS(phase1Path, r1csPath, phase2Path, nbCons, nbR1C, batchSize)
return err
}
func p2c(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
outputPath := cCtx.Args().Get(1)
err := phase2.Contribute(inputPath, outputPath)
return err
}
func p2v(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
originPath := cCtx.Args().Get(1)
err := phase2.Verify(inputPath, originPath)
return err
}
func extract(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 1 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
err := keys.ExtractKeys(inputPath)
return err
}
func extracts(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 2 {
return errors.New("please provide the correct arguments")
}
inputPath := cCtx.Args().Get(0)
session := cCtx.Args().Get(1)
err := keys.ExtractSplitKeys(inputPath, session)
return err
}
func exportSol(cCtx *cli.Context) error {
// sanity check
if cCtx.Args().Len() != 1 {
return errors.New("please provide the correct arguments")
}
session := cCtx.Args().Get(0)
err := keys.ExportSol(session)
return err
}