Skip to content

Commit a8f211e

Browse files
committed
Update interfaces and tasks #86
1 parent 7aaf7a6 commit a8f211e

11 files changed

+40
-52
lines changed

contracts/interfaces/modular_commitment.sol

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ pragma solidity >=0.8.4;
2020
import "../types.sol";
2121

2222
interface ICommitmentScheme {
23+
/**
24+
* @dev Emitted when proof does not contain valid eta point values
25+
*/
26+
event WrongEtaPointValues();
27+
2328
function initialize(
2429
bytes32 tr_state_before
2530
) external returns(bytes32 tr_state_after);
@@ -31,4 +36,4 @@ interface ICommitmentScheme {
3136
uint256 challenge,
3237
bytes32 transcript_state_before
3338
) external view returns (bool);
34-
}
39+
}

contracts/interfaces/modular_verifier.sol

+6-7
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@ interface IModularVerifier {
3232
event WrongCommitment();
3333

3434
/**
35-
* @dev Emitted when table does not satisfy constraint system
35+
* @dev Emitted when proof does not contain valid eta point values
3636
*/
37-
event ConstraintSystemNotSatisfied();
37+
event WrongEtaPointValues();
3838

3939
/**
40-
* @dev Emitted when proof is verified
40+
* @dev Emitted when table does not satisfy constraint system
4141
*/
42-
event ProofVerified();
42+
event ConstraintSystemNotSatisfied();
4343

4444
/**
45-
* @dev Emitted when proof verification failed
45+
* @dev Emitted when proof verification completed
4646
*/
47-
event ProofVerificationFailed();
48-
47+
event VerificationResult(bool result);
4948

5049
/**
5150
* @dev Initializes verifier

contracts/zkllvm/circuit1/modular_verifier.sol

+2-5
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,10 @@ contract modular_verifier_circuit1 is IModularVerifier{
233233
emit ConstraintSystemNotSatisfied();
234234
state.b = false;
235235
}
236-
if(state.b) {
237-
emit ProofVerified();
238-
} else {
239-
emit ProofVerificationFailed();
240-
}
241236
}
242237

238+
emit VerificationResult(state.b);
239+
243240
result = state.b;
244241
}
245242
}

contracts/zkllvm/circuit1/params.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"17166126583027276163107155648953851600645935739886150467584901586847365754678"
4949
],
5050
"grinding_params": {
51-
"mask": "4294934528"
51+
"mask": "4294901760"
5252
}
5353
}
5454
}

contracts/zkllvm/circuit2/input.json

-5
This file was deleted.

contracts/zkllvm/circuit2/modular_verifier.sol

+2-5
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,10 @@ contract modular_verifier_circuit2 is IModularVerifier{
233233
emit ConstraintSystemNotSatisfied();
234234
state.b = false;
235235
}
236-
if(state.b) {
237-
emit ProofVerified();
238-
} else {
239-
emit ProofVerificationFailed();
240-
}
241236
}
242237

238+
emit VerificationResult(state.b);
239+
243240
result = state.b;
244241
}
245242
}

contracts/zkllvm/circuit2/proof.bin

+1-1
Large diffs are not rendered by default.

contracts/zkllvm/circuit3/modular_verifier.sol

+2-5
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,10 @@ contract modular_verifier_circuit3 is IModularVerifier{
251251
emit ConstraintSystemNotSatisfied();
252252
state.b = false;
253253
}
254-
if(state.b) {
255-
emit ProofVerified();
256-
} else {
257-
emit ProofVerificationFailed();
258-
}
259254
}
260255

256+
emit VerificationResult(state.b);
257+
261258
result = state.b;
262259
}
263260
}

contracts/zkllvm/circuit4/modular_verifier.sol

+2-5
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,10 @@ contract modular_verifier_circuit4 is IModularVerifier{
251251
emit ConstraintSystemNotSatisfied();
252252
state.b = false;
253253
}
254-
if(state.b) {
255-
emit ProofVerified();
256-
} else {
257-
emit ProofVerificationFailed();
258-
}
259254
}
260255

256+
emit VerificationResult(state.b);
257+
261258
result = state.b;
262259
}
263260
}

contracts/zkllvm/circuit6/modular_verifier.sol

+2-5
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,10 @@ contract modular_verifier_circuit6 is IModularVerifier{
251251
emit ConstraintSystemNotSatisfied();
252252
state.b = false;
253253
}
254-
if(state.b) {
255-
emit ProofVerified();
256-
} else {
257-
emit ProofVerificationFailed();
258-
}
259254
}
260255

256+
emit VerificationResult(state.b);
257+
261258
result = state.b;
262259
}
263260
}

tasks/modular-test.ts

+16-12
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ function loadPublicInput(public_input_path){
159159
for(let i in public_input){
160160
let field = public_input[i];
161161
for(let k in field){
162-
console.log("parsing: ", k);
163162
let element;
164163
if( k == 'field' ){
165164
element = loadFieldElement(field[k]);
@@ -204,24 +203,29 @@ const verify_circuit_proof = async (modular_path: string, circuit: string) => {
204203
);
205204

206205
let proof_path = folder_path + "/proof.bin";
207-
console.log("Verify :",proof_path);
206+
console.log("Verify :", proof_path);
208207
let proof = loadProof(proof_path);
209208
let public_input = loadPublicInput(folder_path + "/public_input.json");
210-
console.log("public input: ", public_input);
211209
let receipt = await (await verifier_contract.verify(proof, public_input, {gasLimit: 30_500_000})).wait();
212-
console.log("Gas used: ", receipt.gasUsed.toNumber());
210+
console.log("Gas used: ", receipt.gasUsed.toNumber());
213211
console.log("Events received:");
214-
const event_icons : {[key:string] : string } = {
215-
'WrongPublicInput' : '🤔',
216-
'WrongCommitment' : '🤔',
217-
'ConstraintSystemNotSatisfied' : '🤔',
218-
'ProofVerified' : '✅',
219-
'ProofVerificationFailed' : '🛑',
212+
const event_to_string = (event) => {
213+
switch(event.event) {
214+
case 'VerificationResult': {
215+
if (BigInt(event.data) != 0n) {
216+
return '✅ProofVerified';
217+
} else {
218+
return '🛑ProofVerificationFailed';
219+
}
220+
}
221+
break;
222+
default:
223+
return '🤔'+event.event;
224+
}
220225
};
221226

222227
for(const e of receipt.events) {
223-
//console.log(e);
224-
console.log("%s: %s", e.event, event_icons[e.event]);
228+
console.log(event_to_string(e));
225229
}
226230
console.log("====================================");
227231
}

0 commit comments

Comments
 (0)