@@ -47,7 +47,6 @@ func Groth16RecursionImpl() {
47
47
panic (err .Error ())
48
48
}
49
49
50
- // TODO(HS) read maybe more than just a single proof file, but rather multiple GKR proofs?
51
50
proof , err := circuit .ReadProofFile (gkrProofFiles [0 ], fields .ECCBN254 )
52
51
if err != nil {
53
52
panic (err .Error ())
@@ -100,28 +99,31 @@ func Groth16RecursionImpl() {
100
99
vk := groth16 .NewVerifyingKey (ecc .BN254 )
101
100
groth16Proof := groth16 .NewProof (ecc .BN254 )
102
101
102
+ var pkFile * os.File = nil
103
+ var vkFile * os.File = nil
104
+ var proofFile * os.File = nil
105
+
103
106
switch groth16Mode {
104
107
case "setup" :
105
108
println ("Groth16 generating setup from scratch..." )
106
109
if pk , vk , err = groth16 .Setup (r1cs ); err != nil {
107
110
panic (err .Error ())
108
111
}
109
112
110
- pkFile , err : = os .OpenFile (groth16CRSFile , os . O_WRONLY | os . O_CREATE , 0644 )
111
- if err != nil {
113
+ if pkFile , err = os .OpenFile (groth16CRSFile ,
114
+ os . O_WRONLY | os . O_CREATE , 0644 ); err != nil {
112
115
panic (err .Error ())
113
116
}
114
117
pk .WriteTo (pkFile )
115
118
116
- vkFile , err : = os .OpenFile (groth16VKFile , os . O_WRONLY | os . O_CREATE , 0644 )
117
- if err != nil {
119
+ if vkFile , err = os .OpenFile (groth16VKFile ,
120
+ os . O_WRONLY | os . O_CREATE , 0644 ); err != nil {
118
121
panic (err .Error ())
119
122
}
120
123
vk .WriteTo (vkFile )
121
124
case "prove" :
122
125
println ("Groth16 reading CRS from file..." )
123
- pkFile , err := os .OpenFile (groth16CRSFile , os .O_RDONLY , 0444 )
124
- if err != nil {
126
+ if pkFile , err = os .OpenFile (groth16CRSFile , os .O_RDONLY , 0444 ); err != nil {
125
127
panic (err .Error ())
126
128
}
127
129
pk .ReadFrom (pkFile )
@@ -131,24 +133,22 @@ func Groth16RecursionImpl() {
131
133
panic ("Groth16 fails" )
132
134
}
133
135
134
- file , err : = os .OpenFile (recursiveProofFile , os . O_WRONLY | os . O_CREATE | os . O_TRUNC , 0644 )
135
- if err != nil {
136
+ if proofFile , err = os .OpenFile (recursiveProofFile ,
137
+ os . O_WRONLY | os . O_CREATE | os . O_TRUNC , 0644 ); err != nil {
136
138
panic (err .Error ())
137
139
}
138
- groth16Proof .WriteTo (file )
140
+ groth16Proof .WriteTo (proofFile )
139
141
case "verify" :
140
142
println ("Groth16 reading vk from file..." )
141
- vkFile , err := os .OpenFile (groth16VKFile , os .O_RDONLY , 0444 )
142
- if err != nil {
143
+ if vkFile , err = os .OpenFile (groth16VKFile , os .O_RDONLY , 0444 ); err != nil {
143
144
panic (err .Error ())
144
145
}
145
146
vk .ReadFrom (vkFile )
146
147
147
- file , err := os .OpenFile (recursiveProofFile , os .O_RDONLY , 0444 )
148
- if err != nil {
148
+ if proofFile , err = os .OpenFile (recursiveProofFile , os .O_RDONLY , 0444 ); err != nil {
149
149
panic (err .Error ())
150
150
}
151
- groth16Proof .ReadFrom (file )
151
+ groth16Proof .ReadFrom (proofFile )
152
152
153
153
publicWitness , err := witness .Public ()
154
154
if err != nil {
0 commit comments