diff --git a/docs/zkapps/o1js-reference/modules/Experimental.md b/docs/zkapps/o1js-reference/modules/Experimental.md index e5ef12553..3ac8caf73 100644 --- a/docs/zkapps/o1js-reference/modules/Experimental.md +++ b/docs/zkapps/o1js-reference/modules/Experimental.md @@ -17,7 +17,6 @@ This module exposes APIs that are unstable, in the sense that the API surface is ### Functions -- [ZkProgram](Experimental.md#zkprogram) - [createChildAccountUpdate](Experimental.md#createchildaccountupdate) - [memoizeWitness](Experimental.md#memoizewitness) diff --git a/docs/zkapps/o1js/recursion.mdx b/docs/zkapps/o1js/recursion.mdx index 12e0389df..8cebb74b5 100644 --- a/docs/zkapps/o1js/recursion.mdx +++ b/docs/zkapps/o1js/recursion.mdx @@ -32,17 +32,15 @@ Kimchi, the proof system that backs o1js, supports arbitrary infinite recursive More generally, you can use recursion to verify any zero-knowledge program as part of your zkApp. -:::experimental +## ZkProgram Overview -The use of the ZkProgram API with recursion is experimental. This API may change. To learn more, see [Experimental Features](/zkapps/experimental). - -Specifically, ZkProgram methods could be refactored to explicitly return values rather than requiring them to be passed as further inputs. +:::note +zkProgram has been moved out of the Experimental namespace and is available as a top-level import directly. `Experimental.ZkProgram` is deprecated. +If you are experiencing issues with zkProgram, be sure to update o1js to the latest version. ::: -## Overview - -In o1js, you can use `ZkProgram()` to define the steps of our recursive program. Just like `SmartContract()` methods, `ZkProgram()` methods have any number of methods and execute off-chain. +In o1js, you can use `ZkProgram()` to define the steps of a recursive program. Just like `SmartContract()` methods, `ZkProgram()` methods have any number of methods and execute off-chain. After performing your desired recursive steps, you can settle the interaction on Mina's blockchain and by embedding the `ZkProgram` within a `SmartContract` method that verifies the underlying proof of execution and extracts the output that can be used elsewhere in the method (like storing the output in app-state, for example). @@ -53,10 +51,11 @@ Similar to methods within the `SmartContract` class, inputs to `ZkProgram` are _ This simple example has only one method that proves the public input it received is zero. ```typescript -import { Field, Experimental } from 'o1js'; +import { Field, ZkProgram } from 'o1js'; -const SimpleProgram = Experimental.ZkProgram({ - publicInput: Field, +const SimpleProgram = ZkProgram({ + name: "simple-program-example", + publicInputType: Field, methods: { run: { @@ -103,10 +102,11 @@ This example shows a recursive `ZkProgram` that you can use to create recursive This program describes a recursive operation of adding one repeatedly to a number. Note that you recursively depend on the older proof as a private argument to your method. ```typescript -import { SelfProof, Field, Experimental, verify } from 'o1js'; +import { SelfProof, Field, ZkProgram, verify } from 'o1js'; -const AddOne = Experimental.ZkProgram({ - publicInput: Field, +const AddOne = ZkProgram({ + name: "add-one-example", + publicInputType: Field, methods: { baseCase: { @@ -166,10 +166,11 @@ Tree recursion is even more rarely seen in other proof systems and zk toolkits. This example program describes a very simple rollup for adding numbers: ```typescript -import { SelfProof, Field, Experimental, verify } from 'o1js'; +import { SelfProof, Field, ZkProgram, verify } from 'o1js'; -let RollupAdd = Experimental.ZkProgram({ - publicInput: Field, +let RollupAdd = ZkProgram({ + name: "rollup-add-example", + publicInputType: Field, methods: { baseCase: { diff --git a/docs/zkapps/tutorials/09-recursion.mdx b/docs/zkapps/tutorials/09-recursion.mdx index 06c848a8b..bb59dedd7 100644 --- a/docs/zkapps/tutorials/09-recursion.mdx +++ b/docs/zkapps/tutorials/09-recursion.mdx @@ -64,8 +64,9 @@ To create a ZkProgram, start with the `init()` method. - The first argument of a ZkProgram method is always the state of the ZkProgram, named `publicInput` since it is public. ```typescript -const Add = Experimental.ZkProgram({ - publicInput: Field, +const Add = ZkProgram({ + name: 'add-example', + publicInputType: Field, methods: { init: { @@ -263,8 +264,9 @@ class RollupState extends Struct({ ... } -const Rollup = Experimental.ZkProgram({ - publicInput: RollupState, +const Rollup = ZkProgram({ + name: "rollup-example", + publicInputType: Field, methods: { oneStep: { diff --git a/examples/zkapps/09-recursion/src/main.ts b/examples/zkapps/09-recursion/src/main.ts index c6db6293b..8e091f4b8 100644 --- a/examples/zkapps/09-recursion/src/main.ts +++ b/examples/zkapps/09-recursion/src/main.ts @@ -7,7 +7,7 @@ import { PrivateKey, AccountUpdate, SelfProof, - Experimental, + ZkProgram, Struct, Bool, Circuit, @@ -53,7 +53,7 @@ async function main() { await shutdown(); } -const Add = Experimental.ZkProgram({ +const Add = ZkProgram({ publicInput: Field, methods: { diff --git a/examples/zkapps/09-recursion/src/rollup.ts b/examples/zkapps/09-recursion/src/rollup.ts index ece9b5e19..f491764e0 100644 --- a/examples/zkapps/09-recursion/src/rollup.ts +++ b/examples/zkapps/09-recursion/src/rollup.ts @@ -6,7 +6,7 @@ import { PrivateKey, AccountUpdate, SelfProof, - Experimental, + ZkProgram, Struct, Bool, Circuit, @@ -157,7 +157,7 @@ class RollupState extends Struct({ // =============================================================== -const Rollup = Experimental.ZkProgram({ +const Rollup = ZkProgram({ publicInput: RollupState, methods: { @@ -205,7 +205,7 @@ const Rollup = Experimental.ZkProgram({ }, }); -export let RollupProof_ = Experimental.ZkProgram.Proof(Rollup); +export let RollupProof_ = ZkProgram.Proof(Rollup); export class RollupProof extends RollupProof_ {} // =============================================================== diff --git a/examples/zkapps/09-recursion/src/vote.ts b/examples/zkapps/09-recursion/src/vote.ts index 498e35935..709dea1b2 100644 --- a/examples/zkapps/09-recursion/src/vote.ts +++ b/examples/zkapps/09-recursion/src/vote.ts @@ -7,7 +7,7 @@ import { PrivateKey, AccountUpdate, SelfProof, - Experimental, + ZkProgram, Struct, Bool, Circuit, @@ -144,7 +144,7 @@ class VoteState extends Struct({ // =============================================================== -const Vote = Experimental.ZkProgram({ +const Vote = ZkProgram({ publicInput: VoteState, methods: { diff --git a/examples/zkapps/09-recursion/src/zkProgram_wrapper.ts b/examples/zkapps/09-recursion/src/zkProgram_wrapper.ts index 6f4dc48ba..01f38b3ec 100644 --- a/examples/zkapps/09-recursion/src/zkProgram_wrapper.ts +++ b/examples/zkapps/09-recursion/src/zkProgram_wrapper.ts @@ -6,7 +6,7 @@ import { PrivateKey, AccountUpdate, SelfProof, - Experimental, + ZkProgram, Struct, Bool, Circuit, @@ -63,7 +63,7 @@ const ZkProgram = (config : any) => { } }); - const originalZkProgram = Experimental.ZkProgram(zkProgramConfig); + const originalZkProgram = ZkProgram(zkProgramConfig); const zkProgram: any = {};