From 7c78dc0e4a9a8fe368a59e44c8b35ce6624ae46a Mon Sep 17 00:00:00 2001 From: Oleg Komendant <44612825+Hrom131@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:09:14 +0200 Subject: [PATCH] Add verifierNameSuffix parameter into the createVerifier function (#18) --- README.md | 9 +++--- package-lock.json | 4 +-- package.json | 2 +- src/core/CircuitZKit.ts | 21 ++++++++----- src/core/protocols/AbstractImplementer.ts | 8 ++--- src/types/protocols/index.ts | 3 +- test/CircuitZKit.test.ts | 37 +++++++++++++++++++++++ 7 files changed, 64 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3a1ebaa..c9538d8 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,13 @@ The `implementer` is the instance of a certain proving system. Currently `groth1 --- -- **`async createVerifier("sol" | "vy")`** +- **`async createVerifier("sol" | "vy", verifierNameSuffix?: string)`** -Creates a Solidity | Vyper verifier contract on `verifierDirPath` path, which was specified in the config. +Creates a Solidity | Vyper verifier contract with the optional `verifierNameSuffix` on `verifierDirPath` path, which was specified in the config. ```typescript await circuit.createVerifier("sol"); +await circuit.createVerifier("sol", "_suffix_"); ``` - **`async calculateWitness(inputs) -> bigint[]`** @@ -101,12 +102,12 @@ const calldata = await circuit.generateCalldata(proof); Returns the name of the circuit from the config. -- **`getVerifierName() -> string`** +- **`getVerifierName(verifierNameSuffix?: string) -> string`** Returns the name of the verifier in the following form: ```typescript -Verifier +Verifier ``` - **`getProvingSystemType() -> "groth16" | "plonk"`** diff --git a/package-lock.json b/package-lock.json index 959b1dc..007efe9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/zkit", - "version": "0.3.1", + "version": "0.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solarity/zkit", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "dependencies": { "ejs": "3.1.10", diff --git a/package.json b/package.json index 067a78d..0cb1ce7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/zkit", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "author": "Distributed Lab", "readme": "README.md", diff --git a/src/core/CircuitZKit.ts b/src/core/CircuitZKit.ts index 9e8ec2c..4167990 100644 --- a/src/core/CircuitZKit.ts +++ b/src/core/CircuitZKit.ts @@ -17,16 +17,20 @@ export class CircuitZKit { ) {} /** - * Creates a verifier contract for the specified contract language. + * Creates a verifier contract for the specified contract language with optional name suffix. + * For more details regarding the structure of the contract verifier name, see {@link getVerifierName} description. + * + * @param {VerifierLanguageType} languageExtension - The verifier contract language extension. + * @param {string} verifierNameSuffix - The optional verifier name suffix. */ - public async createVerifier(languageExtension: VerifierLanguageType): Promise { + public async createVerifier(languageExtension: VerifierLanguageType, verifierNameSuffix?: string): Promise { const vKeyFilePath: string = this.mustGetArtifactsFilePath("vkey"); const verifierFilePath = path.join( this._config.verifierDirPath, - `${this._implementer.getVerifierName(this._config.circuitName)}.${languageExtension}`, + `${this.getVerifierName(verifierNameSuffix)}.${languageExtension}`, ); - this._implementer.createVerifier(this._config.circuitName, vKeyFilePath, verifierFilePath, languageExtension); + this._implementer.createVerifier(vKeyFilePath, verifierFilePath, languageExtension); } /** @@ -104,12 +108,15 @@ export class CircuitZKit { } /** - * Returns the verifier name. The verifier name is the name of the circuit file without the extension, suffixed with "Verifier". + * Returns the verifier name. The verifier name has the next structure: + * `