#Abstract Merkle Witness

4 messages · Page 1 of 1 (latest)

fossil sentinel
#

Suppose I have a zkApp/zkProgram app aimed at being reusable. It has a @method that uses a merkle witness. I'd like to create several instances of the app, each with a different merkle witness height. Is this possible to achive this? Could you provide any clue please?

 @method transfer(address: Field, witness: AbstractMerkleWitness) {

 }
modern pasture
#

one way could be a factory-like pattern, similarly to

function factory(height: number) {
  class MyMerkleWitness extends MerkleWitness(height) {}
  class SimpleZkapp extends SmartContract {
    @method verifyMerkleWitness(w: MyMerkleWitness, root: Field) {
      w.calculateRoot(root);
    }
  }

  return SimpleZkapp;
}

const myContract = factory(8);
await myContract.compile();
fossil sentinel
#

Can we achive any kind of abstraction to the field elements (provable data)? Like to define the Provable interface with the functions we want to reach in the @method and work only with the interface in zk app? I tried some ways, but failed. Even if my interface extends from Provable I got the error message.

uncut mulch
#

zkApp method input types are picked up by the @method decorator and for that they have to be in a very specific format. Namely, a class that extends the Provable interface