Table of Contents
constructor
The constructor
is a method used to create and initialize objects created within the BarretenbergBackend
class. In this class, you should pass at least one argument for the circuit
.
Syntax
constructor(acirCircuit, (numberOfThreads = 1));
Parameters
Parameter | Type | Description |
---|
acirCircuit | Object | A circuit represented in a json format, containing the ABI and bytecode typically obtained by running nargo compile . This is the same circuit expected to be passed to the Noir class |
numberOfThreads | Number (optional) | The number of threads to be used by the backend. Defaults to 1. |
Usage
const backend = new BarretenbergBackend(acirCircuit);
generateFinalProof
An async wrapper around the generateProof method that passes a false
flag. Usually called by the Noir class.
Syntax
async generateFinalProof(decompressedWitness)
Parameters
Parameter | Type | Description |
---|
decompressedWitness | Object | The decompressed witness for generating the final proof. |
Returns
Return value | Type | Description |
---|
proof | Promise<Uint8Array> | An array with the byte representation of the final proof. |
Usage
const finalProof = await backend.generateFinalProof(decompressedWitness);
An async wrapper around the generateProof method that passes a true
flag. It's not currently being used by the Noir class, but developers can call this method directly to use Noir's recursive features.
Syntax
async generateIntermediateProof(witness)
Parameters
Parameter | Type | Description |
---|
witness | Object | The witness for generating the intermediate proof. |
Returns
Return value | Type | Description |
---|
proof | Promise<Uint8Array> | An array with the byte representation of the intermediate proof |
Usage
const intermediateProof = await backend.generateIntermediateProof(witness);
generateProof
This async method generates a proof. Takes the witness generated by ACVM, and a boolean that evaluates to true
when the proof is meant to be verified in another circuit. Not currently used by the Noir class.
Syntax
async generateProof(decompressedWitness, makeEasyToVerifyInCircuit)
Parameters
Parameter | Type | Description |
---|
decompressedWitness | Object | The decompressed witness for generating the proof. |
makeEasyToVerifyInCircuit | Boolean | A flag indicating whether to generate proof components for easy verification within a circuit. |
Returns
Return value | Type | Description |
---|
proof | Promise<Uint8Array> | An array with the byte representation of the proof |
Usage
const proof = await backend.generateProof(decompressedWitness, makeEasyToVerifyInCircuit);
This async method returns the artifacts needed to verify the intermediate proof in another circuit. It's not currently being used by the Noir class, but developers can call this method directly to use Noir's recursive features.
Syntax
async generateIntermediateProofArtifacts(proof, numOfPublicInputs = 0)
Parameters
Parameter | Type | Description |
---|
proof | Object | The proof object. |
numOfPublicInputs | Number (optional) | The number of public inputs in the inner proof, defaulting to 0. |
Returns
Return value | Type | Description |
---|
proofAsFields | string[] | An array of strings with the hexadecimal representation of the Fields that make up a proof |
vkAsFields | string[] | An array of strings with the hexadecimal representation of the Fields that make up the verification key |
vkHash | string | A pedersen hash of the verification key |
Usage
const artifacts = await backend.generateIntermediateProofArtifacts(proof, numOfPublicInputs);
verifyFinalProof
An async wrapper around verifyProof that sets the false
flag. Usually called by the Noir class.
Syntax
async verifyFinalProof(proof)
Parameters
Parameter | Type | Description |
---|
proof | Object | The proof object to verify. |
Returns
Return value | Type | Description |
---|
verified | Promise <boolean> | A boolean for whether the proof was verified |
Usage
const isValidFinal = await backend.verifyFinalProof(proof);
An async wrapper around verifyProof that sets the true
flag. It's not currently being used by the Noir class, but developers can call this method directly to use Noir's recursive features.
Syntax
async verifyIntermediateProof(proof)
Parameters
Parameter | Type | Description |
---|
proof | Object | The intermediate proof object to verify. |
Returns
Return value | Type | Description |
---|
verified | Promise <boolean> | A boolean for whether the proof was verified |
Usage
const isValidIntermediate = await backend.verifyIntermediateProof(proof);
verifyProof
This async method verifies a proof. Takes the proof, and a boolean that evaluates to true
when the proof is intermediate.
Syntax
async verifyProof(proof, makeEasyToVerifyInCircuit)
Parameters
Parameter | Type | Description |
---|
proof | Object | The proof object to verify |
makeEasyToVerifyInCircuit | Boolean | A flag indicating whether the proof is intermediate or final |
Returns
Parameter | Type | Description |
---|
verified | Promise<boolean> | A boolean for whether the proof was verified |
Usage
const isValid = await backend.verifyProof(proof, makeEasyToVerifyInCircuit);
destroy
This method destroys the resources allocated in the instantiate method. Noir doesn't currently call this method, but it's highly recommended that developers do so in order to save resources.
Syntax
Parameters
This method takes no parameters.
Usage