-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VerifierData & return it alongside the proof
- Loading branch information
1 parent
84a7b89
commit 19cfead
Showing
8 changed files
with
45 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Abi } from '@noir-lang/noirc_abi'; | ||
|
||
export class CircuitAbi { | ||
constructor(public abi: Abi) {} | ||
|
||
public public(): Abi { | ||
const parameters = this.abi.parameters.filter((param) => param.visibility === 'public'); | ||
return { | ||
...this.abi, | ||
parameters | ||
}; | ||
} | ||
|
||
public return(): Abi { | ||
return { | ||
parameters: [], | ||
param_witnesses: {}, | ||
error_types: {}, | ||
return_type: this.abi.return_type, | ||
return_witnesses: this.abi.return_witnesses | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
import { randomUUID } from 'crypto'; | ||
import { MonorepoCircuit } from './circuit.js'; | ||
import { NargoProver } from './nargoProver.js'; | ||
import { encodeProofAsFields, encodePublicInputs } from './utils.js'; | ||
import { encodeProofAsFields } from './utils.js'; | ||
import { InputMap } from '@noir-lang/noirc_abi'; | ||
import { Hex } from 'viem'; | ||
import path from 'path'; | ||
import { VerifierData } from './verifierData.js'; | ||
|
||
export interface ProofWithVerifierData { | ||
proofAsFields: Hex[]; | ||
verifierData: VerifierData; | ||
} | ||
|
||
export class BaseProver { | ||
constructor(public circuit: MonorepoCircuit) {} | ||
public async proveBase(inputs: InputMap): Promise<Hex[]> { | ||
public async proveBase(inputs: InputMap): Promise<ProofWithVerifierData> { | ||
const proofId = randomUUID(); | ||
const prover = new NargoProver(this.circuit, proofId); | ||
|
||
const { proof, verifierData } = await prover.prove(inputs); | ||
const proof = await prover.prove(inputs); | ||
|
||
const proofAsFieldsPath = path.join(this.circuit.root, 'proofs', `${this.circuit.name}.proof.json`); | ||
return await encodeProofAsFields( | ||
const verifierData = await VerifierData.create(prover.verifierTomlPath, this.circuit.artefact.abi); | ||
const proofAsFields = await encodeProofAsFields( | ||
proof, | ||
encodePublicInputs(this.circuit.artefact.abi, verifierData), | ||
verifierData.publicInputs(), | ||
this.circuit.vkPath(), | ||
proofAsFieldsPath | ||
); | ||
return { proofAsFields, verifierData }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.