diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c149a48..6cde271da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased](https://github.com/o1-labs/o1js/compare/450943...HEAD) +### Added + +- Added `VerificationKey.dummy()` method to get the dummy value of a verification key https://github.com/o1-labs/o1js/pull/1852 [@rpanic](https://github.com/rpanic) + ## [1.8.0](https://github.com/o1-labs/o1js/compare/5006e4f...450943) - 2024-09-18 ### Added diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index 7c6402164..aaa444b09 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -50,6 +50,7 @@ import { methodArgumentTypesAndValues, MethodInterface, sortMethodArguments, + VerificationKey, } from '../proof-system/zkprogram.js'; import { Proof } from '../proof-system/proof.js'; import { PublicKey } from '../provable/crypto/signature.js'; @@ -711,9 +712,7 @@ class SmartContract extends SmartContractBase { ._verificationKey; if (verificationKey === undefined) { if (!Mina.getProofsEnabled()) { - await initializeBindings(); - let [, data, hash] = Pickles.dummyVerificationKey(); - verificationKey = { data, hash: Field(hash) }; + verificationKey = await VerificationKey.dummy(); } else { throw Error( `\`${this.constructor.name}.deploy()\` was called but no verification key was found.\n` + diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index dea019650..6c3165f99 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -460,7 +460,16 @@ class VerificationKey extends Struct({ toJSON({ data }: { data: string }) { return data; }, -}) {} +}) { + static async dummy(): Promise { + await initializeBindings(); + const [, data, hash] = Pickles.dummyVerificationKey(); + return new VerificationKey({ + data, + hash: Field(hash), + }); + } +} function sortMethodArguments( programName: string,