This PR fixes #19 by introducing ZkProgrammable, a unified interface for writing ZkPrograms as classes and toggling between js/mock/simulation behavior and real proving.
The attached ZkProgrammable.test.ts showcases the implemented behaviour in full, the following highlights from the implementation are worth mentioning:
ZkProgrammable defines a cached zkProgram getter, while the developer defines a zkProgramFactory to create the respective ZkProgram from their ZkProgrammable class
@provableMethod() decorator must be used on all desired 'prover methods' on the ZkProgrammable class. All of these methods will respect the areProofsEnabled setting, producing mock proofs if proofs are disabled and calling the real provers otherwise. Proofs are retrievable via the ProvableMethodExecutionContext singleton, that keeps the execution context of the last called @provableMethod(). Calling await context.prove() will return a mock or real proof, depending on the aforementioned settings.
All of the following methods respect the areProofsEnabled settings too: provableClass.zkProgram.compile() / verify() including @provableMethod() provableClass.foo()
In order to merge this PR, we need to do the following:
[ ] Update protocol provers to use ZkProgrammable (by also introducing a Protocol DI / module container)
[ ] Update snarkyjs to 0.11.0 across all packages
[ ] Update Runtime zk program generation to adhere to ZkProgrammable
This PR fixes #19 by introducing
ZkProgrammable
, a unified interface for writing ZkPrograms as classes and toggling between js/mock/simulation behavior and real proving.The attached
ZkProgrammable.test.ts
showcases the implemented behaviour in full, the following highlights from the implementation are worth mentioning:areProofsEnabled
setting, producing mock proofs if proofs are disabled and calling the real provers otherwise. Proofs are retrievable via theProvableMethodExecutionContext
singleton, that keeps the execution context of the last called@provableMethod()
. Callingawait context.prove()
will return a mock or real proof, depending on the aforementioned settings.areProofsEnabled
settings too:provableClass.zkProgram.compile() / verify()
including@provableMethod() provableClass.foo()
In order to merge this PR, we need to do the following: