@@ -29,7 +29,7 @@ type NoirVoteCalldata struct {
29
29
ProposalID * big.Int
30
30
Vote []* big.Int
31
31
UserData biopassportvoting.BaseVotingUserData
32
- ZkPoints noirvoting. AQueryProofExecutorProofPoints
32
+ ProofBytes [] byte
33
33
}
34
34
35
35
func VoteV3 (w http.ResponseWriter , r * http.Request ) {
@@ -179,45 +179,51 @@ func parseNoirCallData(data []byte) (NoirVoteCalldata, error) {
179
179
return config , fmt .Errorf ("failed to unpack noir calldata: %v" , err )
180
180
}
181
181
182
- if len (decoded ) != 6 {
183
- return config , fmt .Errorf ("unexpected argument count, expected 6 got %d" , len (decoded ))
182
+ if len (decoded ) != 4 {
183
+ return config , fmt .Errorf ("unexpected argument count, expected 4 got %d" , len (decoded ))
184
184
}
185
185
186
186
config .RegistrationRoot = decoded [0 ].([32 ]byte )
187
187
config .CurrentDate = decoded [1 ].(* big.Int )
188
- config .ProposalID = decoded [2 ].(* big.Int )
189
- config .Vote = decoded [3 ].([]* big.Int )
190
- userDataRaw := decoded [4 ]
191
-
192
- userDataStruct , ok := userDataRaw .(struct {
193
- Nullifier * big.Int `json:"nullifier"`
194
- Citizenship * big.Int `json:"citizenship"`
195
- IdentityCreationTimestamp * big.Int `json:"identityCreationTimestamp"`
188
+ userDataEncoded := decoded [2 ].([]byte )
189
+ config .ProofBytes = decoded [3 ].([]byte )
190
+
191
+ uint256Type , _ := abi .NewType ("uint256" , "" , nil )
192
+ uint256ArrayType , _ := abi .NewType ("uint256[]" , "" , nil )
193
+ tupleType , _ := abi .NewType ("tuple" , "" , []abi.ArgumentMarshaling {
194
+ {Name : "nullifier" , Type : "uint256" },
195
+ {Name : "citizenship" , Type : "uint256" },
196
+ {Name : "timestampUpperbound" , Type : "uint256" },
196
197
})
197
- if ! ok {
198
- return config , fmt .Errorf ("failed to cast userData_ to expected struct, got %T" , userDataRaw )
198
+
199
+ userDataArguments := abi.Arguments {
200
+ {Type : uint256Type },
201
+ {Type : uint256ArrayType },
202
+ {Type : tupleType },
199
203
}
200
204
201
- config .UserData = biopassportvoting.BaseVotingUserData {
202
- Nullifier : userDataStruct .Nullifier ,
203
- Citizenship : userDataStruct .Citizenship ,
204
- IdentityCreationTimestamp : userDataStruct .IdentityCreationTimestamp ,
205
+ userDataDecoded , err := userDataArguments .Unpack (userDataEncoded )
206
+ if err != nil {
207
+ return config , fmt .Errorf ("failed to unpack userDataEncoded: %v" , err )
205
208
}
206
209
207
- zkPointsRaw := decoded [5 ]
208
- zkPointsStruct , ok := zkPointsRaw .(struct {
209
- A [2 ]* big.Int `json:"a"`
210
- B [2 ][2 ]* big.Int `json:"b"`
211
- C [2 ]* big.Int `json:"c"`
212
- })
213
- if ! ok {
214
- return config , fmt .Errorf ("failed to cast zkPoints_ to expected struct, got %T" , zkPointsRaw )
210
+ if len (userDataDecoded ) != 3 {
211
+ return config , fmt .Errorf ("invalid userDataEncoded structure" )
215
212
}
216
213
217
- config .ZkPoints = noirvoting.AQueryProofExecutorProofPoints {
218
- A : zkPointsStruct .A ,
219
- B : zkPointsStruct .B ,
220
- C : zkPointsStruct .C ,
214
+ config .ProposalID = userDataDecoded [0 ].(* big.Int )
215
+ config .Vote = userDataDecoded [1 ].([]* big.Int )
216
+
217
+ userDataTuple := userDataDecoded [2 ].(struct {
218
+ Nullifier * big.Int `json:"nullifier"`
219
+ Citizenship * big.Int `json:"citizenship"`
220
+ TimestampUpperbound * big.Int `json:"timestampUpperbound"`
221
+ })
222
+
223
+ config .UserData = biopassportvoting.BaseVotingUserData {
224
+ Nullifier : userDataTuple .Nullifier ,
225
+ Citizenship : userDataTuple .Citizenship ,
226
+ IdentityCreationTimestamp : userDataTuple .TimestampUpperbound ,
221
227
}
222
228
223
229
return config , nil
0 commit comments