o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
475 stars 105 forks source link

Side loading verification keys give "proof.verify() not called, call it at least once in your circuit" error in SmartContract #1632

Closed dfstio closed 1 month ago

dfstio commented 1 month ago

https://discord.com/channels/484437221055922177/1235505048537010257

The following code

export class MyContract extends SmartContract {
  @state(Field) value = State<Field>();

  async deploy(args: DeployArgs) {
    super.deploy(args);
    this.account.permissions.set({
      ...Permissions.default(),
      editState: Permissions.proof(),
    });
  }

  @method async setValue(
    value: Field,
    proof: SideloadedProgramProof,
    vk: VerificationKey
  ) {
    proof.verify(vk);
    proof.publicInput.assertEquals(value);
    this.value.set(value);
  }
}

gives an error

    proof.verify() not called, call it at least once in your circuit

      at node_modules/o1js/dist/node/index.cjs:9797:15
          at Array.forEach (<anonymous>)
      at main (o1js/dist/node/index.cjs:9789:12)

when compiling SmartContract