From f61c1521d36baa8d147b8d0a44bb66c92be58fda Mon Sep 17 00:00:00 2001 From: dkijania Date: Fri, 29 May 2026 01:58:11 +0200 Subject: [PATCH] docs(zkapps): retire generated o1js API reference, delegate to docs.o1labs.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 of the zkApp-section migration tracked in #1208. The o1js API reference under docs/zkapps/o1js-reference (217 auto-generated pages) is fully reproduced and actively maintained at https://docs.o1labs.org/o1js/api-reference, with a 1:1 URL structure (classes/*, functions/*, variables/*, type-aliases/*, namespaces/*). Delegate it there rather than keep generating a stale local mirror. - Remove docs/zkapps/o1js-reference/** (217 files) - Remove the "o1js Reference" category from sidebars.js - vercel.json: redirect /zkapps/o1js-reference(/**) and the legacy /zkapps/snarkyjs-reference/** to docs.o1labs.org/o1js/api-reference, with the index path landing on api-reference/Introduction - docusaurus.config.js: drop the snarkyjs-reference client redirect whose target no longer exists (vercel.json now handles that path) - Repoint the 12 in-repo pages that linked into the reference to the o1labs api-reference URLs (verified live, no 404s) - Regenerate static/llms-full.txt and static/llms.txt Verified with a full `docusaurus build` (onBrokenLinks: throw) — no broken links. Hand-written guides and the tutorial series are intentionally left in place; they are delegated later as o1labs reaches parity (see #1208). Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/zkapps/faq.mdx | 8 +- docs/zkapps/o1js-reference/README.mdx | 232 - .../o1js-reference/classes/AccountUpdate.mdx | 1449 - .../classes/AccountUpdateForest.mdx | 1113 - .../classes/AccountUpdateTree.mdx | 638 - .../classes/AlmostForeignField.mdx | 1038 - .../classes/BaseMerkleWitness.mdx | 655 - docs/zkapps/o1js-reference/classes/Bool.mdx | 851 - .../classes/CanonicalForeignField.mdx | 1041 - .../o1js-reference/classes/Character.mdx | 549 - .../zkapps/o1js-reference/classes/Circuit.mdx | 120 - .../o1js-reference/classes/CircuitString.mdx | 743 - .../o1js-reference/classes/DynamicProof.mdx | 531 - .../o1js-reference/classes/EcdsaSignature.mdx | 459 - docs/zkapps/o1js-reference/classes/Field.mdx | 1585 - .../o1js-reference/classes/ForeignCurve.mdx | 681 - .../o1js-reference/classes/ForeignField.mdx | 784 - docs/zkapps/o1js-reference/classes/Group.mdx | 740 - docs/zkapps/o1js-reference/classes/Hashed.mdx | 257 - docs/zkapps/o1js-reference/classes/Int64.mdx | 1299 - .../zkapps/o1js-reference/classes/Keypair.mdx | 73 - docs/zkapps/o1js-reference/classes/Ledger.mdx | 108 - .../o1js-reference/classes/MerkleList.mdx | 521 - .../classes/MerkleListIterator.mdx | 631 - .../o1js-reference/classes/MerkleMap.mdx | 186 - .../classes/MerkleMapWitness.mdx | 601 - .../o1js-reference/classes/MerkleTree.mdx | 288 - .../o1js-reference/classes/Nullifier.mdx | 1652 - docs/zkapps/o1js-reference/classes/Packed.mdx | 209 - .../o1js-reference/classes/PrivateKey.mdx | 785 - docs/zkapps/o1js-reference/classes/Proof.mdx | 428 - .../o1js-reference/classes/ProofBase.mdx | 263 - .../o1js-reference/classes/PublicKey.mdx | 790 - docs/zkapps/o1js-reference/classes/Scalar.mdx | 689 - .../o1js-reference/classes/ScalarField.mdx | 972 - .../o1js-reference/classes/SelfProof.mdx | 444 - docs/zkapps/o1js-reference/classes/Sign.mdx | 649 - .../o1js-reference/classes/Signature.mdx | 667 - .../o1js-reference/classes/SmartContract.mdx | 894 - .../classes/TokenAccountUpdateIterator.mdx | 173 - .../o1js-reference/classes/TokenContract.mdx | 1239 - .../o1js-reference/classes/TokenSymbol.mdx | 589 - docs/zkapps/o1js-reference/classes/UInt32.mdx | 1456 - docs/zkapps/o1js-reference/classes/UInt64.mdx | 1406 - docs/zkapps/o1js-reference/classes/UInt8.mdx | 1215 - .../o1js-reference/classes/Unconstrained.mdx | 278 - .../classes/VerificationKey.mdx | 691 - .../zkapps/o1js-reference/functions/Bytes.mdx | 23 - .../functions/ConstantField.mdx | 15 - .../functions/MerkleListBase.mdx | 15 - .../functions/MerkleWitness.mdx | 21 - .../o1js-reference/functions/Option.mdx | 49 - .../o1js-reference/functions/Reducer.mdx | 25 - .../zkapps/o1js-reference/functions/State.mdx | 19 - .../o1js-reference/functions/Struct.mdx | 122 - .../o1js-reference/functions/VarField.mdx | 15 - .../o1js-reference/functions/WithHash.mdx | 19 - .../o1js-reference/functions/ZkProgram.mdx | 83 - .../functions/addCachedAccount.mdx | 19 - .../o1js-reference/functions/assert.mdx | 20 - .../functions/checkBitLength.mdx | 22 - .../functions/checkZkappTransaction.mdx | 29 - .../o1js-reference/functions/circuitMain.mdx | 22 - .../functions/conditionalSwap.mdx | 22 - .../o1js-reference/functions/createEcdsa.mdx | 17 - .../functions/createForeignCurve.mdx | 29 - .../functions/createForeignField.mdx | 63 - .../functions/declareMethods.mdx | 36 - .../o1js-reference/functions/declareState.mdx | 54 - .../o1js-reference/functions/fetchAccount.mdx | 56 - .../o1js-reference/functions/fetchEvents.mdx | 85 - .../functions/fetchLastBlock.mdx | 17 - .../functions/fetchTransactionStatus.mdx | 19 - .../o1js-reference/functions/genericHash.mdx | 26 - .../functions/initializeBindings.mdx | 13 - .../functions/merkleListHash.mdx | 32 - .../o1js-reference/functions/method.mdx | 48 - .../o1js-reference/functions/provable.mdx | 23 - .../o1js-reference/functions/provablePure.mdx | 19 - .../o1js-reference/functions/public.mdx | 22 - .../functions/readVarMessage.mdx | 22 - .../o1js-reference/functions/sendZkapp.mdx | 28 - .../functions/setArchiveGraphqlEndpoint.mdx | 17 - .../functions/setGraphqlEndpoint.mdx | 15 - .../functions/setGraphqlEndpoints.mdx | 15 - .../functions/setNumberOfWorkers.mdx | 23 - .../o1js-reference/functions/state-1.mdx | 44 - .../functions/toConstantField.mdx | 25 - docs/zkapps/o1js-reference/functions/toFp.mdx | 15 - .../o1js-reference/functions/verify.mdx | 17 - .../o1js-reference/functions/withHashes.mdx | 46 - .../o1js-reference/functions/withMessage.mdx | 17 - .../o1js-reference/interfaces/Permissions.mdx | 250 - .../namespaces/Crypto/README.mdx | 6 - .../namespaces/Crypto/type-aliases/Curve.mdx | 7 - .../Crypto/type-aliases/CurveParams.mdx | 10 - .../namespaces/Encryption/README.mdx | 10 - .../Encryption/functions/decrypt.mdx | 19 - .../Encryption/functions/decryptBytes.mdx | 19 - .../Encryption/functions/encrypt.mdx | 19 - .../Encryption/functions/encryptBytes.mdx | 19 - .../Encryption/type-aliases/CipherText.mdx | 24 - .../type-aliases/CipherTextBytes.mdx | 17 - .../namespaces/Experimental/README.mdx | 15 - .../Experimental/classes/BatchReducer.mdx | 3101 -- .../classes/OffchainStateCommitments.mdx | 733 - .../Experimental/functions/ActionBatch.mdx | 719 - .../functions/IndexedMerkleMap.mdx | 52 - .../Experimental/functions/OffchainState.mdx | 79 - .../Experimental/functions/memoizeWitness.mdx | 24 - .../Experimental/type-aliases/ActionBatch.mdx | 11 - .../type-aliases/IndexedMerkleMap.mdx | 7 - .../namespaces/Lightnet/README.mdx | 7 - .../Lightnet/functions/acquireKeyPair.mdx | 53 - .../functions/listAcquiredKeyPairs.mdx | 31 - .../Lightnet/functions/releaseKeyPair.mdx | 30 - .../o1js-reference/namespaces/Mina/README.mdx | 38 - .../Mina/functions/LocalBlockchain.mdx | 329 - .../namespaces/Mina/functions/Network.mdx | 50 - .../Mina/functions/TestPublicKey.mdx | 15 - .../namespaces/Mina/functions/currentSlot.mdx | 13 - .../Mina/functions/currentTransaction.mdx | 11 - .../namespaces/Mina/functions/faucet.mdx | 19 - .../Mina/functions/fetchActions.mdx | 40 - .../namespaces/Mina/functions/fetchEvents.mdx | 52 - .../Mina/functions/filterGroups.mdx | 43 - .../namespaces/Mina/functions/getAccount.mdx | 19 - .../namespaces/Mina/functions/getActions.mdx | 30 - .../namespaces/Mina/functions/getBalance.mdx | 19 - .../Mina/functions/getNetworkConstants.mdx | 13 - .../Mina/functions/getNetworkId.mdx | 13 - .../Mina/functions/getNetworkState.mdx | 13 - .../Mina/functions/getProofsEnabled.mdx | 11 - .../namespaces/Mina/functions/hasAccount.mdx | 19 - .../namespaces/Mina/functions/sender.mdx | 15 - .../Mina/functions/setActiveInstance.mdx | 17 - .../namespaces/Mina/functions/transaction.mdx | 49 - .../Mina/functions/waitForFunding.mdx | 15 - .../Mina/namespaces/TestPublicKey/README.mdx | 6 - .../TestPublicKey/functions/fromBase58.mdx | 15 - .../TestPublicKey/functions/random.mdx | 19 - .../Mina/namespaces/Transaction/README.mdx | 5 - .../Transaction/functions/fromJSON.mdx | 15 - .../Mina/type-aliases/ActionStates.mdx | 24 - .../Mina/type-aliases/FeePayerSpec.mdx | 14 - .../Mina/type-aliases/IncludedTransaction.mdx | 37 - .../Mina/type-aliases/NetworkConstants.mdx | 33 - .../Mina/type-aliases/PendingTransaction.mdx | 151 - .../PendingTransactionPromise.mdx | 22 - .../type-aliases/PendingTransactionStatus.mdx | 7 - .../Mina/type-aliases/RejectedTransaction.mdx | 46 - .../Mina/type-aliases/TestPublicKey.mdx | 17 - .../Mina/type-aliases/Transaction.mdx | 55 - .../Mina/variables/activeInstance.mdx | 7 - .../o1js-reference/type-aliases/Account.mdx | 7 - .../o1js-reference/type-aliases/Bool.mdx | 7 - .../o1js-reference/type-aliases/BoolVar.mdx | 7 - .../o1js-reference/type-aliases/Bytes.mdx | 7 - .../o1js-reference/type-aliases/Cache.mdx | 79 - .../type-aliases/CacheHeader.mdx | 17 - .../type-aliases/ConstantField.mdx | 17 - .../type-aliases/DeployArgs.mdx | 12 - .../o1js-reference/type-aliases/Empty.mdx | 7 - .../type-aliases/FeatureFlags.mdx | 66 - .../o1js-reference/type-aliases/Field.mdx | 7 - .../type-aliases/FlexibleProvable.mdx | 11 - .../type-aliases/FlexibleProvablePure.mdx | 11 - .../o1js-reference/type-aliases/Group.mdx | 7 - .../type-aliases/InferProvable.mdx | 11 - .../o1js-reference/type-aliases/JsonProof.mdx | 38 - .../type-aliases/MerkleListBase.mdx | 30 - .../type-aliases/MerkleListIteratorBase.mdx | 50 - .../o1js-reference/type-aliases/Option.mdx | 55 - .../o1js-reference/type-aliases/Provable.mdx | 190 - .../type-aliases/ProvableExtended.mdx | 15 - .../type-aliases/ProvableHashable-1.mdx | 31 - .../type-aliases/ProvableHashable.mdx | 13 - .../type-aliases/ProvablePure.mdx | 37 - .../type-aliases/ProvableType.mdx | 13 - .../type-aliases/ProvableTypePure.mdx | 13 - .../type-aliases/ProvableWithEmpty.mdx | 27 - .../o1js-reference/type-aliases/Reducer.mdx | 21 - .../type-aliases/ScalarConst.mdx | 7 - .../o1js-reference/type-aliases/State.mdx | 132 - .../o1js-reference/type-aliases/Struct.mdx | 21 - .../type-aliases/ToProvable.mdx | 13 - .../type-aliases/TransactionPromise.mdx | 34 - .../type-aliases/TransactionStatus.mdx | 13 - .../o1js-reference/type-aliases/TupleN.mdx | 15 - .../o1js-reference/type-aliases/Undefined.mdx | 7 - .../o1js-reference/type-aliases/VarField.mdx | 17 - .../o1js-reference/type-aliases/Void.mdx | 7 - .../o1js-reference/type-aliases/WithHash.mdx | 28 - .../type-aliases/WithProvable.mdx | 13 - .../o1js-reference/type-aliases/Witness.mdx | 10 - .../o1js-reference/type-aliases/ZkProgram.mdx | 17 - .../type-aliases/ZkappPublicInput.mdx | 36 - .../o1js-reference/variables/Account.mdx | 7 - docs/zkapps/o1js-reference/variables/Bool.mdx | 33 - .../zkapps/o1js-reference/variables/Cache.mdx | 41 - .../o1js-reference/variables/Crypto.mdx | 35 - .../zkapps/o1js-reference/variables/Empty.mdx | 7 - .../o1js-reference/variables/FeatureFlags.mdx | 216 - .../zkapps/o1js-reference/variables/Field.mdx | 50 - .../o1js-reference/variables/Gadgets.mdx | 1607 - .../zkapps/o1js-reference/variables/Group.mdx | 20 - docs/zkapps/o1js-reference/variables/Hash.mdx | 406 - .../o1js-reference/variables/Keccak.mdx | 111 - .../o1js-reference/variables/Permissions.mdx | 272 - .../o1js-reference/variables/Poseidon.mdx | 132 - .../o1js-reference/variables/ProvableType.mdx | 42 - .../o1js-reference/variables/TokenId.mdx | 52 - .../variables/TransactionVersion.mdx | 21 - .../o1js-reference/variables/TupleN.mdx | 67 - .../o1js-reference/variables/Undefined.mdx | 7 - docs/zkapps/o1js-reference/variables/Void.mdx | 7 - .../variables/ZkappPublicInput.mdx | 30 - .../o1js-reference/variables/emptyHash.mdx | 7 - docs/zkapps/o1js/basic-concepts.mdx | 2 +- docs/zkapps/o1js/foreign-fields.mdx | 6 +- docs/zkapps/o1js/gadgets.mdx | 2 +- docs/zkapps/o1js/indexed-merkle-map.mdx | 2 +- docs/zkapps/tutorials/01-hello-world.mdx | 4 +- .../05-common-types-and-functions.mdx | 28 +- docs/zkapps/tutorials/09-recursion.mdx | 2 +- docs/zkapps/tutorials/10-account-updates.mdx | 4 +- docs/zkapps/tutorials/index.mdx | 2 +- .../how-to-write-a-zkapp.mdx | 2 +- .../smart-contracts.mdx | 2 +- docusaurus.config.js | 4 - sidebars.js | 1255 +- static/llms-full.txt | 46110 +--------------- static/llms.txt | 20 +- vercel.json | 14 +- 234 files changed, 97 insertions(+), 92339 deletions(-) delete mode 100644 docs/zkapps/o1js-reference/README.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/AccountUpdate.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/AccountUpdateForest.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/AccountUpdateTree.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/AlmostForeignField.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/BaseMerkleWitness.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Bool.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/CanonicalForeignField.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Character.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Circuit.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/CircuitString.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/DynamicProof.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/EcdsaSignature.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Field.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/ForeignCurve.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/ForeignField.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Group.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Hashed.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Int64.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Keypair.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Ledger.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/MerkleList.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/MerkleListIterator.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/MerkleMap.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/MerkleMapWitness.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/MerkleTree.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Nullifier.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Packed.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/PrivateKey.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Proof.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/ProofBase.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/PublicKey.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Scalar.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/ScalarField.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/SelfProof.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Sign.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Signature.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/SmartContract.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/TokenAccountUpdateIterator.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/TokenContract.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/TokenSymbol.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/UInt32.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/UInt64.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/UInt8.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/Unconstrained.mdx delete mode 100644 docs/zkapps/o1js-reference/classes/VerificationKey.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/Bytes.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/ConstantField.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/MerkleListBase.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/MerkleWitness.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/Option.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/Reducer.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/State.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/Struct.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/VarField.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/WithHash.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/ZkProgram.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/addCachedAccount.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/assert.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/checkBitLength.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/checkZkappTransaction.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/circuitMain.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/conditionalSwap.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/createEcdsa.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/createForeignCurve.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/createForeignField.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/declareMethods.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/declareState.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/fetchAccount.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/fetchEvents.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/fetchLastBlock.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/fetchTransactionStatus.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/genericHash.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/initializeBindings.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/merkleListHash.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/method.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/provable.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/provablePure.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/public.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/readVarMessage.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/sendZkapp.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/setGraphqlEndpoint.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/setGraphqlEndpoints.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/setNumberOfWorkers.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/state-1.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/toConstantField.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/toFp.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/verify.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/withHashes.mdx delete mode 100644 docs/zkapps/o1js-reference/functions/withMessage.mdx delete mode 100644 docs/zkapps/o1js-reference/interfaces/Permissions.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Crypto/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/functions/decrypt.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/functions/encrypt.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Lightnet/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/Network.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/currentSlot.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/faucet.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/filterGroups.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getAccount.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getActions.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getBalance.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/hasAccount.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/sender.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/transaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction.mdx delete mode 100644 docs/zkapps/o1js-reference/namespaces/Mina/variables/activeInstance.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Account.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Bool.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/BoolVar.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Bytes.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Cache.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/CacheHeader.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ConstantField.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/DeployArgs.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Empty.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/FeatureFlags.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Field.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/FlexibleProvable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/FlexibleProvablePure.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Group.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/InferProvable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/JsonProof.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/MerkleListBase.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/MerkleListIteratorBase.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Option.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Provable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableExtended.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableHashable-1.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableHashable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvablePure.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableType.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableTypePure.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ProvableWithEmpty.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Reducer.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ScalarConst.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/State.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Struct.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ToProvable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/TransactionPromise.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/TransactionStatus.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/TupleN.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Undefined.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/VarField.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Void.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/WithHash.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/WithProvable.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/Witness.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ZkProgram.mdx delete mode 100644 docs/zkapps/o1js-reference/type-aliases/ZkappPublicInput.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Account.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Bool.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Cache.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Crypto.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Empty.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/FeatureFlags.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Field.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Gadgets.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Group.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Hash.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Keccak.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Permissions.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Poseidon.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/ProvableType.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/TokenId.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/TransactionVersion.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/TupleN.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Undefined.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/Void.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/ZkappPublicInput.mdx delete mode 100644 docs/zkapps/o1js-reference/variables/emptyHash.mdx diff --git a/docs/zkapps/faq.mdx b/docs/zkapps/faq.mdx index e0cea97b6..30d3ea1e1 100644 --- a/docs/zkapps/faq.mdx +++ b/docs/zkapps/faq.mdx @@ -42,7 +42,7 @@ There are many approaches to building a smart contract. For the zkApp tutorials, ### Where can I find the o1js API reference documentation? -See the autogenerated [o1js reference](/zkapps/o1js-reference) documentation with doc comments, like the [Provable](/zkapps/o1js-reference/type-aliases/Provable) module. +See the autogenerated [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction) documentation with doc comments, like the [Provable](https://docs.o1labs.org/o1js/api-reference/type-aliases/Provable) module. ### What is ZkProgram? @@ -52,8 +52,8 @@ A general-purpose API for creating zk proofs. A ZkProgram is similar to a zkApp Use the appropriate module to work with the live network or with historical archive nodes: -- [getActions](/zkapps/o1js-reference/namespaces/Mina/functions/getActions) works with the blockchain network -- [fetchActions](/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions) works with archive nodes +- [getActions](https://docs.o1labs.org/o1js/api-reference/namespaces/Mina/functions/getActions) works with the blockchain network +- [fetchActions](https://docs.o1labs.org/o1js/api-reference/namespaces/Mina/functions/fetchActions) works with archive nodes ### Does o1js compile my JavaScript code to an arithmetic circuit? @@ -138,7 +138,7 @@ It allows the method to be invoked by a user interacting with the smart contract ### How can you enforce that an account update must be signed by the account owner? -Use the `requireSignature` command. See the [requireSignature](/zkapps/o1js-reference/classes/SmartContract#requiresignature) Method reference. +Use the `requireSignature` command. See the [requireSignature](https://docs.o1labs.org/o1js/api-reference/classes/SmartContract#requiresignature) Method reference. ### How do I configure who has the authority to interact and make changes to a specific part of an account? diff --git a/docs/zkapps/o1js-reference/README.mdx b/docs/zkapps/o1js-reference/README.mdx deleted file mode 100644 index 25bb069b2..000000000 --- a/docs/zkapps/o1js-reference/README.mdx +++ /dev/null @@ -1,232 +0,0 @@ ---- -title: o1js API Reference -keywords: - - o1js - - API - - Reference ---- - -# o1js   [![npm version](https://img.shields.io/npm/v/o1js.svg?style=flat)](https://www.npmjs.com/package/o1js) [![npm](https://img.shields.io/npm/dm/o1js)](https://www.npmjs.com/package/o1js) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md) - -ℹ️ **o1js** is an evolution of [SnarkyJS](https://www.npmjs.com/package/snarkyjs) which saw -49 updated versions over two years of development with 43,141 downloads. - -This name change to o1js reflects the evolution of our vision for the premiere toolkit used by developers to build zero knowledge-enabled applications, while paying homage to our technology's recursive proof generation capabilities. - -Your favorite functionality stays the same and transitioning to o1js is a quick and easy process: - -- To update zkApp-cli, run the following command: - - `npm i -g zkapp-cli@latest` - -- To remove the now-deprecated SnarkyJS package and install o1js, run the following command: - - `npm remove snarkyjs && npm install o1js` - -- For existing zkApps, make sure to update your imports from `snarkyjs` to `o1js` -- No need to redeploy, you are good to go! - -## o1js - -o1js helps developers build apps powered by zero knowledge (zk) cryptography. - -The easiest way to write zk programs is using o1js. - -o1js is a TypeScript library for [zk-SNARKs](https://minaprotocol.com/blog/what-are-zk-snarks) and zkApps. You can use o1js to write zk smart contracts based on zero-knowledge proofs for the Mina Protocol. - -o1js is automatically included when you create a project using the [zkApp CLI](https://www.npmjs.com/package/zkapp-cli). - -## Learn More - -- To learn more about developing zkApps, see the [zkApp Developers](https://docs.minaprotocol.com/zkapps) docs. - -- For guided steps building and using zkApps, see the [zkApp Developers Tutorials](https://docs.minaprotocol.com/zkapps/tutorials/hello-world). - -- To meet other developers building zkApps with o1js, participate in the [#zkapps-developers](https://discord.com/channels/484437221055922177/915745847692636181) channel on Mina Protocol Discord. - -- For a list of changes between versions, see the [CHANGELOG](https://github.com/o1-labs/o1js/blob/main/CHANGELOG.md). - -- To stay up to date with o1js, see the [O(1) Labs Blog](https://www.o1labs.org/blog?topics=o1js). - -## Contributing - -o1js is an open source project. We appreciate all community contributions to o1js! - -See the [Contributing guidelines](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md) for ways you can contribute. - -## Development Workflow - -For guidance on building o1js from source and understanding the development workflow, see [o1js README-dev](https://github.com/o1-labs/o1js/blob/main/README-dev.md). - -## Community Packages - -High-quality community packages from open source developers are available for your project. - -- **o1js-elgamal** A partially homomorphic encryption library for o1js based on Elgamal encryption: [GitHub](https://github.com/Trivo25/o1js-elgamal) and [npm](https://www.npmjs.com/package/o1js-elgamal) -- **o1js-pack** A library for o1js that allows a zkApp developer to pack extra data into a single Field. [GitHub](https://github.com/45930/o1js-pack) and [npm](https://www.npmjs.com/package/o1js-pack) -- **zk-regex-o1js** A CLI tool for compiling ZK Regex circuits in o1js. [Github](https://github.com/Shigoto-dev19/zk-regex-o1js) and [npm](https://www.npmjs.com/package/zk-regex-o1js) - -To include your package, see [Creating high-quality community packages](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md#creating-high-quality-community-packages). - -| Member | Description | -| :------ | :------ | -| [Crypto](namespaces/Crypto/README.mdx) | - | -| [Encryption](namespaces/Encryption/README.mdx) | - | -| [Experimental](namespaces/Experimental/README.mdx) | This module exposes APIs that are unstable, in the sense that the API surface is expected to change. | -| [Lightnet](namespaces/Lightnet/README.mdx) | - | -| [Mina](namespaces/Mina/README.mdx) | - | -| [AccountUpdate](classes/AccountUpdate.mdx) | An [AccountUpdate](classes/AccountUpdate.mdx) is a set of instructions for the Mina network. | -| [AccountUpdateForest](classes/AccountUpdateForest.mdx) | Class which represents a forest (list of trees) of account updates, | -| [AccountUpdateTree](classes/AccountUpdateTree.mdx) | Class which represents a tree of account updates, | -| [AlmostForeignField](classes/AlmostForeignField.mdx) | - | -| [BaseMerkleWitness](classes/BaseMerkleWitness.mdx) | The [BaseMerkleWitness](classes/BaseMerkleWitness.mdx) class defines a circuit-compatible base class for [Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof). | -| [Bool](classes/Bool.mdx) | A boolean value. You can use it like this: | -| [CanonicalForeignField](classes/CanonicalForeignField.mdx) | - | -| [Character](classes/Character.mdx) | - | -| [Circuit](classes/Circuit.mdx) | - | -| [CircuitString](classes/CircuitString.mdx) | - | -| [DynamicProof](classes/DynamicProof.mdx) | The `DynamicProof` class enables circuits to verify proofs using in-ciruit verfication keys. | -| [EcdsaSignature](classes/EcdsaSignature.mdx) | - | -| [Field](classes/Field.mdx) | A [Field](classes/Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). | -| [ForeignCurve](classes/ForeignCurve.mdx) | - | -| [ForeignField](classes/ForeignField.mdx) | - | -| [Group](classes/Group.mdx) | An element of a Group. | -| [Hashed](classes/Hashed.mdx) | `Hashed` represents a type `T` by its hash. | -| [Int64](classes/Int64.mdx) | A 64 bit signed integer with values ranging from -18,446,744,073,709,551,615 to 18,446,744,073,709,551,615. | -| [Keypair](classes/Keypair.mdx) | - | -| [Ledger](classes/Ledger.mdx) | Represents the Mina ledger. | -| [MerkleList](classes/MerkleList.mdx) | Dynamic-length list which is represented as a single hash | -| [MerkleListIterator](classes/MerkleListIterator.mdx) | MerkleListIterator helps iterating through a Merkle list. | -| [MerkleMap](classes/MerkleMap.mdx) | - | -| [MerkleMapWitness](classes/MerkleMapWitness.mdx) | - | -| [MerkleTree](classes/MerkleTree.mdx) | A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in which every leaf is the cryptography hash of a piece of data, | -| [Nullifier](classes/Nullifier.mdx) | Nullifiers are used as a public commitment to a specific anonymous account, | -| [Packed](classes/Packed.mdx) | `Packed` is a "packed" representation of any type `T`. | -| [PrivateKey](classes/PrivateKey.mdx) | A signing key. You can generate one via [PrivateKey.random](classes/PrivateKey.mdx#random). | -| [Proof](classes/Proof.mdx) | - | -| [ProofBase](classes/ProofBase.mdx) | - | -| [PublicKey](classes/PublicKey.mdx) | A public key, which is also an address on the Mina network. | -| [Scalar](classes/Scalar.mdx) | Represents a [Scalar](classes/Scalar.mdx). | -| [ScalarField](classes/ScalarField.mdx) | ForeignField representing the scalar field of Pallas and the base field of Vesta | -| [SelfProof](classes/SelfProof.mdx) | - | -| [Sign](classes/Sign.mdx) | - | -| [Signature](classes/Signature.mdx) | A Schnorr [Signature](classes/Signature.mdx) over the Pasta Curves. | -| [SmartContract](classes/SmartContract.mdx) | The main zkapp class. To write a zkapp, extend this class as such: | -| [TokenAccountUpdateIterator](classes/TokenAccountUpdateIterator.mdx) | Data structure to represent a forest of account updates that is being iterated over, | -| [TokenContract](classes/TokenContract.mdx) | Base token contract which | -| [TokenSymbol](classes/TokenSymbol.mdx) | - | -| [UInt32](classes/UInt32.mdx) | A 32 bit unsigned integer with values ranging from 0 to 4,294,967,295. | -| [UInt64](classes/UInt64.mdx) | A 64 bit unsigned integer with values ranging from 0 to 18,446,744,073,709,551,615. | -| [UInt8](classes/UInt8.mdx) | A 8 bit unsigned integer with values ranging from 0 to 255. | -| [Unconstrained](classes/Unconstrained.mdx) | Container which holds an unconstrained value. This can be used to pass values | -| [VerificationKey](classes/VerificationKey.mdx) | - | -| [Permissions](interfaces/Permissions.mdx) | Permissions specify how specific aspects of the zkapp account are allowed | -| [Account](type-aliases/Account.mdx) | - | -| [Bool](type-aliases/Bool.mdx) | - | -| [BoolVar](type-aliases/BoolVar.mdx) | - | -| [Bytes](type-aliases/Bytes.mdx) | - | -| [Cache](type-aliases/Cache.mdx) | Interface for storing and retrieving values, for caching. | -| [CacheHeader](type-aliases/CacheHeader.mdx) | A header that is passed to the caching layer, to support rich caching strategies. | -| [ConstantField](type-aliases/ConstantField.mdx) | - | -| [DeployArgs](type-aliases/DeployArgs.mdx) | - | -| [Empty](type-aliases/Empty.mdx) | - | -| [FeatureFlags](type-aliases/FeatureFlags.mdx) | - | -| [Field](type-aliases/Field.mdx) | - | -| [FlexibleProvable](type-aliases/FlexibleProvable.mdx) | - | -| [FlexibleProvablePure](type-aliases/FlexibleProvablePure.mdx) | - | -| [Group](type-aliases/Group.mdx) | - | -| [InferProvable](type-aliases/InferProvable.mdx) | - | -| [JsonProof](type-aliases/JsonProof.mdx) | - | -| [MerkleListBase](type-aliases/MerkleListBase.mdx) | Common base type for [MerkleList](classes/MerkleList.mdx) and [MerkleListIterator](classes/MerkleListIterator.mdx) | -| [MerkleListIteratorBase](type-aliases/MerkleListIteratorBase.mdx) | - | -| [Option](type-aliases/Option.mdx) | - | -| [Provable](type-aliases/Provable.mdx) | `Provable` is the general interface for provable types in o1js. | -| [ProvableExtended](type-aliases/ProvableExtended.mdx) | - | -| [ProvableHashable](type-aliases/ProvableHashable.mdx) | - | -| [ProvableHashable](type-aliases/ProvableHashable-1.mdx) | - | -| [ProvablePure](type-aliases/ProvablePure.mdx) | `ProvablePure` is a special kind of [Provable](type-aliases/Provable.mdx) interface, where the "auxiliary" (non-provable) data is empty. | -| [ProvableType](type-aliases/ProvableType.mdx) | - | -| [ProvableTypePure](type-aliases/ProvableTypePure.mdx) | - | -| [ProvableWithEmpty](type-aliases/ProvableWithEmpty.mdx) | - | -| [Reducer](type-aliases/Reducer.mdx) | - | -| [ScalarConst](type-aliases/ScalarConst.mdx) | - | -| [State](type-aliases/State.mdx) | Gettable and settable state that can be checked for equality. | -| [Struct](type-aliases/Struct.mdx) | - | -| [ToProvable](type-aliases/ToProvable.mdx) | - | -| [TransactionPromise](type-aliases/TransactionPromise.mdx) | A `Promise` with some additional methods for making chained method calls | -| [TransactionStatus](type-aliases/TransactionStatus.mdx) | INCLUDED: A transaction that is on the longest chain | -| [TupleN](type-aliases/TupleN.mdx) | tuple type that has the length as generic parameter | -| [Undefined](type-aliases/Undefined.mdx) | - | -| [VarField](type-aliases/VarField.mdx) | - | -| [Void](type-aliases/Void.mdx) | - | -| [WithHash](type-aliases/WithHash.mdx) | - | -| [WithProvable](type-aliases/WithProvable.mdx) | - | -| [Witness](type-aliases/Witness.mdx) | - | -| [ZkProgram](type-aliases/ZkProgram.mdx) | - | -| [ZkappPublicInput](type-aliases/ZkappPublicInput.mdx) | The public input for zkApps consists of certain hashes of the proving | -| [Account](variables/Account.mdx) | - | -| [Bool](variables/Bool.mdx) | A boolean value. You can create it like this: | -| [Cache](variables/Cache.mdx) | - | -| [Crypto](variables/Crypto.mdx) | - | -| [Empty](variables/Empty.mdx) | - | -| [FeatureFlags](variables/FeatureFlags.mdx) | Feature flags indicate what custom gates are used in a proof of circuit. | -| [Field](variables/Field.mdx) | A [Field](variables/Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). | -| [Gadgets](variables/Gadgets.mdx) | - | -| [Group](variables/Group.mdx) | An element of a Group. | -| [Hash](variables/Hash.mdx) | A collection of hash functions which can be used in provable code. | -| [Keccak](variables/Keccak.mdx) | - | -| [Permissions](variables/Permissions.mdx) | - | -| [Poseidon](variables/Poseidon.mdx) | - | -| [ProvableType](variables/ProvableType.mdx) | - | -| [TokenId](variables/TokenId.mdx) | - | -| [TransactionVersion](variables/TransactionVersion.mdx) | - | -| [TupleN](variables/TupleN.mdx) | - | -| [Undefined](variables/Undefined.mdx) | - | -| [Void](variables/Void.mdx) | - | -| [ZkappPublicInput](variables/ZkappPublicInput.mdx) | - | -| [emptyHash](variables/emptyHash.mdx) | - | -| [Bytes](functions/Bytes.mdx) | A provable type representing an array of bytes. | -| [ConstantField](functions/ConstantField.mdx) | - | -| [MerkleListBase](functions/MerkleListBase.mdx) | - | -| [MerkleWitness](functions/MerkleWitness.mdx) | Returns a circuit-compatible Witness for a specific Tree height. | -| [Option](functions/Option.mdx) | Define an optional version of a provable type. | -| [Reducer](functions/Reducer.mdx) | - | -| [State](functions/State.mdx) | - | -| [Struct](functions/Struct.mdx) | `Struct` lets you declare composite types for use in o1js circuits. | -| [VarField](functions/VarField.mdx) | - | -| [WithHash](functions/WithHash.mdx) | - | -| [ZkProgram](functions/ZkProgram.mdx) | - | -| [addCachedAccount](functions/addCachedAccount.mdx) | Adds an account to the local cache, indexed by a GraphQL endpoint. | -| [assert](functions/assert.mdx) | Assert that a statement is true. If the statement is false, throws an error with the given message. | -| [checkBitLength](functions/checkBitLength.mdx) | - | -| [checkZkappTransaction](functions/checkZkappTransaction.mdx) | - | -| [circuitMain](functions/circuitMain.mdx) | - | -| [conditionalSwap](functions/conditionalSwap.mdx) | - | -| [createEcdsa](functions/createEcdsa.mdx) | Create a class [EcdsaSignature](classes/EcdsaSignature.mdx) for verifying ECDSA signatures on the given curve. | -| [createForeignCurve](functions/createForeignCurve.mdx) | Create a class representing an elliptic curve group, which is different from the native [Group](classes/Group.mdx). | -| [createForeignField](functions/createForeignField.mdx) | Create a class representing a prime order finite field, which is different from the native [Field](classes/Field.mdx). | -| [declareMethods](functions/declareMethods.mdx) | `declareMethods` can be used in place of the `@method` decorator | -| [declareState](functions/declareState.mdx) | `declareState` can be used in place of the `@state` decorator to declare on-chain state on a SmartContract. | -| [fetchAccount](functions/fetchAccount.mdx) | Gets account information on the specified publicKey by performing a GraphQL query | -| [fetchEvents](functions/fetchEvents.mdx) | Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API. | -| [fetchLastBlock](functions/fetchLastBlock.mdx) | Fetches the last block on the Mina network. | -| [fetchTransactionStatus](functions/fetchTransactionStatus.mdx) | Fetches the status of a transaction. | -| [genericHash](functions/genericHash.mdx) | - | -| [initializeBindings](functions/initializeBindings.mdx) | A function that has to finish before any bindings exports can be used. | -| [merkleListHash](functions/merkleListHash.mdx) | - | -| [method](functions/method.mdx) | A decorator to use in a zkApp to mark a method as provable. | -| [provable](functions/provable.mdx) | - | -| [provablePure](functions/provablePure.mdx) | - | -| [public\_](functions/public.mdx) | - | -| [readVarMessage](functions/readVarMessage.mdx) | - | -| [sendZkapp](functions/sendZkapp.mdx) | Sends a zkApp command (transaction) to the specified GraphQL endpoint. | -| [setArchiveGraphqlEndpoint](functions/setArchiveGraphqlEndpoint.mdx) | Sets up a GraphQL endpoint to be used for fetching information from an Archive Node. | -| [setGraphqlEndpoint](functions/setGraphqlEndpoint.mdx) | - | -| [setGraphqlEndpoints](functions/setGraphqlEndpoints.mdx) | - | -| [setNumberOfWorkers](functions/setNumberOfWorkers.mdx) | Set the number of workers to use for parallelizing the proof generation. By default the number of workers is set to the number of physical CPU cores on your machine, but there may be some instances where you want to set the number of workers manually. Some machines may have a large number of cores, but not enough memory to support that many workers. In that case, you can set the number of workers to a lower number to avoid running out of memory. On the other hand, some machines with heterogeneous cores may benefit from setting the number of workers to a lower number to avoid contention between core types if load-link/store-conditional multithreading is used. Feel free to experiment and see what works best for your use case. Maybe you can squeeze slightly more performance out by tweaking this value :) | -| [state](functions/state-1.mdx) | A decorator to use within a zkapp to indicate what will be stored on-chain. | -| [toConstantField](functions/toConstantField.mdx) | - | -| [toFp](functions/toFp.mdx) | - | -| [verify](functions/verify.mdx) | - | -| [withHashes](functions/withHashes.mdx) | - | -| [withMessage](functions/withMessage.mdx) | - | diff --git a/docs/zkapps/o1js-reference/classes/AccountUpdate.mdx b/docs/zkapps/o1js-reference/classes/AccountUpdate.mdx deleted file mode 100644 index 3d4d6db6b..000000000 --- a/docs/zkapps/o1js-reference/classes/AccountUpdate.mdx +++ /dev/null @@ -1,1449 +0,0 @@ -An [AccountUpdate](AccountUpdate.mdx) is a set of instructions for the Mina network. -It includes Preconditions and a list of state updates, which need to -be authorized by either a [Signature](Signature.mdx) or [Proof](Proof.mdx). - -## Implements - -- `AccountUpdate` - -## Constructors - -### new AccountUpdate() - -```ts -new AccountUpdate(body: Body, authorization?: {}): AccountUpdate -``` - -#### Parameters - -• **body**: `Body` - -• **authorization?** - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L703) - -## Properties - -### account - -```ts -account: Account; -``` - -#### Source - -[lib/mina/account-update.ts:694](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L694) - -*** - -### authorization - -```ts -authorization: {}; -``` - -#### Implementation of - -`Types.AccountUpdate.authorization` - -#### Source - -[lib/mina/account-update.ts:691](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L691) - -*** - -### body - -```ts -body: Body; -``` - -#### Implementation of - -`Types.AccountUpdate.body` - -#### Source - -[lib/mina/account-update.ts:690](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L690) - -*** - -### currentSlot - -```ts -currentSlot: CurrentSlot; -``` - -#### Source - -[lib/mina/account-update.ts:696](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L696) - -*** - -### id - -```ts -id: number; -``` - -#### Source - -[lib/mina/account-update.ts:684](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L684) - -*** - -### label - -```ts -label: string = ''; -``` - -A human-readable label for the account update, indicating how that update -was created. Can be modified by applications to add richer information. - -#### Source - -[lib/mina/account-update.ts:689](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L689) - -*** - -### lazyAuthorization - -```ts -lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined; -``` - -#### Source - -[lib/mina/account-update.ts:692](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L692) - -*** - -### network - -```ts -network: Network; -``` - -#### Source - -[lib/mina/account-update.ts:695](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L695) - -*** - -### Actions - -```ts -static Actions: { - "emptyActionState": Field; - "fromList": Events; - "hash": Field; - "pushEvent": Events; - "updateSequenceState": Field; -}; -``` - -#### emptyActionState() - -##### Returns - -[`Field`](Field.mdx) - -#### fromList() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -`Events` - -#### hash() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -[`Field`](Field.mdx) - -#### pushEvent() - -##### Parameters - -• **actions**: `Events` - -• **action**: [`Field`](Field.mdx)[] - -##### Returns - -`Events` - -#### updateSequenceState() - -##### Parameters - -• **state**: [`Field`](Field.mdx) - -• **sequenceEventsHash**: [`Field`](Field.mdx) - -##### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:700](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L700) - -*** - -### Events - -```ts -static Events: { - "fromList": Events; - "hash": Field; - "pushEvent": Events; -}; -``` - -#### fromList() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -`Events` - -#### hash() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -[`Field`](Field.mdx) - -#### pushEvent() - -##### Parameters - -• **events**: `Events` - -• **event**: [`Field`](Field.mdx)[] - -##### Returns - -`Events` - -#### Source - -[lib/mina/account-update.ts:701](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L701) - -*** - -### MayUseToken - -```ts -static MayUseToken: { - "InheritFromParent": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "No": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "ParentsOwnToken": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "isInheritFromParent": (a: AccountUpdate) => Bool; - "isNo": (__namedParameters: AccountUpdate) => Bool; - "isParentsOwnToken": (a: AccountUpdate) => Bool; - "type": BaseMayUseToken; -}; -``` - -#### InheritFromParent - -```ts -InheritFromParent: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### InheritFromParent.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### InheritFromParent.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### No - -```ts -No: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### No.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### No.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### ParentsOwnToken - -```ts -ParentsOwnToken: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### ParentsOwnToken.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### ParentsOwnToken.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### isInheritFromParent() - -```ts -isInheritFromParent: (a: AccountUpdate) => Bool; -``` - -##### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### isNo() - -```ts -isNo: (__namedParameters: AccountUpdate) => Bool; -``` - -##### Parameters - -• **\_\_namedParameters**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### isParentsOwnToken() - -```ts -isParentsOwnToken: (a: AccountUpdate) => Bool; -``` - -##### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### type - -```ts -type: {} = BaseMayUseToken; -``` - -#### Source - -[lib/mina/account-update.ts:1235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1235) - -*** - -### check() - -```ts -static check: (x: AccountUpdate) => void = Types.AccountUpdate.check; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1187) - -*** - -### sizeInFields() - -```ts -static sizeInFields: () => number = Types.AccountUpdate.sizeInFields; -``` - -#### Returns - -`number` - -#### Source - -[lib/mina/account-update.ts:1174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1174) - -*** - -### toFields() - -```ts -static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1175](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1175) - -*** - -### toInput() - -```ts -static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/mina/account-update.ts:1183](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1183) - -*** - -### toValue() - -```ts -static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:1195](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1195) - -## Accessors - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:785](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L785) - -*** - -### balanceChange - -```ts -get balanceChange(): Int64 -``` - -```ts -set balanceChange(x: Int64): void -``` - -#### Parameters - -• **x**: [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/mina/account-update.ts:800](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L800) - -*** - -### publicKey - -```ts -get publicKey(): PublicKey -``` - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Source - -[lib/mina/account-update.ts:875](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L875) - -*** - -### tokenId - -```ts -get tokenId(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:732](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L732) - -*** - -### update - -```ts -get update(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/mina/account-update.ts:807](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L807) - -## Methods - -### approve() - -```ts -approve(child: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Makes another [AccountUpdate](AccountUpdate.mdx) a child of this one. - -The parent-child relationship means that the child becomes part of the "statement" -of the parent, and goes into the commitment that is authorized by either a signature -or a proof. - -For a proof in particular, child account updates are contained in the public input -of the proof that authorizes the parent account update. - -#### Parameters - -• **child**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:773](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L773) - -*** - -### extractTree() - -```ts -extractTree(): AccountUpdateTree -``` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Source - -[lib/mina/account-update.ts:1021](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1021) - -*** - -### hash() - -```ts -hash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:977](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L977) - -*** - -### isDummy() - -```ts -isDummy(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/mina/account-update.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1047) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if this account update should be signed by the account -owner, instead of not having any authorization. - -If you use this and are not relying on a wallet to sign your transaction, -then you should use the following code before sending your transaction: - -```ts -let tx = await Mina.transaction(...); // create transaction as usual, using `requireSignature()` somewhere -tx.sign([privateKey]); // pass the private key of this account to `sign()`! -``` - -Note that an account's [Permissions](../variables/Permissions.mdx) determine which updates have to -be (can be) authorized by a signature. - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:894](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L894) - -*** - -### send() - -```ts -send(__namedParameters: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:736](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L736) - -*** - -### toJSON() - -```ts -toJSON(): AccountUpdate -``` - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:966](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L966) - -*** - -### toPretty() - -```ts -toPretty(): any -``` - -Returns a JSON representation of only the fields that differ from the -default [AccountUpdate](AccountUpdate.mdx). - -#### Returns - -`any` - -#### Source - -[lib/mina/account-update.ts:1241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1241) - -*** - -### toPrettyLayout() - -```ts -toPrettyLayout(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1015](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1015) - -*** - -### toPublicInput() - -```ts -toPublicInput(__namedParameters: { - "accountUpdates": AccountUpdate[]; - }): ZkappPublicInput -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.accountUpdates**: [`AccountUpdate`](AccountUpdate.mdx)[] - -#### Returns - -[`ZkappPublicInput`](../type-aliases/ZkappPublicInput.mdx) - -#### Source - -[lib/mina/account-update.ts:985](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L985) - -*** - -### assertBetween() - -```ts -static assertBetween( - property: OrIgnore>, - lower: T, - upper: T): void -``` - -Constrain a property to lie between lower and upper bounds. - -#### Type parameters - -• **T** - -#### Parameters - -• **property**: `OrIgnore`\<`ClosedInterval`\<`T`\>\> - -The property to constrain - -• **lower**: `T` - -The lower bound - -• **upper**: `T` - -The upper bound - -Example: To constrain the account balance of a SmartContract to lie between -0 and 20 MINA, you can use - -```ts -\@method onlyRunsWhenBalanceIsLow() { - let lower = UInt64.zero; - let upper = UInt64.from(20e9); - AccountUpdate.assertBetween(this.self.body.preconditions.account.balance, lower, upper); - // ... -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:835](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L835) - -*** - -### assertEquals() - -```ts -static assertEquals(property: OrIgnore>, value: T): void -``` - -Fix a property to a certain value. - -#### Type parameters - -• **T** *extends* `object` - -#### Parameters - -• **property**: `OrIgnore`\<`T` \| `ClosedInterval`\<`T`\>\> - -The property to constrain - -• **value**: `T` - -The value it is fixed to - -Example: To fix the account nonce of a SmartContract to 0, you can use - -```ts -\@method onlyRunsWhenNonceIsZero() { - AccountUpdate.assertEquals(this.self.body.preconditions.account.nonce, UInt32.zero); - // ... -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:862](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L862) - -*** - -### attachToTransaction() - -```ts -static attachToTransaction(accountUpdate: AccountUpdate): void -``` - -Attach account update to the current transaction --- if in a smart contract, to its children - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1107](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1107) - -*** - -### clone() - -```ts -static clone(accountUpdate: AccountUpdate): AccountUpdate -``` - -Clones the [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:718](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L718) - -*** - -### create() - -```ts -static create(publicKey: PublicKey, tokenId?: Field): AccountUpdate -``` - -Creates an account update. If this is inside a transaction, the account -update becomes part of the transaction. If this is inside a smart contract -method, the account update will not only become part of the transaction, -but also becomes available for the smart contract to modify, in a way that -becomes part of the proof. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1072](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1072) - -*** - -### createIf() - -```ts -static createIf( - condition: Bool, - publicKey: PublicKey, - tokenId?: Field): AccountUpdate -``` - -Create an account update that is added to the transaction only if a condition is met. - -See [AccountUpdate.create](AccountUpdate.mdx#create) for more information. In this method, you can pass in -a condition that determines whether the account update should be added to the transaction. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1094](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1094) - -*** - -### createSigned() - -```ts -static createSigned(publicKey: PublicKey, tokenId?: Field): AccountUpdate -``` - -Creates an account update, like [AccountUpdate.create](AccountUpdate.mdx#create), but also -makes sure this account update will be authorized with a signature. - -If you use this and are not relying on a wallet to sign your transaction, -then you should use the following code before sending your transaction: - -```ts -let tx = await Mina.transaction(...); // create transaction as usual, using `createSigned()` somewhere -tx.sign([privateKey]); // pass the private key of this account to `sign()`! -``` - -Note that an account's [Permissions](../variables/Permissions.mdx) determine which updates have to -be (can be) authorized by a signature. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1143) - -*** - -### default() - -```ts -static default(address: PublicKey, tokenId?: Field): AccountUpdate -``` - -Create an account update from a public key and an optional token id. - -**Important**: This method is different from `AccountUpdate.create()`, in that it really just creates the account update object. -It does not attach the update to the current transaction or smart contract. -Use this method for lower-level operations with account updates. - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1038](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1038) - -*** - -### defaultFeePayer() - -```ts -static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **nonce**: [`UInt32`](UInt32.mdx) - -#### Returns - -`FeePayerUnsigned` - -#### Source - -[lib/mina/account-update.ts:1051](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1051) - -*** - -### dummy() - -```ts -static dummy(): AccountUpdate -``` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1042](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1042) - -*** - -### dummyFeePayer() - -```ts -static dummyFeePayer(): FeePayerUnsigned -``` - -#### Returns - -`FeePayerUnsigned` - -#### Source - -[lib/mina/account-update.ts:1060](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1060) - -*** - -### empty() - -```ts -static empty(): AccountUpdate -``` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1184](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1184) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **\_\_namedParameters**: `any`[] - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1188](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1188) - -*** - -### fromJSON() - -```ts -static fromJSON(json: AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **json**: `AccountUpdate` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:972](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L972) - -*** - -### fromValue() - -```ts -static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **value**: `AccountUpdate` \| `AccountUpdate` \| [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1196](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1196) - -*** - -### fundNewAccount() - -```ts -static fundNewAccount(feePayer: PublicKey, numberOfAccounts: number): AccountUpdate -``` - -Use this method to pay the account creation fee for another account (or, multiple accounts using the optional second argument). - -Beware that you _don't_ need to specify the account that is created! -Instead, the protocol will automatically identify that accounts need to be created, -and require that the net balance change of the transaction covers the account creation fee. - -#### Parameters - -• **feePayer**: [`PublicKey`](PublicKey.mdx) - -the address of the account that pays the fee - -• **numberOfAccounts**: `number`= `1` - -the number of new accounts to fund (default: 1) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -they [AccountUpdate](AccountUpdate.mdx) for the account which pays the fee - -#### Source - -[lib/mina/account-update.ts:1164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1164) - -*** - -### getNonce() - -```ts -static getNonce(accountUpdate: FeePayerUnsigned | AccountUpdate): UInt32 -``` - -#### Parameters - -• **accountUpdate**: `FeePayerUnsigned` \| [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/mina/account-update.ts:918](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L918) - -*** - -### setValue() - -```ts -static setValue(maybeValue: SetOrKeep, value: T): void -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **maybeValue**: `SetOrKeep`\<`T`\> - -• **value**: `T` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:811](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L811) - -*** - -### signFeePayerInPlace() - -```ts -static signFeePayerInPlace(feePayer: FeePayerUnsigned): void -``` - -#### Parameters - -• **feePayer**: `FeePayerUnsigned` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L912) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(a?: AccountUpdate): (any[] | { - "id": number; - "label": string; - "lazyAuthorization": undefined | LazySignature | LazyProof | LazyNone; - })[] -``` - -#### Parameters - -• **a?**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -(`any`[] \| \{ - `"id"`: `number`; - `"label"`: `string`; - `"lazyAuthorization"`: `undefined` \| `LazySignature` \| `LazyProof` \| `LazyNone`; - \})[] - -#### Source - -[lib/mina/account-update.ts:1176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1176) - -*** - -### toJSON() - -```ts -static toJSON(a: AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:969](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L969) - -*** - -### unlink() - -```ts -static unlink(accountUpdate: AccountUpdate): void -``` - -Disattach an account update from where it's currently located in the transaction - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1124) - -*** - -### witness() - -```ts -static witness( - resultType: FlexibleProvable, - compute: () => Promise<{ - "accountUpdate": AccountUpdate; - "result": T; - }>, - __namedParameters: { - "skipCheck": false; - }): Promise<{ - "accountUpdate": AccountUpdate; - "result": T; -}> -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **resultType**: [`FlexibleProvable`](../type-aliases/FlexibleProvable.mdx)\<`T`\> - -• **compute** - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.skipCheck**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"accountUpdate"`: [`AccountUpdate`](AccountUpdate.mdx); - `"result"`: `T`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: AccountUpdate; -> ``` -> -> ##### result -> -> ```ts -> result: T; -> ``` -> - -#### Source - -[lib/mina/account-update.ts:1219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1219) diff --git a/docs/zkapps/o1js-reference/classes/AccountUpdateForest.mdx b/docs/zkapps/o1js-reference/classes/AccountUpdateForest.mdx deleted file mode 100644 index eaa1a19a5..000000000 --- a/docs/zkapps/o1js-reference/classes/AccountUpdateForest.mdx +++ /dev/null @@ -1,1113 +0,0 @@ -Class which represents a forest (list of trees) of account updates, -in a compressed way which allows iterating and selectively witnessing the account updates. - -The (recursive) type signature is: -``` -type AccountUpdateForest = MerkleList; -type AccountUpdateTree = { - accountUpdate: Hashed; - children: AccountUpdateForest; -}; -``` - -## Extends - -- [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}, `this`\> - -## Constructors - -### new AccountUpdateForest() - -```ts -new AccountUpdateForest(__namedParameters: MerkleListBase<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }>): AccountUpdateForest -``` - -#### Parameters - -• **\_\_namedParameters**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`constructor`](MerkleList.mdx#constructors) - -#### Source - -[lib/provable/merkle-list.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L84) - -## Properties - -### data - -```ts -data: Unconstrained; - "id": RandomId; -}>[]>; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`data`](MerkleList.mdx#data) - -#### Source - -[lib/provable/merkle-list.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L82) - -*** - -### hash - -```ts -hash: Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`hash`](MerkleList.mdx#hash) - -#### Source - -[lib/provable/merkle-list.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L81) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_emptyHash`](MerkleList.mdx#_emptyhash) - -#### Source - -[lib/provable/merkle-list.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L350) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_innerProvable`](MerkleList.mdx#_innerprovable) - -#### Source - -[lib/provable/merkle-list.ts:353](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L353) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, t: any) => Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_nextHash`](MerkleList.mdx#_nexthash) - -#### Source - -[lib/provable/merkle-list.ts:349](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L349) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_provable`](MerkleList.mdx#_provable) - -#### Source - -[lib/provable/merkle-list.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L352) - -*** - -### provable - -```ts -static provable: { - "check": void; - "empty": AccountUpdateForest; - "fromFields": AccountUpdateForest; - "fromValue": AccountUpdateForest; - "sizeInFields": number; - "toAuxiliary": any[]; - "toFields": Field[]; - "toInput": HashInput; - "toValue": any; -}; -``` - -#### check() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`void` - -#### empty() - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### fromFields() - -##### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **aux**: `any`[] - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### fromValue() - -##### Parameters - -• **value**: `any` - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### sizeInFields() - -##### Returns - -`number` - -#### toAuxiliary() - -##### Parameters - -• **value?**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`any`[] - -#### toFields() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -[`Field`](Field.mdx)[] - -#### toInput() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`HashInput` - -#### toValue() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`any` - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).provable` - -#### Source - -[lib/mina/account-update.ts:1379](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1379) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleList -``` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) - -#### Source - -[lib/provable/merkle-list.ts:355](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L355) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:372](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L372) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L367) - -## Methods - -### clone() - -```ts -clone(): MerkleList<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`clone`](MerkleList.mdx#clone) - -#### Source - -[lib/provable/merkle-list.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L223) - -*** - -### forEach() - -```ts -forEach(length: number, callback: (element: { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }, isDummy: Bool, i: number) => void): void -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -#### Parameters - -• **length**: `number` - -• **callback** - -#### Returns - -`void` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`forEach`](MerkleList.mdx#foreach) - -#### Source - -[lib/provable/merkle-list.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L237) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`isEmpty`](MerkleList.mdx#isempty) - -#### Source - -[lib/provable/merkle-list.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L89) - -*** - -### lengthUnconstrained() - -```ts -lengthUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`number`\> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`lengthUnconstrained`](MerkleList.mdx#lengthunconstrained) - -#### Source - -[lib/provable/merkle-list.ts:267](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L267) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value** - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>= `undefined` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`Field`](Field.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`nextHash`](MerkleList.mdx#nexthash) - -#### Source - -[lib/provable/merkle-list.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L359) - -*** - -### pop() - -```ts -pop(): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`pop`](MerkleList.mdx#pop) - -#### Source - -[lib/provable/merkle-list.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L155) - -*** - -### popExn() - -```ts -popExn(): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popExn`](MerkleList.mdx#popexn) - -#### Source - -[lib/provable/merkle-list.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L140) - -*** - -### popIf() - -```ts -popIf(condition: Bool): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popIf`](MerkleList.mdx#popif) - -#### Source - -[lib/provable/merkle-list.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L174) - -*** - -### popIfUnsafe() - -```ts -popIfUnsafe(shouldPop: Bool): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -#### Parameters - -• **shouldPop**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popIfUnsafe`](MerkleList.mdx#popifunsafe) - -#### Source - -[lib/provable/merkle-list.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L200) - -*** - -### push() - -```ts -push(update: AccountUpdate | AccountUpdateTreeBase): void -``` - -Push a new element to the list. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| `AccountUpdateTreeBase` - -#### Returns - -`void` - -#### Overrides - -[`MerkleList`](MerkleList.mdx).[`push`](MerkleList.mdx#push) - -#### Source - -[lib/mina/account-update.ts:1381](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1381) - -*** - -### pushIf() - -```ts -pushIf(condition: Bool, update: AccountUpdate | AccountUpdateTreeBase): void -``` - -Push a new element to the list, if the `condition` is true. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| `AccountUpdateTreeBase` - -#### Returns - -`void` - -#### Overrides - -[`MerkleList`](MerkleList.mdx).[`pushIf`](MerkleList.mdx#pushif) - -#### Source - -[lib/mina/account-update.ts:1386](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1386) - -*** - -### startIterating() - -```ts -startIterating(): MerkleListIterator<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`startIterating`](MerkleList.mdx#startiterating) - -#### Source - -[lib/provable/merkle-list.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L251) - -*** - -### startIteratingFromLast() - -```ts -startIteratingFromLast(): MerkleListIterator<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`startIteratingFromLast`](MerkleList.mdx#startiteratingfromlast) - -#### Source - -[lib/provable/merkle-list.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L256) - -*** - -### toArrayUnconstrained() - -```ts -toArrayUnconstrained(): Unconstrained<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}[]> -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}[]\> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`toArrayUnconstrained`](MerkleList.mdx#toarrayunconstrained) - -#### Source - -[lib/provable/merkle-list.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L261) - -*** - -### toFlatArray() - -```ts -toFlatArray(mutate: boolean, depth: number): AccountUpdate[] -``` - -#### Parameters - -• **mutate**: `boolean`= `true` - -• **depth**: `number`= `0` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1398](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1398) - -*** - -### assertConstant() - -```ts -static assertConstant(forest: AccountUpdateForestBase): void -``` - -#### Parameters - -• **forest**: `AccountUpdateForestBase` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1429](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1429) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleList & { - "empty": () => MerkleList; - "from": (array: T[]) => MerkleList; - "fromReverse": (array: T[]) => MerkleList; - "provable": ProvableHashable>; -} -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) & \{ - `"empty"`: () => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"fromReverse"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleList`](MerkleList.mdx)\<`T`\>\>; - \} - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`create`](MerkleList.mdx#create) - -#### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -#### Source - -[lib/provable/merkle-list.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L283) - -*** - -### empty() - -```ts -static empty(): AccountUpdateForest -``` - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).empty` - -#### Source - -[lib/mina/account-update.ts:1442](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1442) - -*** - -### from() - -```ts -static from(array: AccountUpdateTreeBase[]): AccountUpdateForest -``` - -#### Parameters - -• **array**: `AccountUpdateTreeBase`[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).from` - -#### Source - -[lib/mina/account-update.ts:1445](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1445) - -*** - -### fromFlatArray() - -```ts -static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest -``` - -#### Parameters - -• **updates**: [`AccountUpdate`](AccountUpdate.mdx)[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Source - -[lib/mina/account-update.ts:1393](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1393) - -*** - -### fromReverse() - -```ts -static fromReverse(array: AccountUpdateTreeBase[]): AccountUpdateForest -``` - -#### Parameters - -• **array**: `AccountUpdateTreeBase`[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).fromReverse` - -#### Source - -[lib/mina/account-update.ts:1448](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1448) - -*** - -### toFlatArray() - -```ts -static toFlatArray( - forest: AccountUpdateForestBase, - mutate: boolean, - depth: number): AccountUpdate[] -``` - -#### Parameters - -• **forest**: `AccountUpdateForestBase` - -• **mutate**: `boolean`= `true` - -• **depth**: `number`= `0` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1402](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1402) diff --git a/docs/zkapps/o1js-reference/classes/AccountUpdateTree.mdx b/docs/zkapps/o1js-reference/classes/AccountUpdateTree.mdx deleted file mode 100644 index 27b742324..000000000 --- a/docs/zkapps/o1js-reference/classes/AccountUpdateTree.mdx +++ /dev/null @@ -1,638 +0,0 @@ -Class which represents a tree of account updates, -in a compressed way which allows iterating and selectively witnessing the account updates. - -The (recursive) type signature is: -``` -type AccountUpdateTree = { - accountUpdate: Hashed; - children: AccountUpdateForest; -}; -type AccountUpdateForest = MerkleList; -``` - -## Extends - -- \{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: `AccountUpdateForest`; - `"id"`: `RandomId`; - \} - -## Constructors - -### new AccountUpdateTree() - -```ts -new AccountUpdateTree(value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }): AccountUpdateTree -``` - -#### Parameters - -• **value** - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L280) - -## Properties - -### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).accountUpdate` - -#### Source - -[lib/mina/account-update.ts:1468](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1468) - -*** - -### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).children` - -#### Source - -[lib/mina/account-update.ts:1469](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1469) - -*** - -### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).id` - -#### Source - -[lib/mina/account-update.ts:1467](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1467) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L280) - -*** - -### check() - -```ts -static check: (value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -`void` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### fromValue() - -```ts -static fromValue: (x: any) => { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -}; -``` - -Convert provable type from a normal JS type. - -#### Parameters - -• **x**: `any` - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.accountUpdate?**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children?**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id?**: `number`= `RandomId` - -#### Returns - -`any`[] - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L283) - -*** - -### toValue() - -```ts -static toValue: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => any; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -`any` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree, hash?: Field): void -``` - -Add an [AccountUpdate](AccountUpdate.mdx) or [AccountUpdateTree](AccountUpdateTree.mdx) to the children of this tree's root. - -See [AccountUpdate.approve](AccountUpdate.mdx#approve). - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1488](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1488) - -*** - -### empty() - -```ts -static empty(): AccountUpdateTree -``` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Overrides - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).empty` - -#### Source - -[lib/mina/account-update.ts:1504](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1504) - -*** - -### from() - -```ts -static from(update: AccountUpdate | AccountUpdateTree, hash?: Field): AccountUpdateTree -``` - -Create a tree of account updates which only consists of a root. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Source - -[lib/mina/account-update.ts:1474](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1474) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[], aux: any): AccountUpdateTree -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **aux**: `any` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Overrides - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).fromFields` - -#### Source - -[lib/mina/account-update.ts:1501](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1501) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/classes/AlmostForeignField.mdx b/docs/zkapps/o1js-reference/classes/AlmostForeignField.mdx deleted file mode 100644 index f766bdd5a..000000000 --- a/docs/zkapps/o1js-reference/classes/AlmostForeignField.mdx +++ /dev/null @@ -1,1038 +0,0 @@ -## Extends - -- `ForeignFieldWithMul` - -## Constructors - -### new AlmostForeignField() - -```ts -new AlmostForeignField(x: - | string - | number - | bigint - | Field3 - | AlmostForeignField): AlmostForeignField -``` - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Overrides - -`ForeignFieldWithMul.constructor` - -#### Source - -[lib/provable/foreign-field.ts:487](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L487) - -## Properties - -### type - -```ts -type: "AlmostReduced" | "FullyReduced" = 'AlmostReduced'; -``` - -#### Source - -[lib/provable/foreign-field.ts:485](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L485) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`ForeignFieldWithMul.value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Overrides - -`ForeignFieldWithMul._provable` - -#### Source - -[lib/provable/foreign-field.ts:491](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L491) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`ForeignFieldWithMul._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<[`AlmostForeignField`](AlmostForeignField.mdx), `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:494](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L494) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`ForeignFieldWithMul.assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### div() - -```ts -div(y: number | bigint | AlmostForeignField): AlmostForeignField -``` - -Division in the finite field, i.e. `x*y^(-1) mod p` where `y^(-1)` is the finite field inverse. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.div` - -#### Example - -```ts -let z = x.div(y); // x/y mod p -z.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/foreign-field.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L461) - -*** - -### equals() - -```ts -equals(y: number | bigint): Bool -``` - -Check equality with a constant value. - -#### Parameters - -• **y**: `number` \| `bigint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isXZero = x.equals(0); -``` - -#### Source - -[lib/provable/foreign-field.ts:521](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L521) - -*** - -### inv() - -```ts -inv(): AlmostForeignField -``` - -Multiplicative inverse in the finite field - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.inv` - -#### Example - -```ts -let z = x.inv(); // 1/x mod p -z.mul(x).assertEquals(1); -``` - -#### Source - -[lib/provable/foreign-field.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L447) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`ForeignFieldWithMul.isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### mul() - -```ts -mul(y: number | bigint | AlmostForeignField): UnreducedForeignField -``` - -Finite field multiplication - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.mul` - -#### Example - -```ts -x.mul(y); // x*y mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:433](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L433) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`ForeignFieldWithMul.toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Overrides - -`ForeignFieldWithMul.check` - -#### Source - -[lib/provable/foreign-field.ts:499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L499) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### unsafeFrom() - -```ts -static unsafeFrom(x: ForeignField): AlmostForeignField -``` - -Coerce the input to an [AlmostForeignField](AlmostForeignField.mdx) without additional assertions. - -**Warning:** Only use if you know what you're doing. - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:509](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L509) diff --git a/docs/zkapps/o1js-reference/classes/BaseMerkleWitness.mdx b/docs/zkapps/o1js-reference/classes/BaseMerkleWitness.mdx deleted file mode 100644 index 8125f9f77..000000000 --- a/docs/zkapps/o1js-reference/classes/BaseMerkleWitness.mdx +++ /dev/null @@ -1,655 +0,0 @@ -The [BaseMerkleWitness](BaseMerkleWitness.mdx) class defines a circuit-compatible base class for [Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof). - -## Extends - -- `CircuitValue` - -## Constructors - -### new BaseMerkleWitness() - -```ts -new BaseMerkleWitness(witness: Witness): BaseMerkleWitness -``` - -Takes a [Witness](../type-aliases/Witness.mdx) and turns it into a circuit-compatible Witness. - -#### Parameters - -• **witness**: [`Witness`](../type-aliases/Witness.mdx) - -Witness. - -#### Returns - -[`BaseMerkleWitness`](BaseMerkleWitness.mdx) - -A circuit-compatible Witness. - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/merkle-tree.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L187) - -## Properties - -### isLeft - -```ts -isLeft: Bool[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L177) - -*** - -### path - -```ts -path: Field[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L176) - -*** - -### height - -```ts -static height: number; -``` - -#### Source - -[lib/provable/merkle-tree.ts:175](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L175) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### calculateIndex() - -```ts -calculateIndex(): Field -``` - -Calculates the index of the leaf node that belongs to this Witness. - -#### Returns - -[`Field`](Field.mdx) - -Index of the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:221](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L221) - -*** - -### calculateRoot() - -```ts -calculateRoot(leaf: Field): Field -``` - -Calculates a root depending on the leaf value. - -#### Parameters - -• **leaf**: [`Field`](Field.mdx) - -Value of the leaf node that belongs to this Witness. - -#### Returns - -[`Field`](Field.mdx) - -The calculated root. - -#### Source - -[lib/provable/merkle-tree.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L204) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### height() - -```ts -height(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/merkle-tree.ts:178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L178) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) diff --git a/docs/zkapps/o1js-reference/classes/Bool.mdx b/docs/zkapps/o1js-reference/classes/Bool.mdx deleted file mode 100644 index f8bdb00d5..000000000 --- a/docs/zkapps/o1js-reference/classes/Bool.mdx +++ /dev/null @@ -1,851 +0,0 @@ -A boolean value. You can use it like this: - -``` -const x = new Bool(true); -``` - -You can also combine multiple booleans via [[`not`]], [[`and`]], [[`or`]]. - -Use [[assertEquals]] to enforce the value of a Bool. - -## Constructors - -### new Bool() - -```ts -new Bool(x: boolean | FieldVar | Bool): Bool -``` - -#### Parameters - -• **x**: `boolean` \| `FieldVar` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L33) - -## Properties - -### value - -```ts -value: FieldVar; -``` - -#### Source - -[lib/provable/bool.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L31) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": Bool; -}; -``` - -#### fromField() - -Converts a [Field](Field.mdx) into a [Bool](Bool.mdx). This is an **unsafe** operation -as it assumes that the field element is either 0 or 1 (which might not be true). - -Only use this if you have already constrained the Field element to be 0 or 1. - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -a [Field](Field.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:373](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L373) - -*** - -### sizeInBytes - -```ts -static sizeInBytes: number = 1; -``` - -#### Source - -[lib/provable/bool.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L367) - -## Methods - -### and() - -```ts -and(y: boolean | Bool): Bool -``` - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) to AND with this [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is set to true only if -this [Bool](Bool.mdx) and `y` are also true. - -#### Source - -[lib/provable/bool.ts:73](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L73) - -*** - -### assertEquals() - -```ts -assertEquals(y: boolean | Bool, message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is equal to `y`. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L114) - -*** - -### assertFalse() - -```ts -assertFalse(message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is `false`. - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:145](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L145) - -*** - -### assertTrue() - -```ts -assertTrue(message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is `true`. - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:131](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L131) - -*** - -### equals() - -```ts -equals(y: boolean | Bool): Bool -``` - -Returns true if this [Bool](Bool.mdx) is equal to `y`. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:160](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L160) - -*** - -### implies() - -```ts -implies(y: boolean | Bool): Bool -``` - -Whether this Bool implies another Bool `y`. - -This is the same as `x.not().or(y)`: if `x` is true, then `y` must be true for the implication to be true. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isZero = x.equals(0); -let lessThan10 = x.lessThan(10); -assert(isZero.implies(lessThan10), 'x = 0 implies x < 10'); -``` - -#### Source - -[lib/provable/bool.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L106) - -*** - -### isConstant() - -```ts -isConstant(): this is Object -``` - -#### Returns - -`this is Object` - -#### Source - -[lib/provable/bool.ts:45](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L45) - -*** - -### not() - -```ts -not(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is the negation of this [Bool](Bool.mdx). - -#### Source - -[lib/provable/bool.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L59) - -*** - -### or() - -```ts -or(y: boolean | Bool): Bool -``` - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx) to OR with this [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is set to true if either -this [Bool](Bool.mdx) or `y` is true. - -#### Source - -[lib/provable/bool.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L86) - -*** - -### sizeInFields() - -```ts -sizeInFields(): number -``` - -Returns the size of this type. - -#### Returns - -`number` - -#### Source - -[lib/provable/bool.ts:185](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L185) - -*** - -### toBoolean() - -```ts -toBoolean(): boolean -``` - -This converts the [Bool](Bool.mdx) to a JS `boolean`. -This can only be called on non-witness values. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L216) - -*** - -### toField() - -```ts -toField(): Field -``` - -Converts a [Bool](Bool.mdx) to a [Field](Field.mdx). `false` becomes 0 and `true` becomes 1. - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/bool.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L52) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Serializes this [Bool](Bool.mdx) into [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/bool.ts:192](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L192) - -*** - -### toJSON() - -```ts -toJSON(): boolean -``` - -Serialize the [Bool](Bool.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L208) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [Bool](Bool.mdx) to a string, e.g. for printing. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Returns - -`string` - -#### Source - -[lib/provable/bool.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L200) - -*** - -### and() - -```ts -static and(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Boolean AND operation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L244) - -*** - -### assertEqual() - -```ts -static assertEqual(x: Bool, y: boolean | Bool): void -``` - -Asserts if both [Bool](Bool.mdx) are equal. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:264](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L264) - -*** - -### check() - -```ts -static check(x: Bool): void -``` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:369](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L369) - -*** - -### empty() - -```ts -static empty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:344](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L344) - -*** - -### equal() - -```ts -static equal(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Checks two [Bool](Bool.mdx) for equality. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:275](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L275) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: number[]): Bool -``` - -#### Parameters - -• **bytes**: `number`[] - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L356) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Bool -``` - -Creates a data structure from an array of serialized [Field](Field.mdx) elements. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:299](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L299) - -*** - -### fromJSON() - -```ts -static fromJSON(b: boolean): Bool -``` - -Deserialize a JSON structure into a [Bool](Bool.mdx). -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Parameters - -• **b**: `boolean` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:333](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L333) - -*** - -### fromValue() - -```ts -static fromValue(b: boolean | Bool): Bool -``` - -`Provable.fromValue()` - -#### Parameters - -• **b**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:316](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L316) - -*** - -### not() - -```ts -static not(x: boolean | Bool): Bool -``` - -Boolean negation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:234](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L234) - -*** - -### or() - -```ts -static or(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Boolean OR operation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:254](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L254) - -*** - -### readBytes() - -```ts -static readBytes(bytes: number[], offset: NonNegativeInteger): [Bool, number] -``` - -#### Type parameters - -• **N** *extends* `number` - -#### Parameters - -• **bytes**: `number`[] - -• **offset**: `NonNegativeInteger`\<`N`\> - -#### Returns - -[[`Bool`](Bool.mdx), `number`] - -#### Source - -[lib/provable/bool.ts:360](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L360) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Returns the size of this type. - -#### Returns - -`number` - -#### Source - -[lib/provable/bool.ts:340](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L340) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(_?: Bool): [] -``` - -Static method to serialize a [Bool](Bool.mdx) into its auxiliary data. - -#### Parameters - -• **\_?**: [`Bool`](Bool.mdx) - -#### Returns - -[] - -#### Source - -[lib/provable/bool.ts:292](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L292) - -*** - -### toBytes() - -```ts -static toBytes(b: Bool): number[] -``` - -#### Parameters - -• **b**: [`Bool`](Bool.mdx) - -#### Returns - -`number`[] - -#### Source - -[lib/provable/bool.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L352) - -*** - -### toField() - -```ts -static toField(x: boolean | Bool): Field -``` - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/bool.ts:227](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L227) - -*** - -### toFields() - -```ts -static toFields(x: Bool): Field[] -``` - -Static method to serialize a [Bool](Bool.mdx) into an array of [Field](Field.mdx) elements. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/bool.ts:285](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L285) - -*** - -### toInput() - -```ts -static toInput(x: Bool): { - "packed": [Field, number][]; -} -``` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "packed": [Field, number][]; -} -``` - -##### packed - -```ts -packed: [Field, number][]; -``` - -#### Source - -[lib/provable/bool.ts:348](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L348) - -*** - -### toJSON() - -```ts -static toJSON(x: Bool): boolean -``` - -Serialize a [Bool](Bool.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L325) - -*** - -### toValue() - -```ts -static toValue(x: Bool): boolean -``` - -`Provable.toValue()` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L309) diff --git a/docs/zkapps/o1js-reference/classes/CanonicalForeignField.mdx b/docs/zkapps/o1js-reference/classes/CanonicalForeignField.mdx deleted file mode 100644 index f02422217..000000000 --- a/docs/zkapps/o1js-reference/classes/CanonicalForeignField.mdx +++ /dev/null @@ -1,1041 +0,0 @@ -## Extends - -- `ForeignFieldWithMul` - -## Constructors - -### new CanonicalForeignField() - -```ts -new CanonicalForeignField(x: - | string - | number - | bigint - | Field3 - | CanonicalForeignField): CanonicalForeignField -``` - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Overrides - -`ForeignFieldWithMul.constructor` - -#### Source - -[lib/provable/foreign-field.ts:529](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L529) - -## Properties - -### type - -```ts -type: "FullyReduced"; -``` - -#### Source - -[lib/provable/foreign-field.ts:527](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L527) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`ForeignFieldWithMul.value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Overrides - -`ForeignFieldWithMul._provable` - -#### Source - -[lib/provable/foreign-field.ts:533](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L533) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`ForeignFieldWithMul._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<[`CanonicalForeignField`](CanonicalForeignField.mdx), `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:536](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L536) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`ForeignFieldWithMul.assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### div() - -```ts -div(y: number | bigint | AlmostForeignField): AlmostForeignField -``` - -Division in the finite field, i.e. `x*y^(-1) mod p` where `y^(-1)` is the finite field inverse. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.div` - -#### Example - -```ts -let z = x.div(y); // x/y mod p -z.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/foreign-field.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L461) - -*** - -### equals() - -```ts -equals(y: number | bigint | CanonicalForeignField): Bool -``` - -Check equality with a ForeignField-like value. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isEqual = x.equals(y); -``` - -Note: This method only exists on canonical fields; on unreduced fields, it would be easy to -misuse, because not being exactly equal does not imply being unequal modulo p. - -#### Source - -[lib/provable/foreign-field.ts:566](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L566) - -*** - -### inv() - -```ts -inv(): AlmostForeignField -``` - -Multiplicative inverse in the finite field - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.inv` - -#### Example - -```ts -let z = x.inv(); // 1/x mod p -z.mul(x).assertEquals(1); -``` - -#### Source - -[lib/provable/foreign-field.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L447) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`ForeignFieldWithMul.isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### mul() - -```ts -mul(y: number | bigint | AlmostForeignField): UnreducedForeignField -``` - -Finite field multiplication - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.mul` - -#### Example - -```ts -x.mul(y); // x*y mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:433](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L433) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`ForeignFieldWithMul.toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Overrides - -`ForeignFieldWithMul.check` - -#### Source - -[lib/provable/foreign-field.ts:541](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L541) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### unsafeFrom() - -```ts -static unsafeFrom(x: ForeignField): CanonicalForeignField -``` - -Coerce the input to a [CanonicalForeignField](CanonicalForeignField.mdx) without additional assertions. - -**Warning:** Only use if you know what you're doing. - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:551](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L551) diff --git a/docs/zkapps/o1js-reference/classes/Character.mdx b/docs/zkapps/o1js-reference/classes/Character.mdx deleted file mode 100644 index 0061584b9..000000000 --- a/docs/zkapps/o1js-reference/classes/Character.mdx +++ /dev/null @@ -1,549 +0,0 @@ -## Extends - -- \{ - `"value"`: `Field`; - \} - -## Constructors - -### new Character() - -```ts -new Character(value: number | Field): Character -``` - -#### Parameters - -• **value**: `number` \| [`Field`](Field.mdx) - -#### Returns - -[`Character`](Character.mdx) - -#### Overrides - -`Struct({ value: Field }).constructor` - -#### Source - -[lib/provable/string.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L13) - -## Properties - -### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).value` - -#### Source - -[lib/provable/string.ts:12](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L12) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ value: Field })._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### empty() - -```ts -static empty: () => { - "value": Field; -}; -``` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "value": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: `string`= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "value": Field; - } | { - "value": Field; - }) => { - "value": Field; - } & (value: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ value: Field }).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "value": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.value?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ value: Field }).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "value": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ value: Field }).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: string = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: bigint = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### isNull() - -```ts -isNull(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/string.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L17) - -*** - -### toField() - -```ts -toField(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L21) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/string.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L25) - -*** - -### check() - -```ts -static check(c: { - "value": Field; - }): void -``` - -#### Parameters - -• **c** - -• **c.value**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Overrides - -`Struct({ value: Field }).check` - -#### Source - -[lib/provable/string.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L36) - -*** - -### fromString() - -```ts -static fromString(str: string): Character -``` - -#### Parameters - -• **str**: `string` - -#### Returns - -[`Character`](Character.mdx) - -#### Source - -[lib/provable/string.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L30) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ value: Field }).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - -*** - -### toInput() - -```ts -static toInput(c: { - "value": Field; - }): HashInput -``` - -#### Parameters - -• **c** - -• **c.value**: [`Field`](Field.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`Struct({ value: Field }).toInput` - -#### Source - -[lib/provable/string.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L40) diff --git a/docs/zkapps/o1js-reference/classes/Circuit.mdx b/docs/zkapps/o1js-reference/classes/Circuit.mdx deleted file mode 100644 index 60fd19d8b..000000000 --- a/docs/zkapps/o1js-reference/classes/Circuit.mdx +++ /dev/null @@ -1,120 +0,0 @@ -## Constructors - -### new Circuit() - -```ts -new Circuit(): Circuit -``` - -#### Returns - -[`Circuit`](Circuit.mdx) - -## Properties - -### \_main - -```ts -static _main: CircuitData; -``` - -#### Source - -[lib/proof-system/circuit.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L22) - -## Methods - -### generateKeypair() - -```ts -static generateKeypair(): Promise -``` - -Generates a proving key and a verification key for this circuit. - -#### Returns - -`Promise`\<[`Keypair`](Keypair.mdx)\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -``` - -#### Source - -[lib/proof-system/circuit.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L31) - -*** - -### prove() - -```ts -static prove( - privateInput: any[], - publicInput: any[], -keypair: Keypair): Promise -``` - -Proves a statement using the private input, public input, and the [Keypair](Keypair.mdx) of the circuit. - -#### Parameters - -• **privateInput**: `any`[] - -• **publicInput**: `any`[] - -• **keypair**: [`Keypair`](Keypair.mdx) - -#### Returns - -`Promise`\<`Proof`\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const proof = await MyCircuit.prove(privateInput, publicInput, keypair); -``` - -#### Source - -[lib/proof-system/circuit.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L51) - -*** - -### verify() - -```ts -static verify( - publicInput: any[], - verificationKey: VerificationKey, -proof: Proof): Promise -``` - -Verifies a proof using the public input, the proof, and the initial [Keypair](Keypair.mdx) of the circuit. - -#### Parameters - -• **publicInput**: `any`[] - -• **verificationKey**: `VerificationKey` - -• **proof**: `Proof` - -#### Returns - -`Promise`\<`boolean`\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const proof = await MyCircuit.prove(privateInput, publicInput, keypair); -const isValid = await MyCircuit.verify(publicInput, keypair.vk, proof); -``` - -#### Source - -[lib/proof-system/circuit.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L82) diff --git a/docs/zkapps/o1js-reference/classes/CircuitString.mdx b/docs/zkapps/o1js-reference/classes/CircuitString.mdx deleted file mode 100644 index 1a402c181..000000000 --- a/docs/zkapps/o1js-reference/classes/CircuitString.mdx +++ /dev/null @@ -1,743 +0,0 @@ -## Extends - -- \{ - `"values"`: [`Character`](Character.mdx)[]; - \} - -## Constructors - -### new CircuitString() - -```ts -new CircuitString(value: { - "values": Character[]; - }): CircuitString -``` - -#### Parameters - -• **value** - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Inherited from - -`Struct(RawCircuitString).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).values` - -#### Source - -[lib/provable/string.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L65) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct(RawCircuitString)._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "values": Character[]; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -`void` - -#### Inherited from - -`Struct(RawCircuitString).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "values": Character[]; -}; -``` - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "values": Character[]; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "values": { - "value": Field; - }[]; - }) => { - "values": Character[]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: \{ - `"value"`: `Field`; - \}[]= `undefined` - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: string | { - "values": Character[]; - }) => { - "values": Character[]; - } & (value: string | { - "values": Character[]; - }) => { - "values": Character[]; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct(RawCircuitString).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### maxLength - -```ts -static maxLength: number = DEFAULT_STRING_LENGTH; -``` - -#### Source - -[lib/provable/string.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L72) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "values": Character[]; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.values?**: [`Character`](Character.mdx)[] - -#### Returns - -`any`[] - -#### Inherited from - -`Struct(RawCircuitString).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "values": Character[]; - }) => { - "values": Character[]; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "values": Character[]; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct(RawCircuitString).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "values": Character[]; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "values": Character[]; - }) => { - "values": { - "value": Field; - }[]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "values": { - "value": Field; - }[]; -} -``` - -##### values - -```ts -values: { - "value": Field; - }[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "values": Character[]; - }) => string; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -`string` - -#### Inherited from - -`Struct(RawCircuitString).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### append() - -```ts -append(str: CircuitString): CircuitString -``` - -appends another string to this one, returns the result and proves that it fits -within the `maxLength` of this string (the other string can have a different maxLength) - -#### Parameters - -• **str**: [`CircuitString`](CircuitString.mdx) - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L121) - -*** - -### computeLengthAndMask() - -```ts -computeLengthAndMask(): { - "length": Field; - "mask": Bool[]; -} -``` - -#### Returns - -```ts -{ - "length": Field; - "mask": Bool[]; -} -``` - -##### length - -```ts -length: Field; -``` - -##### mask - -```ts -mask: Bool[]; -``` - -#### Source - -[lib/provable/string.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L84) - -*** - -### equals() - -```ts -equals(other: CircuitString): Bool -``` - -returns true if `this` has the same value as `other` - -#### Parameters - -• **other**: [`CircuitString`](CircuitString.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/string.ts:113](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L113) - -*** - -### hash() - -```ts -hash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:147](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L147) - -*** - -### length() - -```ts -length(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L106) - -*** - -### lengthMask() - -```ts -lengthMask(): Bool[] -``` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Source - -[lib/provable/string.ts:103](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L103) - -*** - -### maxLength() - -```ts -maxLength(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/string.ts:79](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L79) - -*** - -### substring() - -```ts -substring(start: number, end: number): CircuitString -``` - -#### Parameters - -• **start**: `number` - -• **end**: `number` - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L151) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/string.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L155) - -*** - -### fromCharacters() - -```ts -static fromCharacters(chars: Character[]): CircuitString -``` - -#### Parameters - -• **chars**: [`Character`](Character.mdx)[] - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L75) - -*** - -### fromString() - -```ts -static fromString(str: string): CircuitString -``` - -#### Parameters - -• **str**: `string` - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:159](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L159) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct(RawCircuitString).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/classes/DynamicProof.mdx b/docs/zkapps/o1js-reference/classes/DynamicProof.mdx deleted file mode 100644 index 054b1c956..000000000 --- a/docs/zkapps/o1js-reference/classes/DynamicProof.mdx +++ /dev/null @@ -1,531 +0,0 @@ -The `DynamicProof` class enables circuits to verify proofs using in-ciruit verfication keys. -This is opposed to the baked-in verification keys of the `Proof` class. - -In order to use this, a subclass of DynamicProof that specifies the public input and output types along with the maxProofsVerified number has to be created. - -```ts -export class SideloadedProgramProof extends DynamicProof { - static publicInputType = MyStruct; - static publicOutputType = Field; - static maxProofsVerified = 0 as const; -} -``` - -The `maxProofsVerified` constant is a product of the child circuit and indicates the maximum number that that circuit verifies itself. -If you are unsure about what that is for you, you should use `2`. - -Any `DynamicProof` subclass can be used as private input to ZkPrograms or SmartContracts along with a `VerificationKey` input. -```ts -proof.verify(verificationKey) -``` - -NOTE: In the case of `DynamicProof`s, the circuit makes no assertions about the verificationKey used on its own. -This is the responsibility of the application developer and should always implement appropriate checks. -This pattern differs a lot from the usage of normal `Proof`, where the verification key is baked into the compiled circuit. - -## See - -src/examples/zkprogram/dynamic-keys-merkletree.ts for an example of how this can be done using merkle trees - -Assertions generally only happen using the vk hash that is part of the `VerificationKey` struct along with the raw vk data as auxiliary data. -When using verify() on a `DynamicProof`, Pickles makes sure that the verification key data matches the hash. -Therefore all manual assertions have to be made on the vk's hash and it can be assumed that the vk's data is checked to match the hash if it is used with verify(). - -## Extends - -- [`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -## Type parameters - -• **Input** - -• **Output** - -## Constructors - -### new DynamicProof() - -```ts -new DynamicProof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): DynamicProof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`DynamicProof`](DynamicProof.mdx)\<`Input`, `Output`\> - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`constructor`](ProofBase.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`maxProofsVerified`](ProofBase.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`proof`](ProofBase.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInput`](ProofBase.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutput`](ProofBase.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`shouldVerify`](ProofBase.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### usedVerificationKey? - -```ts -optional usedVerificationKey: VerificationKey; -``` - -#### Source - -[lib/proof-system/proof.ts:235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L235) - -*** - -### featureFlags - -```ts -static featureFlags: FeatureFlags = FeatureFlags.allNone; -``` - -As the name indicates, feature flags are features of the proof system. - -If we want to side load proofs and verification keys, we first have to tell Pickles what _shape_ of proofs it should expect. - -For example, if we want to side load proofs that use foreign field arithmetic custom gates, we have to make Pickles aware of that by defining -these custom gates. - -_Note:_ Only proofs that use the exact same composition of custom gates which were expected by Pickles can be verified using side loading. -If you want to verify _any_ proof, no matter what custom gates it uses, you can use FeatureFlags.allMaybe. Please note that this might incur a significant overhead. - -You can also toggle specific feature flags manually by specifying them here. -Alternatively, you can use FeatureFlags.fromZkProgram to compute the set of feature flags that are compatible with a given program. - -#### Source - -[lib/proof-system/proof.ts:222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L222) - -*** - -### maxProofsVerified - -```ts -static maxProofsVerified: 0 | 1 | 2; -``` - -#### Source - -[lib/proof-system/proof.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L204) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInputType`](ProofBase.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutputType`](ProofBase.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`DynamicProof`](DynamicProof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L309) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`toJSON`](ProofBase.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(vk: VerificationKey): void -``` - -Verifies this DynamicProof using a given verification key - -#### Parameters - -• **vk**: [`VerificationKey`](VerificationKey.mdx) - -The verification key this proof will be verified against - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L241) - -*** - -### verifyIf() - -```ts -verifyIf(vk: VerificationKey, condition: Bool): void -``` - -#### Parameters - -• **vk**: [`VerificationKey`](VerificationKey.mdx) - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:245](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L245) - -*** - -### dummy() - -```ts -static dummy( - this: S, - publicInput: InferProvable, - publicOutput: InferProvable, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **publicInput**: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\> - -• **publicOutput**: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\> - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<`InstanceType`\<`S`\>\> - -#### Source - -[lib/proof-system/proof.ts:274](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L274) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`DynamicProof`](DynamicProof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Source - -[lib/proof-system/proof.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L250) - -*** - -### fromProof() - -```ts -static fromProof(this: S, proof: Proof, InferProvable>): InstanceType -``` - -Converts a Proof into a DynamicProof carrying over all relevant data. -This method can be used to convert a Proof computed by a ZkProgram -into a DynamicProof that is accepted in a circuit that accepts DynamicProofs - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **proof**: [`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\> - -#### Returns - -`InstanceType`\<`S`\> - -#### Source - -[lib/proof-system/proof.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L294) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) - -*** - -### tag() - -```ts -static tag(): { - "name": string; -} -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Overrides - -`ProofBase.tag` - -#### Source - -[lib/proof-system/proof.ts:224](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L224) diff --git a/docs/zkapps/o1js-reference/classes/EcdsaSignature.mdx b/docs/zkapps/o1js-reference/classes/EcdsaSignature.mdx deleted file mode 100644 index b4fbae60e..000000000 --- a/docs/zkapps/o1js-reference/classes/EcdsaSignature.mdx +++ /dev/null @@ -1,459 +0,0 @@ -## Constructors - -### new EcdsaSignature() - -```ts -new EcdsaSignature(signature: { - "r": number | bigint | Field3 | AlmostForeignField; - "s": number | bigint | Field3 | AlmostForeignField; - }): EcdsaSignature -``` - -Create a new [EcdsaSignature](EcdsaSignature.mdx) from an object containing the scalars r and s. - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. Please refer to the [ForeignField](ForeignField.mdx) constructor comments for more details. - -#### Parameters - -• **signature** - -• **signature.r**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **signature.s**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L39) - -## Properties - -### r - -```ts -r: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L31) - -*** - -### s - -```ts -s: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L32) - -*** - -### \_Curve? - -```ts -static optional _Curve: typeof ForeignCurve; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:220](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L220) - -*** - -### \_provable? - -```ts -static optional _provable: ProvablePureExtended; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:221](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L221) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof EcdsaSignature -``` - -#### Returns - -*typeof* [`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:217](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L217) - -*** - -### Curve - -```ts -get static Curve(): typeof ForeignCurve -``` - -The [ForeignCurve](ForeignCurve.mdx) on which the ECDSA signature is defined. - -#### Returns - -*typeof* [`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L230) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -`Provable` - -#### Returns - -`ProvablePureExtended`\<[`EcdsaSignature`](EcdsaSignature.mdx), \{ - `"r"`: `bigint`; - `"s"`: `bigint`; - \}, \{ - `"r"`: `string`; - `"s"`: `string`; - \}\> - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L237) - -## Methods - -### toBigInt() - -```ts -toBigInt(): { - "r": bigint; - "s": bigint; -} -``` - -Convert this signature to an object with bigint fields. - -#### Returns - -```ts -{ - "r": bigint; - "s": bigint; -} -``` - -##### r - -```ts -r: bigint; -``` - -##### s - -```ts -s: bigint; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L67) - -*** - -### verify() - -```ts -verify(message: Bytes, publicKey: FlexiblePoint): Bool -``` - -Verify the ECDSA signature given the message (an array of bytes) and public key (a [Curve](EcdsaSignature.mdx#curve) point). - -**Important:** This method returns a [Bool](Bool.mdx) which indicates whether the signature is valid. -So, to actually prove validity of a signature, you need to assert that the result is true. - -#### Parameters - -• **message**: `Bytes` - -• **publicKey**: `FlexiblePoint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Throws - -if one of the signature scalars is zero or if the public key is not on the curve. - -#### Example - -```ts -// create classes for your curve -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} -class Scalar extends Secp256k1.Scalar {} -class Ecdsa extends createEcdsa(Secp256k1) {} - -let message = 'my message'; -let messageBytes = new TextEncoder().encode(message); - -// outside provable code: create inputs -let privateKey = Scalar.random(); -let publicKey = Secp256k1.generator.scale(privateKey); -let signature = Ecdsa.sign(messageBytes, privateKey.toBigInt()); - -// ... -// in provable code: create input witnesses (or use method inputs, or constants) -let pk = Provable.witness(Secp256k1, () => publicKey); -let msg = Provable.witness(Provable.Array(Field, 9), () => messageBytes.map(Field)); -let sig = Provable.witness(Ecdsa, () => signature); - -// verify signature -let isValid = sig.verify(msg, pk); -isValid.assertTrue('signature verifies'); -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L105) - -*** - -### verifyEthers() - -```ts -verifyEthers(message: Bytes, publicKey: FlexiblePoint): Bool -``` - -Verify an ECDSA signature generated by the ethers.js library, given the message (as a byte array) and a public key (a [Curve](EcdsaSignature.mdx#curve) point). -The message digest used for signing follows the format defined in EIP-191, with the Ethereum-specific prefix. - -**Important:** This method returns a [Bool](Bool.mdx) which indicates whether the signature is valid. -So, to actually prove validity of a signature, you need to assert that the result is true. - -**Note:** This method is specifically designed to verify signatures generated by ethers.js. -Ensure that the curve being used is Secp256k1, as demonstrated in the example. - -#### Parameters - -• **message**: `Bytes` - -The original message as a byte array. - -• **publicKey**: `FlexiblePoint` - -The public key as a point on the Secp256k1 elliptic curve. - -#### Returns - -[`Bool`](Bool.mdx) - -- A [Bool](Bool.mdx) indicating the validity of the signature. - -#### Throws - -An error will be thrown if one of the signature scalars is zero or if the public key does not lie on the curve. - -#### Example - -```ts -import { Wallet } from 'ethers'; - -// create the class for Secp256k1 curve -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} -class Ecdsa extends createEcdsa(Secp256k1) {} - -// outside provable code: create inputs -let message = 'my message'; -let signatureRaw = await wallet.signMessage(message); -let compressedPublicKey = wallet.signingKey.compressedPublicKey; - -// this also works for uncompressed public keys (wallet.signingKey.publicKey) -let publicKey = Secp256k1.fromEthers(compressedPublicKey.slice(2)); -let signature = Ecdsa.fromHex(signatureRaw); - -// ... -// in provable code: create input witnesses (or use method inputs, or constants) -// and verify the signature -let isValid = signature.verifyEthers(Bytes.fromString(message), publicKey); -isValid.assertTrue('signature verifies'); -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L151) - -*** - -### verifySignedHash() - -```ts -verifySignedHash(msgHash: bigint | AlmostForeignField, publicKey: FlexiblePoint): Bool -``` - -Verify the ECDSA signature given the message hash (a [Scalar](Scalar.mdx)) and public key (a [Curve](EcdsaSignature.mdx#curve) point). - -This is a building block of [EcdsaSignature.verify](EcdsaSignature.mdx#verify), where the input message is also hashed. -In contrast, this method just takes the message hash (a curve scalar) as input, giving you flexibility in -choosing the hashing algorithm. - -#### Parameters - -• **msgHash**: `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **publicKey**: `FlexiblePoint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L170) - -*** - -### check() - -```ts -static check(signature: EcdsaSignature): void -``` - -#### Parameters - -• **signature**: [`EcdsaSignature`](EcdsaSignature.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:209](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L209) - -*** - -### from() - -```ts -static from(signature: FlexibleSignature): EcdsaSignature -``` - -Coerce the input to a [EcdsaSignature](EcdsaSignature.mdx). - -#### Parameters - -• **signature**: `FlexibleSignature` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L50) - -*** - -### fromHex() - -```ts -static fromHex(rawSignature: string): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) from a raw 130-char hex string as used in -[Ethereum transactions](https://ethereum.org/en/developers/docs/transactions/#typed-transaction-envelope). - -#### Parameters - -• **rawSignature**: `string` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L59) - -*** - -### sign() - -```ts -static sign(message: Uint8Array | (number | bigint)[], privateKey: bigint): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) by signing a message with a private key. - -Note: This method is not provable, and only takes JS bigints as input. - -#### Parameters - -• **message**: `Uint8Array` \| (`number` \| `bigint`)[] - -• **privateKey**: `bigint` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L189) - -*** - -### signHash() - -```ts -static signHash(msgHash: bigint, privateKey: bigint): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) by signing a message hash with a private key. - -This is a building block of [EcdsaSignature.sign](EcdsaSignature.mdx#sign), where the input message is also hashed. -In contrast, this method just takes the message hash (a curve scalar) as input, giving you flexibility in -choosing the hashing algorithm. - -Note: This method is not provable, and only takes JS bigints as input. - -#### Parameters - -• **msgHash**: `bigint` - -• **privateKey**: `bigint` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L204) diff --git a/docs/zkapps/o1js-reference/classes/Field.mdx b/docs/zkapps/o1js-reference/classes/Field.mdx deleted file mode 100644 index 0937675fe..000000000 --- a/docs/zkapps/o1js-reference/classes/Field.mdx +++ /dev/null @@ -1,1585 +0,0 @@ -A [Field](Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). -Every other provable type is built using the [Field](Field.mdx) type. - -The field is the [pasta base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) of order 2^254 + 0x224698fc094cf91b992d30ed00000001 ([Field.ORDER](Field.mdx#order)). - -You can create a new Field from everything "field-like" (`bigint`, integer `number`, decimal `string`, `Field`). - -## Example - -``` -Field(10n); // Field construction from a big integer -Field(100); // Field construction from a number -Field("1"); // Field construction from a decimal string -``` - -**Beware**: Fields _cannot_ be constructed from fractional numbers or alphanumeric strings: -```ts -Field(3.141); // ERROR: Cannot convert a float to a field element -Field("abc"); // ERROR: Invalid argument "abc" -``` - -Creating a Field from a negative number can result in unexpected behavior if you are not familiar with [modular arithmetic](https://en.wikipedia.org/wiki/Modular_arithmetic). - -## Example - -``` -const x = Field(-1); // Valid Field construction from negative number -const y = Field(Field.ORDER - 1n); // equivalent to `x` -``` - -**Important**: All the functions defined on a Field (arithmetic, logic, etc.) take their arguments as "field-like". A Field itself is also defined as a "field-like" element. - -## Param - -the value to convert to a [Field](Field.mdx) - -## Constructors - -### new Field() - -```ts -new Field(x: - | string - | number - | bigint - | FieldConst - | FieldVar - | Field): Field -``` - -Coerce anything "field-like" (bigint, number, string, and [Field](Field.mdx)) to a Field. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldConst` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L97) - -## Properties - -### value - -```ts -value: FieldVar; -``` - -#### Source - -[lib/provable/field.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L86) - -*** - -### ORDER - -```ts -static ORDER: bigint = Fp.modulus; -``` - -The order of the pasta curve that [Field](Field.mdx) type build on as a `bigint`. -Order of the [Field](Field.mdx) is 28948022309329048855892746252171976963363056481941560715954676764349967630337. - -#### Source - -[lib/provable/field.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L92) - -*** - -### sizeInBits - -```ts -static sizeInBits: number = Fp.sizeInBits; -``` - -The size of a [Field](Field.mdx) element in bits - 255. - -#### Source - -[lib/provable/field.ts:1127](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1127) - -*** - -### sizeInBytes - -```ts -static sizeInBytes: number = BinableFp.sizeInBytes; -``` - -The size of a [Field](Field.mdx) element in bytes - 32. - -#### Source - -[lib/provable/field.ts:1122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1122) - -## Methods - -### add() - -```ts -add(y: string | number | bigint | Field): Field -``` - -Add a field-like value to this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular addition of the two value. - -#### Example - -```ts -const x = Field(3); -const sum = x.add(5); - -sum.assertEquals(Field(8)); -``` - -**Warning**: This is a modular addition in the pasta field. - -#### Example - -```ts -const x = Field(1); -const sum = x.add(Field(-7)); - -// If you try to print sum - `console.log(sum.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 + (-7) circles around the field to become p - 6. -// You can use the reverse operation of addition (subtraction) to prove the sum is calculated correctly. - -sum.sub(x).assertEquals(Field(-7)); -sum.sub(Field(-7)).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L250) - -*** - -### assertBool() - -```ts -assertBool(message?: string): Bool -``` - -Prove that this [Field](Field.mdx) is equal to 0 or 1. -Returns the Field wrapped in a [Bool](Bool.mdx). - -If the assertion fails, the code throws an error. - -#### Parameters - -• **message?**: `string` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/field.ts:780](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L780) - -*** - -### assertEquals() - -```ts -assertEquals(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is equal another "field-like" value. -Calling this function is equivalent to `Field(...).equals(...).assertEquals(Bool(true))`. -See [Field.equals](Field.mdx#equals) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L208) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is greater than another "field-like" value. - -Note: This uses fewer constraints than `x.greaterThan(y).assertTrue()`. -See [Field.greaterThan](Field.mdx#greaterthan) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:714](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L714) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is greater than or equal to another "field-like" value. - -Note: This uses fewer constraints than `x.greaterThanOrEqual(y).assertTrue()`. -See [Field.greaterThanOrEqual](Field.mdx#greaterthanorequal) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:729](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L729) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is less than another "field-like" value. - -Note: This uses fewer constraints than `x.lessThan(y).assertTrue()`. -See [lessThan](Field.mdx#lessthan) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:664](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L664) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is less than or equal to another "field-like" value. - -Note: This uses fewer constraints than `x.lessThanOrEqual(y).assertTrue()`. -See [Field.lessThanOrEqual](Field.mdx#lessthanorequal) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:689](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L689) - -*** - -### assertNotEquals() - -```ts -assertNotEquals(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) does not equal another field-like value. - -Note: This uses fewer constraints than `x.equals(y).assertFalse()`. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Example - -```ts -x.assertNotEquals(0, "expect x to be non-zero"); -``` - -#### Source - -[lib/provable/field.ts:746](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L746) - -*** - -### div() - -```ts -div(y: string | number | bigint | Field): Field -``` - -Divide another "field-like" value through this [Field](Field.mdx). - -Proves that the denominator is non-zero, or throws a "Division by zero" error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular division of the two value. - -#### Example - -```ts -const x = Field(6); -const quotient = x.div(Field(3)); - -quotient.assertEquals(Field(2)); -``` - -**Warning**: This is a modular division in the pasta field. You can think this as the reverse operation of modular multiplication. - -#### Example - -```ts -const x = Field(2); -const y = Field(5); - -const quotient = x.div(y); - -// If you try to print quotient - `console.log(quotient.toBigInt())` - you will realize that it prints a very big integer because this is a modular inverse. -// You can use the reverse operation of division (multiplication) to prove the quotient is calculated correctly. - -quotient.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:442](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L442) - -*** - -### equals() - -```ts -equals(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is equal another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is equal another "field-like" value. - -#### Example - -```ts -Field(5).equals(5).assertEquals(Bool(true)); -``` - -#### Source - -[lib/provable/field.ts:522](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L522) - -*** - -### greaterThan() - -```ts -greaterThan(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is greater than another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is greater than another "field-like" value. - -#### Example - -```ts -let isTrue = Field(5).greaterThan(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(2).greaterThan(Field(1).div(3); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:625](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L625) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is greater than or equal another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is greater than or equal another "field-like" value. - -#### Example - -```ts -let isTrue = Field(3).greaterThanOrEqual(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(2).greaterThanOrEqual(Field(1).div(3); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:649](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L649) - -*** - -### inv() - -```ts -inv(): Field -``` - -[Modular inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of this [Field](Field.mdx) element. -Equivalent to 1 divided by this [Field](Field.mdx), in the sense of modular arithmetic. - -Proves that this Field is non-zero, or throws a "Division by zero" error. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element that is equivalent to one divided by this element. - -#### Example - -```ts -const someField = Field(42); -const inverse = someField.inv(); -inverse.assertEquals(Field(1).div(someField)); // This statement is always true regardless of the value of `someField` -``` - -**Warning**: This is a modular inverse. See [div](Field.mdx#div) method for more details. - -#### Source - -[lib/provable/field.ts:396](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L396) - -*** - -### isConstant() - -```ts -isConstant(): this is Object -``` - -Check whether this [Field](Field.mdx) element is a hard-coded constant in the constraint system. -If a [Field](Field.mdx) is constructed outside a zkApp method, it is a constant. - -#### Returns - -`this is Object` - -A `boolean` showing if this [Field](Field.mdx) is a constant or not. - -#### Example - -```ts -console.log(Field(42).isConstant()); // true -``` - -#### Example - -```ts -\@method myMethod(x: Field) { - console.log(x.isConstant()); // false -} -``` - -#### Source - -[lib/provable/field.ts:142](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L142) - -*** - -### isEven() - -```ts -isEven(): Bool -``` - -Checks if this [Field](Field.mdx) is even. Returns `true` for even elements and `false` for odd elements. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let a = Field(5); -a.isEven(); // false - -let b = Field(4); -b.isEven(); // true -``` - -#### Source - -[lib/provable/field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L339) - -*** - -### isOdd() - -```ts -isOdd(): Bool -``` - -Checks if this [Field](Field.mdx) is odd. Returns `true` for odd elements and `false` for even elements. - -See [Field.isEven](Field.mdx#iseven) for examples. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/field.ts:323](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L323) - -*** - -### lessThan() - -```ts -lessThan(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is less than another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used prove to the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is less than another "field-like" value. - -#### Example - -```ts -let isTrue = Field(2).lessThan(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behavior when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(3).lessThan(Field(1).div(2)); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:571](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L571) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is less than or equal to another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is less than or equal another "field-like" value. - -#### Example - -```ts -let isTrue = Field(3).lessThanOrEqual(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(3).lessThanOrEqual(Field(1).div(2)); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L598) - -*** - -### mul() - -```ts -mul(y: string | number | bigint | Field): Field -``` - -Multiply another "field-like" value with this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular difference of the two value. - -#### Example - -```ts -const x = Field(3); -const product = x.mul(Field(5)); - -product.assertEquals(Field(15)); -``` - -#### Source - -[lib/provable/field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L358) - -*** - -### neg() - -```ts -neg(): Field -``` - -Negate a [Field](Field.mdx). This is equivalent to multiplying the [Field](Field.mdx) by -1. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element that is equivalent to the element multiplied by -1. - -#### Example - -```ts -const negOne = Field(1).neg(); -negOne.assertEquals(-1); -``` - -#### Example - -```ts -const someField = Field(42); -someField.neg().assertEquals(someField.mul(Field(-1))); // This statement is always true regardless of the value of `someField` -``` - -**Warning**: This is a modular negation. For details, see the [sub](Field.mdx#sub) method. - -#### Source - -[lib/provable/field.ts:278](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L278) - -*** - -### seal() - -```ts -seal(): VarField | ConstantField -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -In o1js, addition and scaling (multiplication of variables by a constant) of variables is represented as an AST - [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree). For example, the expression `x.add(y).mul(2)` is represented as `Scale(2, Add(x, y))`. - - A new internal variable is created only when the variable is needed in a multiplicative or any higher level constraint (for example multiplication of two [Field](Field.mdx) elements) to represent the operation. - -The `seal()` function tells o1js to stop building an AST and create a new variable right away. - -#### Returns - -[`VarField`](../type-aliases/VarField.mdx) \| [`ConstantField`](../type-aliases/ConstantField.mdx) - -A [Field](Field.mdx) element that is equal to the result of AST that was previously on this [Field](Field.mdx) element. - -#### Source - -[lib/provable/field.ts:872](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L872) - -*** - -### sqrt() - -```ts -sqrt(): Field -``` - -Take the square root of this [Field](Field.mdx) element. - -Proves that the Field element has a square root in the finite field, or throws if it doesn't. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the square root of the [Field](Field.mdx) element. - -#### Example - -```ts -let z = x.sqrt(); -z.mul(z).assertEquals(x); // true for every `x` -``` - -**Warning**: This is a modular square root, which is any number z that satisfies z*z = x (mod p). -Note that, if a square root z exists, there also exists a second one, -z (which is different if z != 0). -Therefore, this method leaves an adversarial prover the choice between two different values to return. - -#### Source - -[lib/provable/field.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L492) - -*** - -### square() - -```ts -square(): Field -``` - -Square this [Field](Field.mdx) element. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the multiplication of the [Field](Field.mdx) element with itself. - -#### Example - -```ts -const someField = Field(7); -const square = someField.square(); - -square.assertEquals(someField.mul(someField)); // This statement is always true regardless of the value of `someField` -``` - -** Warning: This is a modular multiplication. See `mul()` method for more details. - -#### Source - -[lib/provable/field.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L463) - -*** - -### sub() - -```ts -sub(y: string | number | bigint | Field): Field -``` - -Subtract another "field-like" value from this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular difference of the two value. - -#### Example - -```ts -const x = Field(3); -const difference = x.sub(5); - -difference.assertEquals(Field(-2)); -``` - -**Warning**: This is a modular subtraction in the pasta field. - -#### Example - -```ts -const x = Field(1); -const difference = x.sub(Field(2)); - -// If you try to print difference - `console.log(difference.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 - 2 circles around the field to become p - 1. -// You can use the reverse operation of subtraction (addition) to prove the difference is calculated correctly. -difference.add(Field(2)).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L314) - -*** - -### toAuxiliary() - -```ts -toAuxiliary(): [] -``` - -This function is the implementation of Provable.toAuxiliary for the [Field](Field.mdx) type. - -As the primitive [Field](Field.mdx) type has no auxiliary data associated with it, this function will always return an empty array. - -#### Returns - -[] - -#### Source - -[lib/provable/field.ts:1005](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1005) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Serialize the [Field](Field.mdx) to a bigint, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the bigint representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`bigint` - -A bigint equivalent to the bigint representation of the Field. - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toBigInt()); -``` - -#### Source - -[lib/provable/field.ts:176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L176) - -*** - -### toBits() - -```ts -toBits(length: number): Bool[] -``` - -Returns an array of [Bool](Bool.mdx) elements representing [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of this [Field](Field.mdx) element. - -If you use the optional `length` argument, proves that the field element fits in `length` bits. -The `length` has to be between 0 and 254 and the method throws if it isn't. - -**Warning**: The cost of this operation in a zk proof depends on the `length` you specify, -which by default is 254 bits. Prefer to pass a smaller `length` if possible. - -#### Parameters - -• **length**: `number`= `254` - -the number of bits to fit the element. If the element does not fit in `length` bits, the functions throws an error. - -#### Returns - -[`Bool`](Bool.mdx)[] - -An array of [Bool](Bool.mdx) element representing little endian binary representation of this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:810](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L810) - -*** - -### toConstant() - -```ts -toConstant(): ConstantField -``` - -Create a [Field](Field.mdx) element equivalent to this [Field](Field.mdx) element's value, -but is a constant. -See [Field.isConstant](Field.mdx#isconstant) for more information about what is a constant [Field](Field.mdx). - -#### Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -A constant [Field](Field.mdx) element equivalent to this [Field](Field.mdx) element. - -#### Example - -```ts -const someField = Field(42); -someField.toConstant().assertEquals(someField); // Always true -``` - -#### Source - -[lib/provable/field.ts:159](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L159) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -This function is the implementation of Provable.toFields for the [Field](Field.mdx) type. - -The result will be always an array of length 1, where the first and only element equals the [Field](Field.mdx) itself. - -#### Returns - -[`Field`](Field.mdx)[] - -A [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:996](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L996) - -*** - -### toJSON() - -```ts -toJSON(): string -``` - -Serialize the [Field](Field.mdx) to a JSON string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the JSON string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`string` - -A string equivalent to the JSON representation of the [Field](Field.mdx). - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toJSON()); -``` - -#### Source - -[lib/provable/field.ts:1028](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1028) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [Field](Field.mdx) to a string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`string` - -A string equivalent to the string representation of the Field. - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toString()); -``` - -#### Source - -[lib/provable/field.ts:194](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L194) - -*** - -### check() - -```ts -static check(): void -``` - -This function is the implementation of Provable.check in [Field](Field.mdx) type. - -As any field element can be a [Field](Field.mdx), this function does not create any assertions, so it does nothing. - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:966](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L966) - -*** - -### empty() - -```ts -static empty(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:1011](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1011) - -*** - -### from() - -```ts -static from(x: string | number | bigint | Field): Field -``` - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:119](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L119) - -*** - -### fromBits() - -```ts -static fromBits(bits: (boolean | Bool)[]): Field -``` - -Convert a bit array into a [Field](Field.mdx) element using [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) - -The method throws if the given bits do not fit in a single Field element. In this case, no more than 254 bits are allowed because some 255 bit integers do not fit into a single Field element. - -**Important**: If the given `bytes` array is an array of `booleans` or [Bool](Bool.mdx) elements that all are `constant`, the resulting [Field](Field.mdx) element will be a constant as well. Or else, if the given array is a mixture of constants and variables of [Bool](Bool.mdx) type, the resulting [Field](Field.mdx) will be a variable as well. - -#### Parameters - -• **bits**: (`boolean` \| [`Bool`](Bool.mdx))[] - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element matching the [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of the given `bytes` array. - -#### Source - -[lib/provable/field.ts:843](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L843) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: number[]): Field -``` - -Coerce a new [Field](Field.mdx) element using the [little-endian](https://en.wikipedia.org/wiki/Endianness) representation of the given `bytes` array. -Note that the given `bytes` array may have at most 32 elements as the [Field](Field.mdx) is a `finite-field` in the order of [Field.ORDER](Field.mdx#order). - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the byte representation of the [Field](Field.mdx). - -#### Parameters - -• **bytes**: `number`[] - -The bytes array to coerce the [Field](Field.mdx) from. - -#### Returns - -[`Field`](Field.mdx) - -A new [Field](Field.mdx) element created using the [little-endian](https://en.wikipedia.org/wiki/Endianness) representation of the given `bytes` array. - -#### Source - -[lib/provable/field.ts:1115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1115) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Field -``` - -Implementation of Provable.fromFields for the [Field](Field.mdx) type. - -**Warning**: This function is designed for internal use. It is not intended to be used by a zkApp developer. - -Creates a [Field](Field.mdx) from an array of Fields of length 1. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of length 1 serialized from [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx) - -The first [Field](Field.mdx) element of the given array. - -#### Source - -[lib/provable/field.ts:955](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L955) - -*** - -### fromJSON() - -```ts -static fromJSON(json: string): Field -``` - -Deserialize a JSON string containing a "field-like" value into a [Field](Field.mdx) element. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the [Field](Field.mdx). - -#### Parameters - -• **json**: `string` - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) coerced from the given JSON string. - -#### Source - -[lib/provable/field.ts:1060](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1060) - -*** - -### fromValue() - -```ts -static fromValue(x: string | number | bigint | Field): Field -``` - -`Provable.fromValue()` - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:985](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L985) - -*** - -### random() - -```ts -static random(): Field -``` - -A random [Field](Field.mdx) element. - -#### Returns - -[`Field`](Field.mdx) - -A random [Field](Field.mdx) element. - -#### Example - -```ts -console.log(Field.random().toBigInt()); // Run this code twice! -``` - -#### Source - -[lib/provable/field.ts:894](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L894) - -*** - -### readBytes() - -```ts -static readBytes(bytes: number[], offset: NonNegativeInteger): [Field, number] -``` - -Part of the `Binable` interface. - -**Warning**: This function is for internal use. It is not intended to be used by a zkApp developer. - -#### Type parameters - -• **N** *extends* `number` - -#### Parameters - -• **bytes**: `number`[] - -• **offset**: `NonNegativeInteger`\<`N`\> - -#### Returns - -[[`Field`](Field.mdx), `number`] - -#### Source - -[lib/provable/field.ts:1098](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1098) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -This function is the implementation of Provable.sizeInFields for the [Field](Field.mdx) type. - -Size of the [Field](Field.mdx) type is 1, as it is the primitive type. -This function returns a regular number, so you cannot use it to prove something on chain. You can use it during debugging or to understand the memory complexity of some type. - -#### Returns - -`number` - -A number representing the size of the [Field](Field.mdx) type in terms of [Field](Field.mdx) type itself. - -#### Example - -```ts -console.log(Field.sizeInFields()); // Prints 1 -``` - -#### Source - -[lib/provable/field.ts:940](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L940) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -This function is the implementation of Provable.toAuxiliary for the [Field](Field.mdx) type. - -As the primitive [Field](Field.mdx) type has no auxiliary data associated with it, this function will always return an empty array. - -#### Returns - -[] - -#### Source - -[lib/provable/field.ts:923](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L923) - -*** - -### toBigint() - -```ts -static toBigint(x: Field): bigint -``` - -Convert a [Field](Field.mdx) element to a bigint. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/field.ts:978](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L978) - -*** - -### toBytes() - -```ts -static toBytes(x: Field): number[] -``` - -Create an array of digits equal to the [little-endian](https://en.wikipedia.org/wiki/Endianness) byte order of the given [Field](Field.mdx) element. -Note that the array has always 32 elements as the [Field](Field.mdx) is a `finite-field` in the order of [Field.ORDER](Field.mdx#order). - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`number`[] - -An array of digits equal to the [little-endian](https://en.wikipedia.org/wiki/Endianness) byte order of the given [Field](Field.mdx) element. - -#### Source - -[lib/provable/field.ts:1089](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1089) - -*** - -### toFields() - -```ts -static toFields(x: Field): Field[] -``` - -This function is the implementation of Provable.toFields for the [Field](Field.mdx) type. - -Static function to serializes a [Field](Field.mdx) into an array of [Field](Field.mdx) elements. -This will be always an array of length 1, where the first and only element equals the given parameter itself. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -A [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L912) - -*** - -### toInput() - -```ts -static toInput(x: Field): { - "fields": Field[]; -} -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -This function is the implementation of `ProvableExtended.toInput()` for the [Field](Field.mdx) type. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -```ts -{ - "fields": Field[]; -} -``` - -An object where the `fields` key is a [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -##### fields - -```ts -fields: Field[]; -``` - -#### Source - -[lib/provable/field.ts:1074](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1074) - -*** - -### toJSON() - -```ts -static toJSON(x: Field): string -``` - -Serialize the given [Field](Field.mdx) element to a JSON string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the JSON string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`string` - -A string equivalent to the JSON representation of the given [Field](Field.mdx). - -#### Example - -```ts -const someField = Field(42); -console.log(Field.toJSON(someField)); -``` - -#### Source - -[lib/provable/field.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1047) - -*** - -### toValue() - -```ts -static toValue(x: Field): bigint -``` - -`Provable.toValue()` - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/field.ts:971](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L971) diff --git a/docs/zkapps/o1js-reference/classes/ForeignCurve.mdx b/docs/zkapps/o1js-reference/classes/ForeignCurve.mdx deleted file mode 100644 index 870693162..000000000 --- a/docs/zkapps/o1js-reference/classes/ForeignCurve.mdx +++ /dev/null @@ -1,681 +0,0 @@ -## Constructors - -### new ForeignCurve() - -```ts -new ForeignCurve(g: { - "x": number | bigint | Field3 | AlmostForeignField; - "y": number | bigint | Field3 | AlmostForeignField; - }): ForeignCurve -``` - -Create a new [ForeignCurve](ForeignCurve.mdx) from an object representing the (affine) x and y coordinates. - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. Please refer to the [ForeignField](ForeignField.mdx) constructor comments for more details. - -#### Parameters - -• **g** - -• **g.x**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **g.y**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let x = new ForeignCurve({ x: 1n, y: 1n }); -``` - -**Important**: By design, there is no way for a `ForeignCurve` to represent the zero point. - -**Warning**: This fails for a constant input which does not represent an actual point on the curve. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L49) - -## Properties - -### x - -```ts -x: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L32) - -*** - -### y - -```ts -y: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L33) - -*** - -### \_Bigint? - -```ts -static optional _Bigint: {}; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:362](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L362) - -*** - -### \_Field? - -```ts -static optional _Field: typeof AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:363](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L363) - -*** - -### \_Scalar? - -```ts -static optional _Scalar: typeof AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:364](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L364) - -*** - -### \_provable? - -```ts -static optional _provable: ProvablePureExtended; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:365](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L365) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignCurve -``` - -#### Returns - -*typeof* [`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L359) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -The size of the curve's base field. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:203](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L203) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -Curve arithmetic on JS bigints. - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:374](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L374) - -*** - -### Field - -```ts -get static Field(): typeof AlmostForeignField -``` - -The base field of this curve as a [ForeignField](ForeignField.mdx). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:381](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L381) - -*** - -### Scalar - -```ts -get static Scalar(): typeof AlmostForeignField -``` - -The scalar field of this curve as a [ForeignField](ForeignField.mdx). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L388) - -*** - -### generator - -```ts -get static generator(): ForeignCurve -``` - -The constant generator point. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:191](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L191) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -The size of the curve's base field. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L197) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -`Provable` - -#### Returns - -`ProvablePureExtended`\<[`ForeignCurve`](ForeignCurve.mdx), \{ - `"x"`: `bigint`; - `"y"`: `bigint`; - \}, \{ - `"x"`: `string`; - `"y"`: `string`; - \}\> - -#### Source - -[lib/provable/crypto/foreign-curve.ts:395](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L395) - -## Methods - -### add() - -```ts -add(h: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Elliptic curve addition. - -```ts -let r = p.add(q); // r = p + q -``` - -**Important**: this is _incomplete addition_ and does not handle the degenerate cases: -- Inputs are equal, `g = h` (where you would use [double](ForeignCurve.mdx#double)). - In this case, the result of this method is garbage and can be manipulated arbitrarily by a malicious prover. -- Inputs are inverses of each other, `g = -h`, so that the result would be the zero point. - In this case, the proof fails. - -If you want guaranteed soundness regardless of the input, use [addSafe](ForeignCurve.mdx#addsafe) instead. - -#### Parameters - -• **h**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the inputs are inverses of each other. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:243](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L243) - -*** - -### addSafe() - -```ts -addSafe(h: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Safe elliptic curve addition. - -This is the same as [add](ForeignCurve.mdx#add), but additionally proves that the inputs are not equal. -Therefore, the method is guaranteed to either fail or return a valid addition result. - -**Beware**: this is more expensive than [add](ForeignCurve.mdx#add), and is still incomplete in that -it does not succeed on equal or inverse inputs. - -#### Parameters - -• **h**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the inputs are equal or inverses of each other. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L261) - -*** - -### assertInSubgroup() - -```ts -assertInSubgroup(): void -``` - -Assert that this point lies in the subgroup defined by `order*P = 0`. - -Note: this is a no-op if the curve has cofactor equal to 1. Otherwise -it performs the full scalar multiplication `order*P` and is expensive. - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:341](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L341) - -*** - -### assertOnCurve() - -```ts -assertOnCurve(): void -``` - -Assert that this point lies on the elliptic curve, which means it satisfies the equation -`y^2 = x^3 + ax + b` - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L325) - -*** - -### double() - -```ts -double(): ForeignCurve -``` - -Elliptic curve doubling. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let r = p.double(); // r = 2 * p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L280) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this curve point is constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L212) - -*** - -### negate() - -```ts -negate(): ForeignCurve -``` - -Elliptic curve negation. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let r = p.negate(); // r = -p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L294) - -*** - -### scale() - -```ts -scale(scalar: number | bigint | AlmostForeignField): ForeignCurve -``` - -Elliptic curve scalar multiplication, where the scalar is represented as a [ForeignField](ForeignField.mdx) element. - -**Important**: this proves that the result of the scalar multiplication is not the zero point. - -#### Parameters - -• **scalar**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the scalar multiplication results in the zero point; for example, if the scalar is zero. - -#### Example - -```ts -let r = p.scale(s); // r = s * p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:310](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L310) - -*** - -### toBigint() - -```ts -toBigint(): GroupAffine -``` - -Convert this curve point to a point with bigint coordinates. - -#### Returns - -`GroupAffine` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L219) - -*** - -### assertInSubgroup() - -```ts -static assertInSubgroup(g: ForeignCurve): void -``` - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:329](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L329) - -*** - -### assertOnCurve() - -```ts -static assertOnCurve(g: ForeignCurve): void -``` - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L317) - -*** - -### check() - -```ts -static check(g: ForeignCurveNotNeeded): void -``` - -Check that this is a valid element of the target subgroup of the curve: -- Check that the coordinates are valid field elements -- Use [()](ForeignCurve.mdx#assertoncurve-1) to check that the point lies on the curve -- If the curve has cofactor unequal to 1, use [()](ForeignCurve.mdx#assertinsubgroup-1). - -#### Parameters - -• **g**: `ForeignCurveNotNeeded` - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:351](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L351) - -*** - -### from() - -```ts -static from(g: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Coerce the input to a [ForeignCurve](ForeignCurve.mdx). - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L65) - -*** - -### fromEthers() - -```ts -static fromEthers(hex: string): ForeignCurve -``` - -Create a new [ForeignCurve](ForeignCurve.mdx) instance from an Ethereum public key in hex format, which may be either compressed or uncompressed. -This method is designed to handle the parsing of public keys as used by the ethers.js library. - -The input should represent the affine x and y coordinates of the point, in hexadecimal format. -Compressed keys are 33 bytes long and begin with 0x02 or 0x03, while uncompressed keys are 65 bytes long and begin with 0x04. - -**Warning:** This method is specifically designed for use with the Secp256k1 curve. Using it with other curves may result in incorrect behavior or errors. -Ensure that the curve setup matches Secp256k1, as shown in the example, to avoid unintended issues. - -#### Parameters - -• **hex**: `string` - -The public key as a hexadecimal string (without the "0x" prefix). - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -A new instance of the curve representing the given public key. - -#### Example - -```ts -import { Wallet, Signature, getBytes } from 'ethers'; - -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} - -const wallet = Wallet.createRandom(); - -const publicKey = Secp256k1.fromEthers(wallet.publicKey.slice(2)); -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L143) - -*** - -### fromHex() - -```ts -static fromHex(hex: string): ForeignCurve -``` - -Parses a hexadecimal string representing an uncompressed elliptic curve point and coerces it into a [ForeignCurve](ForeignCurve.mdx) point. - -The method extracts the x and y coordinates from the provided hex string and verifies that the resulting point lies on the curve. - -**Note:** This method only supports uncompressed elliptic curve points, which are 65 bytes in total (1-byte prefix + 32 bytes for x + 32 bytes for y). - -#### Parameters - -• **hex**: `string` - -The hexadecimal string representing the uncompressed elliptic curve point. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -- A point on the foreign curve, parsed from the given hexadecimal string. - -#### Throws - -- Throws an error if the input is not a valid public key. - -#### Example - -```ts -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} - -const publicKeyHex = '04f8b8db25c619d0c66b2dc9e97ecbafafae...'; // Example hex string for uncompressed point -const point = Secp256k1.fromHex(publicKeyHex); -``` - -**Important:** This method is only designed to handle uncompressed elliptic curve points in hex format. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L92) diff --git a/docs/zkapps/o1js-reference/classes/ForeignField.mdx b/docs/zkapps/o1js-reference/classes/ForeignField.mdx deleted file mode 100644 index 1df7e78a0..000000000 --- a/docs/zkapps/o1js-reference/classes/ForeignField.mdx +++ /dev/null @@ -1,784 +0,0 @@ -## Constructors - -### new ForeignField() - -```ts -new ForeignField(x: - | string - | number - | bigint - | Field3 - | ForeignField): ForeignField -``` - -Create a new [ForeignField](ForeignField.mdx) from a bigint, number, string or another ForeignField. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Example - -```ts -let x = new ForeignField(5); -``` - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. - -- When constructing from another [ForeignField](ForeignField.mdx) instance, ensure the modulus matches. If not, check the modulus using `Gadgets.ForeignField.assertLessThan()` and handle appropriately. -- When constructing from a Field3 array, ensure all elements are valid Field elements and range checked. -- Ensure constants are correctly reduced to the modulus of the field. - -#### Source - -[lib/provable/foreign-field.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L101) - -## Properties - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: any = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:414](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L414) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): any -``` - -`Provable`, see [Provable](../type-aliases/Provable.mdx) - -#### Returns - -`any` - -#### Source - -[lib/provable/foreign-field.ts:419](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L419) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(_: ForeignField): void -``` - -#### Parameters - -• **\_**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/foreign-field.ts:410](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L410) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) diff --git a/docs/zkapps/o1js-reference/classes/Group.mdx b/docs/zkapps/o1js-reference/classes/Group.mdx deleted file mode 100644 index 219cf7c36..000000000 --- a/docs/zkapps/o1js-reference/classes/Group.mdx +++ /dev/null @@ -1,740 +0,0 @@ -An element of a Group. - -## Constructors - -### new Group() - -```ts -new Group(__namedParameters: { - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }): Group -``` - -Coerces anything group-like to a [Group](Group.mdx). - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **\_\_namedParameters.y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L50) - -## Properties - -### x - -```ts -x: Field; -``` - -#### Source - -[lib/provable/group.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L21) - -*** - -### y - -```ts -y: Field; -``` - -#### Source - -[lib/provable/group.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L22) - -## Accessors - -### generator - -```ts -get static generator(): Group -``` - -The generator `g` of the Group. - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L27) - -*** - -### zero - -```ts -get static zero(): Group -``` - -Unique representation of the `zero` element of the Group (the identity element of addition in this Group). - -**Note**: The `zero` element is represented as `(0, 0)`. - -```typescript -// g + -g = 0 -g.add(g.neg()).assertEquals(zero); -// g + 0 = g -g.add(zero).assertEquals(g); -``` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:43](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L43) - -## Methods - -### add() - -```ts -add(g: Group): Group -``` - -Adds this [Group](Group.mdx) element to another [Group](Group.mdx) element. - -```ts -let g1 = Group({ x: -1, y: 2}) -let g2 = g1.add(g1) -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L97) - -*** - -### addNonZero() - -```ts -addNonZero(g2: Group, allowZeroOutput: boolean): Group -``` - -Lower-level variant of [add](Group.mdx#add) which doesn't handle the case where one of the operands is zero, and -asserts that the output is non-zero. - -Optionally, zero outputs can be allowed by setting `allowZeroOutput` to `true`. - -**Warning**: If one of the inputs is zero, the result will be garbage and the proof useless. -This case has to be prevented or handled separately by the caller of this method. - -#### Parameters - -• **g2**: [`Group`](Group.mdx) - -• **allowZeroOutput**: `boolean`= `false` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L136) - -*** - -### assertEquals() - -```ts -assertEquals(g: Group, message?: string): void -``` - -Assert that this [Group](Group.mdx) element equals another [Group](Group.mdx) element. -Throws an error if the assertion fails. - -```ts -g1.assertEquals(g2); -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/group.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L200) - -*** - -### equals() - -```ts -equals(g: Group): Bool -``` - -Check if this [Group](Group.mdx) element equals another [Group](Group.mdx) element. -Returns a [Bool](Bool.mdx). - -```ts -g1.equals(g1); // Bool(true) -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/group.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L216) - -*** - -### isZero() - -```ts -isZero(): Bool -``` - -Checks if this element is the `zero` element `{x: 0, y: 0}`. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/group.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L84) - -*** - -### neg() - -```ts -neg(): Group -``` - -Negates this [Group](Group.mdx). Under the hood, it simply negates the `y` coordinate and leaves the `x` coordinate as is. - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L165) - -*** - -### scale() - -```ts -scale(s: number | bigint | Field | Scalar): Group -``` - -Elliptic curve scalar multiplication. Scales the [Group](Group.mdx) element `n`-times by itself, where `n` is the [Scalar](Scalar.mdx). - -```typescript -let s = Scalar(5); -let 5g = g.scale(s); -``` - -#### Parameters - -• **s**: `number` \| `bigint` \| [`Field`](Field.mdx) \| [`Scalar`](Scalar.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L179) - -*** - -### sub() - -```ts -sub(g: Group): Group -``` - -Subtracts another [Group](Group.mdx) element from this one. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L158) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an array containing this [Group](Group.mdx) element as an array of [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/group.ts:253](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L253) - -*** - -### toJSON() - -```ts -toJSON(): { - "x": string; - "y": string; -} -``` - -Serializes this [Group](Group.mdx) element to a JSON object. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Returns - -```ts -{ - "x": string; - "y": string; -} -``` - -##### x - -```ts -x: string; -``` - -##### y - -```ts -y: string; -``` - -#### Source - -[lib/provable/group.ts:238](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L238) - -*** - -### check() - -```ts -static check(g: Group): unknown -``` - -Checks that a [Group](Group.mdx) element is constraint properly by checking that the element is on the curve. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -`unknown` - -#### Source - -[lib/provable/group.ts:330](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L330) - -*** - -### empty() - -```ts -static empty(): Group -``` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L356) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | FieldVar - | Field, y: - | string - | number - | bigint - | FieldVar - | Field): Group -``` - -Coerces two x and y coordinates into a [Group](Group.mdx) element. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:260](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L260) - -*** - -### fromFields() - -```ts -static fromFields(__namedParameters: Field[]): Group -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Deserializes a [Group](Group.mdx) element from a list of field elements. - -#### Parameters - -• **\_\_namedParameters**: [`Field`](Field.mdx)[] - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:290](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L290) - -*** - -### fromJSON() - -```ts -static fromJSON(__namedParameters: { - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }): Group -``` - -Deserializes a JSON-like structure to a [Group](Group.mdx) element. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **\_\_namedParameters.y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L317) - -*** - -### fromValue() - -```ts -static fromValue(g: Group | { - "x": number | bigint | Field; - "y": number | bigint | Field; - }): Group -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) \| \{ - `"x"`: `number` \| `bigint` \| [`Field`](Field.mdx); - `"y"`: `number` \| `bigint` \| [`Field`](Field.mdx); - \} - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:227](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L227) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns 2. - -#### Returns - -`number` - -#### Source - -[lib/provable/group.ts:299](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L299) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(g?: Group): never[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an empty array. - -#### Parameters - -• **g?**: [`Group`](Group.mdx) - -#### Returns - -`never`[] - -#### Source - -[lib/provable/group.ts:281](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L281) - -*** - -### toFields() - -```ts -static toFields(g: Group): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an array containing a [Group](Group.mdx) element as an array of [Field](Field.mdx) elements. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/group.ts:272](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L272) - -*** - -### toInput() - -```ts -static toInput(x: Group): { - "fields": Field[]; -} -``` - -#### Parameters - -• **x**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "fields": Field[]; -} -``` - -##### fields - -```ts -fields: Field[]; -``` - -#### Source - -[lib/provable/group.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L350) - -*** - -### toJSON() - -```ts -static toJSON(g: Group): { - "x": string; - "y": string; -} -``` - -Serializes a [Group](Group.mdx) element to a JSON object. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "x": string; - "y": string; -} -``` - -##### x - -```ts -x: string; -``` - -##### y - -```ts -y: string; -``` - -#### Source - -[lib/provable/group.ts:308](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L308) - -*** - -### toValue() - -```ts -static toValue(__namedParameters: Group): { - "x": bigint; - "y": bigint; -} -``` - -#### Parameters - -• **\_\_namedParameters**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "x": bigint; - "y": bigint; -} -``` - -##### x - -```ts -x: bigint; -``` - -##### y - -```ts -y: bigint; -``` - -#### Source - -[lib/provable/group.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L223) diff --git a/docs/zkapps/o1js-reference/classes/Hashed.mdx b/docs/zkapps/o1js-reference/classes/Hashed.mdx deleted file mode 100644 index 3c4e25a5b..000000000 --- a/docs/zkapps/o1js-reference/classes/Hashed.mdx +++ /dev/null @@ -1,257 +0,0 @@ -`Hashed` represents a type `T` by its hash. - -Since a hash is only a single field element, this can be more efficient in provable code -where the number of constraints depends on the number of field elements per value. - -For example, `Provable.if(bool, x, y)` takes O(n) constraints, where n is the number of field -elements in x and y. With Hashed, this is reduced to O(1). - -The downside is that you will pay the overhead of hashing your values, so it helps to experiment -in which parts of your code a hashed representation is beneficial. - -Usage: - -```ts -// define a hashed type from a type -let HashedType = Hashed.create(MyType); - -// hash a value -let hashed = HashedType.hash(value); - -// ... operations on hashes, more efficient than on plain values ... - -// unhash to get the original value -let value = hashed.unhash(); -``` - -**Warning**: When wrapping a type with `Hashed`, make sure that that type is safe to automatically _pack_ -and _unpack_ in provable code. In particular, do not use `Hashed` with types that define a custom `toInput()` -(specifying a certain bit packing) but no corresponding `check()` method (that constrains the bit lengths of the packed parts). - -## Type parameters - -• **T** - -## Constructors - -### new Hashed() - -```ts -new Hashed(hash: Field, value: Unconstrained): Hashed -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Hashed`](Hashed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L241) - -## Properties - -### hash - -```ts -hash: Field; -``` - -#### Source - -[lib/provable/packed.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L204) - -*** - -### value - -```ts -value: Unconstrained; -``` - -#### Source - -[lib/provable/packed.ts:205](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L205) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/packed.ts:288](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L288) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/packed.ts:287](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L287) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof Hashed -``` - -#### Returns - -*typeof* [`Hashed`](Hashed.mdx) - -#### Source - -[lib/provable/packed.ts:290](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L290) - -*** - -### innerProvable - -```ts -get static innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`any`\> - -#### Source - -[lib/provable/packed.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L294) - -## Methods - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/packed.ts:282](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L282) - -*** - -### unhash() - -```ts -unhash(): T -``` - -Unwrap a value from its hashed variant. - -#### Returns - -`T` - -#### Source - -[lib/provable/packed.ts:270](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L270) - -*** - -### \_hash() - -```ts -static _hash(_: any): Field -``` - -#### Parameters - -• **\_**: `any` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/packed.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L246) - -*** - -### create() - -```ts -static create(type: WithProvable>, hash?: (t: T) => Field): typeof Hashed & { - "provable": ProvableHashable>; - "empty": Hashed; -} -``` - -Create a hashed representation of `type`. You can then use `HashedType.hash(x)` to wrap a value in a `Hashed`. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **hash?** - -#### Returns - -*typeof* [`Hashed`](Hashed.mdx) & \{ - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`Hashed`](Hashed.mdx)\<`T`\>\>; - `"empty"`: [`Hashed`](Hashed.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/packed.ts:210](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L210) - -*** - -### hash() - -```ts -static hash(value: T, hash?: Field): Hashed -``` - -Wrap a value, and represent it by its hash in provable code. - -```ts -let hashed = HashedType.hash(value); -``` - -Optionally, if you already have the hash, you can pass it in and avoid recomputing it. - -#### Type parameters - -• **T** - -#### Parameters - -• **value**: `T` - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -[`Hashed`](Hashed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L259) diff --git a/docs/zkapps/o1js-reference/classes/Int64.mdx b/docs/zkapps/o1js-reference/classes/Int64.mdx deleted file mode 100644 index ac946a03c..000000000 --- a/docs/zkapps/o1js-reference/classes/Int64.mdx +++ /dev/null @@ -1,1299 +0,0 @@ -A 64 bit signed integer with values ranging from -18,446,744,073,709,551,615 to 18,446,744,073,709,551,615. - -## Extends - -- `CircuitValue` - -## Implements - -- `BalanceChange` - -## Constructors - -### new Int64() - -```ts -new Int64(magnitude: UInt64, sgn?: Sign): Int64 -``` - -#### Parameters - -• **magnitude**: [`UInt64`](UInt64.mdx) - -The magnitude of the integer as a UInt64. - -• **sgn?**: [`Sign`](Sign.mdx)= `Sign.one` - -The sign of the integer. Default is positive (Sign.one). - -#### Returns - -[`Int64`](Int64.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Deprecated - -Use [Int64.create](Int64.mdx#create) for safe creation. - -WARNING: This constructor allows for ambiguous representation of zero (both +0 and -0). -This can lead to unexpected behavior in operations like [()](Int64.mdx#ispositive) and [()](Int64.mdx#mod). - -Security Implications: -1. A malicious prover could choose either positive or negative zero. -2. Arithmetic operations that result in 0 may allow an attacker to arbitrarily choose the sign. -3. This ambiguity could be exploited in protocols using Int64s for calculations like PNL tracking. - -Recommended Fix: -Use Int64.create() which enforces a canonical representation of zero, or -explicitly handle the zero case in operations like mod(). - -#### Source - -[lib/provable/int.ts:1141](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1141) - -## Properties - -### magnitude - -```ts -magnitude: UInt64; -``` - -#### Implementation of - -`BalanceChange.magnitude` - -#### Source - -[lib/provable/int.ts:1100](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1100) - -*** - -### sgn - -```ts -sgn: Sign; -``` - -#### Implementation of - -`BalanceChange.sgn` - -#### Source - -[lib/provable/int.ts:1101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1101) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromObject": Int64; -}; -``` - -#### fromObject() - -##### Parameters - -• **obj** - -• **obj.magnitude**: [`UInt64`](UInt64.mdx) - -• **obj.sgn**: [`Sign`](Sign.mdx) - -##### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1206](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1206) - -## Accessors - -### minusOne - -```ts -get static minusOne(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `-1`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1258) - -*** - -### one - -```ts -get static one(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `1`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1252](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1252) - -*** - -### zero - -```ts -get static zero(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `0`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1246) - -## Methods - -### add() - -```ts -add(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.add` - -#### Source - -[lib/provable/int.ts:1309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1309) - -*** - -### assertEquals() - -```ts -assertEquals(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64, message?: string): void -``` - -Asserts that two values are equal. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Implementation of - -`BalanceChange.assertEquals` - -#### Overrides - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/int.ts:1391](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1391) - -*** - -### div() - -```ts -div(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Integer division with canonical zero representation. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -The divisor. Can be an Int64, number, string, bigint, UInt64, or UInt32. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 representing the quotient, with canonical zero representation. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -*`z`* such that *`z * y <= x`. -On negative numbers, this rounds towards zero. - -This method guarantees that all results, including zero, have a consistent -representation, eliminating potential ambiguities in zero handling. - -#### Implementation of - -`BalanceChange.div` - -#### Source - -[lib/provable/int.ts:1341](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1341) - -*** - -### equals() - -```ts -equals(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Bool -``` - -Checks if two values are equal. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.equals` - -#### Overrides - -`CircuitValue.equals` - -#### Source - -[lib/provable/int.ts:1384](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1384) - -*** - -### fromObject() - -```ts -fromObject(obj: { - "magnitude": string | number | bigint | UInt64; - "sgn": bigint | Sign; - }): Int64 -``` - -#### Parameters - -• **obj** - -• **obj.magnitude**: `string` \| `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **obj.sgn**: `bigint` \| [`Sign`](Sign.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.fromObject` - -#### Source - -[lib/provable/int.ts:1212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1212) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Implementation of - -`BalanceChange.isConstant` - -#### Overrides - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/int.ts:1235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1235) - -*** - -### isNegative() - -```ts -isNegative(): Bool -``` - -Checks if the value is negative (x < 0). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.isNegative` - -#### Source - -[lib/provable/int.ts:1424](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1424) - -*** - -### isNonNegative() - -```ts -isNonNegative(): Bool -``` - -Checks if the value is non-negative (x >= 0). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.isNonNegative` - -#### Source - -[lib/provable/int.ts:1416](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1416) - -*** - -### isPositive() - -```ts -isPositive(): Bool -``` - -Checks if the value is strictly positive (x > 0). - -#### Returns - -[`Bool`](Bool.mdx) - -True if the value is greater than zero, false otherwise. - -#### Implementation of - -`BalanceChange.isPositive` - -#### Remarks - -This method considers zero as non-positive. It ensures consistency -with the mathematical definition of "positive" as strictly greater than zero. -This differs from some other methods which may treat zero as non-negative. - -#### Source - -[lib/provable/int.ts:1409](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1409) - -*** - -### mod() - -```ts -mod(y: - | string - | number - | bigint - | UInt64 - | UInt32): Int64 -``` - -Calculates the integer remainder of this Int64 divided by the given value. - -The result `z` satisfies the following conditions: -1. 0 ≤ z < |y| -2. x - z is divisible by y - -Note: This method follows the "truncate toward zero" convention for negative numbers. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -The divisor. Will be converted to UInt64 if not already. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance representing the remainder. - -#### Implementation of - -`BalanceChange.mod` - -#### Example - -```ts -const x1 = Int64.from(17); -const y1 = UInt64.from(5); -console.log(x1.mod(y1).toString()); // Output: 2 -``` - -#### Throws - -Implicitly, if y is zero or negative. - -#### Source - -[lib/provable/int.ts:1369](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1369) - -*** - -### mul() - -```ts -mul(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.mul` - -#### Source - -[lib/provable/int.ts:1323](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1323) - -*** - -### neg() - -```ts -neg(): Int64 -``` - -Negates the current Int64 value. - -This method returns a new Int64 instance with the opposite sign of the current value. -If the current value is zero, it returns zero. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance with the negated value. - -#### Implementation of - -`BalanceChange.neg` - -#### Example - -```ts -Int64.from(5).neg(); -``` - -#### See - - - Int64#from for creating Int64 instances - - Int64#zero for the zero constant - -#### Throws - -Implicitly, if the internal Provable.if condition fails - -#### Source - -[lib/provable/int.ts:1298](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1298) - -*** - -### sub() - -```ts -sub(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.sub` - -#### Source - -[lib/provable/int.ts:1316](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1316) - -*** - -### toBigint() - -```ts -toBigint(): bigint -``` - -Turns the [Int64](Int64.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Implementation of - -`BalanceChange.toBigint` - -#### Source - -[lib/provable/int.ts:1222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1222) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Implementation of - -`BalanceChange.toConstant` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toField() - -```ts -toField(): Field -``` - -Returns the [Field](../variables/Field.mdx) value. - -#### Returns - -[`Field`](Field.mdx) - -#### Implementation of - -`BalanceChange.toField` - -#### Source - -[lib/provable/int.ts:1265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1265) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Implementation of - -`BalanceChange.toFields` - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Implementation of - -`BalanceChange.toJSON` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [Int64](Int64.mdx) into a string. - -#### Returns - -`string` - -#### Implementation of - -`BalanceChange.toString` - -#### Source - -[lib/provable/int.ts:1231](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1231) - -*** - -### check() - -```ts -static check(__namedParameters: { - "magnitude": UInt64; - "sgn": Sign; - }): void -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.magnitude**: [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.sgn**: [`Sign`](Sign.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:1428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1428) - -*** - -### create() - -```ts -static create(magnitude: UInt64, sign: Sign): Int64 -``` - -Safely creates a new Int64 instance, enforcing canonical representation of zero. -This is the recommended way to create Int64 instances. - -#### Parameters - -• **magnitude**: [`UInt64`](UInt64.mdx) - -The magnitude of the integer as a UInt64 - -• **sign**: [`Sign`](Sign.mdx)= `Sign.one` - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance with a canonical representation. - -#### Example - -```ts -const x = Int64.create(0); // canonical representation of zero -``` - -#### Source - -[lib/provable/int.ts:1158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1158) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | Field - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Creates a new [Int64](Int64.mdx). - -Check the range if the argument is a constant. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`Field`](Field.mdx) - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1198](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1198) - -*** - -### fromField() - -```ts -static fromField(x: Field): Int64 -``` - -Static method to create a [Int64](Int64.mdx) from a [Field](../variables/Field.mdx). - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1271](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1271) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromUnsigned() - -```ts -static fromUnsigned(x: UInt64 | UInt32): Int64 -``` - -Creates a new [Int64](Int64.mdx) from a [Field](../variables/Field.mdx). - -**Does not** check if the [Field](../variables/Field.mdx) is within range. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1188](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1188) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) diff --git a/docs/zkapps/o1js-reference/classes/Keypair.mdx b/docs/zkapps/o1js-reference/classes/Keypair.mdx deleted file mode 100644 index bbd967cc7..000000000 --- a/docs/zkapps/o1js-reference/classes/Keypair.mdx +++ /dev/null @@ -1,73 +0,0 @@ -## Constructors - -### new Keypair() - -```ts -new Keypair(value: unknown): Keypair -``` - -#### Parameters - -• **value**: `unknown` - -#### Returns - -[`Keypair`](Keypair.mdx) - -#### Source - -[lib/proof-system/circuit.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L104) - -## Properties - -### value - -```ts -value: unknown; -``` - -#### Source - -[lib/proof-system/circuit.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L102) - -## Methods - -### constraintSystem() - -```ts -constraintSystem(): Gate[] -``` - -Returns a low-level JSON representation of the [Circuit](Circuit.mdx) from its [Keypair](Keypair.mdx): -a list of gates, each of which represents a row in a table, with certain coefficients and wires to other (row, column) pairs - -#### Returns - -`Gate`[] - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const json = MyProvable.witnessFromKeypair(keypair); -``` - -#### Source - -[lib/proof-system/circuit.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L123) - -*** - -### verificationKey() - -```ts -verificationKey(): VerificationKey -``` - -#### Returns - -`VerificationKey` - -#### Source - -[lib/proof-system/circuit.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L108) diff --git a/docs/zkapps/o1js-reference/classes/Ledger.mdx b/docs/zkapps/o1js-reference/classes/Ledger.mdx deleted file mode 100644 index c9d7ed17e..000000000 --- a/docs/zkapps/o1js-reference/classes/Ledger.mdx +++ /dev/null @@ -1,108 +0,0 @@ -Represents the Mina ledger. - -## Constructors - -### new Ledger() - -```ts -new Ledger(): Ledger -``` - -#### Returns - -[`Ledger`](Ledger.mdx) - -## Methods - -### addAccount() - -```ts -addAccount(publicKey: MlPublicKey, balance: string): void -``` - -Adds an account and its balance to the ledger. - -#### Parameters - -• **publicKey**: `MlPublicKey` - -• **balance**: `string` - -#### Returns - -`void` - -#### Source - -[snarky.d.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L492) - -*** - -### applyJsonTransaction() - -```ts -applyJsonTransaction( - txJson: string, - accountCreationFee: string, - networkState: string): void -``` - -Applies a JSON transaction to the ledger. - -#### Parameters - -• **txJson**: `string` - -• **accountCreationFee**: `string` - -• **networkState**: `string` - -#### Returns - -`void` - -#### Source - -[snarky.d.ts:497](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L497) - -*** - -### getAccount() - -```ts -getAccount(publicKey: MlPublicKey, tokenId: FieldConst): undefined | Account -``` - -Returns an account. - -#### Parameters - -• **publicKey**: `MlPublicKey` - -• **tokenId**: `FieldConst` - -#### Returns - -`undefined` \| `Account` - -#### Source - -[snarky.d.ts:506](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L506) - -*** - -### create() - -```ts -static create(): Ledger -``` - -Creates a fresh ledger. - -#### Returns - -[`Ledger`](Ledger.mdx) - -#### Source - -[snarky.d.ts:487](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L487) diff --git a/docs/zkapps/o1js-reference/classes/MerkleList.mdx b/docs/zkapps/o1js-reference/classes/MerkleList.mdx deleted file mode 100644 index 84882d2e2..000000000 --- a/docs/zkapps/o1js-reference/classes/MerkleList.mdx +++ /dev/null @@ -1,521 +0,0 @@ -Dynamic-length list which is represented as a single hash - -Supported operations are [()](MerkleList.mdx#push) and [()](MerkleList.mdx#pop) and some variants thereof. - -A Merkle list is generic over its element types, so before using it you must create a subclass for your element type: - -```ts -class MyList extends MerkleList.create(MyType) {} - -// now use it -let list = MyList.empty(); - -list.push(new MyType(...)); - -let element = list.pop(); -``` - -Internal detail: `push()` adds elements to the _start_ of the internal array and `pop()` removes them from the start. -This is so that the hash which represents the list is consistent with [MerkleListIterator](MerkleListIterator.mdx), -and so a `MerkleList` can be used as input to `MerkleListIterator.startIterating(list)` -(which will then iterate starting from the last pushed element). - -## Extended by - -- [`AccountUpdateForest`](AccountUpdateForest.mdx) - -## Type parameters - -• **T** - -## Implements - -- [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\> - -## Constructors - -### new MerkleList() - -```ts -new MerkleList(__namedParameters: MerkleListBase): MerkleList -``` - -#### Parameters - -• **\_\_namedParameters**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\> - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L84) - -## Properties - -### data - -```ts -data: Unconstrained[]>; -``` - -#### Implementation of - -`MerkleListBase.data` - -#### Source - -[lib/provable/merkle-list.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L82) - -*** - -### hash - -```ts -hash: Field; -``` - -#### Implementation of - -`MerkleListBase.hash` - -#### Source - -[lib/provable/merkle-list.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L81) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L350) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/merkle-list.ts:353](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L353) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, t: any) => Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:349](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L349) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/merkle-list.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L352) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleList -``` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) - -#### Source - -[lib/provable/merkle-list.ts:355](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L355) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:372](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L372) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L367) - -## Methods - -### clone() - -```ts -clone(): MerkleList -``` - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L223) - -*** - -### forEach() - -```ts -forEach(length: number, callback: (element: T, isDummy: Bool, i: number) => void): void -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -#### Parameters - -• **length**: `number` - -• **callback** - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L237) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L89) - -*** - -### lengthUnconstrained() - -```ts -lengthUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`number`\> - -#### Source - -[lib/provable/merkle-list.ts:267](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L267) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: T): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: `T` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L359) - -*** - -### pop() - -```ts -pop(): T -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L155) - -*** - -### popExn() - -```ts -popExn(): T -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L140) - -*** - -### popIf() - -```ts -popIf(condition: Bool): T -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L174) - -*** - -### popIfUnsafe() - -```ts -popIfUnsafe(shouldPop: Bool): T -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -#### Parameters - -• **shouldPop**: [`Bool`](Bool.mdx) - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L200) - -*** - -### push() - -```ts -push(element: T): void -``` - -Push a new element to the list. - -#### Parameters - -• **element**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:96](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L96) - -*** - -### pushIf() - -```ts -pushIf(condition: Bool, element: T): void -``` - -Push a new element to the list, if the `condition` is true. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **element**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L108) - -*** - -### startIterating() - -```ts -startIterating(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L251) - -*** - -### startIteratingFromLast() - -```ts -startIteratingFromLast(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L256) - -*** - -### toArrayUnconstrained() - -```ts -toArrayUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`[]\> - -#### Source - -[lib/provable/merkle-list.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L261) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleList & { - "empty": () => MerkleList; - "from": (array: T[]) => MerkleList; - "fromReverse": (array: T[]) => MerkleList; - "provable": ProvableHashable>; -} -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) & \{ - `"empty"`: () => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"fromReverse"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleList`](MerkleList.mdx)\<`T`\>\>; - \} - -#### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -#### Source - -[lib/provable/merkle-list.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L283) diff --git a/docs/zkapps/o1js-reference/classes/MerkleListIterator.mdx b/docs/zkapps/o1js-reference/classes/MerkleListIterator.mdx deleted file mode 100644 index a933c3ad1..000000000 --- a/docs/zkapps/o1js-reference/classes/MerkleListIterator.mdx +++ /dev/null @@ -1,631 +0,0 @@ -MerkleListIterator helps iterating through a Merkle list. -This works similar to calling `list.pop()` or `list.push()` repeatedly, but maintaining the entire list instead of removing elements. - -The core methods that support iteration are [()](MerkleListIterator.mdx#next) and [()](MerkleListIterator.mdx#previous). - -```ts -let iterator = MerkleListIterator.startIterating(list); - -let firstElement = iterator.next(); -``` - -We maintain two commitments: -- One to the entire array, to be able to prove that we end iteration at the correct point. -- One to the array from the current index until the end, to efficiently step forward. - -## Type parameters - -• **T** - -## Implements - -- [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\> - -## Constructors - -### new MerkleListIterator() - -```ts -new MerkleListIterator(value: MerkleListIteratorBase): MerkleListIterator -``` - -#### Parameters - -• **value**: [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\> - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:426](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L426) - -## Properties - -### currentHash - -```ts -currentHash: Field; -``` - -#### Implementation of - -`MerkleListIteratorBase.currentHash` - -#### Source - -[lib/provable/merkle-list.ts:423](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L423) - -*** - -### currentIndex - -```ts -currentIndex: Unconstrained; -``` - -#### Implementation of - -`MerkleListIteratorBase.currentIndex` - -#### Source - -[lib/provable/merkle-list.ts:424](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L424) - -*** - -### data - -```ts -readonly data: Unconstrained[]>; -``` - -#### Implementation of - -`MerkleListIteratorBase.data` - -#### Source - -[lib/provable/merkle-list.ts:419](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L419) - -*** - -### hash - -```ts -readonly hash: Field; -``` - -#### Implementation of - -`MerkleListIteratorBase.hash` - -#### Source - -[lib/provable/merkle-list.ts:420](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L420) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:722](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L722) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/merkle-list.ts:725](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L725) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, value: any) => Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:721](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L721) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/merkle-list.ts:724](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L724) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleListIterator -``` - -#### Returns - -*typeof* [`MerkleListIterator`](MerkleListIterator.mdx) - -#### Source - -[lib/provable/merkle-list.ts:727](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L727) - -*** - -### Unsafe - -```ts -get Unsafe(): { - "next": { - "element": T; - "isDummy": Bool; - }; - "previous": { - "element": T; - "isDummy": Bool; - }; -} -``` - -Low-level APIs for advanced uses - -#### Returns - -```ts -{ - "next": { - "element": T; - "isDummy": Bool; - }; - "previous": { - "element": T; - "isDummy": Bool; - }; -} -``` - -##### next() - -Version of next which doesn't guarantee anything about -the returned element in case the iterator is at the end. - -Instead, the `isDummy` flag is also returned so that this case can -be handled in a custom way. - -###### Returns - -```ts -{ - "element": T; - "isDummy": Bool; -} -``` - -###### element - -```ts -element: T; -``` - -###### isDummy - -```ts -isDummy: Bool; -``` - -##### previous() - -Version of previous which doesn't guarantee anything about -the returned element in case the iterator is at the start. - -Instead, the `isDummy` flag is also returned so that this case can -be handled in a custom way. - -###### Returns - -```ts -{ - "element": T; - "isDummy": Bool; -} -``` - -###### element - -```ts -element: T; -``` - -###### isDummy - -```ts -isDummy: Bool; -``` - -#### Source - -[lib/provable/merkle-list.ts:556](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L556) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:744](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L744) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:739](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L739) - -## Methods - -### \_index() - -```ts -_index(direction: "next" | "previous", i?: number): number -``` - -#### Parameters - -• **direction**: `"next"` \| `"previous"` - -• **i?**: `number` - -#### Returns - -`number` - -#### Source - -[lib/provable/merkle-list.ts:483](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L483) - -*** - -### \_updateIndex() - -```ts -_updateIndex(direction: "next" | "previous"): void -``` - -#### Parameters - -• **direction**: `"next"` \| `"previous"` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:491](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L491) - -*** - -### assertAtEnd() - -```ts -assertAtEnd(message?: string): void -``` - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:452](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L452) - -*** - -### assertAtStart() - -```ts -assertAtStart(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:430](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L430) - -*** - -### clone() - -```ts -clone(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:613](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L613) - -*** - -### isAtEnd() - -```ts -isAtEnd(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:434](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L434) - -*** - -### isAtStart() - -```ts -isAtStart(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:459](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L459) - -*** - -### jumpToEnd() - -```ts -jumpToEnd(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:438](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L438) - -*** - -### jumpToEndIf() - -```ts -jumpToEndIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:443](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L443) - -*** - -### jumpToStart() - -```ts -jumpToStart(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L463) - -*** - -### jumpToStartIf() - -```ts -jumpToStartIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:470](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L470) - -*** - -### next() - -```ts -next(): T -``` - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:529](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L529) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: T): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: `T` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:731](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L731) - -*** - -### previous() - -```ts -previous(): T -``` - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:498](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L498) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleListIterator & { - "empty": () => MerkleListIterator; - "from": (array: T[]) => MerkleListIterator; - "provable": ProvableHashable>; - "startIterating": (list: MerkleListBase) => MerkleListIterator; - "startIteratingFromLast": (list: MerkleListBase) => MerkleListIterator; -} -``` - -Create a Merkle array type - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleListIterator`](MerkleListIterator.mdx) & \{ - `"empty"`: () => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>\>; - `"startIterating"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"startIteratingFromLast"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/merkle-list.ts:627](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L627) - -*** - -### createFromList() - -```ts -static createFromList(merkleList: typeof MerkleList): (value: MerkleListIteratorBase) => MerkleListIterator & { - "empty": () => MerkleListIterator; - "from": (array: T[]) => MerkleListIterator; - "provable": ProvableHashable>; - "startIterating": (list: MerkleListBase) => MerkleListIterator; - "startIteratingFromLast": (list: MerkleListBase) => MerkleListIterator; -} -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **merkleList**: *typeof* [`MerkleList`](MerkleList.mdx) - -#### Returns - -(`value`: [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> & \{ - `"empty"`: () => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>\>; - `"startIterating"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"startIteratingFromLast"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/merkle-list.ts:712](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L712) diff --git a/docs/zkapps/o1js-reference/classes/MerkleMap.mdx b/docs/zkapps/o1js-reference/classes/MerkleMap.mdx deleted file mode 100644 index c6db5f369..000000000 --- a/docs/zkapps/o1js-reference/classes/MerkleMap.mdx +++ /dev/null @@ -1,186 +0,0 @@ -## Constructors - -### new MerkleMap() - -```ts -new MerkleMap(): MerkleMap -``` - -Creates a new, empty Merkle Map. - -#### Returns - -[`MerkleMap`](MerkleMap.mdx) - -A new MerkleMap - -#### Example - -```ts -const merkleMap = new MerkleMap(); -``` - -#### Source - -[lib/provable/merkle-map.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L21) - -## Properties - -### tree - -```ts -tree: MerkleTree; -``` - -#### Source - -[lib/provable/merkle-map.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L11) - -## Methods - -### \_keyToIndex() - -```ts -_keyToIndex(key: Field): bigint -``` - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/merkle-map.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L25) - -*** - -### get() - -```ts -get(key: Field): Field -``` - -Returns a value given a key. Values are by default Field(0). - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to get the value from. - -#### Returns - -[`Field`](Field.mdx) - -The value stored at the key. - -#### Example - -```ts -const key = Field(5); -const value = merkleMap.get(key); -console.log(value); // Output: the value at key 5 or Field(0) if key does not exist -``` - -#### Source - -[lib/provable/merkle-map.ts:71](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L71) - -*** - -### getRoot() - -```ts -getRoot(): Field -``` - -Returns the root of the Merkle Map. - -#### Returns - -[`Field`](Field.mdx) - -The root of the Merkle Map. - -#### Example - -```ts -const root = merkleMap.getRoot(); -``` - -#### Source - -[lib/provable/merkle-map.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L84) - -*** - -### getWitness() - -```ts -getWitness(key: Field): MerkleMapWitness -``` - -Returns a circuit-compatible witness (also known as [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof)) for the given key. - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to make a witness for. - -#### Returns - -[`MerkleMapWitness`](MerkleMapWitness.mdx) - -A MerkleMapWitness, which can be used to assert changes to the MerkleMap, and the witness's key. - -#### Example - -```ts -const key = Field(5); -const witness = merkleMap.getWitness(key); -``` - -#### Source - -[lib/provable/merkle-map.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L98) - -*** - -### set() - -```ts -set(key: Field, value: Field): void -``` - -Sets a key of the merkle map to a given value. - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to set in the map. - -• **value**: [`Field`](Field.mdx) - -The value to set. - -#### Returns - -`void` - -#### Example - -```ts -const key = Field(5); -const value = Field(10); -merkleMap.set(key, value); -``` - -#### Source - -[lib/provable/merkle-map.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L55) diff --git a/docs/zkapps/o1js-reference/classes/MerkleMapWitness.mdx b/docs/zkapps/o1js-reference/classes/MerkleMapWitness.mdx deleted file mode 100644 index ba4493ef8..000000000 --- a/docs/zkapps/o1js-reference/classes/MerkleMapWitness.mdx +++ /dev/null @@ -1,601 +0,0 @@ -## Extends - -- `CircuitValue` - -## Constructors - -### new MerkleMapWitness() - -```ts -new MerkleMapWitness(isLefts: Bool[], siblings: Field[]): MerkleMapWitness -``` - -#### Parameters - -• **isLefts**: [`Bool`](Bool.mdx)[] - -• **siblings**: [`Field`](Field.mdx)[] - -#### Returns - -[`MerkleMapWitness`](MerkleMapWitness.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/merkle-map.ts:110](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L110) - -## Properties - -### isLefts - -```ts -isLefts: Bool[]; -``` - -#### Source - -[lib/provable/merkle-map.ts:107](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L107) - -*** - -### siblings - -```ts -siblings: Field[]; -``` - -#### Source - -[lib/provable/merkle-map.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L108) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### computeRootAndKey() - -```ts -computeRootAndKey(value: Field): Field[] -``` - -Computes the merkle tree root for a given value and the key for this witness - -#### Parameters - -• **value**: [`Field`](Field.mdx) - -The value to compute the root for. - -#### Returns - -[`Field`](Field.mdx)[] - -A tuple of the computed merkle root, and the key that is connected to the path updated by this witness. - -#### Source - -[lib/provable/merkle-map.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L121) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) diff --git a/docs/zkapps/o1js-reference/classes/MerkleTree.mdx b/docs/zkapps/o1js-reference/classes/MerkleTree.mdx deleted file mode 100644 index cc9c4ead2..000000000 --- a/docs/zkapps/o1js-reference/classes/MerkleTree.mdx +++ /dev/null @@ -1,288 +0,0 @@ -A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in which every leaf is the cryptography hash of a piece of data, -and every node is the hash of the concatenation of its two child nodes. - -A Merkle Tree allows developers to easily and securely verify the integrity of large amounts of data. - -Take a look at our [documentation](https://docs.minaprotocol.com/en/zkapps) on how to use Merkle Trees in combination with zkApps and zero knowledge programming! - -Levels are indexed from leaves (level 0) to root (level N - 1). - -## Constructors - -### new MerkleTree() - -```ts -new MerkleTree(height: number): MerkleTree -``` - -Creates a new, empty [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree). - -#### Parameters - -• **height**: `number` - -The height of Merkle Tree. - -#### Returns - -[`MerkleTree`](MerkleTree.mdx) - -A new MerkleTree - -#### Source - -[lib/provable/merkle-tree.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L37) - -## Properties - -### height - -```ts -readonly height: number; -``` - -The height of Merkle Tree. - -#### Source - -[lib/provable/merkle-tree.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L37) - -*** - -### nodes - -```ts -nodes: Record> = {}; -``` - -#### Source - -[lib/provable/merkle-tree.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L29) - -*** - -### zeroes - -```ts -zeroes: Field[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L30) - -## Accessors - -### leafCount - -```ts -get leafCount(): bigint -``` - -Returns the amount of leaf nodes. - -#### Returns - -`bigint` - -Amount of leaf nodes. - -#### Source - -[lib/provable/merkle-tree.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L166) - -## Methods - -### clone() - -```ts -clone(): MerkleTree -``` - -Return a new MerkleTree with the same contents as this one. - -#### Returns - -[`MerkleTree`](MerkleTree.mdx) - -#### Source - -[lib/provable/merkle-tree.ts:48](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L48) - -*** - -### fill() - -```ts -fill(leaves: Field[]): void -``` - -Fills all leaves of the tree. - -#### Parameters - -• **leaves**: [`Field`](Field.mdx)[] - -Values to fill the leaves with. - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-tree.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L156) - -*** - -### getLeaf() - -```ts -getLeaf(key: bigint): Field -``` - -Returns a leaf at a given index. - -#### Parameters - -• **key**: `bigint` - -#### Returns - -[`Field`](Field.mdx) - -The data of the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:71](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L71) - -*** - -### getNode() - -```ts -getNode(level: number, index: bigint): Field -``` - -Returns a node which lives at a given index and level. - -#### Parameters - -• **level**: `number` - -Level of the node. - -• **index**: `bigint` - -Index of the node. - -#### Returns - -[`Field`](Field.mdx) - -The data of the node. - -#### Source - -[lib/provable/merkle-tree.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L62) - -*** - -### getRoot() - -```ts -getRoot(): Field -``` - -Returns the root of the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree). - -#### Returns - -[`Field`](Field.mdx) - -The root of the Merkle Tree. - -#### Source - -[lib/provable/merkle-tree.ts:79](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L79) - -*** - -### getWitness() - -```ts -getWitness(index: bigint): Witness -``` - -Returns the witness (also known as [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof)) for the leaf at the given index. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -#### Returns - -[`Witness`](../type-aliases/Witness.mdx) - -The witness that belongs to the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:117](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L117) - -*** - -### setLeaf() - -```ts -setLeaf(index: bigint, leaf: Field): void -``` - -Sets the value of a leaf node at a given index to a given value. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -• **leaf**: [`Field`](Field.mdx) - -New value. - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-tree.ts:94](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L94) - -*** - -### validate() - -```ts -validate(index: bigint): boolean -``` - -Checks if the witness that belongs to the leaf at the given index is a valid witness. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -#### Returns - -`boolean` - -True if the witness for the leaf node is valid. - -#### Source - -[lib/provable/merkle-tree.ts:139](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L139) diff --git a/docs/zkapps/o1js-reference/classes/Nullifier.mdx b/docs/zkapps/o1js-reference/classes/Nullifier.mdx deleted file mode 100644 index 2c5d78ddd..000000000 --- a/docs/zkapps/o1js-reference/classes/Nullifier.mdx +++ /dev/null @@ -1,1652 +0,0 @@ -Nullifiers are used as a public commitment to a specific anonymous account, -to forbid actions like double spending, or allow a consistent identity between anonymous actions. - -RFC: https://github.com/o1-labs/o1js/issues/756 - -Paper: https://eprint.iacr.org/2022/1255.pdf - -## Extends - -- \{ - `"private"`: \{ - `"c"`: `Field`; - `"g_r"`: `Group`; - `"h_m_pk_r"`: `Group`; - \}; - `"public"`: \{ - `"nullifier"`: `Group`; - `"s"`: `Scalar`; - \}; - `"publicKey"`: `Group`; - \} - -## Constructors - -### new Nullifier() - -```ts -new Nullifier(value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }): Nullifier -``` - -#### Parameters - -• **value** - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -[`Nullifier`](Nullifier.mdx) - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -#### c - -```ts -c: Field = Field; -``` - -#### g\_r - -```ts -g_r: Group = Group; -``` - -#### h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).private` - -#### Source - -[lib/provable/crypto/nullifier.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L26) - -*** - -### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -#### nullifier - -```ts -nullifier: Group = Group; -``` - -#### s - -```ts -s: Scalar = Scalar; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).public` - -#### Source - -[lib/provable/crypto/nullifier.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L22) - -*** - -### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).publicKey` - -#### Source - -[lib/provable/crypto/nullifier.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L21) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -`void` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - } | { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - } & (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.private?**= `undefined` - -• **value.private.c?**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r?**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r?**: [`Group`](Group.mdx)= `Group` - -• **value.public?**= `undefined` - -• **value.public.nullifier?**: [`Group`](Group.mdx)= `Group` - -• **value.public.s?**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey?**: [`Group`](Group.mdx)= `Group` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: string = Field; -``` - -##### private.g\_r - -```ts -g_r: { - "x": string; - "y": string; - } = Group; -``` - -##### private.g\_r.x - -```ts -x: string; -``` - -##### private.g\_r.y - -```ts -y: string; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: { - "x": string; - "y": string; - } = Group; -``` - -##### private.h\_m\_pk\_r.x - -```ts -x: string; -``` - -##### private.h\_m\_pk\_r.y - -```ts -y: string; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: { - "x": string; - "y": string; - } = Group; -``` - -##### public.nullifier.x - -```ts -x: string; -``` - -##### public.nullifier.y - -```ts -y: string; -``` - -##### public.s - -```ts -s: string = Scalar; -``` - -##### publicKey - -```ts -publicKey: { - "x": string; - "y": string; - } = Group; -``` - -##### publicKey.x - -```ts -x: string; -``` - -##### publicKey.y - -```ts -y: string; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: bigint = Field; -``` - -##### private.g\_r - -```ts -g_r: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### private.g\_r.x - -```ts -x: bigint; -``` - -##### private.g\_r.y - -```ts -y: bigint; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### private.h\_m\_pk\_r.x - -```ts -x: bigint; -``` - -##### private.h\_m\_pk\_r.y - -```ts -y: bigint; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### public.nullifier.x - -```ts -x: bigint; -``` - -##### public.nullifier.y - -```ts -y: bigint; -``` - -##### public.s - -```ts -s: bigint = Scalar; -``` - -##### publicKey - -```ts -publicKey: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### publicKey.x - -```ts -x: bigint; -``` - -##### publicKey.y - -```ts -y: bigint; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### assertUnused() - -```ts -assertUnused(witness: MerkleMapWitness, root: Field): void -``` - -Checks if the Nullifier has been used before. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -• **root**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Example - -```ts -// asserts that the nullifier has not been used before, throws an error otherwise -nullifier.assertUnused(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:128](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L128) - -*** - -### getPublicKey() - -```ts -getPublicKey(): PublicKey -``` - -Returns the [PublicKey](PublicKey.mdx) that is associated with this Nullifier. - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Example - -```ts -let pk = nullifier.getPublicKey(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L157) - -*** - -### isUnused() - -```ts -isUnused(witness: MerkleMapWitness, root: Field): Bool -``` - -Returns the state of the Nullifier. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -• **root**: [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// returns a Bool based on whether or not the nullifier has been used before -let isUnused = nullifier.isUnused(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L108) - -*** - -### key() - -```ts -key(): Field -``` - -The key of the nullifier, which belongs to a unique message and a public key. -Used as an index in Merkle trees. - -#### Returns - -[`Field`](Field.mdx) - -#### Example - -```ts -// returns the key of the nullifier which can be used as index in a Merkle tree/map -let key = nullifier.key(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:95](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L95) - -*** - -### setUsed() - -```ts -setUsed(witness: MerkleMapWitness): Field -``` - -Sets the Nullifier, returns the new Merkle root. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Example - -```ts -// calculates the new root of the Merkle tree in which the nullifier is set to used -let newRoot = nullifier.setUsed(witness); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L143) - -*** - -### verify() - -```ts -verify(message: Field[]): void -``` - -Verifies that the Nullifier belongs to a specific message. Throws an error if the Nullifier is incorrect. - -#### Parameters - -• **message**: [`Field`](Field.mdx)[] - -#### Returns - -`void` - -#### Example - -```ts -let nullifierMessage = [voteId, ...otherData]; -// throws an error if the nullifier is invalid or doesn't belong to this specific message -nullifier.verify(nullifierMessage); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L47) - -*** - -### createTestNullifier() - -```ts -static createTestNullifier(message: Field[], sk: PrivateKey): Nullifier -``` - -_Note_: This is *not* the recommended way to create a Nullifier in production. Please use mina-signer to create Nullifiers. -Also, this function cannot be run within provable code to avoid unintended creations of Nullifiers - a Nullifier should never be created inside proveable code (e.g. a smart contract) directly, but rather created inside the users wallet (or other secure enclaves, so the private key never leaves that enclave). - -PLUME: An ECDSA Nullifier Scheme for Unique -Pseudonymity within Zero Knowledge Proofs -https://eprint.iacr.org/2022/1255.pdf chapter 3 page 14 - -#### Parameters - -• **message**: [`Field`](Field.mdx)[] - -• **sk**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`Nullifier` - -#### Source - -[lib/provable/crypto/nullifier.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L170) - -*** - -### fromJSON() - -```ts -static fromJSON(json: Nullifier): Nullifier -``` - -#### Parameters - -• **json**: `Nullifier` - -#### Returns - -[`Nullifier`](Nullifier.mdx) - -#### Overrides - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromJSON` - -#### Source - -[lib/provable/crypto/nullifier.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L32) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/classes/Packed.mdx b/docs/zkapps/o1js-reference/classes/Packed.mdx deleted file mode 100644 index 40139cfce..000000000 --- a/docs/zkapps/o1js-reference/classes/Packed.mdx +++ /dev/null @@ -1,209 +0,0 @@ -`Packed` is a "packed" representation of any type `T`. - -"Packed" means that field elements which take up fewer than 254 bits are packed together into -as few field elements as possible. - -For example, you can pack several Bools (1 bit) or UInt32s (32 bits) into a single field element. - -Using a packed representation can make sense in provable code where the number of constraints -depends on the number of field elements per value. - -For example, `Provable.if(bool, x, y)` takes O(n) constraints, where n is the number of field -elements in x and y. - -Usage: - -```ts -// define a packed type from a type -let PackedType = Packed.create(MyType); - -// pack a value -let packed = PackedType.pack(value); - -// ... operations on packed values, more efficient than on plain values ... - -// unpack a value -let value = packed.unpack(); -``` - -**Warning**: Packing only makes sense where packing actually reduces the number of field elements. -For example, it doesn't make sense to pack a _single_ Bool, because it will be 1 field element before -and after packing. On the other hand, it does makes sense to pack a type that holds 10 or 20 Bools. - -**Warning**: When wrapping a type with `Packed`, make sure that that type is safe to automatically _pack_ -and _unpack_ in provable code. In particular, do not use `Packed` with types that define a custom `toInput()` -(specifying a certain bit packing) but no corresponding `check()` method (that constrains the bit lengths of the packed parts). - -## Type parameters - -• **T** - -## Constructors - -### new Packed() - -```ts -new Packed(packed: Field[], value: Unconstrained): Packed -``` - -#### Parameters - -• **packed**: [`Field`](Field.mdx)[] - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Packed`](Packed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L115) - -## Properties - -### packed - -```ts -packed: Field[]; -``` - -#### Source - -[lib/provable/packed.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L51) - -*** - -### value - -```ts -value: Unconstrained; -``` - -#### Source - -[lib/provable/packed.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L52) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/packed.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L144) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/packed.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L143) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof Packed -``` - -#### Returns - -*typeof* [`Packed`](Packed.mdx) - -#### Source - -[lib/provable/packed.ts:146](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L146) - -*** - -### innerProvable - -```ts -get static innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`any`\> - -#### Source - -[lib/provable/packed.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L150) - -## Methods - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/packed.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L138) - -*** - -### unpack() - -```ts -unpack(): T -``` - -Unpack a value. - -#### Returns - -`T` - -#### Source - -[lib/provable/packed.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L123) - -*** - -### create() - -```ts -static create(type: WithProvable>): typeof Packed & { - "provable": ProvableHashable, V>; - "pack": Packed; -} -``` - -Create a packed representation of `type`. You can then use `PackedType.pack(x)` to pack a value. - -#### Type parameters - -• **T** - -• **V** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`, `V`\>\> - -#### Returns - -*typeof* [`Packed`](Packed.mdx) & \{ - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`Packed`](Packed.mdx)\<`T`\>, `V`\>; - `"pack"`: [`Packed`](Packed.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/packed.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L57) diff --git a/docs/zkapps/o1js-reference/classes/PrivateKey.mdx b/docs/zkapps/o1js-reference/classes/PrivateKey.mdx deleted file mode 100644 index ba1b5aecd..000000000 --- a/docs/zkapps/o1js-reference/classes/PrivateKey.mdx +++ /dev/null @@ -1,785 +0,0 @@ -A signing key. You can generate one via [PrivateKey.random](PrivateKey.mdx#random). - -## Extends - -- `CircuitValue` - -## Constructors - -### new PrivateKey() - -```ts -new PrivateKey(s: Scalar): PrivateKey -``` - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/crypto/signature.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L25) - -## Properties - -### s - -```ts -s: Scalar; -``` - -#### Source - -[lib/provable/crypto/signature.ts:23](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L23) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [PrivateKey](PrivateKey.mdx) into a base58 string. - -#### Returns - -`string` - -a base58 encoded string - -#### Source - -[lib/provable/crypto/signature.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L105) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this [PrivateKey](PrivateKey.mdx) to a bigint - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/signature.ts:68](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L68) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toPublicKey() - -```ts -toPublicKey(): PublicKey -``` - -Derives the associated public key. - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L87) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromBase58() - -```ts -static fromBase58(privateKeyBase58: string): PrivateKey -``` - -Decodes a base58 string into a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **privateKeyBase58**: `string` - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:96](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L96) - -*** - -### fromBigInt() - -```ts -static fromBigInt(sk: bigint): PrivateKey -``` - -Create a [PrivateKey](PrivateKey.mdx) from a bigint - -**Warning**: Private keys should be sampled from secure randomness with sufficient entropy. -Be careful that you don't use this method to create private keys that were sampled insecurely. - -#### Parameters - -• **sk**: `bigint` - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:78](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L78) - -*** - -### fromBits() - -```ts -static fromBits(bs: Bool[]): PrivateKey -``` - -Deserializes a list of bits into a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **bs**: [`Bool`](Bool.mdx)[] - -a list of [Bool](../variables/Bool.mdx). - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:61](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L61) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, v: bigint | PrivateKey): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `bigint` \| [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/crypto/signature.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L121) - -*** - -### random() - -```ts -static random(): PrivateKey -``` - -Generate a random private key. - -You can obtain the associated public key via [toPublicKey](PrivateKey.mdx#topublickey). -And generate signatures via [Signature.create](Signature.mdx#create). - -Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, -and can be safely used to generate a real private key. - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a new [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L40) - -*** - -### randomKeypair() - -```ts -static randomKeypair(): { - "privateKey": PrivateKey; - "publicKey": PublicKey; -} -``` - -Create a random keypair `{ privateKey: PrivateKey, publicKey: PublicKey }`. - -Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, -and can be safely used to generate a real keypair. - -#### Returns - -```ts -{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -} -``` - -##### privateKey - -```ts -privateKey: PrivateKey; -``` - -##### publicKey - -```ts -publicKey: PublicKey; -``` - -#### Source - -[lib/provable/crypto/signature.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L50) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toBase58() - -```ts -static toBase58(privateKey: { - "s": Scalar; - }): string -``` - -Static method to encode a [PrivateKey](PrivateKey.mdx) into a base58 string. - -#### Parameters - -• **privateKey** - -• **privateKey.s**: [`Scalar`](Scalar.mdx) - -#### Returns - -`string` - -a base58 encoded string - -#### Source - -[lib/provable/crypto/signature.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L114) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(v: PrivateKey): bigint -``` - -#### Parameters - -• **v**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/crypto/signature.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L118) diff --git a/docs/zkapps/o1js-reference/classes/Proof.mdx b/docs/zkapps/o1js-reference/classes/Proof.mdx deleted file mode 100644 index dd8cbdc3e..000000000 --- a/docs/zkapps/o1js-reference/classes/Proof.mdx +++ /dev/null @@ -1,428 +0,0 @@ -## Extends - -- [`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -## Type parameters - -• **Input** - -• **Output** - -## Constructors - -### new Proof() - -```ts -new Proof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): Proof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`Proof`](Proof.mdx)\<`Input`, `Output`\> - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`constructor`](ProofBase.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`maxProofsVerified`](ProofBase.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`proof`](ProofBase.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInput`](ProofBase.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutput`](ProofBase.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`shouldVerify`](ProofBase.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInputType`](ProofBase.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutputType`](ProofBase.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`tag`](ProofBase.mdx#tag) - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`Proof`](Proof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L165) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`toJSON`](ProofBase.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L98) - -*** - -### verifyIf() - -```ts -verifyIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L101) - -*** - -### dummy() - -```ts -static dummy( - publicInput: Input, - publicOutput: OutPut, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -Dummy proof. This can be useful for ZkPrograms that handle the base case in the same -method as the inductive case, using a pattern like this: - -```ts -method(proof: SelfProof, isRecursive: Bool) { - proof.verifyIf(isRecursive); - // ... -} -``` - -To use such a method in the base case, you need a dummy proof: - -```ts -let dummy = await MyProof.dummy(publicInput, publicOutput, 1); -await myProgram.myMethod(dummy, Bool(false)); -``` - -**Note**: The types of `publicInput` and `publicOutput`, as well as the `maxProofsVerified` parameter, -must match your ZkProgram. `maxProofsVerified` is the maximum number of proofs that any of your methods take as arguments. - -#### Type parameters - -• **Input** - -• **OutPut** - -#### Parameters - -• **publicInput**: `Input` - -• **publicOutput**: `OutPut` - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<`Input`, `OutPut`\>\> - -#### Source - -[lib/proof-system/proof.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L150) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`Proof`](Proof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Source - -[lib/proof-system/proof.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L105) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) diff --git a/docs/zkapps/o1js-reference/classes/ProofBase.mdx b/docs/zkapps/o1js-reference/classes/ProofBase.mdx deleted file mode 100644 index da88aeb00..000000000 --- a/docs/zkapps/o1js-reference/classes/ProofBase.mdx +++ /dev/null @@ -1,263 +0,0 @@ -## Extended by - -- [`Proof`](Proof.mdx) -- [`DynamicProof`](DynamicProof.mdx) - -## Type parameters - -• **Input** = `any` - -• **Output** = `any` - -## Constructors - -### new ProofBase() - -```ts -new ProofBase(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): ProofBase -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): Provable -``` - -#### Returns - -`Provable`\<`any`\> - -#### Source - -[lib/proof-system/proof.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L66) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) diff --git a/docs/zkapps/o1js-reference/classes/PublicKey.mdx b/docs/zkapps/o1js-reference/classes/PublicKey.mdx deleted file mode 100644 index 98215f2fe..000000000 --- a/docs/zkapps/o1js-reference/classes/PublicKey.mdx +++ /dev/null @@ -1,790 +0,0 @@ -A public key, which is also an address on the Mina network. -You can derive a [PublicKey](PublicKey.mdx) directly from a [PrivateKey](PrivateKey.mdx). - -## Extends - -- `CircuitValue` - -## Constructors - -### new PublicKey() - -```ts -new PublicKey(...props: any[]): PublicKey -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### isOdd - -```ts -isOdd: Bool; -``` - -#### Source - -[lib/provable/crypto/signature.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L138) - -*** - -### x - -```ts -x: Field; -``` - -#### Source - -[lib/provable/crypto/signature.ts:137](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L137) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -Checks if a [PublicKey](PublicKey.mdx) is empty. - -#### Returns - -[`Bool`](Bool.mdx) - -a [Bool](../variables/Bool.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:193](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L193) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [PublicKey](PublicKey.mdx) in base58 format. - -#### Returns - -`string` - -a base58 encoded [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:211](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L211) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toGroup() - -```ts -toGroup(): Group -``` - -Returns the [Group](../variables/Group.mdx) representation of this [PublicKey](PublicKey.mdx). - -#### Returns - -[`Group`](Group.mdx) - -A [Group](../variables/Group.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L144) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -Creates an empty [PublicKey](PublicKey.mdx). - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -an empty [PublicKey](PublicKey.mdx) - -#### Overrides - -`CircuitValue.empty` - -#### Source - -[lib/provable/crypto/signature.ts:185](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L185) - -*** - -### from() - -```ts -static from(g: { - "isOdd": boolean | Bool; - "x": bigint | Field; - }): PublicKey -``` - -Creates a [PublicKey](PublicKey.mdx) from a JSON structure element. - -#### Parameters - -• **g** - -• **g.isOdd**: `boolean` \| [`Bool`](Bool.mdx) - -• **g.x**: `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L177) - -*** - -### fromBase58() - -```ts -static fromBase58(publicKeyBase58: string): PublicKey -``` - -Decodes a base58 encoded [PublicKey](PublicKey.mdx) into a [PublicKey](PublicKey.mdx). - -#### Parameters - -• **publicKeyBase58**: `string` - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:202](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L202) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromGroup() - -```ts -static fromGroup(__namedParameters: Group): PublicKey -``` - -Creates a [PublicKey](PublicKey.mdx) from a [Group](../variables/Group.mdx) element. - -#### Parameters - -• **\_\_namedParameters**: [`Group`](Group.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:161](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L161) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, publicKey: string): InstanceType -``` - -Deserializes a JSON string into a [PublicKey](PublicKey.mdx). - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **publicKey**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -a JSON string - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/crypto/signature.ts:239](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L239) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromPrivateKey() - -```ts -static fromPrivateKey(__namedParameters: PrivateKey): PublicKey -``` - -Derives a [PublicKey](PublicKey.mdx) from a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **\_\_namedParameters**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:169](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L169) - -*** - -### fromValue() - -```ts -static fromValue(this: T, __namedParameters: { - "isOdd": boolean | Bool; - "x": bigint | Field; -}): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **\_\_namedParameters** - -• **\_\_namedParameters.isOdd**: `boolean` \| [`Bool`](Bool.mdx) - -• **\_\_namedParameters.x**: `bigint` \| [`Field`](Field.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/crypto/signature.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L246) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toBase58() - -```ts -static toBase58(__namedParameters: PublicKey): string -``` - -Static method to encode a [PublicKey](PublicKey.mdx) into base58 format. - -#### Parameters - -• **\_\_namedParameters**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -`string` - -a base58 encoded [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L219) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(publicKey: PublicKey): string -``` - -Serializes a [PublicKey](PublicKey.mdx) into its JSON representation. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -`string` - -a JSON string - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/crypto/signature.ts:231](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L231) - -*** - -### toValue() - -```ts -static toValue(__namedParameters: PublicKey): { - "isOdd": boolean; - "x": bigint; -} -``` - -#### Parameters - -• **\_\_namedParameters**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -```ts -{ - "isOdd": boolean; - "x": bigint; -} -``` - -##### isOdd - -```ts -isOdd: boolean; -``` - -##### x - -```ts -x: bigint; -``` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/crypto/signature.ts:243](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L243) diff --git a/docs/zkapps/o1js-reference/classes/Scalar.mdx b/docs/zkapps/o1js-reference/classes/Scalar.mdx deleted file mode 100644 index 5566cdab9..000000000 --- a/docs/zkapps/o1js-reference/classes/Scalar.mdx +++ /dev/null @@ -1,689 +0,0 @@ -Represents a [Scalar](Scalar.mdx). - -## Implements - -- `ShiftedScalar` - -## Properties - -### high254 - -```ts -high254: Field; -``` - -#### Implementation of - -`ShiftedScalar.high254` - -#### Source - -[lib/provable/scalar.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L32) - -*** - -### lowBit - -```ts -lowBit: Bool; -``` - -We represent a scalar s in shifted form t = s - 2^255 mod q, -split into its low bit (t & 1) and high 254 bits (t >> 1). -The reason is that we can efficiently compute the scalar multiplication `(t + 2^255) * P = s * P`. - -#### Implementation of - -`ShiftedScalar.lowBit` - -#### Source - -[lib/provable/scalar.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L31) - -*** - -### ORDER - -```ts -static ORDER: bigint = Fq.modulus; -``` - -#### Source - -[lib/provable/scalar.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L34) - -## Methods - -### add() - -```ts -add(y: Scalar): Scalar -``` - -Add scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L143) - -*** - -### div() - -```ts -div(y: Scalar): Scalar -``` - -Divide scalar field elements. -Throws if the denominator is zero. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:180](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L180) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Check whether this [Scalar](Scalar.mdx) is a hard-coded constant in the constraint system. -If a [Scalar](Scalar.mdx) is constructed outside provable code, it is a constant. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/scalar.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L75) - -*** - -### mul() - -```ts -mul(y: Scalar): Scalar -``` - -Multiply scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:167](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L167) - -*** - -### neg() - -```ts -neg(): Scalar -``` - -Negate a scalar field element. - -**Warning**: This method is not available for provable code. - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L132) - -*** - -### sub() - -```ts -sub(y: Scalar): Scalar -``` - -Subtract scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L155) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this [Scalar](Scalar.mdx) into a bigint - -#### Returns - -`bigint` - -#### Source - -[lib/provable/scalar.ts:95](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L95) - -*** - -### toConstant() - -```ts -toConstant(): Scalar -``` - -Convert this [Scalar](Scalar.mdx) into a constant if it isn't already. - -If the scalar is a variable, this only works inside `asProver` or `witness` blocks. - -See FieldVar for an explanation of constants vs. variables. - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L87) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Serialize this Scalar to Field elements. - -**Warning**: This function is for internal usage. It returns 255 field elements -which represent the Scalar in a shifted, bitwise format. -The fields are not constrained to be boolean. - -Check out [Scalar.toFieldsCompressed](Scalar.mdx#tofieldscompressed) for a user-friendly serialization -that can be used outside proofs. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/scalar.ts:233](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L233) - -*** - -### toFieldsCompressed() - -```ts -toFieldsCompressed(): { - "field": Field; - "highBit": Bool; -} -``` - -Serialize a Scalar into a Field element plus one bit, where the bit is represented as a Bool. - -**Warning**: This method is not available for provable code. - -Note: Since the Scalar field is slightly larger than the base Field, an additional high bit -is needed to represent all Scalars. However, for a random Scalar, the high bit will be `false` with overwhelming probability. - -#### Returns - -```ts -{ - "field": Field; - "highBit": Bool; -} -``` - -##### field - -```ts -field: Field; -``` - -##### highBit - -```ts -highBit: Bool; -``` - -#### Source - -[lib/provable/scalar.ts:196](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L196) - -*** - -### toJSON() - -```ts -toJSON(): string -``` - -Serializes this Scalar to a string - -#### Returns - -`string` - -#### Source - -[lib/provable/scalar.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L325) - -*** - -### check() - -```ts -static check(s: Scalar): void -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/scalar.ts:287](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L287) - -*** - -### empty() - -```ts -static empty(): Scalar -``` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:337](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L337) - -*** - -### from() - -```ts -static from(s: string | number | bigint | Scalar): Scalar -``` - -Create a constant [Scalar](Scalar.mdx) from a bigint, number, string or Scalar. - -If the input is too large, it is reduced modulo the scalar field size. - -#### Parameters - -• **s**: `string` \| `number` \| `bigint` \| [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L46) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): Scalar -``` - -Creates a Scalar from an array of [Bool](Bool.mdx). -This method is provable. - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L105) - -*** - -### fromField() - -```ts -static fromField(s: Field): Scalar -``` - -Provable method to convert a [Field](Field.mdx) into a [Scalar](Scalar.mdx). - -This is always possible and unambiguous, since the scalar field is larger than the base field. - -#### Parameters - -• **s**: [`Field`](Field.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L66) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Scalar -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Creates a data structure from an array of serialized [Field](Field.mdx) elements. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L265) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): Scalar -``` - -Deserialize a JSON structure into a [Scalar](Scalar.mdx). -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Scalar. - -#### Parameters - -• **x**: `string` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:333](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L333) - -*** - -### fromShiftedScalar() - -```ts -static fromShiftedScalar(s: ShiftedScalar): Scalar -``` - -Provable method to convert a ShiftedScalar to a [Scalar](Scalar.mdx). - -#### Parameters - -• **s**: `ShiftedScalar` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L57) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint): Scalar -``` - -#### Parameters - -• **x**: `bigint` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:307](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L307) - -*** - -### random() - -```ts -static random(): Scalar -``` - -Returns a random [Scalar](Scalar.mdx). -Randomness can not be proven inside a circuit! - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L121) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns the size of this type in [Field](Field.mdx) elements. - -#### Returns - -`number` - -#### Source - -[lib/provable/scalar.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L280) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): never[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Serialize a [Scalar](Scalar.mdx) into its auxiliary data, which are empty. - -#### Returns - -`never`[] - -#### Source - -[lib/provable/scalar.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L256) - -*** - -### toCanonical() - -```ts -static toCanonical(s: Scalar): Scalar -``` - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:295](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L295) - -*** - -### toFields() - -```ts -static toFields(x: Scalar): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Serialize a [Scalar](Scalar.mdx) into an array of [Field](Field.mdx) elements. - -**Warning**: This function is for internal usage. It returns 255 field elements -which represent the Scalar in a shifted, bitwise format. -The fields are not constrained to be boolean. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/scalar.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L219) - -*** - -### toInput() - -```ts -static toInput(x: Scalar): HashInput -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -This function is the implementation of `ProvableExtended.toInput()` for the [Scalar](Scalar.mdx) type. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`HashInput` - -An object where the `fields` key is a [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/scalar.ts:247](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L247) - -*** - -### toJSON() - -```ts -static toJSON(x: Scalar): string -``` - -Serialize a [Scalar](Scalar.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Scalar. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`string` - -#### Source - -[lib/provable/scalar.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L317) - -*** - -### toValue() - -```ts -static toValue(x: Scalar): bigint -``` - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/scalar.ts:303](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L303) diff --git a/docs/zkapps/o1js-reference/classes/ScalarField.mdx b/docs/zkapps/o1js-reference/classes/ScalarField.mdx deleted file mode 100644 index 2958cfdde..000000000 --- a/docs/zkapps/o1js-reference/classes/ScalarField.mdx +++ /dev/null @@ -1,972 +0,0 @@ -ForeignField representing the scalar field of Pallas and the base field of Vesta - -## Extends - -- `UnreducedForeignField`\<`this`\> - -## Constructors - -### new ScalarField() - -```ts -new ScalarField(x: - | string - | number - | bigint - | Field3 - | ForeignField): ScalarField -``` - -Create a new [ForeignField](ForeignField.mdx) from a bigint, number, string or another ForeignField. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`ScalarField`](ScalarField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).constructor` - -#### Example - -```ts -let x = new ForeignField(5); -``` - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. - -- When constructing from another [ForeignField](ForeignField.mdx) instance, ensure the modulus matches. If not, check the modulus using `Gadgets.ForeignField.assertLessThan()` and handle appropriately. -- When constructing from a Field3 array, ensure all elements are valid Field elements and range checked. -- Ensure constants are correctly reduced to the modulus of the field. - -#### Source - -[lib/provable/foreign-field.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L101) - -## Properties - -### type - -```ts -type: "Unreduced" | "AlmostReduced" | "FullyReduced" = 'Unreduced'; -``` - -#### Inherited from - -`createForeignField(Fq.modulus).type` - -#### Source - -[lib/provable/foreign-field.ts:469](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L469) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`createForeignField(Fq.modulus).value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._provable` - -#### Source - -[lib/provable/foreign-field.ts:471](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L471) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`createForeignField(Fq.modulus)._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<`UnreducedForeignField`, `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:474](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L474) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`createForeignField(Fq.modulus).assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`createForeignField(Fq.modulus).isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`createForeignField(Fq.modulus).toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`createForeignField(Fq.modulus).toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`createForeignField(Fq.modulus).toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### toScalar() - -```ts -toScalar(): Scalar -``` - -Provable method to convert a [ScalarField](ScalarField.mdx) into a [Scalar](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar-field.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L16) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`createForeignField(Fq.modulus).assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Inherited from - -`createForeignField(Fq.modulus).check` - -#### Source - -[lib/provable/foreign-field.ts:479](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L479) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### fromScalar() - -```ts -static fromScalar(s: Scalar): ScalarField -``` - -Converts this [Scalar](Scalar.mdx) into a [ScalarField](ScalarField.mdx) - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`ScalarField`](ScalarField.mdx) - -#### Source - -[lib/provable/scalar-field.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L34) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### toScalar() - -```ts -static toScalar(field: ForeignField): Scalar -``` - -#### Parameters - -• **field**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar-field.ts:20](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L20) diff --git a/docs/zkapps/o1js-reference/classes/SelfProof.mdx b/docs/zkapps/o1js-reference/classes/SelfProof.mdx deleted file mode 100644 index f62ebd5e5..000000000 --- a/docs/zkapps/o1js-reference/classes/SelfProof.mdx +++ /dev/null @@ -1,444 +0,0 @@ -## Extends - -- [`Proof`](Proof.mdx)\<`PublicInput`, `PublicOutput`\> - -## Type parameters - -• **PublicInput** - -• **PublicOutput** - -## Constructors - -### new SelfProof() - -```ts -new SelfProof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": PublicInput; - "publicOutput": PublicOutput; -}): SelfProof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `PublicInput` - -• **\_\_namedParameters.publicOutput**: `PublicOutput` - -#### Returns - -[`SelfProof`](SelfProof.mdx)\<`PublicInput`, `PublicOutput`\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`constructor`](Proof.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`maxProofsVerified`](Proof.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`proof`](Proof.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: PublicInput; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicInput`](Proof.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: PublicOutput; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicOutput`](Proof.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`shouldVerify`](Proof.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicInputType`](Proof.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicOutputType`](Proof.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`tag`](Proof.mdx#tag) - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`Proof`](Proof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L165) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicFields`](Proof.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`Proof`](Proof.mdx).[`toJSON`](Proof.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(): void -``` - -#### Returns - -`void` - -#### Inherited from - -[`Proof`](Proof.mdx).[`verify`](Proof.mdx#verify) - -#### Source - -[lib/proof-system/proof.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L98) - -*** - -### verifyIf() - -```ts -verifyIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Inherited from - -[`Proof`](Proof.mdx).[`verifyIf`](Proof.mdx#verifyif) - -#### Source - -[lib/proof-system/proof.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L101) - -*** - -### dummy() - -```ts -static dummy( - publicInput: Input, - publicOutput: OutPut, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -Dummy proof. This can be useful for ZkPrograms that handle the base case in the same -method as the inductive case, using a pattern like this: - -```ts -method(proof: SelfProof, isRecursive: Bool) { - proof.verifyIf(isRecursive); - // ... -} -``` - -To use such a method in the base case, you need a dummy proof: - -```ts -let dummy = await MyProof.dummy(publicInput, publicOutput, 1); -await myProgram.myMethod(dummy, Bool(false)); -``` - -**Note**: The types of `publicInput` and `publicOutput`, as well as the `maxProofsVerified` parameter, -must match your ZkProgram. `maxProofsVerified` is the maximum number of proofs that any of your methods take as arguments. - -#### Type parameters - -• **Input** - -• **OutPut** - -#### Parameters - -• **publicInput**: `Input` - -• **publicOutput**: `OutPut` - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<`Input`, `OutPut`\>\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`dummy`](Proof.mdx#dummy) - -#### Source - -[lib/proof-system/proof.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L150) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`Proof`](Proof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`fromJSON`](Proof.mdx#fromjson) - -#### Source - -[lib/proof-system/proof.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L105) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicFields`](Proof.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) diff --git a/docs/zkapps/o1js-reference/classes/Sign.mdx b/docs/zkapps/o1js-reference/classes/Sign.mdx deleted file mode 100644 index 4c7b30bdf..000000000 --- a/docs/zkapps/o1js-reference/classes/Sign.mdx +++ /dev/null @@ -1,649 +0,0 @@ -## Extends - -- `CircuitValue` - -## Constructors - -### new Sign() - -```ts -new Sign(...props: any[]): Sign -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`Sign`](Sign.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:1034](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1034) - -## Accessors - -### minusOne - -```ts -get static minusOne(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1039](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1039) - -*** - -### one - -```ts -get static one(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1036](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1036) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### isNegative() - -```ts -isNegative(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:1071](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1071) - -*** - -### isPositive() - -```ts -isPositive(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:1068](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1068) - -*** - -### mul() - -```ts -mul(y: Sign): Sign -``` - -#### Parameters - -• **y**: [`Sign`](Sign.mdx) - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1065](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1065) - -*** - -### neg() - -```ts -neg(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1062](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1062) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:1075](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1075) - -*** - -### check() - -```ts -static check(x: Sign): void -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:1042](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1042) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.empty` - -#### Source - -[lib/provable/int.ts:1046](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1046) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: "Positive" | "Negative"): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `"Positive"` \| `"Negative"` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:1057](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1057) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | Sign): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`Sign`](Sign.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:1083](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1083) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: Sign): HashInput -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:1049](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1049) - -*** - -### toJSON() - -```ts -static toJSON(x: Sign): "Positive" | "Negative" -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`"Positive"` \| `"Negative"` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:1052](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1052) - -*** - -### toValue() - -```ts -static toValue(x: Sign): Sign -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`Sign` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:1079](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1079) diff --git a/docs/zkapps/o1js-reference/classes/Signature.mdx b/docs/zkapps/o1js-reference/classes/Signature.mdx deleted file mode 100644 index 937fdbac8..000000000 --- a/docs/zkapps/o1js-reference/classes/Signature.mdx +++ /dev/null @@ -1,667 +0,0 @@ -A Schnorr [Signature](Signature.mdx) over the Pasta Curves. - -## Extends - -- `CircuitValue` - -## Constructors - -### new Signature() - -```ts -new Signature(...props: any[]): Signature -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`Signature`](Signature.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### r - -```ts -r: Field; -``` - -#### Source - -[lib/provable/crypto/signature.ts:258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L258) - -*** - -### s - -```ts -s: Scalar; -``` - -#### Source - -[lib/provable/crypto/signature.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L259) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [Signature](Signature.mdx) in base58 format. - -#### Returns - -`string` - -#### Source - -[lib/provable/crypto/signature.ts:321](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L321) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### verify() - -```ts -verify(publicKey: PublicKey, msg: Field[]): Bool -``` - -Verifies the [Signature](Signature.mdx) using a message and the corresponding [PublicKey](PublicKey.mdx). - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **msg**: [`Field`](Field.mdx)[] - -#### Returns - -[`Bool`](Bool.mdx) - -a [Bool](../variables/Bool.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L296) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### create() - -```ts -static create(privKey: PrivateKey, msg: Field[]): Signature -``` - -Signs a message using a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **privKey**: [`PrivateKey`](PrivateKey.mdx) - -• **msg**: [`Field`](Field.mdx)[] - -#### Returns - -[`Signature`](Signature.mdx) - -a [Signature](Signature.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L265) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromBase58() - -```ts -static fromBase58(signatureBase58: string): Signature -``` - -Decodes a base58 encoded signature into a [Signature](Signature.mdx). - -#### Parameters - -• **signatureBase58**: `string` - -#### Returns - -[`Signature`](Signature.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L314) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) diff --git a/docs/zkapps/o1js-reference/classes/SmartContract.mdx b/docs/zkapps/o1js-reference/classes/SmartContract.mdx deleted file mode 100644 index 4cbc5e328..000000000 --- a/docs/zkapps/o1js-reference/classes/SmartContract.mdx +++ /dev/null @@ -1,894 +0,0 @@ -The main zkapp class. To write a zkapp, extend this class as such: - -``` -class YourSmartContract extends SmartContract { - // your smart contract code here -} -``` - -## Extends - -- `SmartContractBase` - -## Constructors - -### new SmartContract() - -```ts -new SmartContract(address: PublicKey, tokenId?: Field): SmartContract -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`SmartContract`](SmartContract.mdx) - -#### Overrides - -`SmartContractBase.constructor` - -#### Source - -[lib/mina/zkapp.ts:614](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L614) - -## Properties - -### address - -```ts -address: PublicKey; -``` - -#### Source - -[lib/mina/zkapp.ts:579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L579) - -*** - -### events - -```ts -events: {} = {}; -``` - -A list of event types that can be emitted using this.emitEvent()`. - -#### Index signature - - \[`key`: `string`\]: [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -#### Source - -[lib/mina/zkapp.ts:979](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L979) - -*** - -### sender - -```ts -sender: { - "self": SmartContract; - "getAndRequireSignature": PublicKey; - "getUnconstrained": PublicKey; -}; -``` - -#### self - -```ts -self: SmartContract; -``` - -#### getAndRequireSignature() - -Return a public key that is forced to sign this transaction. - -Note: This doesn't prove that the return value is the transaction sender, but it proves that whoever created -the transaction controls the private key associated with the returned public key. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### getUnconstrained() - -The public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -**Warning**: The fact that this public key equals the current sender is not part of the proof. -A malicious prover could use any other public key without affecting the validity of the proof. - -Consider using `this.sender.getAndRequireSignature()` if you need to prove that the sender controls this account. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Source - -[lib/mina/zkapp.ts:868](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L868) - -*** - -### tokenId - -```ts -tokenId: Field; -``` - -#### Source - -[lib/mina/zkapp.ts:580](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L580) - -*** - -### \_maxProofsVerified? - -```ts -static optional _maxProofsVerified: 0 | 2 | 1; -``` - -#### Source - -[lib/mina/zkapp.ts:599](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L599) - -*** - -### \_methodMetadata? - -```ts -static optional _methodMetadata: Record; -``` - -#### Source - -[lib/mina/zkapp.ts:589](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L589) - -*** - -### \_methods? - -```ts -static optional _methods: MethodInterface[]; -``` - -#### Source - -[lib/mina/zkapp.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L588) - -*** - -### \_provers? - -```ts -static optional _provers: Prover[]; -``` - -#### Source - -[lib/mina/zkapp.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L598) - -*** - -### \_verificationKey? - -```ts -static optional _verificationKey: { - "data": string; - "hash": Field; -}; -``` - -#### data - -```ts -data: string; -``` - -#### hash - -```ts -hash: Field; -``` - -#### Source - -[lib/mina/zkapp.ts:600](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L600) - -## Accessors - -### account - -```ts -get account(): Account -``` - -Current account of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Account` - -#### Source - -[lib/mina/zkapp.ts:920](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L920) - -*** - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -Balance of this [SmartContract](SmartContract.mdx). - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:973](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L973) - -*** - -### currentSlot - -```ts -get currentSlot(): CurrentSlot -``` - -Current global slot on the network. This is the slot at which this transaction is included in a block. Since we cannot know this value -at the time of transaction construction, this only has the `assertBetween()` method but no `get()` (impossible to implement) -or `assertEquals()` (confusing, because the developer can't know the exact slot at which this will be included either) - -#### Returns - -`CurrentSlot` - -#### Source - -[lib/mina/zkapp.ts:934](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L934) - -*** - -### network - -```ts -get network(): Network -``` - -Current network state of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Network` - -#### Source - -[lib/mina/zkapp.ts:926](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L926) - -*** - -### self - -```ts -get self(): AccountUpdate -``` - -Returns the current [AccountUpdate](AccountUpdate.mdx) associated to this [SmartContract](SmartContract.mdx). - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:823](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L823) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Approve an account update or tree / forest of updates. Doing this means you include the account update in the zkApp's public input, -which allows you to read and use its content in a proof, make assertions about it, and modify it. - -```ts -`@method` myApprovingMethod(update: AccountUpdate) { - this.approve(update); - - // read balance on the account (for example) - let balance = update.account.balance.getAndRequireEquals(); -} -``` - -Under the hood, "approving" just means that the account update is made a child of the zkApp in the -tree of account updates that forms the transaction. Similarly, if you pass in an [AccountUpdateTree](AccountUpdateTree.mdx), -the entire tree will become a subtree of the zkApp's account update. - -Passing in a forest is a bit different, because it means you set the entire children of the zkApp's account update -at once. `approve()` will fail if the zkApp's account update already has children, to prevent you from accidentally -excluding important information from the public input. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:959](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L959) - -*** - -### deploy() - -```ts -deploy(__namedParameters: { - "verificationKey": { - "data": string; - "hash": string | Field; - }; -}): Promise -``` - -Deploys a [SmartContract](SmartContract.mdx). - -```ts -let tx = await Mina.transaction(sender, async () => { - AccountUpdate.fundNewAccount(sender); - await zkapp.deploy(); -}); -tx.sign([senderKey, zkAppKey]); -``` - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.verificationKey?** - -• **\_\_namedParameters.verificationKey.data**: `string` - -• **\_\_namedParameters.verificationKey.hash**: `string` \| [`Field`](Field.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/zkapp.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L703) - -*** - -### emitEvent() - -```ts -emitEvent(type: K, event: any): void -``` - -Emits an event. Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:1030](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1030) - -*** - -### emitEventIf() - -```ts -emitEventIf( - condition: Bool, - type: K, - event: any): void -``` - -Conditionally emits an event. - -Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:987](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L987) - -*** - -### fetchEvents() - -```ts -fetchEvents(start?: UInt32, end?: UInt32): Promise<{ - "blockHash": string; - "blockHeight": UInt32; - "chainStatus": string; - "event": { - "data": ProvablePure; - "transactionInfo": { - "transactionHash": string; - "transactionMemo": string; - "transactionStatus": string; - }; - }; - "globalSlot": UInt32; - "parentBlockHash": string; - "type": string; -}[]> -``` - -Asynchronously fetches events emitted by this [SmartContract](SmartContract.mdx) and returns an array of events with their corresponding types. - -#### Parameters - -• **start?**: [`UInt32`](UInt32.mdx)= `undefined` - -The start height of the events to fetch. - -• **end?**: [`UInt32`](UInt32.mdx) - -The end height of the events to fetch. If not provided, fetches events up to the latest height. - -#### Returns - -`Promise`\<\{ - `"blockHash"`: `string`; - `"blockHeight"`: [`UInt32`](UInt32.mdx); - `"chainStatus"`: `string`; - `"event"`: \{ - `"data"`: [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`any`\>; - `"transactionInfo"`: \{ - `"transactionHash"`: `string`; - `"transactionMemo"`: `string`; - `"transactionStatus"`: `string`; - \}; - \}; - `"globalSlot"`: [`UInt32`](UInt32.mdx); - `"parentBlockHash"`: `string`; - `"type"`: `string`; - \}[]\> - -A promise that resolves to an array of objects, each containing the event type and event data for the specified range. - -#### Async - -#### Throws - -If there is an error fetching events from the Mina network. - -#### Example - -```ts -const startHeight = UInt32.from(1000); -const endHeight = UInt32.from(2000); -const events = await myZkapp.fetchEvents(startHeight, endHeight); -console.log(events); -``` - -#### Source - -[lib/mina/zkapp.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1047) - -*** - -### init() - -```ts -init(): void -``` - -`SmartContract.init()` will be called only when a [SmartContract](SmartContract.mdx) will be first deployed, not for redeployment. -This method can be overridden as follows -``` -class MyContract extends SmartContract { - init() { - super.init(); - this.account.permissions.set(...); - this.x.set(Field(1)); - } -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:771](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L771) - -*** - -### newSelf() - -```ts -newSelf(methodName?: string): AccountUpdate -``` - -Same as `SmartContract.self` but explicitly creates a new [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **methodName?**: `string` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:858](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L858) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if the account update created by this SmartContract should be signed by the account owner, -instead of authorized with a proof. - -Note that the smart contract's [Permissions](../variables/Permissions.mdx) determine which updates have to be (can be) authorized by a signature. - -If you only want to avoid creating proofs for quicker testing, we advise you to -use `LocalBlockchain({ proofsEnabled: false })` instead of `requireSignature()`. Setting -`proofsEnabled` to `false` allows you to test your transactions with the same authorization flow as in production, -with the only difference being that quick mock proofs are filled in instead of real proofs. - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:804](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L804) - -*** - -### send() - -```ts -send(args: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **args** - -• **args.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **args.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:963](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L963) - -*** - -### skipAuthorization() - -```ts -skipAuthorization(): void -``` - -Use this command if the account update created by this SmartContract should have no authorization on it, -instead of being authorized with a proof. - -WARNING: This is a method that should rarely be useful. If you want to disable proofs for quicker testing, take a look -at `LocalBlockchain({ proofsEnabled: false })`, which causes mock proofs to be created and doesn't require changing the -authorization flow. - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:816](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L816) - -*** - -### Proof() - -```ts -static Proof(): typeof __class -``` - -Returns a Proof type that belongs to this [SmartContract](SmartContract.mdx). - -#### Returns - -*typeof* `__class` - -#### Source - -[lib/mina/zkapp.ts:605](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L605) - -*** - -### analyzeMethods() - -```ts -static analyzeMethods(__namedParameters: { - "printSummary": false; - }): Promise> -``` - -This function is run internally before compiling a smart contract, to collect metadata about what each of your -smart contract methods does. - -For external usage, this function can be handy because calling it involves running all methods in the same "mode" as `compile()` does, -so it serves as a quick-to-run check for whether your contract can be compiled without errors, which can greatly speed up iterating. - -`analyzeMethods()` will also return the number of `rows` of each of your method circuits (i.e., the number of constraints in the underlying proof system), -which is a good indicator for circuit size and the time it will take to create proofs. -To inspect the created circuit in detail, you can look at the returned `gates`. - -Note: If this function was already called before, it will short-circuit and just return the metadata collected the first time. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.printSummary**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<`Record`\<`string`, \{ - `"actions"`: `number`; - `"digest"`: `string`; - `"gates"`: `Gate`[]; - `"rows"`: `number`; - \}\>\> - -an object, keyed by method name, each entry containing: - - `rows` the size of the constraint system created by this method - - `digest` a digest of the method circuit - - `actions` the number of actions the method dispatches - - `gates` the constraint system, represented as an array of gates - -#### Source - -[lib/mina/zkapp.ts:1178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1178) - -*** - -### compile() - -```ts -static compile(__namedParameters: { - "cache": Cache.FileSystemDefault; - "forceRecompile": false; - }): Promise<{ - "provers": Prover[]; - "verificationKey": { - "data": string; - "hash": Field; - }; - "verify": (statement: Statement, proof: unknown) => Promise; -}> -``` - -Compile your smart contract. - -This generates both the prover functions, needed to create proofs for running `@method`s, -and the verification key, needed to deploy your zkApp. - -Although provers and verification key are returned by this method, they are also cached internally and used when needed, -so you don't actually have to use the return value of this function. - -Under the hood, "compiling" means calling into the lower-level [Pickles and Kimchi libraries](https://o1-labs.github.io/proof-systems/kimchi/overview.html) to -create multiple prover & verifier indices (one for each smart contract method as part of a "step circuit" and one for the "wrap circuit" which recursively wraps -it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**, -up to several minutes if your circuit is large or your hardware is not optimal for these operations. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.cache**: `undefined` \| [`Cache`](../type-aliases/Cache.mdx)= `Cache.FileSystemDefault` - -• **\_\_namedParameters.forceRecompile**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"provers"`: `Prover`[]; - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](Field.mdx); - \}; - `"verify"`: (`statement`: `Statement`\<`FieldConst`\>, `proof`: `unknown`) => `Promise`\<`boolean`\>; - \}\> - -> ##### provers -> -> ```ts -> provers: Prover[]; -> ``` -> -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> -> ##### verify() -> -> ```ts -> verify: (statement: Statement, proof: unknown) => Promise; -> ``` -> -> ###### Parameters -> -> • **statement**: `Statement`\<`FieldConst`\> -> -> • **proof**: `unknown` -> -> ###### Returns -> -> `Promise`\<`boolean`\> -> - -#### Source - -[lib/mina/zkapp.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L642) - -*** - -### digest() - -```ts -static digest(): Promise -``` - -Computes a hash of your smart contract, which will reliably change _whenever one of your method circuits changes_. -This digest is quick to compute. it is designed to help with deciding whether a contract should be re-compiled or -a cached verification key can be used. - -#### Returns - -`Promise`\<`string`\> - -the digest, as a hex string - -#### Source - -[lib/mina/zkapp.ts:683](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L683) - -*** - -### runOutsideCircuit() - -```ts -static runOutsideCircuit(run: () => void): void -``` - -#### Parameters - -• **run** - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:1153](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1153) diff --git a/docs/zkapps/o1js-reference/classes/TokenAccountUpdateIterator.mdx b/docs/zkapps/o1js-reference/classes/TokenAccountUpdateIterator.mdx deleted file mode 100644 index f420208d3..000000000 --- a/docs/zkapps/o1js-reference/classes/TokenAccountUpdateIterator.mdx +++ /dev/null @@ -1,173 +0,0 @@ -Data structure to represent a forest of account updates that is being iterated over, -in the context of a token manager contract. - -The iteration is done in a depth-first manner. - -```ts -let forest: AccountUpdateForest = ...; -let tokenIterator = TokenAccountUpdateIterator.create(forest, tokenId); - -// process the first 5 account updates in the tree -for (let i = 0; i < 5; i++) { - let { accountUpdate, usesThisToken } = tokenIterator.next(); - // ... do something with the account update ... -} -``` - -**Important**: Since this is specifically used by token manager contracts to process their entire subtree -of account updates, the iterator skips subtrees that don't inherit token permissions and can therefore definitely not use the token. - -So, the assumption is that the consumer of this iterator is only interested in account updates that use the token. -We still can't avoid processing some account updates that don't use the token, therefore the iterator returns a boolean -`usesThisToken` alongside each account update. - -## Constructors - -### new TokenAccountUpdateIterator() - -```ts -new TokenAccountUpdateIterator( - forest: MerkleListIterator, - mayUseToken: MayUseToken, - selfToken: Field): TokenAccountUpdateIterator -``` - -#### Parameters - -• **forest**: [`MerkleListIterator`](MerkleListIterator.mdx)\<`AccountUpdateTreeBase`\> - -• **mayUseToken**: `MayUseToken` - -• **selfToken**: [`Field`](Field.mdx) - -#### Returns - -[`TokenAccountUpdateIterator`](TokenAccountUpdateIterator.mdx) - -#### Source - -[lib/mina/token/forest-iterator.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L59) - -## Properties - -### currentLayer - -```ts -currentLayer: Layer; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L55) - -*** - -### selfToken - -```ts -selfToken: Field; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L57) - -*** - -### unfinishedParentLayers - -```ts -unfinishedParentLayers: MerkleList; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:56](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L56) - -## Methods - -### assertFinished() - -```ts -assertFinished(message?: string): void -``` - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/mina/token/forest-iterator.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L140) - -*** - -### next() - -```ts -next(): { - "accountUpdate": update; - "usesThisToken": Bool; -} -``` - -Make a single step along a tree of account updates. - -This function is guaranteed to visit each account update in the tree that uses the token -exactly once, when called repeatedly. - -The method makes a best effort to avoid visiting account updates that are not using the token, -and in particular, to avoid returning dummy updates. -However, neither can be ruled out. We're returning `{ update, usesThisToken: Bool }` and let the -caller handle the irrelevant case where `usesThisToken` is false. - -#### Returns - -```ts -{ - "accountUpdate": update; - "usesThisToken": Bool; -} -``` - -##### accountUpdate - -```ts -accountUpdate: AccountUpdate = update; -``` - -##### usesThisToken - -```ts -usesThisToken: Bool; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:88](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L88) - -*** - -### create() - -```ts -static create(forest: AccountUpdateForest, selfToken: Field): TokenAccountUpdateIterator -``` - -#### Parameters - -• **forest**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -• **selfToken**: [`Field`](Field.mdx) - -#### Returns - -[`TokenAccountUpdateIterator`](TokenAccountUpdateIterator.mdx) - -#### Source - -[lib/mina/token/forest-iterator.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L69) diff --git a/docs/zkapps/o1js-reference/classes/TokenContract.mdx b/docs/zkapps/o1js-reference/classes/TokenContract.mdx deleted file mode 100644 index 40240bd62..000000000 --- a/docs/zkapps/o1js-reference/classes/TokenContract.mdx +++ /dev/null @@ -1,1239 +0,0 @@ -Base token contract which -- implements the `Approvable` API, with the `approveBase()` method left to be defined by subclasses -- implements the `Transferable` API as a wrapper around the `Approvable` API - -## Extends - -- [`SmartContract`](SmartContract.mdx) - -## Constructors - -### new TokenContract() - -```ts -new TokenContract(address: PublicKey, tokenId?: Field): TokenContract -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`TokenContract`](TokenContract.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`constructor`](SmartContract.mdx#constructors) - -#### Source - -[lib/mina/zkapp.ts:614](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L614) - -## Properties - -### address - -```ts -address: PublicKey; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`address`](SmartContract.mdx#address) - -#### Source - -[lib/mina/zkapp.ts:579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L579) - -*** - -### events - -```ts -events: {} = {}; -``` - -A list of event types that can be emitted using this.emitEvent()`. - -#### Index signature - - \[`key`: `string`\]: [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`events`](SmartContract.mdx#events) - -#### Source - -[lib/mina/zkapp.ts:979](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L979) - -*** - -### sender - -```ts -sender: { - "self": SmartContract; - "getAndRequireSignature": PublicKey; - "getUnconstrained": PublicKey; -}; -``` - -#### self - -```ts -self: SmartContract; -``` - -#### getAndRequireSignature() - -Return a public key that is forced to sign this transaction. - -Note: This doesn't prove that the return value is the transaction sender, but it proves that whoever created -the transaction controls the private key associated with the returned public key. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### getUnconstrained() - -The public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -**Warning**: The fact that this public key equals the current sender is not part of the proof. -A malicious prover could use any other public key without affecting the validity of the proof. - -Consider using `this.sender.getAndRequireSignature()` if you need to prove that the sender controls this account. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`sender`](SmartContract.mdx#sender) - -#### Source - -[lib/mina/zkapp.ts:868](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L868) - -*** - -### tokenId - -```ts -tokenId: Field; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`tokenId`](SmartContract.mdx#tokenid) - -#### Source - -[lib/mina/zkapp.ts:580](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L580) - -*** - -### MAX\_ACCOUNT\_UPDATES - -```ts -static MAX_ACCOUNT_UPDATES: number = 9; -``` - -The maximum number of account updates using the token in a single -transaction that this contract supports. - -#### Source - -[lib/mina/token/token-contract.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L29) - -*** - -### \_maxProofsVerified? - -```ts -static optional _maxProofsVerified: 0 | 2 | 1; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_maxProofsVerified`](SmartContract.mdx#_maxproofsverified) - -#### Source - -[lib/mina/zkapp.ts:599](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L599) - -*** - -### \_methodMetadata? - -```ts -static optional _methodMetadata: Record; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_methodMetadata`](SmartContract.mdx#_methodmetadata) - -#### Source - -[lib/mina/zkapp.ts:589](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L589) - -*** - -### \_methods? - -```ts -static optional _methods: MethodInterface[]; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_methods`](SmartContract.mdx#_methods) - -#### Source - -[lib/mina/zkapp.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L588) - -*** - -### \_provers? - -```ts -static optional _provers: Prover[]; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_provers`](SmartContract.mdx#_provers) - -#### Source - -[lib/mina/zkapp.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L598) - -*** - -### \_verificationKey? - -```ts -static optional _verificationKey: { - "data": string; - "hash": Field; -}; -``` - -#### data - -```ts -data: string; -``` - -#### hash - -```ts -hash: Field; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_verificationKey`](SmartContract.mdx#_verificationkey) - -#### Source - -[lib/mina/zkapp.ts:600](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L600) - -## Accessors - -### account - -```ts -get account(): Account -``` - -Current account of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Account` - -#### Source - -[lib/mina/zkapp.ts:920](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L920) - -*** - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -Balance of this [SmartContract](SmartContract.mdx). - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:973](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L973) - -*** - -### currentSlot - -```ts -get currentSlot(): CurrentSlot -``` - -Current global slot on the network. This is the slot at which this transaction is included in a block. Since we cannot know this value -at the time of transaction construction, this only has the `assertBetween()` method but no `get()` (impossible to implement) -or `assertEquals()` (confusing, because the developer can't know the exact slot at which this will be included either) - -#### Returns - -`CurrentSlot` - -#### Source - -[lib/mina/zkapp.ts:934](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L934) - -*** - -### internal - -```ts -get internal(): { - "burn": AccountUpdate; - "mint": AccountUpdate; - "send": AccountUpdate; -} -``` - -Helper methods to use from within a token contract. - -#### Returns - -```ts -{ - "burn": AccountUpdate; - "mint": AccountUpdate; - "send": AccountUpdate; -} -``` - -##### burn() - -Burn token balance on `address`. Returns the burn account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.address**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -##### mint() - -Mints token balance to `address`. Returns the mint account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.address**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -##### send() - -Move token balance from `from` to `to`. Returns the `to` account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.from**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/token/token-contract.ts:77](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L77) - -*** - -### network - -```ts -get network(): Network -``` - -Current network state of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Network` - -#### Source - -[lib/mina/zkapp.ts:926](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L926) - -*** - -### self - -```ts -get self(): AccountUpdate -``` - -Returns the current [AccountUpdate](AccountUpdate.mdx) associated to this [SmartContract](SmartContract.mdx). - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:823](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L823) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Approve an account update or tree / forest of updates. Doing this means you include the account update in the zkApp's public input, -which allows you to read and use its content in a proof, make assertions about it, and modify it. - -```ts -`@method` myApprovingMethod(update: AccountUpdate) { - this.approve(update); - - // read balance on the account (for example) - let balance = update.account.balance.getAndRequireEquals(); -} -``` - -Under the hood, "approving" just means that the account update is made a child of the zkApp in the -tree of account updates that forms the transaction. Similarly, if you pass in an [AccountUpdateTree](AccountUpdateTree.mdx), -the entire tree will become a subtree of the zkApp's account update. - -Passing in a forest is a bit different, because it means you set the entire children of the zkApp's account update -at once. `approve()` will fail if the zkApp's account update already has children, to prevent you from accidentally -excluding important information from the public input. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`approve`](SmartContract.mdx#approve) - -#### Source - -[lib/mina/zkapp.ts:959](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L959) - -*** - -### approveAccountUpdate() - -```ts -approveAccountUpdate(accountUpdate: AccountUpdate | AccountUpdateTree): Promise -``` - -Approve a single account update (with arbitrarily many children). - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L144) - -*** - -### approveAccountUpdates() - -```ts -approveAccountUpdates(accountUpdates: (AccountUpdate | AccountUpdateTree)[]): Promise -``` - -Approve a list of account updates (with arbitrarily many children). - -#### Parameters - -• **accountUpdates**: ([`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx))[] - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L152) - -*** - -### approveBase() - -```ts -abstract approveBase(forest: AccountUpdateForest): Promise -``` - -#### Parameters - -• **forest**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L84) - -*** - -### checkZeroBalanceChange() - -```ts -checkZeroBalanceChange(updates: AccountUpdateForest): void -``` - -Use `forEachUpdate()` to prove that the total balance change of child account updates is zero. - -This is provided out of the box as it is both a good example, and probably the most common implementation, of `approveBase()`. - -#### Parameters - -• **updates**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/token/token-contract.ts:128](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L128) - -*** - -### deploy() - -```ts -deploy(args?: DeployArgs): Promise -``` - -Deploys a [TokenContract](TokenContract.mdx). - -In addition to base smart contract deployment, this adds two steps: -- set the `access` permission to `proofOrSignature()`, to prevent against unauthorized token operations - - not doing this would imply that anyone can bypass token contract authorization and simply mint themselves tokens -- require the zkapp account to be new, using the `isNew` precondition. - this guarantees that the access permission is set from the very start of the existence of this account. - creating the zkapp account before deployment would otherwise be a security vulnerability that is too easy to introduce. - -Note that because of the `isNew` precondition, the zkapp account must not be created prior to calling `deploy()`. - -If the contract needs to be re-deployed, you can switch off this behaviour by overriding the `isNew` precondition: -```ts -async deploy() { - await super.deploy(); - // DON'T DO THIS ON THE INITIAL DEPLOYMENT! - this.account.isNew.requireNothing(); -} -``` - -#### Parameters - -• **args?**: [`DeployArgs`](../type-aliases/DeployArgs.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Overrides - -[`SmartContract`](SmartContract.mdx).[`deploy`](SmartContract.mdx#deploy) - -#### Source - -[lib/mina/token/token-contract.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L52) - -*** - -### deriveTokenId() - -```ts -deriveTokenId(): Field -``` - -Returns the `tokenId` of the token managed by this contract. - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/token/token-contract.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L70) - -*** - -### emitEvent() - -```ts -emitEvent(type: K, event: any): void -``` - -Emits an event. Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`emitEvent`](SmartContract.mdx#emitevent) - -#### Source - -[lib/mina/zkapp.ts:1030](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1030) - -*** - -### emitEventIf() - -```ts -emitEventIf( - condition: Bool, - type: K, - event: any): void -``` - -Conditionally emits an event. - -Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`emitEventIf`](SmartContract.mdx#emiteventif) - -#### Source - -[lib/mina/zkapp.ts:987](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L987) - -*** - -### fetchEvents() - -```ts -fetchEvents(start?: UInt32, end?: UInt32): Promise<{ - "blockHash": string; - "blockHeight": UInt32; - "chainStatus": string; - "event": { - "data": ProvablePure; - "transactionInfo": { - "transactionHash": string; - "transactionMemo": string; - "transactionStatus": string; - }; - }; - "globalSlot": UInt32; - "parentBlockHash": string; - "type": string; -}[]> -``` - -Asynchronously fetches events emitted by this [SmartContract](SmartContract.mdx) and returns an array of events with their corresponding types. - -#### Parameters - -• **start?**: [`UInt32`](UInt32.mdx)= `undefined` - -The start height of the events to fetch. - -• **end?**: [`UInt32`](UInt32.mdx) - -The end height of the events to fetch. If not provided, fetches events up to the latest height. - -#### Returns - -`Promise`\<\{ - `"blockHash"`: `string`; - `"blockHeight"`: [`UInt32`](UInt32.mdx); - `"chainStatus"`: `string`; - `"event"`: \{ - `"data"`: [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`any`\>; - `"transactionInfo"`: \{ - `"transactionHash"`: `string`; - `"transactionMemo"`: `string`; - `"transactionStatus"`: `string`; - \}; - \}; - `"globalSlot"`: [`UInt32`](UInt32.mdx); - `"parentBlockHash"`: `string`; - `"type"`: `string`; - \}[]\> - -A promise that resolves to an array of objects, each containing the event type and event data for the specified range. - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`fetchEvents`](SmartContract.mdx#fetchevents) - -#### Async - -#### Throws - -If there is an error fetching events from the Mina network. - -#### Example - -```ts -const startHeight = UInt32.from(1000); -const endHeight = UInt32.from(2000); -const events = await myZkapp.fetchEvents(startHeight, endHeight); -console.log(events); -``` - -#### Source - -[lib/mina/zkapp.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1047) - -*** - -### forEachUpdate() - -```ts -forEachUpdate(updates: AccountUpdateForest, callback: (update: AccountUpdate, usesToken: Bool) => void): void -``` - -Iterate through the account updates in `updates` and apply `callback` to each. - -This method is provable and is suitable as a base for implementing `approveUpdates()`. - -#### Parameters - -• **updates**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -• **callback** - -#### Returns - -`void` - -#### Source - -[lib/mina/token/token-contract.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L91) - -*** - -### init() - -```ts -init(): void -``` - -`SmartContract.init()` will be called only when a [SmartContract](SmartContract.mdx) will be first deployed, not for redeployment. -This method can be overridden as follows -``` -class MyContract extends SmartContract { - init() { - super.init(); - this.account.permissions.set(...); - this.x.set(Field(1)); - } -} -``` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`init`](SmartContract.mdx#init) - -#### Source - -[lib/mina/zkapp.ts:771](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L771) - -*** - -### newSelf() - -```ts -newSelf(methodName?: string): AccountUpdate -``` - -Same as `SmartContract.self` but explicitly creates a new [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **methodName?**: `string` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`newSelf`](SmartContract.mdx#newself) - -#### Source - -[lib/mina/zkapp.ts:858](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L858) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if the account update created by this SmartContract should be signed by the account owner, -instead of authorized with a proof. - -Note that the smart contract's [Permissions](../variables/Permissions.mdx) determine which updates have to be (can be) authorized by a signature. - -If you only want to avoid creating proofs for quicker testing, we advise you to -use `LocalBlockchain({ proofsEnabled: false })` instead of `requireSignature()`. Setting -`proofsEnabled` to `false` allows you to test your transactions with the same authorization flow as in production, -with the only difference being that quick mock proofs are filled in instead of real proofs. - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`requireSignature`](SmartContract.mdx#requiresignature) - -#### Source - -[lib/mina/zkapp.ts:804](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L804) - -*** - -### send() - -```ts -send(args: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **args** - -• **args.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **args.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`send`](SmartContract.mdx#send) - -#### Source - -[lib/mina/zkapp.ts:963](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L963) - -*** - -### skipAuthorization() - -```ts -skipAuthorization(): void -``` - -Use this command if the account update created by this SmartContract should have no authorization on it, -instead of being authorized with a proof. - -WARNING: This is a method that should rarely be useful. If you want to disable proofs for quicker testing, take a look -at `LocalBlockchain({ proofsEnabled: false })`, which causes mock proofs to be created and doesn't require changing the -authorization flow. - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`skipAuthorization`](SmartContract.mdx#skipauthorization) - -#### Source - -[lib/mina/zkapp.ts:816](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L816) - -*** - -### transfer() - -```ts -transfer( - from: PublicKey | AccountUpdate, - to: PublicKey | AccountUpdate, -amount: number | bigint | UInt64): Promise -``` - -Transfer `amount` of tokens from `from` to `to`. - -#### Parameters - -• **from**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) - -• **to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) - -• **amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L164) - -*** - -### Proof() - -```ts -static Proof(): typeof __class -``` - -Returns a Proof type that belongs to this [SmartContract](SmartContract.mdx). - -#### Returns - -*typeof* `__class` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`Proof`](SmartContract.mdx#proof) - -#### Source - -[lib/mina/zkapp.ts:605](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L605) - -*** - -### analyzeMethods() - -```ts -static analyzeMethods(__namedParameters: { - "printSummary": false; - }): Promise> -``` - -This function is run internally before compiling a smart contract, to collect metadata about what each of your -smart contract methods does. - -For external usage, this function can be handy because calling it involves running all methods in the same "mode" as `compile()` does, -so it serves as a quick-to-run check for whether your contract can be compiled without errors, which can greatly speed up iterating. - -`analyzeMethods()` will also return the number of `rows` of each of your method circuits (i.e., the number of constraints in the underlying proof system), -which is a good indicator for circuit size and the time it will take to create proofs. -To inspect the created circuit in detail, you can look at the returned `gates`. - -Note: If this function was already called before, it will short-circuit and just return the metadata collected the first time. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.printSummary**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<`Record`\<`string`, \{ - `"actions"`: `number`; - `"digest"`: `string`; - `"gates"`: `Gate`[]; - `"rows"`: `number`; - \}\>\> - -an object, keyed by method name, each entry containing: - - `rows` the size of the constraint system created by this method - - `digest` a digest of the method circuit - - `actions` the number of actions the method dispatches - - `gates` the constraint system, represented as an array of gates - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`analyzeMethods`](SmartContract.mdx#analyzemethods) - -#### Source - -[lib/mina/zkapp.ts:1178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1178) - -*** - -### compile() - -```ts -static compile(__namedParameters: { - "cache": Cache.FileSystemDefault; - "forceRecompile": false; - }): Promise<{ - "provers": Prover[]; - "verificationKey": { - "data": string; - "hash": Field; - }; - "verify": (statement: Statement, proof: unknown) => Promise; -}> -``` - -Compile your smart contract. - -This generates both the prover functions, needed to create proofs for running `@method`s, -and the verification key, needed to deploy your zkApp. - -Although provers and verification key are returned by this method, they are also cached internally and used when needed, -so you don't actually have to use the return value of this function. - -Under the hood, "compiling" means calling into the lower-level [Pickles and Kimchi libraries](https://o1-labs.github.io/proof-systems/kimchi/overview.html) to -create multiple prover & verifier indices (one for each smart contract method as part of a "step circuit" and one for the "wrap circuit" which recursively wraps -it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**, -up to several minutes if your circuit is large or your hardware is not optimal for these operations. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.cache**: `undefined` \| [`Cache`](../type-aliases/Cache.mdx)= `Cache.FileSystemDefault` - -• **\_\_namedParameters.forceRecompile**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"provers"`: `Prover`[]; - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](Field.mdx); - \}; - `"verify"`: (`statement`: `Statement`\<`FieldConst`\>, `proof`: `unknown`) => `Promise`\<`boolean`\>; - \}\> - -> ##### provers -> -> ```ts -> provers: Prover[]; -> ``` -> -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> -> ##### verify() -> -> ```ts -> verify: (statement: Statement, proof: unknown) => Promise; -> ``` -> -> ###### Parameters -> -> • **statement**: `Statement`\<`FieldConst`\> -> -> • **proof**: `unknown` -> -> ###### Returns -> -> `Promise`\<`boolean`\> -> - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`compile`](SmartContract.mdx#compile) - -#### Source - -[lib/mina/zkapp.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L642) - -*** - -### digest() - -```ts -static digest(): Promise -``` - -Computes a hash of your smart contract, which will reliably change _whenever one of your method circuits changes_. -This digest is quick to compute. it is designed to help with deciding whether a contract should be re-compiled or -a cached verification key can be used. - -#### Returns - -`Promise`\<`string`\> - -the digest, as a hex string - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`digest`](SmartContract.mdx#digest) - -#### Source - -[lib/mina/zkapp.ts:683](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L683) - -*** - -### runOutsideCircuit() - -```ts -static runOutsideCircuit(run: () => void): void -``` - -#### Parameters - -• **run** - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`runOutsideCircuit`](SmartContract.mdx#runoutsidecircuit) - -#### Source - -[lib/mina/zkapp.ts:1153](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1153) diff --git a/docs/zkapps/o1js-reference/classes/TokenSymbol.mdx b/docs/zkapps/o1js-reference/classes/TokenSymbol.mdx deleted file mode 100644 index 8e017196c..000000000 --- a/docs/zkapps/o1js-reference/classes/TokenSymbol.mdx +++ /dev/null @@ -1,589 +0,0 @@ -## Extends - -- \{ - `"field"`: [`Field`](Field.mdx); - `"symbol"`: `string`; - \} - -## Constructors - -### new TokenSymbol() - -```ts -new TokenSymbol(value: { - "field": Field; - "symbol": string; - }): TokenSymbol -``` - -#### Parameters - -• **value** - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -[`TokenSymbol`](TokenSymbol.mdx) - -#### Inherited from - -`Struct(TokenSymbolPure).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### field - -```ts -field: Field; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).field` - -#### Source - -[lib/provable/crypto/poseidon.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L212) - -*** - -### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).symbol` - -#### Source - -[lib/provable/crypto/poseidon.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L212) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct(TokenSymbolPure)._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "field": Field; - "symbol": string; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -`void` - -#### Inherited from - -`Struct(TokenSymbolPure).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "field": Field; - "symbol": string; -}; -``` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[], aux: any[]) => { - "field": Field; - "symbol": string; -}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling [toFields](TokenSymbol.mdx#tofields) and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of [Field](Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L59) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: string) => { - "field": Field; - "symbol": string; -}; -``` - -#### Parameters - -• **x**: `string` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: string | { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; - } & (value: string | { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct(TokenSymbolPure).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "field": Field; - "symbol": string; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.field?**: [`Field`](Field.mdx) - -• **value.symbol?**: `string` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct(TokenSymbolPure).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "field": Field; - "symbol": string; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct(TokenSymbolPure).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "field": Field; - "symbol": string; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "field": Field; - "symbol": string; - }) => string; -``` - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -`string` - -#### Inherited from - -`Struct(TokenSymbolPure).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "field": Field; - "symbol": string; - }) => string; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -`string` - -#### Inherited from - -`Struct(TokenSymbolPure).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### from() - -```ts -static from(value: string | TokenSymbol): TokenSymbol -``` - -#### Parameters - -• **value**: `string` \| [`TokenSymbol`](TokenSymbol.mdx) - -#### Returns - -[`TokenSymbol`](TokenSymbol.mdx) - -#### Source - -[lib/provable/crypto/poseidon.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L259) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct(TokenSymbolPure).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/classes/UInt32.mdx b/docs/zkapps/o1js-reference/classes/UInt32.mdx deleted file mode 100644 index 04f8031ea..000000000 --- a/docs/zkapps/o1js-reference/classes/UInt32.mdx +++ /dev/null @@ -1,1456 +0,0 @@ -A 32 bit unsigned integer with values ranging from 0 to 4,294,967,295. - -## Extends - -- `CircuitValue` - -## Constructors - -### new UInt32() - -```ts -new UInt32(x: - | string - | number - | bigint - | FieldVar - | UInt32): UInt32 -``` - -Create a [UInt32](UInt32.mdx). -The max value of a [UInt32](UInt32.mdx) is `2^32 - 1 = UInt32.MAXINT()`. - -**Warning**: Cannot overflow, an error is thrown if the result is greater than UInt32.MAXINT() - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/int.ts:540](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L540) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:531](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L531) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 32; -``` - -#### Source - -[lib/provable/int.ts:532](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L532) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt32; -}; -``` - -#### fromField() - -Create a [UInt32](UInt32.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 32 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt32.from](UInt32.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:548](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L548) - -## Accessors - -### one - -```ts -get static one(): UInt32 -``` - -Static method to create a [UInt32](UInt32.mdx) with value `0`. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:570](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L570) - -*** - -### zero - -```ts -get static zero(): UInt32 -``` - -Static method to create a [UInt32](UInt32.mdx) with value `0`. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:563](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L563) - -## Methods - -### add() - -```ts -add(y: number | UInt32): UInt32 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:717](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L717) - -*** - -### addMod32() - -```ts -addMod32(y: UInt32): UInt32 -``` - -Addition modulo 2^32. Check Gadgets.addMod32 for a detailed description. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:643](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L643) - -*** - -### and() - -```ts -and(x: UInt32): UInt32 -``` - -Bitwise AND gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values below. - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```typescript -let a = UInt32.from(3); // ... 000011 -let b = UInt32.from(5); // ... 000101 - -let c = a.and(b, 2); // ... 000001 -c.assertEquals(1); -``` - -#### Source - -[lib/provable/int.ts:888](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L888) - -*** - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:975](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L975) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:989](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L989) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:952](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L952) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:924](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L924) - -*** - -### div() - -```ts -div(y: number | UInt32): UInt32 -``` - -Integer division. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -`z` such that `x * y <= x`. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:694](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L694) - -*** - -### divMod() - -```ts -divMod(y: string | number | UInt32): { - "quotient": UInt32; - "rest": UInt32; -} -``` - -Integer division with remainder. - -`x.divMod(y)` returns the quotient and the remainder. - -#### Parameters - -• **y**: `string` \| `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -```ts -{ - "quotient": UInt32; - "rest": UInt32; -} -``` - -##### quotient - -```ts -quotient: UInt32; -``` - -##### rest - -```ts -rest: UInt32; -``` - -#### Source - -[lib/provable/int.ts:652](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L652) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### greaterThan() - -```ts -greaterThan(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:968](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L968) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:982](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L982) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### leftShift() - -```ts -leftShift(bits: number): UInt32 -``` - -Performs a left shift operation on the provided [UInt32](UInt32.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -The operation expects the input to be range checked to 32 bit. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt32](UInt32.mdx) element to the left. The amount should be between 0 and 32 (or else the shift will fail). - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); // 12 in binary -const y = x.leftShift(2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:836](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L836) - -*** - -### lessThan() - -```ts -lessThan(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:940](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L940) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L912) - -*** - -### mod() - -```ts -mod(y: number | UInt32): UInt32 -``` - -Integer remainder. - -`x.mod(y)` returns the value `z` such that `0 <= z < y` and -`x - z` is divisible by `y`. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L703) - -*** - -### mul() - -```ts -mul(y: number | UInt32): UInt32 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:709](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L709) - -*** - -### not() - -```ts -not(): UInt32 -``` - -Bitwise NOT gate on [UInt32](UInt32.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate operates over 32 bit for UInt32 types. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -NOT is implemented as a subtraction of the input from the all one bitmask. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -// NOTing 4 bits with the unchecked version -let a = UInt32.from(0b0101); -let b = a.not(); - -console.log(b.toBigInt().toString(2)); -// 11111111111111111111111111111010 -``` - -#### Source - -[lib/provable/int.ts:781](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L781) - -*** - -### or() - -```ts -or(x: UInt32): UInt32 -``` - -Bitwise OR gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```typescript -let a = UInt32.from(3); // ... 000011 -let b = UInt32.from(5); // ... 000101 - -let c = a.or(b); // ... 000111 -c.assertEquals(7); -``` - -#### Source - -[lib/provable/int.ts:905](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L905) - -*** - -### rightShift() - -```ts -rightShift(bits: number): UInt32 -``` - -Performs a left right operation on the provided [UInt32](UInt32.mdx) element. -This operation is similar to the `>>` shift operation in JavaScript, -where bits are shifted to the right, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt32](UInt32.mdx) element to the right. The amount should be between 0 and 32 (or else the shift will fail). - -The operation expects the input to be range checked to 32 bit. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); // 12 in binary -const y = x.rightShift(2); // left shift by 2 bits -y.assertEquals(0b000011); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:859](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L859) - -*** - -### rotate() - -```ts -rotate(bits: number, direction: "left" | "right"): UInt32 -``` - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -To safely use `rotate()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **bits**: `number` - -amount of bits to rotate this [UInt32](UInt32.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); -const y = x.rotate(2, 'left'); -const z = x.rotate(2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); -``` - -#### Source - -[lib/provable/int.ts:813](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L813) - -*** - -### sub() - -```ts -sub(y: number | UInt32): UInt32 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:725](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L725) - -*** - -### toBigint() - -```ts -toBigint(): bigint -``` - -Turns the [UInt32](UInt32.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:582](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L582) - -*** - -### toBytes() - -```ts -toBytes(): [UInt8, UInt8, UInt8, UInt8] -``` - -Split a UInt32 into 4 UInt8s, in little-endian order. - -#### Returns - -[[`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx)] - -#### Source - -[lib/provable/int.ts:1006](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1006) - -*** - -### toBytesBE() - -```ts -toBytesBE(): [UInt8, UInt8, UInt8, UInt8] -``` - -Split a UInt32 into 4 UInt8s, in big-endian order. - -#### Returns - -[[`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx)] - -#### Source - -[lib/provable/int.ts:1013](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1013) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [UInt32](UInt32.mdx) into a string. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:576](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L576) - -*** - -### toUInt64() - -```ts -toUInt64(): UInt64 -``` - -Turns the [UInt32](UInt32.mdx) into a [UInt64](UInt64.mdx). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L588) - -*** - -### xor() - -```ts -xor(x: UInt32): UInt32 -``` - -Bitwise XOR gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -[UInt32](UInt32.mdx) element to compare. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -let a = UInt32.from(0b0101); -let b = UInt32.from(0b0011); - -let c = a.xor(b); -c.assertEquals(0b0110); -``` - -#### Source - -[lib/provable/int.ts:750](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L750) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt32 -``` - -Creates a [UInt32](UInt32.mdx) with a value of 4,294,967,295. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:636](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L636) - -*** - -### check() - -```ts -static check(x: UInt32): void -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:593](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L593) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: string | number | bigint | UInt32): UInt32 -``` - -Creates a new [UInt32](UInt32.mdx). - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:628](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L628) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: UInt8[]): UInt32 -``` - -Combine 4 UInt8s into a UInt32, in little-endian order. - -#### Parameters - -• **bytes**: [`UInt8`](UInt8.mdx)[] - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1020](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1020) - -*** - -### fromBytesBE() - -```ts -static fromBytesBE(bytes: UInt8[]): UInt32 -``` - -Combine 4 UInt8s into a UInt32, in big-endian order. - -#### Parameters - -• **bytes**: [`UInt8`](UInt8.mdx)[] - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1028](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1028) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): InstanceType -``` - -Decodes a JSON-like object into this structure. - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:609](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L609) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | UInt32): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`UInt32`](UInt32.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:997](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L997) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: UInt32): HashInput -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:596](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L596) - -*** - -### toJSON() - -```ts -static toJSON(x: UInt32): string -``` - -Encodes this structure into a JSON-like object. - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`string` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:602](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L602) - -*** - -### toValue() - -```ts -static toValue(x: UInt32): bigint -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:993](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L993) diff --git a/docs/zkapps/o1js-reference/classes/UInt64.mdx b/docs/zkapps/o1js-reference/classes/UInt64.mdx deleted file mode 100644 index cc0b463fc..000000000 --- a/docs/zkapps/o1js-reference/classes/UInt64.mdx +++ /dev/null @@ -1,1406 +0,0 @@ -A 64 bit unsigned integer with values ranging from 0 to 18,446,744,073,709,551,615. - -## Extends - -- `CircuitValue` - -## Constructors - -### new UInt64() - -```ts -new UInt64(x: - | string - | number - | bigint - | FieldVar - | UInt64 - | UInt32): UInt64 -``` - -Create a [UInt64](UInt64.mdx). -The max value of a [UInt64](UInt64.mdx) is `2^64 - 1 = UInt64.MAXINT()`. - -**Warning**: Cannot overflow, an error is thrown if the result is greater than UInt64.MAXINT() - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/int.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L40) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L31) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 64; -``` - -#### Source - -[lib/provable/int.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L32) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt64; -}; -``` - -#### fromField() - -Create a [UInt64](UInt64.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 64 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt64.from](UInt64.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:48](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L48) - -## Accessors - -### one - -```ts -get static one(): UInt64 -``` - -Static method to create a [UInt64](UInt64.mdx) with value `1`. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L69) - -*** - -### zero - -```ts -get static zero(): UInt64 -``` - -Static method to create a [UInt64](UInt64.mdx) with value `0`. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L63) - -## Methods - -### add() - -```ts -add(y: number | UInt64): UInt64 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L241) - -*** - -### addMod64() - -```ts -addMod64(y: UInt64): UInt64 -``` - -Addition modulo 2^64. Check Gadgets.addMod64 for a detailed description. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L163) - -*** - -### and() - -```ts -and(x: UInt64): UInt64 -``` - -Bitwise AND gadget on [UInt64](UInt64.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values below. - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```typescript -let a = UInt64.from(3); // ... 000011 -let b = UInt64.from(5); // ... 000101 - -let c = a.and(b); // ... 000001 -c.assertEquals(1); -``` - -#### Source - -[lib/provable/int.ts:411](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L411) - -*** - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L499) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:513](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L513) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:476](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L476) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L447) - -*** - -### div() - -```ts -div(y: number | UInt64): UInt64 -``` - -Integer division. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -`z` such that `z * y <= x`. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:215](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L215) - -*** - -### divMod() - -```ts -divMod(y: string | number | UInt64): { - "quotient": UInt64; - "rest": UInt64; -} -``` - -Integer division with remainder. - -`x.divMod(y)` returns the quotient and the remainder. - -#### Parameters - -• **y**: `string` \| `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -```ts -{ - "quotient": UInt64; - "rest": UInt64; -} -``` - -##### quotient - -```ts -quotient: UInt64; -``` - -##### rest - -```ts -rest: UInt64; -``` - -#### Source - -[lib/provable/int.ts:172](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L172) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### greaterThan() - -```ts -greaterThan(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L492) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:506](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L506) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### leftShift() - -```ts -leftShift(bits: number): UInt64 -``` - -Performs a left shift operation on the provided [UInt64](UInt64.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt64](UInt64.mdx) element to the left. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); // 12 in binary -const y = x.leftShift(2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:361](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L361) - -*** - -### lessThan() - -```ts -lessThan(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:464](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L464) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:435](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L435) - -*** - -### mod() - -```ts -mod(y: number | UInt64): UInt64 -``` - -Integer remainder. - -`x.mod(y)` returns the value `z` such that `0 <= z < y` and -`x - z` is divisible by `y`. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:225](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L225) - -*** - -### mul() - -```ts -mul(y: number | UInt64): UInt64 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:232](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L232) - -*** - -### not() - -```ts -not(): UInt64 -``` - -Bitwise NOT gate on [Field](../variables/Field.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate operates over 64 bit for UInt64 types. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -NOT is implemented as a subtraction of the input from the all one bitmask - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -// NOTing 4 bits with the unchecked version -let a = UInt64.from(0b0101); -let b = a.not(false); - -console.log(b.toBigInt().toString(2)); -// 1111111111111111111111111111111111111111111111111111111111111010 - -``` - -#### Source - -[lib/provable/int.ts:308](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L308) - -*** - -### or() - -```ts -or(x: UInt64): UInt64 -``` - -Bitwise OR gadget on [UInt64](UInt64.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```typescript -let a = UInt64.from(3); // ... 000011 -let b = UInt64.from(5); // ... 000101 - -let c = a.or(b); // ... 000111 -c.assertEquals(7); -``` - -#### Source - -[lib/provable/int.ts:428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L428) - -*** - -### rightShift() - -```ts -rightShift(bits: number): UInt64 -``` - -Performs a right shift operation on the provided [UInt64](UInt64.mdx) element. -This operation is similar to the `>>` shift operation in JavaScript, -where bits are shifted to the right, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt64](UInt64.mdx) element to the right. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); // 12 in binary -const y = x.rightShift(2); // right shift by 2 bits -y.assertEquals(0b000011); // 3 in binary -``` - -#### Source - -[lib/provable/int.ts:382](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L382) - -*** - -### rotate() - -```ts -rotate(bits: number, direction: "left" | "right"): UInt64 -``` - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -To safely use `rotate()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **bits**: `number` - -amount of bits to rotate this [UInt64](UInt64.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); -const y = x.rotate(2, 'left'); -const z = x.rotate(2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); -``` - -#### Source - -[lib/provable/int.ts:340](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L340) - -*** - -### sub() - -```ts -sub(y: number | UInt64): UInt64 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L250) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Turns the [UInt64](UInt64.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L83) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [UInt64](UInt64.mdx) into a string. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L76) - -*** - -### toUInt32() - -```ts -toUInt32(): UInt32 -``` - -Turns the [UInt64](UInt64.mdx) into a [UInt32](UInt32.mdx), asserting that it fits in 32 bits. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:90](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L90) - -*** - -### toUInt32Clamped() - -```ts -toUInt32Clamped(): UInt32 -``` - -Turns the [UInt64](UInt64.mdx) into a [UInt32](UInt32.mdx), clamping to the 32 bits range if it's too large. -```ts -UInt64.from(4294967296).toUInt32Clamped().toString(); // "4294967295" -``` - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L102) - -*** - -### xor() - -```ts -xor(x: UInt64): UInt64 -``` - -Bitwise XOR gadget on [Field](../variables/Field.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -[UInt64](UInt64.mdx) element to XOR. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -let a = UInt64.from(0b0101); -let b = UInt64.from(0b0011); - -let c = a.xor(b); -c.assertEquals(0b0110); -``` - -#### Source - -[lib/provable/int.ts:275](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L275) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt64 -``` - -Creates a [UInt64](UInt64.mdx) with a value of 18,446,744,073,709,551,615. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L156) - -*** - -### check() - -```ts -static check(x: UInt64): void -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:112](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L112) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | UInt64 - | UInt32): UInt64 -``` - -Creates a new [UInt64](UInt64.mdx). - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L148) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): InstanceType -``` - -Decodes a JSON-like object into this structure. - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L130) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | UInt64): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`UInt64`](UInt64.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:521](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L521) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: UInt64): HashInput -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:116](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L116) - -*** - -### toJSON() - -```ts -static toJSON(x: UInt64): string -``` - -Encodes this structure into a JSON-like object. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`string` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L123) - -*** - -### toValue() - -```ts -static toValue(x: UInt64): bigint -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L517) diff --git a/docs/zkapps/o1js-reference/classes/UInt8.mdx b/docs/zkapps/o1js-reference/classes/UInt8.mdx deleted file mode 100644 index f2efccb3b..000000000 --- a/docs/zkapps/o1js-reference/classes/UInt8.mdx +++ /dev/null @@ -1,1215 +0,0 @@ -A 8 bit unsigned integer with values ranging from 0 to 255. - -## Extends - -- \{ - `"value"`: `Field`; - \} - -## Constructors - -### new UInt8() - -```ts -new UInt8(x: number | bigint | FieldVar | UInt8): UInt8 -``` - -Create a [UInt8](UInt8.mdx) from a bigint or number. -The max value of a [UInt8](UInt8.mdx) is `2^8 - 1 = 255`. - -**Warning**: Cannot overflow past 255, an error is thrown if the result is greater than 255. - -#### Parameters - -• **x**: `number` \| `bigint` \| `FieldVar` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Overrides - -`Struct({ - value: Field, -}).constructor` - -#### Source - -[lib/provable/int.ts:1456](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1456) - -## Properties - -### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).value` - -#### Source - -[lib/provable/int.ts:1446](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1446) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 8; -``` - -#### Source - -[lib/provable/int.ts:1448](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1448) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt8; -}; -``` - -#### fromField() - -Create a [UInt8](UInt8.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 8 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt8.from](UInt8.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1462](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1462) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - value: Field, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### empty() - -```ts -static empty: () => { - "value": Field; -}; -``` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "value": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: `string`= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "value": Field; - } | { - "value": Field; - }) => { - "value": Field; - } & (value: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - value: Field, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "value": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.value?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - value: Field, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "value": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - value: Field, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: string = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: bigint = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Accessors - -### one - -```ts -get static one(): UInt8 -``` - -Static method to create a [UInt8](UInt8.mdx) with value `1`. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1483](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1483) - -*** - -### zero - -```ts -get static zero(): UInt8 -``` - -Static method to create a [UInt8](UInt8.mdx) with value `0`. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1477](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1477) - -## Methods - -### add() - -```ts -add(y: number | bigint | UInt8): UInt8 -``` - -Add a [UInt8](UInt8.mdx) to another [UInt8](UInt8.mdx) without allowing overflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(3); -const sum = x.add(5); -sum.assertEquals(8); -``` - -#### Throws - -if the result is greater than 255. - -#### Source - -[lib/provable/int.ts:1499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1499) - -*** - -### assertEquals() - -```ts -assertEquals(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is equal another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1765](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1765) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is greater than another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1741](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1741) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is greater than or equal to another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1753](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1753) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is less than another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1659](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1659) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is less than or equal to another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1684](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1684) - -*** - -### div() - -```ts -div(y: number | bigint | UInt8): UInt8 -``` - -Divide a [UInt8](UInt8.mdx) by another [UInt8](UInt8.mdx). -This is integer division that rounds down. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(7); -const quotient = x.div(2); -quotient.assertEquals(3); -``` - -#### Source - -[lib/provable/int.ts:1552](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1552) - -*** - -### divMod() - -```ts -divMod(y: number | bigint | UInt8): { - "quotient": UInt8; - "remainder": UInt8; -} -``` - -Get the quotient and remainder of a [UInt8](UInt8.mdx) divided by another [UInt8](UInt8.mdx): - -`x == y * q + r`, where `0 <= r < y`. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -a [UInt8](UInt8.mdx) to get the quotient and remainder of another [UInt8](UInt8.mdx). - -#### Returns - -```ts -{ - "quotient": UInt8; - "remainder": UInt8; -} -``` - -The quotient `q` and remainder `r`. - -##### quotient - -```ts -quotient: UInt8; -``` - -##### remainder - -```ts -remainder: UInt8; -``` - -#### Source - -[lib/provable/int.ts:1579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1579) - -*** - -### greaterThan() - -```ts -greaterThan(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is greater than another [UInt8](UInt8.mdx). -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// 5 > 3 -UInt8.from(5).greaterThan(3); -``` - -#### Source - -[lib/provable/int.ts:1715](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1715) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is greater than or equal another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// 3 >= 3 -UInt8.from(3).greaterThanOrEqual(3); -``` - -#### Source - -[lib/provable/int.ts:1729](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1729) - -*** - -### lessThan() - -```ts -lessThan(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is less than another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -UInt8.from(2).lessThan(UInt8.from(3)); -``` - -#### Source - -[lib/provable/int.ts:1638](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1638) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is less than or equal to another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -UInt8.from(3).lessThanOrEqual(UInt8.from(5)); -``` - -#### Source - -[lib/provable/int.ts:1616](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1616) - -*** - -### mod() - -```ts -mod(y: number | bigint | UInt8): UInt8 -``` - -Get the remainder a [UInt8](UInt8.mdx) of division of another [UInt8](UInt8.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(50); -const mod = x.mod(30); -mod.assertEquals(20); -``` - -#### Source - -[lib/provable/int.ts:1566](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1566) - -*** - -### mul() - -```ts -mul(y: number | bigint | UInt8): UInt8 -``` - -Multiply a [UInt8](UInt8.mdx) by another [UInt8](UInt8.mdx) without allowing overflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(3); -const product = x.mul(5); -product.assertEquals(15); -``` - -#### Throws - -if the result is greater than 255. - -#### Source - -[lib/provable/int.ts:1535](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1535) - -*** - -### sub() - -```ts -sub(y: number | bigint | UInt8): UInt8 -``` - -Subtract a [UInt8](UInt8.mdx) from another [UInt8](UInt8.mdx) without allowing underflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(8); -const difference = x.sub(5); -difference.assertEquals(3); -``` - -#### Throws - -if the result is less than 0. - -#### Source - -[lib/provable/int.ts:1517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1517) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Serialize the [UInt8](UInt8.mdx) to a bigint. - -**Warning**: This operation is not provable. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:1793](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1793) - -*** - -### toNumber() - -```ts -toNumber(): number -``` - -Serialize the [UInt8](UInt8.mdx) to a number. - -**Warning**: This operation is not provable. - -#### Returns - -`number` - -#### Source - -[lib/provable/int.ts:1784](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1784) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [UInt8](UInt8.mdx) to a string, e.g. for printing. - -**Warning**: This operation is not provable. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:1775](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1775) - -*** - -### toUInt32() - -```ts -toUInt32(): UInt32 -``` - -Turns a [UInt8](UInt8.mdx) into a [UInt32](UInt32.mdx). - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1813](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1813) - -*** - -### toUInt64() - -```ts -toUInt64(): UInt64 -``` - -Turns a [UInt8](UInt8.mdx) into a [UInt64](UInt64.mdx). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:1820](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1820) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt8 -``` - -Creates a [UInt8](UInt8.mdx) with a value of 255. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1827](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1827) - -*** - -### check() - -```ts -static check(x: Field | { - "value": Field; - }): void -``` - -Provable.check for [UInt8](UInt8.mdx). -Proves that the input is in the [0, 255] range. - -#### Parameters - -• **x**: [`Field`](Field.mdx) \| \{ - `"value"`: [`Field`](Field.mdx); - \} - -#### Returns - -`void` - -#### Overrides - -`Struct({ - value: Field, -}).check` - -#### Source - -[lib/provable/int.ts:1801](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1801) - -*** - -### from() - -```ts -static from(x: - | number - | bigint - | Field - | UInt64 - | UInt32 - | UInt8): UInt8 -``` - -Creates a new [UInt8](UInt8.mdx). - -#### Parameters - -• **x**: - \| `number` - \| `bigint` - \| [`Field`](Field.mdx) - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1834](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1834) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - value: Field, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - -*** - -### toInput() - -```ts -static toInput(x: { - "value": Field; - }): HashInput -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`Struct({ - value: Field, -}).toInput` - -#### Source - -[lib/provable/int.ts:1806](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1806) diff --git a/docs/zkapps/o1js-reference/classes/Unconstrained.mdx b/docs/zkapps/o1js-reference/classes/Unconstrained.mdx deleted file mode 100644 index 9bbb92684..000000000 --- a/docs/zkapps/o1js-reference/classes/Unconstrained.mdx +++ /dev/null @@ -1,278 +0,0 @@ -Container which holds an unconstrained value. This can be used to pass values -between the out-of-circuit blocks in provable code. - -Invariants: -- An `Unconstrained`'s value can only be accessed in auxiliary contexts. -- An `Unconstrained` can be empty when compiling, but never empty when running as the prover. - (there is no way to create an empty `Unconstrained` in the prover) - -## Example - -```ts -let x = Unconstrained.from(0n); - -class MyContract extends SmartContract { - `@method` myMethod(x: Unconstrained) { - - Provable.witness(Field, () => { - // we can access and modify `x` here - let newValue = x.get() + otherField.toBigInt(); - x.set(newValue); - - // ... - }); - - // throws an error! - x.get(); - } -``` - -## Type parameters - -• **T** - -## Properties - -### provable - -```ts -static provable: UnconstrainedProvable & { - "empty": () => Unconstrained; - "toInput": (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; - }; -}; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => Unconstrained; -``` - -###### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`any`\> - -##### toInput() - -```ts -toInput: (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -###### Parameters - -• **x**: [`Unconstrained`](Unconstrained.mdx)\<`any`\> - -###### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -###### fields? - -```ts -optional fields: Field[]; -``` - -###### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Source - -[lib/provable/types/unconstrained.ts:111](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L111) - -## Methods - -### get() - -```ts -get(): T -``` - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -#### Returns - -`T` - -#### Source - -[lib/provable/types/unconstrained.ts:53](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L53) - -*** - -### set() - -```ts -set(value: T): void -``` - -Modify the unconstrained value. - -#### Parameters - -• **value**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L67) - -*** - -### setTo() - -```ts -setTo(value: Unconstrained): void -``` - -Set the unconstrained value to the same as another `Unconstrained`. - -#### Parameters - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:74](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L74) - -*** - -### updateAsProver() - -```ts -updateAsProver(compute: (value: T) => T): void -``` - -Update an `Unconstrained` by a witness computation. - -#### Parameters - -• **compute** - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L104) - -*** - -### from() - -```ts -static from(value: T | Unconstrained): Unconstrained -``` - -Create an `Unconstrained` with the given `value`. - -Note: If `T` contains provable types, `Unconstrained.from` is an anti-pattern, -because it stores witnesses in a space that's intended to be used outside the proof. -Something like the following should be used instead: - -```ts -let xWrapped = Unconstrained.witness(() => Provable.toConstant(type, x)); -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **value**: `T` \| [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Source - -[lib/provable/types/unconstrained.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L89) - -*** - -### withEmpty() - -```ts -static withEmpty(empty: T): Provable, T> & { - "empty": () => Unconstrained; - "toInput": (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; - }; -} -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **empty**: `T` - -#### Returns - -`Provable`\<[`Unconstrained`](Unconstrained.mdx)\<`T`\>, `T`\> & \{ - `"empty"`: () => [`Unconstrained`](Unconstrained.mdx)\<`T`\>; - `"toInput"`: (`x`: [`Unconstrained`](Unconstrained.mdx)\<`T`\>) => \{ - `"fields"`: [`Field`](Field.mdx)[]; - `"packed"`: [[`Field`](Field.mdx), `number`][]; - \}; - \} - -#### Source - -[lib/provable/types/unconstrained.ts:131](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L131) - -*** - -### witness() - -```ts -static witness(compute: () => T): Unconstrained -``` - -Create an `Unconstrained` from a witness computation. - -#### Type parameters - -• **T** - -#### Parameters - -• **compute** - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Source - -[lib/provable/types/unconstrained.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L97) diff --git a/docs/zkapps/o1js-reference/classes/VerificationKey.mdx b/docs/zkapps/o1js-reference/classes/VerificationKey.mdx deleted file mode 100644 index 639ba2c49..000000000 --- a/docs/zkapps/o1js-reference/classes/VerificationKey.mdx +++ /dev/null @@ -1,691 +0,0 @@ -## Extends - -- \{ - `"data"`: `String`; - `"hash"`: `Field`; - \} - -## Constructors - -### new VerificationKey() - -```ts -new VerificationKey(value: { - "data": String; - "hash": Field; - }): VerificationKey -``` - -#### Parameters - -• **value** - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`VerificationKey`](VerificationKey.mdx) - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### data - -```ts -data: string = String; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).data` - -#### Source - -[lib/proof-system/zkprogram.ts:545](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L545) - -*** - -### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).hash` - -#### Source - -[lib/proof-system/zkprogram.ts:545](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L545) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "data": String; - "hash": Field; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`void` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "data": String; - "hash": Field; -}; -``` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[], aux: any[]) => { - "data": String; - "hash": Field; -}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling [toFields](VerificationKey.mdx#tofields) and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of [Field](Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L59) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: string) => { - "data": String; - "hash": Field; -}; -``` - -#### Parameters - -• **x**: `string` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "data": String; - "hash": Field; - } | { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; - } & (value: { - "data": String; - "hash": Field; - } | { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "data": String; - "hash": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.data?**: `string`= `String` - -• **value.hash?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "data": String; - "hash": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "data": String; - "hash": Field; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "data": String; - "hash": Field; - }) => string; -``` - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`string` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: bigint = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### dummy() - -```ts -static dummy(): Promise -``` - -#### Returns - -`Promise`\<[`VerificationKey`](VerificationKey.mdx)\> - -#### Source - -[lib/proof-system/zkprogram.ts:550](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L550) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/functions/Bytes.mdx b/docs/zkapps/o1js-reference/functions/Bytes.mdx deleted file mode 100644 index b4ae1972d..000000000 --- a/docs/zkapps/o1js-reference/functions/Bytes.mdx +++ /dev/null @@ -1,23 +0,0 @@ -```ts -function Bytes(size: number): typeof Bytes -``` - -A provable type representing an array of bytes. - -```ts -class Bytes32 extends Bytes(32) {} - -let bytes = Bytes32.fromHex('deadbeef'); -``` - -## Parameters - -• **size**: `number` - -## Returns - -*typeof* `Bytes` - -## Source - -[lib/provable/wrapped-classes.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped-classes.ts#L16) diff --git a/docs/zkapps/o1js-reference/functions/ConstantField.mdx b/docs/zkapps/o1js-reference/functions/ConstantField.mdx deleted file mode 100644 index 26915c1d8..000000000 --- a/docs/zkapps/o1js-reference/functions/ConstantField.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function ConstantField(x: bigint | ConstantFieldVar): ConstantField -``` - -## Parameters - -• **x**: `bigint` \| `ConstantFieldVar` - -## Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -## Source - -[lib/provable/field.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1246) diff --git a/docs/zkapps/o1js-reference/functions/MerkleListBase.mdx b/docs/zkapps/o1js-reference/functions/MerkleListBase.mdx deleted file mode 100644 index b46b0ac93..000000000 --- a/docs/zkapps/o1js-reference/functions/MerkleListBase.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function MerkleListBase(): ProvableHashable> -``` - -## Type parameters - -• **T** - -## Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>\> - -## Source - -[lib/provable/merkle-list.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L46) diff --git a/docs/zkapps/o1js-reference/functions/MerkleWitness.mdx b/docs/zkapps/o1js-reference/functions/MerkleWitness.mdx deleted file mode 100644 index 8878ac299..000000000 --- a/docs/zkapps/o1js-reference/functions/MerkleWitness.mdx +++ /dev/null @@ -1,21 +0,0 @@ -```ts -function MerkleWitness(height: number): typeof BaseMerkleWitness -``` - -Returns a circuit-compatible Witness for a specific Tree height. - -## Parameters - -• **height**: `number` - -Height of the Merkle Tree that this Witness belongs to. - -## Returns - -*typeof* [`BaseMerkleWitness`](../classes/BaseMerkleWitness.mdx) - -A circuit-compatible Merkle Witness. - -## Source - -[lib/provable/merkle-tree.ts:240](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L240) diff --git a/docs/zkapps/o1js-reference/functions/Option.mdx b/docs/zkapps/o1js-reference/functions/Option.mdx deleted file mode 100644 index 7c212fe00..000000000 --- a/docs/zkapps/o1js-reference/functions/Option.mdx +++ /dev/null @@ -1,49 +0,0 @@ -```ts -function Option(type: A): ProvableInferPureFrom, InferValue>, InferValue | undefined> & (option: { - "isSome": Bool; - "value": InferProvable; - }) => Option, InferValue> & { - "from": Option, InferValue>; - "fromValue": Option, InferValue>; - "none": Option, InferValue>; -} -``` - -Define an optional version of a provable type. - -## Type parameters - -• **A** *extends* [`ProvableType`](../type-aliases/ProvableType.mdx) - -## Parameters - -• **type**: `A` - -## Returns - -`ProvableInferPureFrom`\<`A`, [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>, `InferValue`\<`A`\> \| `undefined`\> & (`option`: \{ - `"isSome"`: [`Bool`](../type-aliases/Bool.mdx); - `"value"`: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>; - \}) => [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\> & \{ - `"from"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - `"fromValue"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - `"none"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - \} - -## Example - -```ts -class OptionUInt64 extends Option(UInt64) {} - -// create an optional UInt64 -let some = OptionUInt64.from(5n); -let none = OptionUInt64.none(); - -// get back a UInt64 -let five: UInt64 = some.assertSome('must have a value'); -let zero: UInt64 = none.orElse(0n); // specify a default value -``` - -## Source - -[lib/provable/option.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/option.ts#L37) diff --git a/docs/zkapps/o1js-reference/functions/Reducer.mdx b/docs/zkapps/o1js-reference/functions/Reducer.mdx deleted file mode 100644 index c53011e63..000000000 --- a/docs/zkapps/o1js-reference/functions/Reducer.mdx +++ /dev/null @@ -1,25 +0,0 @@ -```ts -function Reducer(reducer: { - "actionType": T; -}): ReducerReturn -``` - -## Type parameters - -• **T** *extends* [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -• **A** *extends* `any` = [`InferProvable`](../type-aliases/InferProvable.mdx)\<`T`\> - -## Parameters - -• **reducer** - -• **reducer.actionType**: `T` - -## Returns - -`ReducerReturn`\<`A`\> - -## Source - -[lib/mina/actions/reducer.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/reducer.ts#L17) diff --git a/docs/zkapps/o1js-reference/functions/State.mdx b/docs/zkapps/o1js-reference/functions/State.mdx deleted file mode 100644 index da1b7c14f..000000000 --- a/docs/zkapps/o1js-reference/functions/State.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function State(defaultValue?: A): State -``` - -## Type parameters - -• **A** - -## Parameters - -• **defaultValue?**: `A` - -## Returns - -[`State`](../type-aliases/State.mdx)\<`A`\> - -## Source - -[lib/mina/state.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L91) diff --git a/docs/zkapps/o1js-reference/functions/Struct.mdx b/docs/zkapps/o1js-reference/functions/Struct.mdx deleted file mode 100644 index c5f00af43..000000000 --- a/docs/zkapps/o1js-reference/functions/Struct.mdx +++ /dev/null @@ -1,122 +0,0 @@ -```ts -function Struct(type: A): (value: T) => T & { - "_isStruct": true; - } & Pure extends true ? ProvablePure : Provable & { - "empty": () => T; - "fromJSON": (x: J) => T; - "fromValue": (value: From) => T; - "toInput": (x: T) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: T) => J; -} -``` - -`Struct` lets you declare composite types for use in o1js circuits. - -These composite types can be passed in as arguments to smart contract methods, used for on-chain state variables -or as event / action types. - -Here's an example of creating a "Voter" struct, which holds a public key and a collection of votes on 3 different proposals: -```ts -let Vote = { hasVoted: Bool, inFavor: Bool }; - -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote] -}) {} - -// use Voter as SmartContract input: -class VoterContract extends SmartContract { - \@method register(voter: Voter) { - // ... - } -} -``` -In this example, there are no instance methods on the class. This makes `Voter` type-compatible with an anonymous object of the form -`{ publicKey: PublicKey, votes: Vote[] }`. -This mean you don't have to create instances by using `new Voter(...)`, you can operate with plain objects: -```ts -voterContract.register({ publicKey, votes }); -``` - -On the other hand, you can also add your own methods: -```ts -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote] -}) { - vote(index: number, inFavor: Bool) { - let vote = this.votes[i]; - vote.hasVoted = Bool(true); - vote.inFavor = inFavor; - } -} -``` - -In this case, you'll need the constructor to create instances of `Voter`. It always takes as input the plain object: -```ts -let emptyVote = { hasVoted: Bool(false), inFavor: Bool(false) }; -let voter = new Voter({ publicKey, votes: Array(3).fill(emptyVote) }); -voter.vote(1, Bool(true)); -``` - -In addition to creating types composed of Field elements, you can also include auxiliary data which does not become part of the proof. -This, for example, allows you to re-use the same type outside o1js methods, where you might want to store additional metadata. - -To declare non-proof values of type `string`, `number`, etc, you can use the built-in objects `String`, `Number`, etc. -Here's how we could add the voter's name (a string) as auxiliary data: -```ts -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote], - fullName: String -}) {} -``` - -Again, it's important to note that this doesn't enable you to prove anything about the `fullName` string. -From the circuit point of view, it simply doesn't exist! - -## Type parameters - -• **A** - -• **T** *extends* `unknown` = [`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\> - -• **V** *extends* `unknown` = `InferValue`\<`A`\> - -• **J** *extends* `unknown` = `InferJson`\<`A`\> - -• **Pure** *extends* `boolean` = `IsPure`\<`A`\> - -## Parameters - -• **type**: `A` - -Object specifying the layout of the `Struct` - -## Returns - -(`value`: `T`) => `T` & \{ - `"_isStruct"`: `true`; - \} & `Pure` *extends* `true` ? [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`T`, `V`\> : `Provable`\<`T`, `V`\> & \{ - `"empty"`: () => `T`; - `"fromJSON"`: (`x`: `J`) => `T`; - `"fromValue"`: (`value`: `From`\<`A`\>) => `T`; - `"toInput"`: (`x`: `T`) => \{ - `"fields"`: [`Field`](../type-aliases/Field.mdx)[]; - `"packed"`: [[`Field`](../type-aliases/Field.mdx), `number`][]; - \}; - `"toJSON"`: (`x`: `T`) => `J`; - \} - -Class which you can extend - -## Note - -Ensure you do not use or extend `Struct` as a type directly. Instead, always call it as a function to construct a type. `Struct` is not a valid provable type itself, types created with `Struct(...)` are. - -## Source - -[lib/provable/types/struct.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L140) diff --git a/docs/zkapps/o1js-reference/functions/VarField.mdx b/docs/zkapps/o1js-reference/functions/VarField.mdx deleted file mode 100644 index 81f6bc9a7..000000000 --- a/docs/zkapps/o1js-reference/functions/VarField.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function VarField(x: VarFieldVar): VarField -``` - -## Parameters - -• **x**: `VarFieldVar` - -## Returns - -[`VarField`](../type-aliases/VarField.mdx) - -## Source - -[lib/provable/field.ts:1242](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1242) diff --git a/docs/zkapps/o1js-reference/functions/WithHash.mdx b/docs/zkapps/o1js-reference/functions/WithHash.mdx deleted file mode 100644 index 1432ea4eb..000000000 --- a/docs/zkapps/o1js-reference/functions/WithHash.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function WithHash(type: ProvableHashable): ProvableHashable> -``` - -## Type parameters - -• **T** - -## Parameters - -• **type**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -## Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`WithHash`](../type-aliases/WithHash.mdx)\<`T`\>\> - -## Source - -[lib/provable/merkle-list.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L28) diff --git a/docs/zkapps/o1js-reference/functions/ZkProgram.mdx b/docs/zkapps/o1js-reference/functions/ZkProgram.mdx deleted file mode 100644 index 00abdc780..000000000 --- a/docs/zkapps/o1js-reference/functions/ZkProgram.mdx +++ /dev/null @@ -1,83 +0,0 @@ -```ts -function ZkProgram(config: Config & { - "methods": { [I in string | number | symbol]: Methods[I] }; - "name": string; - "overrideWrapDomain": 0 | 2 | 1; - }): { - "analyzeMethods": () => Promise<{ [I in keyof Config["methods"]]: UnwrapPromise> }>; - "auxiliaryOutputTypes": AuxiliaryOutputs; - "compile": (options?: { - "cache": Cache; - "forceRecompile": boolean; - "proofsEnabled": boolean; - }) => Promise<{ - "verificationKey": { - "data": string; - "hash": Field; - }; - }>; - "digest": () => Promise; - "name": string; - "privateInputTypes": PrivateInputs; - "proofsEnabled": boolean; - "publicInputType": ProvableOrUndefined>; - "publicOutputType": ProvableOrVoid>; - "rawMethods": { [I in keyof Config["methods"]]: Methods[I]["method"] }; - "verify": (proof: Proof>, InferProvableOrVoid>>) => Promise; - "setProofsEnabled": void; - } & { [I in keyof Config["methods"]]: Prover>, InferProvableOrVoid>, PrivateInputs[I], InferProvableOrUndefined> } -``` - -## Type parameters - -• **Config** *extends* \{ - `"methods"`: \{\}; - `"publicInput"`: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx); - `"publicOutput"`: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx); - \} - -• **Methods** *extends* \{ [I in string \| number \| symbol]: Method\\>, InferProvableOrVoid\\>, Config["methods"][I]\> \} - -• **MethodSignatures** *extends* \{\} = `Config`\[`"methods"`\] - -• **PrivateInputs** *extends* \{ [I in string \| number \| symbol]: MethodSignatures[I]["privateInputs"] \} = \{ [I in string \| number \| symbol]: MethodSignatures[I]["privateInputs"] \} - -• **AuxiliaryOutputs** *extends* \{ [I in string \| number \| symbol]: Get\ \} = \{ [I in string \| number \| symbol]: Get\ \} - -## Parameters - -• **config**: `Config` & \{ - `"methods"`: \{ [I in string \| number \| symbol]: Methods[I] \}; - `"name"`: `string`; - `"overrideWrapDomain"`: `0` \| `2` \| `1`; - \} - -## Returns - -\{ - `"analyzeMethods"`: () => `Promise`\<`{ [I in keyof Config["methods"]]: UnwrapPromise> }`\>; - `"auxiliaryOutputTypes"`: `AuxiliaryOutputs`; - `"compile"`: (`options`?: \{ - `"cache"`: [`Cache`](../type-aliases/Cache.mdx); - `"forceRecompile"`: `boolean`; - `"proofsEnabled"`: `boolean`; - \}) => `Promise`\<\{ - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](../type-aliases/Field.mdx); - \}; - \}\>; - `"digest"`: () => `Promise`\<`string`\>; - `"name"`: `string`; - `"privateInputTypes"`: `PrivateInputs`; - `"proofsEnabled"`: `boolean`; - `"publicInputType"`: `ProvableOrUndefined`\<`Get`\<`Config`, `"publicInput"`\>\>; - `"publicOutputType"`: `ProvableOrVoid`\<`Get`\<`Config`, `"publicOutput"`\>\>; - `"rawMethods"`: `{ [I in keyof Config["methods"]]: Methods[I]["method"] }`; - `"verify"`: (`proof`: [`Proof`](../classes/Proof.mdx)\<`InferProvableOrUndefined`\<`Get`\<`Config`, `"publicInput"`\>\>, `InferProvableOrVoid`\<`Get`\<`Config`, `"publicOutput"`\>\>\>) => `Promise`\<`boolean`\>; - `"setProofsEnabled"`: `void`; - \} & `{ [I in keyof Config["methods"]]: Prover>, InferProvableOrVoid>, PrivateInputs[I], InferProvableOrUndefined> }` - -## Source - -[lib/proof-system/zkprogram.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L174) diff --git a/docs/zkapps/o1js-reference/functions/addCachedAccount.mdx b/docs/zkapps/o1js-reference/functions/addCachedAccount.mdx deleted file mode 100644 index 2c2887789..000000000 --- a/docs/zkapps/o1js-reference/functions/addCachedAccount.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function addCachedAccount(partialAccount: PartialAccount, graphqlEndpoint: string): void -``` - -Adds an account to the local cache, indexed by a GraphQL endpoint. - -## Parameters - -• **partialAccount**: `PartialAccount` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:418](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L418) diff --git a/docs/zkapps/o1js-reference/functions/assert.mdx b/docs/zkapps/o1js-reference/functions/assert.mdx deleted file mode 100644 index ee44feb60..000000000 --- a/docs/zkapps/o1js-reference/functions/assert.mdx +++ /dev/null @@ -1,20 +0,0 @@ -```ts -function assert(stmt: boolean | Bool, message?: string): asserts stmt -``` - -Assert that a statement is true. If the statement is false, throws an error with the given message. -Can be used in provable code. - -## Parameters - -• **stmt**: `boolean` \| [`Bool`](../classes/Bool.mdx) - -• **message?**: `string` - -## Returns - -`asserts stmt` - -## Source - -[lib/provable/gadgets/common.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/common.ts#L57) diff --git a/docs/zkapps/o1js-reference/functions/checkBitLength.mdx b/docs/zkapps/o1js-reference/functions/checkBitLength.mdx deleted file mode 100644 index cb6ead918..000000000 --- a/docs/zkapps/o1js-reference/functions/checkBitLength.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -function checkBitLength( - name: string, - length: number, - maxLength: number): void -``` - -## Parameters - -• **name**: `string` - -• **length**: `number` - -• **maxLength**: `number`= `Fp.sizeInBits` - -## Returns - -`void` - -## Source - -[lib/provable/field.ts:1180](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1180) diff --git a/docs/zkapps/o1js-reference/functions/checkZkappTransaction.mdx b/docs/zkapps/o1js-reference/functions/checkZkappTransaction.mdx deleted file mode 100644 index 0c9be63ba..000000000 --- a/docs/zkapps/o1js-reference/functions/checkZkappTransaction.mdx +++ /dev/null @@ -1,29 +0,0 @@ -```ts -function checkZkappTransaction(transactionHash: string, blockLength: number): Promise<{ - "failureReason": string[][][]; - "success": false; - } | { - "failureReason": null; - "success": true; -}> -``` - -## Parameters - -• **transactionHash**: `string` - -• **blockLength**: `number`= `20` - -## Returns - -`Promise`\<\{ - `"failureReason"`: `string`[][][]; - `"success"`: `false`; - \} \| \{ - `"failureReason"`: `null`; - `"success"`: `true`; - \}\> - -## Source - -[lib/mina/fetch.ts:517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L517) diff --git a/docs/zkapps/o1js-reference/functions/circuitMain.mdx b/docs/zkapps/o1js-reference/functions/circuitMain.mdx deleted file mode 100644 index 66fdeae90..000000000 --- a/docs/zkapps/o1js-reference/functions/circuitMain.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -function circuitMain( - target: typeof Circuit, - propertyName: string, - _descriptor?: PropertyDescriptor): any -``` - -## Parameters - -• **target**: *typeof* [`Circuit`](../classes/Circuit.mdx) - -• **propertyName**: `string` - -• **\_descriptor?**: `PropertyDescriptor` - -## Returns - -`any` - -## Source - -[lib/proof-system/circuit.ts:192](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L192) diff --git a/docs/zkapps/o1js-reference/functions/conditionalSwap.mdx b/docs/zkapps/o1js-reference/functions/conditionalSwap.mdx deleted file mode 100644 index 8428ea3c8..000000000 --- a/docs/zkapps/o1js-reference/functions/conditionalSwap.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -function conditionalSwap( - b: Bool, - x: Field, - y: Field): [Field, Field] -``` - -## Parameters - -• **b**: [`Bool`](../classes/Bool.mdx) - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -## Returns - -[[`Field`](../type-aliases/Field.mdx), [`Field`](../type-aliases/Field.mdx)] - -## Source - -[lib/provable/merkle-tree.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L251) diff --git a/docs/zkapps/o1js-reference/functions/createEcdsa.mdx b/docs/zkapps/o1js-reference/functions/createEcdsa.mdx deleted file mode 100644 index c102b5ee0..000000000 --- a/docs/zkapps/o1js-reference/functions/createEcdsa.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function createEcdsa(curve: CurveParams | typeof ForeignCurve): typeof EcdsaSignature -``` - -Create a class [EcdsaSignature](../classes/EcdsaSignature.mdx) for verifying ECDSA signatures on the given curve. - -## Parameters - -• **curve**: `CurveParams` \| *typeof* [`ForeignCurve`](../classes/ForeignCurve.mdx) - -## Returns - -*typeof* [`EcdsaSignature`](../classes/EcdsaSignature.mdx) - -## Source - -[lib/provable/crypto/foreign-ecdsa.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L246) diff --git a/docs/zkapps/o1js-reference/functions/createForeignCurve.mdx b/docs/zkapps/o1js-reference/functions/createForeignCurve.mdx deleted file mode 100644 index bf3ca8df2..000000000 --- a/docs/zkapps/o1js-reference/functions/createForeignCurve.mdx +++ /dev/null @@ -1,29 +0,0 @@ -```ts -function createForeignCurve(params: CurveParams): typeof ForeignCurve -``` - -Create a class representing an elliptic curve group, which is different from the native [Group](../classes/Group.mdx). - -```ts -const Curve = createForeignCurve(Crypto.CurveParams.Secp256k1); -``` - -`createForeignCurve(params)` takes curve parameters CurveParams as input. -We support `modulus` and `order` to be prime numbers up to 259 bits. - -The returned ForeignCurveNotNeeded class represents a _non-zero curve point_ and supports standard -elliptic curve operations like point addition and scalar multiplication. - -ForeignCurveNotNeeded also includes to associated foreign fields: `ForeignCurve.Field` and `ForeignCurve.Scalar`, see [createForeignField](createForeignField.mdx). - -## Parameters - -• **params**: `CurveParams` - -## Returns - -*typeof* [`ForeignCurve`](../classes/ForeignCurve.mdx) - -## Source - -[lib/provable/crypto/foreign-curve.ts:432](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L432) diff --git a/docs/zkapps/o1js-reference/functions/createForeignField.mdx b/docs/zkapps/o1js-reference/functions/createForeignField.mdx deleted file mode 100644 index b5604565e..000000000 --- a/docs/zkapps/o1js-reference/functions/createForeignField.mdx +++ /dev/null @@ -1,63 +0,0 @@ -```ts -function createForeignField(modulus: bigint): typeof UnreducedForeignField -``` - -Create a class representing a prime order finite field, which is different from the native [Field](../classes/Field.mdx). - -```ts -const SmallField = createForeignField(17n); // the finite field F_17 -``` - -`createForeignField(p)` takes the prime modulus `p` of the finite field as input, as a bigint. -We support prime moduli up to a size of 259 bits. - -The returned [ForeignField](../classes/ForeignField.mdx) class supports arithmetic modulo `p` (addition and multiplication), -as well as helper methods like `assertEquals()` and `equals()`. - -_Advanced details:_ - -Internally, a foreign field element is represented as three native field elements, each of which -represents a limb of 88 bits. Therefore, being a valid foreign field element means that all 3 limbs -fit in 88 bits, and the foreign field element altogether is smaller than the modulus p. - -Since the full `x < p` check is expensive, by default we only prove a weaker assertion, `x < 2^ceil(log2(p))`, -see [ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) for more details. - -This weaker assumption is what we call "almost reduced", and it is represented by the [AlmostForeignField](../classes/AlmostForeignField.mdx) class. -Note that only [AlmostForeignField](../classes/AlmostForeignField.mdx) supports multiplication and inversion, while UnreducedForeignField -only supports addition and subtraction. - -This function returns the `Unreduced` class, which will cause the minimum amount of range checks to be created by default. -If you want to do multiplication, you have two options: -- create your field elements using the [ForeignField.AlmostReduced](../classes/ForeignField.mdx#almostreduced) constructor. -```ts -let x = Provable.witness(ForeignField.AlmostReduced, () => 5n); -``` -- create your field elements normally and convert them using `x.assertAlmostReduced()`. -```ts -let xChecked = x.assertAlmostReduced(); // asserts x < 2^ceil(log2(p)); returns `AlmostForeignField` -``` - -Similarly, there is a separate class [CanonicalForeignField](../classes/CanonicalForeignField.mdx) which represents fully reduced, "canonical" field elements. -To convert to a canonical field element, use `ForeignField.assertCanonical()`: - -```ts -x.assertCanonical(); // asserts x < p; returns `CanonicalForeignField` -``` -You will likely not need canonical fields most of the time. - -Base types for all of these classes are separately exported as UnreducedForeignField, [AlmostForeignField](../classes/AlmostForeignField.mdx) and [CanonicalForeignField](../classes/CanonicalForeignField.mdx)., - -## Parameters - -• **modulus**: `bigint` - -the modulus of the finite field you are instantiating - -## Returns - -*typeof* `UnreducedForeignField` - -## Source - -[lib/provable/foreign-field.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L642) diff --git a/docs/zkapps/o1js-reference/functions/declareMethods.mdx b/docs/zkapps/o1js-reference/functions/declareMethods.mdx deleted file mode 100644 index 3efaf5957..000000000 --- a/docs/zkapps/o1js-reference/functions/declareMethods.mdx +++ /dev/null @@ -1,36 +0,0 @@ -```ts -function declareMethods(SmartContract: T, methodArguments: Record[]>): void -``` - -`declareMethods` can be used in place of the `@method` decorator -to declare SmartContract methods along with their list of arguments. -It should be placed _after_ the class declaration. -Here is an example of declaring a method `update`, which takes a single argument of type `Field`: -```ts -class MyContract extends SmartContract { - // ... - update(x: Field) { - // ... - } -} -declareMethods(MyContract, { update: [Field] }); // `[Field]` is the list of arguments! -``` -Note that a method of the same name must still be defined on the class, just without the decorator. - -## Type parameters - -• **T** *extends* *typeof* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **SmartContract**: `T` - -• **methodArguments**: `Record`\<`string`, `Provable`\<`unknown`\>[]\> - -## Returns - -`void` - -## Source - -[lib/mina/zkapp.ts:1270](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1270) diff --git a/docs/zkapps/o1js-reference/functions/declareState.mdx b/docs/zkapps/o1js-reference/functions/declareState.mdx deleted file mode 100644 index f4e7f90b8..000000000 --- a/docs/zkapps/o1js-reference/functions/declareState.mdx +++ /dev/null @@ -1,54 +0,0 @@ -```ts -function declareState(SmartContract: T, states: Record>): void -``` - -`declareState` can be used in place of the `@state` decorator to declare on-chain state on a SmartContract. -It should be placed _after_ the class declaration. -Here is an example of declaring a state property `x` of type `Field`. -```ts -class MyContract extends SmartContract { - x = State(); - // ... -} -declareState(MyContract, { x: Field }); -``` - -If you're using pure JS, it's _not_ possible to use the built-in class field syntax, -i.e. the following will _not_ work: - -```js -// THIS IS WRONG IN JS! -class MyContract extends SmartContract { - x = State(); -} -declareState(MyContract, { x: Field }); -``` - -Instead, add a constructor where you assign the property: -```js -class MyContract extends SmartContract { - constructor(x) { - super(); - this.x = State(); - } -} -declareState(MyContract, { x: Field }); -``` - -## Type parameters - -• **T** *extends* *typeof* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **SmartContract**: `T` - -• **states**: `Record`\<`string`, [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\>\> - -## Returns - -`void` - -## Source - -[lib/mina/state.ts:183](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L183) diff --git a/docs/zkapps/o1js-reference/functions/fetchAccount.mdx b/docs/zkapps/o1js-reference/functions/fetchAccount.mdx deleted file mode 100644 index 487d38dd1..000000000 --- a/docs/zkapps/o1js-reference/functions/fetchAccount.mdx +++ /dev/null @@ -1,56 +0,0 @@ -```ts -function fetchAccount( - accountInfo: { - "publicKey": string | PublicKey; - "tokenId": string | Field; - }, - graphqlEndpoint: string, - __namedParameters: { - "timeout": defaultTimeout; - }): Promise<{ - "account": Types.Account; - "error": undefined; - } | { - "account": undefined; - "error": FetchError; -}> -``` - -Gets account information on the specified publicKey by performing a GraphQL query -to the specified endpoint. This will call the 'GetAccountInfo' query which fetches -zkapp related account information. - -If an error is returned by the specified endpoint, an error is thrown. Otherwise, -the data is returned. - -## Parameters - -• **accountInfo** - -• **accountInfo.publicKey**: `string` \| [`PublicKey`](../classes/PublicKey.mdx) - -• **accountInfo.tokenId?**: `string` \| [`Field`](../classes/Field.mdx) - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -The graphql endpoint to fetch from - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.timeout**: `undefined` \| `number`= `defaultTimeout` - -## Returns - -`Promise`\<\{ - `"account"`: `Types.Account`; - `"error"`: `undefined`; - \} \| \{ - `"account"`: `undefined`; - `"error"`: `FetchError`; - \}\> - -zkapp information on the specified account or an error is thrown - -## Source - -[lib/mina/fetch.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L179) diff --git a/docs/zkapps/o1js-reference/functions/fetchEvents.mdx b/docs/zkapps/o1js-reference/functions/fetchEvents.mdx deleted file mode 100644 index ac01f3b70..000000000 --- a/docs/zkapps/o1js-reference/functions/fetchEvents.mdx +++ /dev/null @@ -1,85 +0,0 @@ -```ts -function fetchEvents( - accountInfo: { - "publicKey": string; - "tokenId": string; - }, - graphqlEndpoint?: string, - filterOptions?: EventActionFilterOptions): Promise<{ - "blockHash": event.blockInfo.stateHash; - "blockHeight": UInt32; - "chainStatus": event.blockInfo.chainStatus; - "events": { - "data": string[]; - "transactionInfo": { - "hash": string; - "memo": string; - "status": string; - }; - }[]; - "globalSlot": UInt32; - "parentBlockHash": event.blockInfo.parentHash; -}[]> -``` - -Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API. - -## Parameters - -• **accountInfo** - -The account information object. - -• **accountInfo.publicKey**: `string` - -The account public key. - -• **accountInfo.tokenId?**: `string` - -The optional token ID for the account. - -• **graphqlEndpoint?**: `string`= `networkConfig.archiveEndpoint` - -The GraphQL endpoint to query. Defaults to the Archive Node GraphQL API. - -• **filterOptions?**: `EventActionFilterOptions`= `{}` - -The optional filter options object. - -## Returns - -`Promise`\<\{ - `"blockHash"`: `event.blockInfo.stateHash`; - `"blockHeight"`: [`UInt32`](../classes/UInt32.mdx); - `"chainStatus"`: `event.blockInfo.chainStatus`; - `"events"`: \{ - `"data"`: `string`[]; - `"transactionInfo"`: \{ - `"hash"`: `string`; - `"memo"`: `string`; - `"status"`: `string`; - \}; - \}[]; - `"globalSlot"`: [`UInt32`](../classes/UInt32.mdx); - `"parentBlockHash"`: `event.blockInfo.parentHash`; - \}[]\> - -A promise that resolves to an array of objects containing event data, block information and transaction information for the account. - -## Async - -## Throws - -If the GraphQL request fails or the response is invalid. - -## Example - -```ts -const accountInfo = { publicKey: 'B62qiwmXrWn7Cok5VhhB3KvCwyZ7NHHstFGbiU5n7m8s2RqqNW1p1wF' }; -const events = await fetchEvents(accountInfo); -console.log(events); -``` - -## Source - -[lib/mina/fetch.ts:648](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L648) diff --git a/docs/zkapps/o1js-reference/functions/fetchLastBlock.mdx b/docs/zkapps/o1js-reference/functions/fetchLastBlock.mdx deleted file mode 100644 index abace3706..000000000 --- a/docs/zkapps/o1js-reference/functions/fetchLastBlock.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function fetchLastBlock(graphqlEndpoint: string): Promise> -``` - -Fetches the last block on the Mina network. - -## Parameters - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`Promise`\<`PreconditionBaseTypes`\<\{\}\>\> - -## Source - -[lib/mina/fetch.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L461) diff --git a/docs/zkapps/o1js-reference/functions/fetchTransactionStatus.mdx b/docs/zkapps/o1js-reference/functions/fetchTransactionStatus.mdx deleted file mode 100644 index d9d19b667..000000000 --- a/docs/zkapps/o1js-reference/functions/fetchTransactionStatus.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function fetchTransactionStatus(txId: string, graphqlEndpoint: string): Promise -``` - -Fetches the status of a transaction. - -## Parameters - -• **txId**: `string` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`Promise`\<[`TransactionStatus`](../type-aliases/TransactionStatus.mdx)\> - -## Source - -[lib/mina/fetch.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L598) diff --git a/docs/zkapps/o1js-reference/functions/genericHash.mdx b/docs/zkapps/o1js-reference/functions/genericHash.mdx deleted file mode 100644 index f92f0fb75..000000000 --- a/docs/zkapps/o1js-reference/functions/genericHash.mdx +++ /dev/null @@ -1,26 +0,0 @@ -```ts -function genericHash( - provable: ProvableHashable, - prefix: string, - value: T): Field -``` - -## Type parameters - -• **T** - -## Parameters - -• **provable**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -• **prefix**: `string` - -• **value**: `T` - -## Returns - -[`Field`](../classes/Field.mdx) - -## Source - -[lib/provable/merkle-list.ts:755](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L755) diff --git a/docs/zkapps/o1js-reference/functions/initializeBindings.mdx b/docs/zkapps/o1js-reference/functions/initializeBindings.mdx deleted file mode 100644 index a1b5e5a5b..000000000 --- a/docs/zkapps/o1js-reference/functions/initializeBindings.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -function initializeBindings(): Promise -``` - -A function that has to finish before any bindings exports can be used. - -## Returns - -`Promise`\<`void`\> - -## Source - -[snarky.d.ts:763](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L763) diff --git a/docs/zkapps/o1js-reference/functions/merkleListHash.mdx b/docs/zkapps/o1js-reference/functions/merkleListHash.mdx deleted file mode 100644 index b9b738617..000000000 --- a/docs/zkapps/o1js-reference/functions/merkleListHash.mdx +++ /dev/null @@ -1,32 +0,0 @@ -```ts -function merkleListHash(provable: ProvableHashable, prefix: string): (hash: Field, value: T) => Field -``` - -## Type parameters - -• **T** - -## Parameters - -• **provable**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -• **prefix**: `string`= `''` - -## Returns - -`Function` - -> ### Parameters -> -> • **hash**: [`Field`](../classes/Field.mdx) -> -> • **value**: `T` -> -> ### Returns -> -> [`Field`](../classes/Field.mdx) -> - -## Source - -[lib/provable/merkle-list.ts:765](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L765) diff --git a/docs/zkapps/o1js-reference/functions/method.mdx b/docs/zkapps/o1js-reference/functions/method.mdx deleted file mode 100644 index 17befba8a..000000000 --- a/docs/zkapps/o1js-reference/functions/method.mdx +++ /dev/null @@ -1,48 +0,0 @@ -```ts -function method( - target: T & { [k in string]: Function }, - methodName: K & string & keyof T, - descriptor: PropertyDescriptor, - returnType?: Provable): void -``` - -A decorator to use in a zkApp to mark a method as provable. -You can use inside your zkApp class as: - -``` -\@method async myMethod(someArg: Field) { - // your code here -} -``` - -To return a value from the method, you have to explicitly declare the return type using the [method.returns](method.mdx#returns) decorator: -``` -\@method.returns(Field) -async myMethod(someArg: Field): Promise { - // your code here -} -``` - -## Type parameters - -• **K** *extends* `string` - -• **T** *extends* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **target**: `T` & `{ [k in string]: Function }` - -• **methodName**: `K` & `string` & keyof `T` - -• **descriptor**: `PropertyDescriptor` - -• **returnType?**: `Provable`\<`any`\> - -## Returns - -`void` - -## Source - -[lib/mina/zkapp.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L105) diff --git a/docs/zkapps/o1js-reference/functions/provable.mdx b/docs/zkapps/o1js-reference/functions/provable.mdx deleted file mode 100644 index 7ce20a31b..000000000 --- a/docs/zkapps/o1js-reference/functions/provable.mdx +++ /dev/null @@ -1,23 +0,0 @@ -```ts -function provable(typeObj: A, options?: {}): InferredProvable -``` - -## Type parameters - -• **A** - -## Parameters - -• **typeObj**: `A` - -• **options?** - -**Deprecated** - -## Returns - -`InferredProvable`\<`A`, [`Field`](../classes/Field.mdx)\> - -## Source - -[lib/provable/types/provable-derivers.ts:78](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L78) diff --git a/docs/zkapps/o1js-reference/functions/provablePure.mdx b/docs/zkapps/o1js-reference/functions/provablePure.mdx deleted file mode 100644 index c120b3a07..000000000 --- a/docs/zkapps/o1js-reference/functions/provablePure.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function provablePure(typeObj: A): ProvablePureExtended, InferValue, InferJson> -``` - -## Type parameters - -• **A** - -## Parameters - -• **typeObj**: `A` - -## Returns - -`ProvablePureExtended`\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>, `InferJson`\<`A`\>\> - -## Source - -[lib/provable/types/provable-derivers.ts:80](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L80) diff --git a/docs/zkapps/o1js-reference/functions/public.mdx b/docs/zkapps/o1js-reference/functions/public.mdx deleted file mode 100644 index 0b9572bef..000000000 --- a/docs/zkapps/o1js-reference/functions/public.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -function public_( - target: any, - _key: string | symbol, - index: number): void -``` - -## Parameters - -• **target**: `any` - -• **\_key**: `string` \| `symbol` - -• **index**: `number` - -## Returns - -`void` - -## Source - -[lib/proof-system/circuit.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L156) diff --git a/docs/zkapps/o1js-reference/functions/readVarMessage.mdx b/docs/zkapps/o1js-reference/functions/readVarMessage.mdx deleted file mode 100644 index fbc26227b..000000000 --- a/docs/zkapps/o1js-reference/functions/readVarMessage.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -function readVarMessage( - methodName: string, - varName: string, - varDescription: string): string -``` - -## Parameters - -• **methodName**: `string` - -• **varName**: `string` - -• **varDescription**: `string` - -## Returns - -`string` - -## Source - -[lib/provable/field.ts:1222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1222) diff --git a/docs/zkapps/o1js-reference/functions/sendZkapp.mdx b/docs/zkapps/o1js-reference/functions/sendZkapp.mdx deleted file mode 100644 index 55c65fb2e..000000000 --- a/docs/zkapps/o1js-reference/functions/sendZkapp.mdx +++ /dev/null @@ -1,28 +0,0 @@ -```ts -function sendZkapp( - json: string, - graphqlEndpoint: string, - __namedParameters: { - "timeout": defaultTimeout; -}): Promise<[undefined, FetchError] | [FetchResponse, undefined]> -``` - -Sends a zkApp command (transaction) to the specified GraphQL endpoint. - -## Parameters - -• **json**: `string` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.timeout**: `undefined` \| `number`= `defaultTimeout` - -## Returns - -`Promise`\<[`undefined`, `FetchError`] \| [`FetchResponse`\<`SendZkAppResponse`\>, `undefined`]\> - -## Source - -[lib/mina/fetch.ts:618](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L618) diff --git a/docs/zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint.mdx b/docs/zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint.mdx deleted file mode 100644 index 79118e9fd..000000000 --- a/docs/zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function setArchiveGraphqlEndpoint(graphqlEndpoint: string): void -``` - -Sets up a GraphQL endpoint to be used for fetching information from an Archive Node. - -## Parameters - -• **graphqlEndpoint**: `string` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L134) diff --git a/docs/zkapps/o1js-reference/functions/setGraphqlEndpoint.mdx b/docs/zkapps/o1js-reference/functions/setGraphqlEndpoint.mdx deleted file mode 100644 index 0dce3d55a..000000000 --- a/docs/zkapps/o1js-reference/functions/setGraphqlEndpoint.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function setGraphqlEndpoint(graphqlEndpoint: string): void -``` - -## Parameters - -• **graphqlEndpoint**: `string` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:112](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L112) diff --git a/docs/zkapps/o1js-reference/functions/setGraphqlEndpoints.mdx b/docs/zkapps/o1js-reference/functions/setGraphqlEndpoints.mdx deleted file mode 100644 index 2c5fdc112..000000000 --- a/docs/zkapps/o1js-reference/functions/setGraphqlEndpoints.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function setGraphqlEndpoints(__namedParameters: string[]): void -``` - -## Parameters - -• **\_\_namedParameters**: `string`[] - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L105) diff --git a/docs/zkapps/o1js-reference/functions/setNumberOfWorkers.mdx b/docs/zkapps/o1js-reference/functions/setNumberOfWorkers.mdx deleted file mode 100644 index b5c29bc84..000000000 --- a/docs/zkapps/o1js-reference/functions/setNumberOfWorkers.mdx +++ /dev/null @@ -1,23 +0,0 @@ -```ts -function setNumberOfWorkers(numWorkers: number): void -``` - -Set the number of workers to use for parallelizing the proof generation. By default the number of workers is set to the number of physical CPU cores on your machine, but there may be some instances where you want to set the number of workers manually. Some machines may have a large number of cores, but not enough memory to support that many workers. In that case, you can set the number of workers to a lower number to avoid running out of memory. On the other hand, some machines with heterogeneous cores may benefit from setting the number of workers to a lower number to avoid contention between core types if load-link/store-conditional multithreading is used. Feel free to experiment and see what works best for your use case. Maybe you can squeeze slightly more performance out by tweaking this value :) - -## Parameters - -• **numWorkers**: `number` - -## Returns - -`void` - -## Example - -```typescript -setNumberOfWorkers(2); // set the number of workers to 2 -``` - -## Source - -[lib/proof-system/workers.ts:15](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/workers.ts#L15) diff --git a/docs/zkapps/o1js-reference/functions/state-1.mdx b/docs/zkapps/o1js-reference/functions/state-1.mdx deleted file mode 100644 index af422ba20..000000000 --- a/docs/zkapps/o1js-reference/functions/state-1.mdx +++ /dev/null @@ -1,44 +0,0 @@ -```ts -function state(type: ProvableTypePure | FlexibleProvablePure): (target: SmartContract & { - "constructor": any; - }, key: string, _descriptor?: PropertyDescriptor) => void -``` - -A decorator to use within a zkapp to indicate what will be stored on-chain. -For example, if you want to store a field element `some_state` in a zkapp, -you can use the following in the declaration of your zkapp: - -``` -@state(Field) some_state = State(); -``` - -## Type parameters - -• **A** - -## Parameters - -• **type**: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx)\<`A`\> \| [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`A`\> - -## Returns - -`Function` - -> ### Parameters -> -> • **target**: [`SmartContract`](../classes/SmartContract.mdx) & \{ -> `"constructor"`: `any`; -> \} -> -> • **key**: `string` -> -> • **\_descriptor?**: `PropertyDescriptor` -> -> ### Returns -> -> `void` -> - -## Source - -[lib/mina/state.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L105) diff --git a/docs/zkapps/o1js-reference/functions/toConstantField.mdx b/docs/zkapps/o1js-reference/functions/toConstantField.mdx deleted file mode 100644 index e131292fd..000000000 --- a/docs/zkapps/o1js-reference/functions/toConstantField.mdx +++ /dev/null @@ -1,25 +0,0 @@ -```ts -function toConstantField( - x: Field, - methodName: string, - varName: string, - varDescription: string): ConstantField -``` - -## Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **methodName**: `string` - -• **varName**: `string`= `'x'` - -• **varDescription**: `string`= `'field element'` - -## Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -## Source - -[lib/provable/field.ts:1197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1197) diff --git a/docs/zkapps/o1js-reference/functions/toFp.mdx b/docs/zkapps/o1js-reference/functions/toFp.mdx deleted file mode 100644 index 7df5cea2c..000000000 --- a/docs/zkapps/o1js-reference/functions/toFp.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function toFp(x: string | number | bigint | Field): bigint -``` - -## Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](../classes/Field.mdx) - -## Returns - -`bigint` - -## Source - -[lib/provable/field.ts:1156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1156) diff --git a/docs/zkapps/o1js-reference/functions/verify.mdx b/docs/zkapps/o1js-reference/functions/verify.mdx deleted file mode 100644 index 42760cab8..000000000 --- a/docs/zkapps/o1js-reference/functions/verify.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function verify(proof: ProofBase | JsonProof, verificationKey: string | VerificationKey): Promise -``` - -## Parameters - -• **proof**: [`ProofBase`](../classes/ProofBase.mdx)\<`any`, `any`\> \| [`JsonProof`](../type-aliases/JsonProof.mdx) - -• **verificationKey**: `string` \| [`VerificationKey`](../classes/VerificationKey.mdx) - -## Returns - -`Promise`\<`boolean`\> - -## Source - -[lib/proof-system/zkprogram.ts:109](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L109) diff --git a/docs/zkapps/o1js-reference/functions/withHashes.mdx b/docs/zkapps/o1js-reference/functions/withHashes.mdx deleted file mode 100644 index edce0a79e..000000000 --- a/docs/zkapps/o1js-reference/functions/withHashes.mdx +++ /dev/null @@ -1,46 +0,0 @@ -```ts -function withHashes( - data: T[], - nextHash: (hash: Field, value: T) => Field, - emptyHash: Field): { - "data": WithHash[]; - "hash": Field; -} -``` - -## Type parameters - -• **T** - -## Parameters - -• **data**: `T`[] - -• **nextHash** - -• **emptyHash**: [`Field`](../classes/Field.mdx) - -## Returns - -```ts -{ - "data": WithHash[]; - "hash": Field; -} -``` - -### data - -```ts -data: WithHash[]; -``` - -### hash - -```ts -hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:773](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L773) diff --git a/docs/zkapps/o1js-reference/functions/withMessage.mdx b/docs/zkapps/o1js-reference/functions/withMessage.mdx deleted file mode 100644 index 67836806c..000000000 --- a/docs/zkapps/o1js-reference/functions/withMessage.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function withMessage(error: unknown, message?: string): unknown -``` - -## Parameters - -• **error**: `unknown` - -• **message?**: `string` - -## Returns - -`unknown` - -## Source - -[lib/provable/field.ts:1174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1174) diff --git a/docs/zkapps/o1js-reference/interfaces/Permissions.mdx b/docs/zkapps/o1js-reference/interfaces/Permissions.mdx deleted file mode 100644 index 61a9523fb..000000000 --- a/docs/zkapps/o1js-reference/interfaces/Permissions.mdx +++ /dev/null @@ -1,250 +0,0 @@ -Permissions specify how specific aspects of the zkapp account are allowed -to be modified. All fields are denominated by a Permission. - -## Extends - -- `Permissions_` - -## Properties - -### access - -```ts -access: AuthRequired; -``` - -Permission to control the ability to include _any_ account update for this -account in a transaction. Note that this is more restrictive than all other -permissions combined. For normal accounts it can safely be set to `none`, -but for token contracts this has to be more restrictive, to prevent -unauthorized token interactions -- for example, it could be -`proofOrSignature`. - -#### Overrides - -`Permissions_.access` - -#### Source - -[lib/mina/account-update.ts:397](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L397) - -*** - -### editActionState - -```ts -editActionState: AuthRequired; -``` - -The Permission corresponding to the ability to emit actions to the account. - -#### Overrides - -`Permissions_.editActionState` - -#### Source - -[lib/mina/account-update.ts:376](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L376) - -*** - -### editState - -```ts -editState: AuthRequired; -``` - -The Permission corresponding to the 8 state fields associated with -an account. - -#### Overrides - -`Permissions_.editState` - -#### Source - -[lib/mina/account-update.ts:332](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L332) - -*** - -### incrementNonce - -```ts -incrementNonce: AuthRequired; -``` - -#### Overrides - -`Permissions_.incrementNonce` - -#### Source - -[lib/mina/account-update.ts:385](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L385) - -*** - -### receive - -```ts -receive: AuthRequired; -``` - -The Permission corresponding to the ability to receive transactions -to this account. - -#### Overrides - -`Permissions_.receive` - -#### Source - -[lib/mina/account-update.ts:344](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L344) - -*** - -### send - -```ts -send: AuthRequired; -``` - -The Permission corresponding to the ability to send transactions -from this account. - -#### Overrides - -`Permissions_.send` - -#### Source - -[lib/mina/account-update.ts:338](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L338) - -*** - -### setDelegate - -```ts -setDelegate: AuthRequired; -``` - -The Permission corresponding to the ability to set the delegate -field of the account. - -#### Overrides - -`Permissions_.setDelegate` - -#### Source - -[lib/mina/account-update.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L350) - -*** - -### setPermissions - -```ts -setPermissions: AuthRequired; -``` - -The Permission corresponding to the ability to set the permissions -field of the account. - -#### Overrides - -`Permissions_.setPermissions` - -#### Source - -[lib/mina/account-update.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L356) - -*** - -### setTiming - -```ts -setTiming: AuthRequired; -``` - -#### Overrides - -`Permissions_.setTiming` - -#### Source - -[lib/mina/account-update.ts:387](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L387) - -*** - -### setTokenSymbol - -```ts -setTokenSymbol: AuthRequired; -``` - -The Permission corresponding to the ability to set the token symbol -for this account. - -#### Overrides - -`Permissions_.setTokenSymbol` - -#### Source - -[lib/mina/account-update.ts:382](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L382) - -*** - -### setVerificationKey - -```ts -setVerificationKey: VerificationKeyPermission; -``` - -The Permission corresponding to the ability to set the verification -key associated with the circuit tied to this account. Effectively -"upgradeability" of the smart contract. - -#### Overrides - -`Permissions_.setVerificationKey` - -#### Source - -[lib/mina/account-update.ts:363](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L363) - -*** - -### setVotingFor - -```ts -setVotingFor: AuthRequired; -``` - -#### Overrides - -`Permissions_.setVotingFor` - -#### Source - -[lib/mina/account-update.ts:386](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L386) - -*** - -### setZkappUri - -```ts -setZkappUri: AuthRequired; -``` - -The Permission corresponding to the ability to set the zkapp uri -typically pointing to the source code of the smart contract. Usually this -should be changed whenever the [Permissions.setVerificationKey](Permissions.mdx#setverificationkey) is -changed. Effectively "upgradeability" of the smart contract. - -#### Overrides - -`Permissions_.setZkappUri` - -#### Source - -[lib/mina/account-update.ts:371](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L371) diff --git a/docs/zkapps/o1js-reference/namespaces/Crypto/README.mdx b/docs/zkapps/o1js-reference/namespaces/Crypto/README.mdx deleted file mode 100644 index 0e8c17dfa..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Crypto/README.mdx +++ /dev/null @@ -1,6 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [Curve](type-aliases/Curve.mdx) | - | -| [CurveParams](type-aliases/CurveParams.mdx) | Parameters defining an elliptic curve in short Weierstraß form | diff --git a/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve.mdx b/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve.mdx deleted file mode 100644 index 22638b09e..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Curve: CurveAffine; -``` - -## Source - -[lib/provable/crypto/crypto.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L29) diff --git a/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams.mdx b/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams.mdx deleted file mode 100644 index 748471769..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams.mdx +++ /dev/null @@ -1,10 +0,0 @@ -```ts -type CurveParams: CurveParams_; -``` - -Parameters defining an elliptic curve in short Weierstraß form -y^2 = x^3 + ax + b - -## Source - -[lib/provable/crypto/crypto.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L27) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/README.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/README.mdx deleted file mode 100644 index 0897f86e4..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/README.mdx +++ /dev/null @@ -1,10 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [CipherText](type-aliases/CipherText.mdx) | - | -| [CipherTextBytes](type-aliases/CipherTextBytes.mdx) | - | -| [decrypt](functions/decrypt.mdx) | Decrypts a [CipherText](type-aliases/CipherText.mdx) using a [PrivateKey](../../classes/PrivateKey.mdx). | -| [decryptBytes](functions/decryptBytes.mdx) | Decrypts a [CipherText](type-aliases/CipherText.mdx) using a [PrivateKey](../../classes/PrivateKey.mdx). | -| [encrypt](functions/encrypt.mdx) | Public Key Encryption, encrypts Field elements using a [PublicKey](../../classes/PublicKey.mdx). | -| [encryptBytes](functions/encryptBytes.mdx) | Public Key Encryption, encrypts Bytes using a [PublicKey](../../classes/PublicKey.mdx). | diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decrypt.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decrypt.mdx deleted file mode 100644 index 48185032a..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decrypt.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function decrypt(__namedParameters: CipherText, privateKey: PrivateKey): Field[] -``` - -Decrypts a [CipherText](../type-aliases/CipherText.mdx) using a [PrivateKey](../../../classes/PrivateKey.mdx). - -## Parameters - -• **\_\_namedParameters**: [`CipherText`](../type-aliases/CipherText.mdx) - -• **privateKey**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -[`Field`](../../../classes/Field.mdx)[] - -## Source - -[lib/provable/crypto/encryption.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L28) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes.mdx deleted file mode 100644 index 52ac2f0a2..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function decryptBytes(cipherText: CipherTextBytes, privateKey: PrivateKey): Bytes -``` - -Decrypts a [CipherText](../type-aliases/CipherText.mdx) using a [PrivateKey](../../../classes/PrivateKey.mdx). - -## Parameters - -• **cipherText**: [`CipherTextBytes`](../type-aliases/CipherTextBytes.mdx) - -• **privateKey**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -`Bytes` - -## Source - -[lib/provable/crypto/encryption.ts:129](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L129) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encrypt.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encrypt.mdx deleted file mode 100644 index 495f3703f..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encrypt.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function encrypt(message: Field[], otherPublicKey: PublicKey): CipherText -``` - -Public Key Encryption, encrypts Field elements using a [PublicKey](../../../classes/PublicKey.mdx). - -## Parameters - -• **message**: [`Field`](../../../classes/Field.mdx)[] - -• **otherPublicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -## Returns - -[`CipherText`](../type-aliases/CipherText.mdx) - -## Source - -[lib/provable/crypto/encryption.ts:64](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L64) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes.mdx deleted file mode 100644 index 07186a8e7..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function encryptBytes(message: Bytes, otherPublicKey: PublicKey): CipherTextBytes -``` - -Public Key Encryption, encrypts Bytes using a [PublicKey](../../../classes/PublicKey.mdx). - -## Parameters - -• **message**: `Bytes` - -• **otherPublicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -## Returns - -[`CipherTextBytes`](../type-aliases/CipherTextBytes.mdx) - -## Source - -[lib/provable/crypto/encryption.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L97) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText.mdx deleted file mode 100644 index df8bea9bc..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText.mdx +++ /dev/null @@ -1,24 +0,0 @@ -```ts -type CipherText: { - "cipherText": Field[]; - "publicKey": Group; -}; -``` - -## Type declaration - -### cipherText - -```ts -cipherText: Field[]; -``` - -### publicKey - -```ts -publicKey: Group; -``` - -## Source - -[lib/provable/crypto/encryption.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L19) diff --git a/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes.mdx b/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes.mdx deleted file mode 100644 index 556722b73..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type CipherTextBytes: CipherText & { - "messageLength": number; -}; -``` - -## Type declaration - -### messageLength - -```ts -messageLength: number; -``` - -## Source - -[lib/provable/crypto/encryption.ts:23](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L23) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/README.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/README.mdx deleted file mode 100644 index 4e8134ea4..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/README.mdx +++ /dev/null @@ -1,15 +0,0 @@ -This module exposes APIs that are unstable, in the sense that the API surface is expected to change. -(Not unstable in the sense that they are less functional or tested than other parts.) - -## Index - -| Member | Description | -| :------ | :------ | -| [BatchReducer](classes/BatchReducer.mdx) | A reducer to process actions in fixed-size batches. | -| [OffchainStateCommitments](classes/OffchainStateCommitments.mdx) | Commitments that keep track of the current state of an offchain Merkle tree constructed from actions. | -| [ActionBatch](type-aliases/ActionBatch.mdx) | - | -| [IndexedMerkleMap](type-aliases/IndexedMerkleMap.mdx) | - | -| [ActionBatch](functions/ActionBatch.mdx) | Provable type that represents a batch of actions. | -| [IndexedMerkleMap](functions/IndexedMerkleMap.mdx) | Class factory for an Indexed Merkle Map with a given height. | -| [OffchainState](functions/OffchainState.mdx) | Offchain state for a `SmartContract`. | -| [memoizeWitness](functions/memoizeWitness.mdx) | Like Provable.witness, but memoizes the witness during transaction construction | diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer.mdx deleted file mode 100644 index 25009f00c..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer.mdx +++ /dev/null @@ -1,3101 +0,0 @@ -A reducer to process actions in fixed-size batches. - -```ts -let batchReducer = new BatchReducer({ actionType: Action, batchSize: 5 }); - -// in contract: concurrent dispatching of actions -batchReducer.dispatch(action); - -// reducer logic -// outside contract: prepare a list of { batch, proof } objects which cover all pending actions -let batches = await batchReducer.prepareBatches(); - -// in contract: process a single batch -// create one transaction that does this for each batch! -batchReducer.processBatch({ batch, proof }, (action, isDummy) => { - // ... -}); -``` - -## Extends - -- `BatchReducer`\<`ActionType`, `BatchSize`, `Action`\> - -## Type parameters - -• **ActionType** *extends* `Actionable`\<`any`\> - -• **BatchSize** *extends* `number` = `number` - -• **Action** = [`InferProvable`](../../../type-aliases/InferProvable.mdx)\<`ActionType`\> - -## Constructors - -### new BatchReducer() - -```ts -new BatchReducer(__namedParameters: { - "actionType": ActionType; - "batchSize": BatchSize; - "maxActionsPerUpdate": number; - "maxUpdatesFinalProof": 100; - "maxUpdatesPerProof": 300; -}): BatchReducer -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.actionType**: `ActionType` - -The provable type of actions submitted by this reducer. - -• **\_\_namedParameters.batchSize**: `BatchSize` - -The number of actions in a batch. The idea is to process one batch per transaction, by calling `processBatch()`. - -The motivation for processing actions in small batches is to work around the protocol limit on the number of account updates. -If every action should result in an account update, then you have to set the batch size low enough to not exceed the limit. - -If transaction limits are no concern, the `batchSize` could be set based on amount of logic you do per action. -A smaller batch size will make proofs faster, but you might need more individual transactions as more batches are needed to process all pending actions. - -• **\_\_namedParameters.maxActionsPerUpdate?**: `number`= `undefined` - -The maximum number of actions dispatched in any of the zkApp methods on the contract. - -Note: This number just has to be an upper bound of the actual maximum, but if it's the precise number, -fewer constraints will be used. (The overhead of a higher number is fairly small though.) - -A restriction is that the number has to be less or equal than the `batchSize`. -The reason is that actions in one account update are always processed together, so if you'd have more actions in one than the batch size, we couldn't process them at all. - -By default, this is set to `Math.min(batchSize, 5)` which should be sensible for most applications. - -• **\_\_namedParameters.maxUpdatesFinalProof?**: `number`= `100` - -The maximum number of action lists (= all actions on an account update) to process inside `processBatch()`, -i.e. in your zkApp method. - -Default: 100, which will take up about 3000 constraints. - -The current default should be sensible for most applications, but here are some trade-offs to consider when changing it: - -- Using a smaller number means a smaller circuit, so proofs of your method will be faster. -- Using a bigger number means it's more likely that you can prove _all_ actions in the method call and won't need a recursive proof. - -So, go lower if you expect very few actions, and higher if you expect a lot of actions. - -• **\_\_namedParameters.maxUpdatesPerProof?**: `number`= `300` - -The maximum number of action lists (= all actions on an account update) to process in a single recursive proof, in `prepareBatches()`. - -Default: 300, which will take up about 9000 constraints. - -The current default should be sensible for most applications, but here are some trade-offs to consider when changing it: - -- Using a smaller number means a smaller circuit, so recursive proofs will be faster. -- Using a bigger number means you'll need fewer recursive proofs in the case a lot of actions are pending. - -So, go lower if you expect very few actions, and higher if you expect a lot of actions. -(Note: A larger circuit causes longer compilation and proof times for your zkApp even if you _never_ need a recursive proof) - -#### Returns - -[`BatchReducer`](BatchReducer.mdx)\<`ActionType`, `BatchSize`, `Action`\> - -#### Inherited from - -`BatchReducer_.BatchReducer.constructor` - -#### Source - -[lib/mina/actions/batch-reducer.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L75) - -## Properties - -### Batch - -```ts -Batch: (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - } & { - "_isStruct": true; - } & Provable<{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }, { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses; - }> & { - "empty": () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromValue": (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "toInput": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }; -}; -``` - -#### Type declaration - -##### \_isStruct - -```ts -_isStruct: true; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### fromJSON() - -```ts -fromJSON: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: `boolean`= `Bool` - -• **x.onchainActionState**: `string`= `Field` - -• **x.onchainStack**: `string`= `Field` - -• **x.processedActionState**: `string`= `Field` - -• **x.stack**= `undefined` - -• **x.stack.\_emptyHash**: `null` \| `string` - -• **x.stack.\_innerProvable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.\_nextHash**: `null` \| \{\} - -• **x.stack.\_provable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.empty** - -• **x.stack.emptyHash**: `string` - -• **x.stack.from** - -• **x.stack.fromReverse** - -• **x.stack.prototype** - -• **x.stack.prototype.Constructor** - -• **x.stack.prototype.Constructor.\_emptyHash**: `null` \| `string` - -• **x.stack.prototype.Constructor.\_innerProvable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.prototype.Constructor.\_nextHash**: `null` \| \{\} - -• **x.stack.prototype.Constructor.\_provable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.prototype.Constructor.emptyHash**: `string` - -• **x.stack.prototype.Constructor.prototype**: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \} - -• **x.stack.prototype.Constructor.create** - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -**Example** -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -• **x.stack.prototype.data** - -• **x.stack.prototype.data.get** - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -• **x.stack.prototype.data.set** - -Modify the unconstrained value. - -• **x.stack.prototype.data.setTo** - -Set the unconstrained value to the same as another `Unconstrained`. - -• **x.stack.prototype.data.updateAsProver** - -Update an `Unconstrained` by a witness computation. - -• **x.stack.prototype.hash**: `string` - -• **x.stack.prototype.innerProvable** - -• **x.stack.prototype.innerProvable.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.stack.prototype.innerProvable.empty** - -• **x.stack.prototype.innerProvable.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.stack.prototype.innerProvable.fromValue** - -Convert provable type from a normal JS type. - -• **x.stack.prototype.innerProvable.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.stack.prototype.innerProvable.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.stack.prototype.innerProvable.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.stack.prototype.innerProvable.toInput** - -• **x.stack.prototype.innerProvable.toValue** - -Convert provable type to a normal JS type. - -• **x.stack.prototype.innerProvable.sizeInFields** - -• **x.stack.prototype.clone** - -• **x.stack.prototype.forEach** - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -• **x.stack.prototype.isEmpty** - -• **x.stack.prototype.lengthUnconstrained** - -• **x.stack.prototype.nextHash** - -• **x.stack.prototype.pop** - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -• **x.stack.prototype.popExn** - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -• **x.stack.prototype.popIf** - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -• **x.stack.prototype.popIfUnsafe** - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -• **x.stack.prototype.push** - -Push a new element to the list. - -• **x.stack.prototype.pushIf** - -Push a new element to the list, if the `condition` is true. - -• **x.stack.prototype.startIterating** - -• **x.stack.prototype.startIteratingFromLast** - -• **x.stack.prototype.toArrayUnconstrained** - -• **x.stack.provable** - -• **x.stack.provable.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.stack.provable.empty** - -• **x.stack.provable.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.stack.provable.fromValue** - -Convert provable type from a normal JS type. - -• **x.stack.provable.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.stack.provable.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.stack.provable.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.stack.provable.toInput** - -• **x.stack.provable.toValue** - -Convert provable type to a normal JS type. - -• **x.stack.provable.sizeInFields** - -• **x.stack.create** - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -**Example** -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -• **x.useOnchainStack**: `boolean`= `Bool` - -• **x.witnesses**= `undefined` - -• **x.witnesses.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.witnesses.empty** - -• **x.witnesses.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.witnesses.fromValue** - -Convert provable type from a normal JS type. - -• **x.witnesses.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.witnesses.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.witnesses.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.witnesses.toInput** - -• **x.witnesses.toValue** - -Convert provable type to a normal JS type. - -• **x.witnesses.sizeInFields** - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### fromValue() - -```ts -fromValue: (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Parameters - -• **value** - -• **value.isRecursive**: `boolean` \| [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **value.onchainActionState**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.onchainStack**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.processedActionState**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.stack**: `any`= `undefined` - -• **value.useOnchainStack**: `boolean` \| [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **value.witnesses**: `ActionWitnesses` \| [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### toInput() - -```ts -toInput: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.onchainActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.onchainStack**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.processedActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.stack**: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`any`\>\>\>= `undefined` - -• **x.useOnchainStack**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.witnesses**: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -###### fields? - -```ts -optional fields: Field[]; -``` - -###### packed? - -```ts -optional packed: [Field, number][]; -``` - -##### toJSON() - -```ts -toJSON: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.onchainActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.onchainStack**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.processedActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.stack**: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`any`\>\>\>= `undefined` - -• **x.useOnchainStack**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.witnesses**: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; -} -``` - -###### isRecursive - -```ts -isRecursive: boolean = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: string = Field; -``` - -###### onchainStack - -```ts -onchainStack: string = Field; -``` - -###### processedActionState - -```ts -processedActionState: string = Field; -``` - -###### stack - -```ts -stack: { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; -}; -``` - -###### stack.\_emptyHash - -```ts -_emptyHash: null | string; -``` - -###### stack.\_innerProvable - -```ts -_innerProvable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.\_nextHash - -```ts -_nextHash: null | {}; -``` - -###### stack.\_provable - -```ts -_provable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.empty - -```ts -empty: {}; -``` - -###### stack.emptyHash - -```ts -emptyHash: string; -``` - -###### stack.from - -```ts -from: {}; -``` - -###### stack.fromReverse - -```ts -fromReverse: {}; -``` - -###### stack.prototype - -```ts -prototype: { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; -}; -``` - -###### stack.prototype.Constructor - -```ts -Constructor: { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; -}; -``` - -###### stack.prototype.Constructor.\_emptyHash - -```ts -_emptyHash: null | string; -``` - -###### stack.prototype.Constructor.\_innerProvable - -```ts -_innerProvable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.Constructor.\_nextHash - -```ts -_nextHash: null | {}; -``` - -###### stack.prototype.Constructor.\_provable - -```ts -_provable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.Constructor.emptyHash - -```ts -emptyHash: string; -``` - -###### stack.prototype.Constructor.prototype - -```ts -prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; -``` - -###### stack.prototype.Constructor.create - -```ts -create; -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -###### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -###### stack.prototype.data - -```ts -data: { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; -}; -``` - -###### stack.prototype.data.get - -```ts -get; -``` - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -###### stack.prototype.data.set - -```ts -set; -``` - -Modify the unconstrained value. - -###### stack.prototype.data.setTo - -```ts -setTo; -``` - -Set the unconstrained value to the same as another `Unconstrained`. - -###### stack.prototype.data.updateAsProver - -```ts -updateAsProver; -``` - -Update an `Unconstrained` by a witness computation. - -###### stack.prototype.hash - -```ts -hash: string; -``` - -###### stack.prototype.innerProvable - -```ts -innerProvable: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.innerProvable.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### stack.prototype.innerProvable.empty - -```ts -empty: {}; -``` - -###### stack.prototype.innerProvable.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### stack.prototype.innerProvable.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### stack.prototype.innerProvable.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### stack.prototype.innerProvable.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### stack.prototype.innerProvable.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### stack.prototype.innerProvable.toInput - -```ts -toInput: {}; -``` - -###### stack.prototype.innerProvable.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### stack.prototype.innerProvable.sizeInFields - -```ts -sizeInFields; -``` - -###### stack.prototype.clone - -```ts -clone; -``` - -###### stack.prototype.forEach - -```ts -forEach; -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -###### stack.prototype.isEmpty - -```ts -isEmpty; -``` - -###### stack.prototype.lengthUnconstrained - -```ts -lengthUnconstrained; -``` - -###### stack.prototype.nextHash - -```ts -nextHash; -``` - -###### stack.prototype.pop - -```ts -pop; -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -###### stack.prototype.popExn - -```ts -popExn; -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -###### stack.prototype.popIf - -```ts -popIf; -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -###### stack.prototype.popIfUnsafe - -```ts -popIfUnsafe; -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -###### stack.prototype.push - -```ts -push; -``` - -Push a new element to the list. - -###### stack.prototype.pushIf - -```ts -pushIf; -``` - -Push a new element to the list, if the `condition` is true. - -###### stack.prototype.startIterating - -```ts -startIterating; -``` - -###### stack.prototype.startIteratingFromLast - -```ts -startIteratingFromLast; -``` - -###### stack.prototype.toArrayUnconstrained - -```ts -toArrayUnconstrained; -``` - -###### stack.provable - -```ts -provable: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.provable.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### stack.provable.empty - -```ts -empty: {}; -``` - -###### stack.provable.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### stack.provable.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### stack.provable.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### stack.provable.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### stack.provable.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### stack.provable.toInput - -```ts -toInput: {}; -``` - -###### stack.provable.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### stack.provable.sizeInFields - -```ts -sizeInFields; -``` - -###### stack.create - -```ts -create; -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -###### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -###### useOnchainStack - -```ts -useOnchainStack: boolean = Bool; -``` - -###### witnesses - -```ts -witnesses: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### witnesses.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### witnesses.empty - -```ts -empty: {}; -``` - -###### witnesses.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### witnesses.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### witnesses.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### witnesses.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### witnesses.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### witnesses.toInput - -```ts -toInput: {}; -``` - -###### witnesses.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### witnesses.sizeInFields - -```ts -sizeInFields; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.Batch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L67) - -*** - -### BatchProof - -```ts -BatchProof: typeof Proof; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.BatchProof` - -#### Source - -[lib/mina/actions/batch-reducer.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L70) - -*** - -### \_contract? - -```ts -optional _contract: BatchReducerContract; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer._contract` - -#### Source - -[lib/mina/actions/batch-reducer.ts:164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L164) - -*** - -### \_contractClass? - -```ts -optional _contractClass: BatchReducerContractClass; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer._contractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L165) - -*** - -### actionType - -```ts -actionType: Provable & { - "empty": () => Action; - } & { - "toInput": (x: Action) => HashInput; - } & Omit, "fromFields"> & { - "fromFields": (fields: Field[]) => Action; -}; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => Action; -``` - -###### Returns - -`Action` - -#### Type declaration - -##### toInput() - -```ts -toInput: (x: Action) => HashInput; -``` - -###### Parameters - -• **x**: `Action` - -###### Returns - -`HashInput` - -#### Type declaration - -##### fromFields() - -```ts -fromFields: (fields: Field[]) => Action; -``` - -###### Parameters - -• **fields**: [`Field`](../../../classes/Field.mdx)[] - -###### Returns - -`Action` - -#### Inherited from - -`BatchReducer_.BatchReducer.actionType` - -#### Source - -[lib/mina/actions/batch-reducer.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L66) - -*** - -### batchSize - -```ts -batchSize: BatchSize; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.batchSize` - -#### Source - -[lib/mina/actions/batch-reducer.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L65) - -*** - -### maxActionsPerUpdate - -```ts -maxActionsPerUpdate: number; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.maxActionsPerUpdate` - -#### Source - -[lib/mina/actions/batch-reducer.ts:73](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L73) - -*** - -### maxUpdatesFinalProof - -```ts -maxUpdatesFinalProof: number; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.maxUpdatesFinalProof` - -#### Source - -[lib/mina/actions/batch-reducer.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L72) - -*** - -### program - -```ts -program: ActionStackProgram; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.program` - -#### Source - -[lib/mina/actions/batch-reducer.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L69) - -## Accessors - -### initialActionStack - -```ts -get static initialActionStack(): Field -``` - -#### Returns - -[`Field`](../../../classes/Field.mdx) - -#### Source - -[lib/mina/actions/batch-reducer.ts:160](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L160) - -*** - -### initialActionState - -```ts -get static initialActionState(): Field -``` - -#### Returns - -[`Field`](../../../classes/Field.mdx) - -#### Source - -[lib/mina/actions/batch-reducer.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L157) - -## Methods - -### compile() - -```ts -compile(): Promise<{ - "verificationKey": { - "data": string; - "hash": Field; - }; -}> -``` - -Compile the recursive action stack prover. - -#### Returns - -`Promise`\<\{ - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](../../../classes/Field.mdx); - \}; - \}\> - -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> - -#### Inherited from - -`BatchReducer_.BatchReducer.compile` - -#### Source - -[lib/mina/actions/batch-reducer.ts:421](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L421) - -*** - -### contract() - -```ts -contract(): BatchReducerContract -``` - -#### Returns - -`BatchReducerContract` - -#### Inherited from - -`BatchReducer_.BatchReducer.contract` - -#### Source - -[lib/mina/actions/batch-reducer.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L174) - -*** - -### contractClass() - -```ts -contractClass(): BatchReducerContractClass -``` - -#### Returns - -`BatchReducerContractClass` - -#### Inherited from - -`BatchReducer_.BatchReducer.contractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:167](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L167) - -*** - -### dispatch() - -```ts -dispatch(action: From): void -``` - -Submit an action. - -#### Parameters - -• **action**: `From`\<`ActionType`\> - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.dispatch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:202](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L202) - -*** - -### dispatchIf() - -```ts -dispatchIf(condition: Bool, action: From): void -``` - -Conditionally submit an action. - -#### Parameters - -• **condition**: [`Bool`](../../../classes/Bool.mdx) - -• **action**: `From`\<`ActionType`\> - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.dispatchIf` - -#### Source - -[lib/mina/actions/batch-reducer.ts:215](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L215) - -*** - -### prepareBatches() - -```ts -prepareBatches(): Promise<{ - "batch": ActionBatch; - "proof": ActionStackProof; -}[]> -``` - -Create a proof which returns the next actions batch(es) to process and helps guarantee their correctness. - -#### Returns - -`Promise`\<\{ - `"batch"`: `ActionBatch`\<`Action`\>; - `"proof"`: `ActionStackProof`; - \}[]\> - -#### Inherited from - -`BatchReducer_.BatchReducer.prepareBatches` - -#### Source - -[lib/mina/actions/batch-reducer.ts:428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L428) - -*** - -### processBatch() - -```ts -processBatch(__namedParameters: { - "batch": ActionBatch; - "proof": Proof; - }, callback: (action: Action, isDummy: Bool, i: number) => void): void -``` - -Process a batch of actions which was created by `prepareBatches()`. - -**Important**: The callback exposes the action's value along with an `isDummy` flag. -This is necessary because we process a dynamically-sized list in a fixed number of steps. -Dummies will be passed to your callback once the actual actions are exhausted. - -Make sure to write your code to account for dummies. For example, when sending MINA from your contract for every action, -you probably want to zero out the balance decrease in the `isDummy` case: -```ts -processBatch({ batch, proof }, (action, isDummy) => { - // ... other logic ... - - let amountToSend = Provable.if(isDummy, UInt64.zero, action.amount); - this.balance.subInPlace(amountToSend); -}); -``` - -**Warning**: Don't call `processBatch()` on two _different_ batches within the same method. The second call -would override the preconditions set by the first call, which would leave the method insecure. -To process more actions per method call, increase the `batchSize`. - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.batch**: `ActionBatch`\<`Action`\> - -• **\_\_namedParameters.proof**: [`Proof`](../../../classes/Proof.mdx)\<[`Field`](../../../classes/Field.mdx), `ActionStackState`\> - -• **callback** - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.processBatch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:253](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L253) - -*** - -### setContractClass() - -```ts -setContractClass(contractClass: BatchReducerContractClass): void -``` - -Set the smart contract class this reducer is connected with. - -Note: You can use either this method or `setContractInstance()` before calling `compile()`. -However, `setContractInstance()` is required for `proveNextBatch()`. - -#### Parameters - -• **contractClass**: `BatchReducerContractClass` - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.setContractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:195](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L195) - -*** - -### setContractInstance() - -```ts -setContractInstance(contract: BatchReducerContract): void -``` - -Set the smart contract instance this reducer is connected with. - -Note: This is a required step before using `dispatch()`, `proveNextBatch()` or `processNextBatch()`. - -#### Parameters - -• **contract**: `BatchReducerContract` - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.setContractInstance` - -#### Source - -[lib/mina/actions/batch-reducer.ts:184](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L184) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments.mdx deleted file mode 100644 index f35086982..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments.mdx +++ /dev/null @@ -1,733 +0,0 @@ -Commitments that keep track of the current state of an offchain Merkle tree constructed from actions. -Intended to be stored on-chain. - -Fields: -- `root`: The root of the current Merkle tree -- `actionState`: The hash pointing to the list of actions that have been applied to form the current Merkle tree - -## Extends - -- `OffchainStateCommitments` - -## Constructors - -### new OffchainStateCommitments() - -```ts -new OffchainStateCommitments(value: { - "actionState": Field; - "length": Field; - "root": Field; - }): OffchainStateCommitments -``` - -#### Parameters - -• **value** - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -[`OffchainStateCommitments`](OffchainStateCommitments.mdx) - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### actionState - -```ts -actionState: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.actionState` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L49) - -*** - -### length - -```ts -length: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.length` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L46) - -*** - -### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.root` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:45](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L45) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -`void` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](../../../classes/Field.mdx)[] - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: `string`= `Field` - -• **x.length**: `string`= `Field` - -• **x.root**: `string`= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "actionState": Field; - "length": Field; - "root": Field; - } | { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; - } & (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "actionState": Field; - "length": Field; - "root": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.actionState?**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length?**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root?**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -[`Field`](../../../classes/Field.mdx)[] - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: string = Field; -``` - -##### length - -```ts -length: string = Field; -``` - -##### root - -```ts -root: string = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: bigint = Field; -``` - -##### length - -```ts -length: bigint = Field; -``` - -##### root - -```ts -root: bigint = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### emptyFromHeight() - -```ts -static emptyFromHeight(height: number): OffchainStateCommitments -``` - -#### Parameters - -• **height**: `number` - -#### Returns - -`OffchainStateCommitments` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.emptyFromHeight` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L51) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](../../../classes/Field.mdx) type, as [Field](../../../classes/Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](../../../classes/Field.mdx) type. - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch.mdx deleted file mode 100644 index a716c2b1a..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch.mdx +++ /dev/null @@ -1,719 +0,0 @@ -```ts -function ActionBatch(actionType: A): (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - } & { - "_isStruct": true; - } & Provable<{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }, { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses; - }> & { - "empty": () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromValue": (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "toInput": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }; -} -``` - -Provable type that represents a batch of actions. - -## Type parameters - -• **A** *extends* `Actionable`\<`any`\> - -## Parameters - -• **actionType**: `A` - -## Returns - -(`value`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \} & \{ - `"_isStruct"`: `true`; - \} & `Provable`\<\{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}, \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: `any`; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: `ActionWitnesses`; - \}\> & \{ - `"empty"`: () => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"fromJSON"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"empty"`: \{\}; - `"emptyHash"`: `string`; - `"from"`: \{\}; - `"fromReverse"`: \{\}; - `"prototype"`: \{ - `"Constructor"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"emptyHash"`: `string`; - `"prototype"`: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \}; - `"create"`: ; - \}; - `"data"`: \{ - `"get"`: ; - `"set"`: ; - `"setTo"`: ; - `"updateAsProver"`: ; - \}; - `"hash"`: `string`; - `"innerProvable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"clone"`: ; - `"forEach"`: ; - `"isEmpty"`: ; - `"lengthUnconstrained"`: ; - `"nextHash"`: ; - `"pop"`: ; - `"popExn"`: ; - `"popIf"`: ; - `"popIfUnsafe"`: ; - `"push"`: ; - `"pushIf"`: ; - `"startIterating"`: ; - `"startIteratingFromLast"`: ; - `"toArrayUnconstrained"`: ; - \}; - `"provable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"create"`: ; - \}; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"fromValue"`: (`value`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: `any`; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: `ActionWitnesses` \| [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"toInput"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"fields"`: [`Field`](../../../classes/Field.mdx)[]; - `"packed"`: [[`Field`](../../../classes/Field.mdx), `number`][]; - \}; - `"toJSON"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"empty"`: \{\}; - `"emptyHash"`: `string`; - `"from"`: \{\}; - `"fromReverse"`: \{\}; - `"prototype"`: \{ - `"Constructor"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"emptyHash"`: `string`; - `"prototype"`: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \}; - `"create"`: ; - \}; - `"data"`: \{ - `"get"`: ; - `"set"`: ; - `"setTo"`: ; - `"updateAsProver"`: ; - \}; - `"hash"`: `string`; - `"innerProvable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"clone"`: ; - `"forEach"`: ; - `"isEmpty"`: ; - `"lengthUnconstrained"`: ; - `"nextHash"`: ; - `"pop"`: ; - `"popExn"`: ; - `"popIf"`: ; - `"popIfUnsafe"`: ; - `"push"`: ; - `"pushIf"`: ; - `"startIterating"`: ; - `"startIteratingFromLast"`: ; - `"toArrayUnconstrained"`: ; - \}; - `"provable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"create"`: ; - \}; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - \}; - \} - -## Source - -[index.ts:213](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L213) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap.mdx deleted file mode 100644 index 1a98404bb..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap.mdx +++ /dev/null @@ -1,52 +0,0 @@ -```ts -function IndexedMerkleMap(height: number): typeof IndexedMerkleMapBase -``` - -Class factory for an Indexed Merkle Map with a given height. - -```ts -class MerkleMap extends IndexedMerkleMap(33) {} - -let map = new MerkleMap(); - -map.insert(2n, 14n); -map.insert(1n, 13n); - -let x = map.get(2n); // 14 -``` - -Indexed Merkle maps can be used directly in provable code: - -```ts -ZkProgram({ - methods: { - test: { - privateInputs: [MerkleMap, Field], - - method(map: MerkleMap, key: Field) { - // get the value associated with `key` - let value = map.getOption(key).orElse(0n); - - // increment the value by 1 - map.set(key, value.add(1)); - } - } - } -}) -``` - -Initially, every `IndexedMerkleMap` is populated by a single key-value pair: `(0, 0)`. The value for key `0` can be updated like any other. -When keys and values are hash outputs, `(0, 0)` can serve as a convenient way to represent a dummy update to the tree, since 0 is not -effciently computable as a hash image, and this update doesn't affect the Merkle root. - -## Parameters - -• **height**: `number` - -## Returns - -*typeof* `IndexedMerkleMapBase` - -## Source - -[index.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L166) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState.mdx deleted file mode 100644 index 2eaf4faae..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState.mdx +++ /dev/null @@ -1,79 +0,0 @@ -```ts -function OffchainState(config: Config, options?: { - "logTotalCapacity": number; - "maxActionsPerProof": number; - "maxActionsPerUpdate": number; -}): OffchainState -``` - -Offchain state for a `SmartContract`. - -```ts -// declare your offchain state - -const offchainState = OffchainState({ - accounts: OffchainState.Map(PublicKey, UInt64), - totalSupply: OffchainState.Field(UInt64), -}); - -// use it in a contract, by adding an onchain state field of type `OffchainStateCommitments` - -class MyContract extends SmartContract { - \@state(OffchainStateCommitments) offchainState = State( - OffchainStateCommitments.empty() - ); - - // ... -} - -// set the contract instance - -let contract = new MyContract(address); -offchainState.setContractInstance(contract); -``` - -See the individual methods on `offchainState` for more information on usage. - -## Type parameters - -• **Config** *extends* \{\} - -## Parameters - -• **config**: `Config` - -• **options?** - -• **options.logTotalCapacity?**: `number` - -The base-2 logarithm of the total capacity of the offchain state. - -Example: if you want to have 1 million individual state fields and map entries available, -set this to 20, because 2^20 ~= 1M. - -The default is 30, which allows for ~1 billion entries. - -Passing in lower numbers will reduce the number of constraints required to prove offchain state updates, -which we will make proof creation slightly faster. -Instead, you could also use a smaller total capacity to increase the `maxActionsPerProof`, so that fewer proofs are required, -which will reduce the proof time even more, but only in the case of many actions. - -• **options.maxActionsPerProof?**: `number` - -• **options.maxActionsPerUpdate?**: `number` - -The maximum number of offchain state actions that can be included in a single account update. - -In other words, you must not call `.update()` or `.overwrite()` more than this number of times in any of your smart contract methods. - -The default is 4. - -Note: When increasing this, consider decreasing `maxActionsPerProof` or `logTotalCapacity` in order to not exceed the circuit size limit. - -## Returns - -`OffchainState`\<`Config`\> - -## Source - -[index.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L170) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness.mdx deleted file mode 100644 index 31c332569..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness.mdx +++ /dev/null @@ -1,24 +0,0 @@ -```ts -function memoizeWitness(type: FlexibleProvable, compute: () => T): T -``` - -Like Provable.witness, but memoizes the witness during transaction construction -for reuse by the prover. This is needed to witness non-deterministic values. - -## Type parameters - -• **T** - -## Parameters - -• **type**: [`FlexibleProvable`](../../../type-aliases/FlexibleProvable.mdx)\<`T`\> - -• **compute** - -## Returns - -`T` - -## Source - -[index.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L163) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch.mdx deleted file mode 100644 index 6fc1f2170..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -type ActionBatch: BatchReducer_.ActionBatch; -``` - -## Type parameters - -• **Action** - -## Source - -[index.ts:213](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L213) diff --git a/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap.mdx b/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap.mdx deleted file mode 100644 index 7937ed580..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type IndexedMerkleMap: IndexedMerkleMapBase; -``` - -## Source - -[index.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L166) diff --git a/docs/zkapps/o1js-reference/namespaces/Lightnet/README.mdx b/docs/zkapps/o1js-reference/namespaces/Lightnet/README.mdx deleted file mode 100644 index f66dfdfe9..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Lightnet/README.mdx +++ /dev/null @@ -1,7 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [acquireKeyPair](functions/acquireKeyPair.mdx) | Gets random key pair (public and private keys) from account manager | -| [listAcquiredKeyPairs](functions/listAcquiredKeyPairs.mdx) | Gets previously acquired key pairs list. | -| [releaseKeyPair](functions/releaseKeyPair.mdx) | Releases previously acquired key pair by public key. | diff --git a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair.mdx b/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair.mdx deleted file mode 100644 index c83b8554d..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair.mdx +++ /dev/null @@ -1,53 +0,0 @@ -```ts -function acquireKeyPair(options: { - "isRegularAccount": boolean; - "lightnetAccountManagerEndpoint": string; - }): Promise<{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -}> -``` - -Gets random key pair (public and private keys) from account manager -that operates with accounts configured in target network Genesis Ledger. - -If an error is returned by the specified endpoint, an error is thrown. Otherwise, -the data is returned. - -## Parameters - -• **options**= `{}` - -• **options.isRegularAccount?**: `boolean` - -Whether to acquire key pair of regular or zkApp account (one with already configured verification key) - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -## Returns - -`Promise`\<\{ - `"privateKey"`: [`PrivateKey`](../../../classes/PrivateKey.mdx); - `"publicKey"`: [`PublicKey`](../../../classes/PublicKey.mdx); - \}\> - -Key pair - -> ### privateKey -> -> ```ts -> privateKey: PrivateKey; -> ``` -> -> ### publicKey -> -> ```ts -> publicKey: PublicKey; -> ``` -> - -## Source - -[lib/mina/fetch.ts:843](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L843) diff --git a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs.mdx b/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs.mdx deleted file mode 100644 index 0d9f2cf30..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs.mdx +++ /dev/null @@ -1,31 +0,0 @@ -```ts -function listAcquiredKeyPairs(options: { - "lightnetAccountManagerEndpoint": string; - }): Promise<{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -}[] | null> -``` - -Gets previously acquired key pairs list. - -## Parameters - -• **options** - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -## Returns - -`Promise`\<\{ - `"privateKey"`: [`PrivateKey`](../../../classes/PrivateKey.mdx); - `"publicKey"`: [`PublicKey`](../../../classes/PublicKey.mdx); - \}[] \| `null`\> - -Key pairs list or null if the request failed - -## Source - -[lib/mina/fetch.ts:923](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L923) diff --git a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair.mdx b/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair.mdx deleted file mode 100644 index 39fa8c93f..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair.mdx +++ /dev/null @@ -1,30 +0,0 @@ -```ts -function releaseKeyPair(options: { - "lightnetAccountManagerEndpoint": string; - "publicKey": string; -}): Promise -``` - -Releases previously acquired key pair by public key. - -## Parameters - -• **options** - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -• **options.publicKey**: `string` - -Public key of previously acquired key pair to release - -## Returns - -`Promise`\<`string` \| `null`\> - -Response message from the account manager as string or null if the request failed - -## Source - -[lib/mina/fetch.ts:886](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L886) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/README.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/README.mdx deleted file mode 100644 index 342f2a285..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/README.mdx +++ /dev/null @@ -1,38 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [TestPublicKey](namespaces/TestPublicKey/README.mdx) | - | -| [Transaction](namespaces/Transaction/README.mdx) | - | -| [ActionStates](type-aliases/ActionStates.mdx) | - | -| [FeePayerSpec](type-aliases/FeePayerSpec.mdx) | Allows you to specify information about the fee payer account and the transaction. | -| [IncludedTransaction](type-aliases/IncludedTransaction.mdx) | Represents a transaction that has been successfully included in a block. | -| [NetworkConstants](type-aliases/NetworkConstants.mdx) | - | -| [PendingTransaction](type-aliases/PendingTransaction.mdx) | Represents a transaction that has been submitted to the blockchain but has not yet reached a final state. | -| [PendingTransactionPromise](type-aliases/PendingTransactionPromise.mdx) | A `Promise` with an additional `wait` method, which calls | -| [PendingTransactionStatus](type-aliases/PendingTransactionStatus.mdx) | - | -| [RejectedTransaction](type-aliases/RejectedTransaction.mdx) | Represents a transaction that has been rejected and not included in a blockchain block. | -| [TestPublicKey](type-aliases/TestPublicKey.mdx) | - | -| [Transaction](type-aliases/Transaction.mdx) | Defines the structure and operations associated with a transaction. | -| [activeInstance](variables/activeInstance.mdx) | - | -| [LocalBlockchain](functions/LocalBlockchain.mdx) | A mock Mina blockchain running locally and useful for testing. | -| [Network](functions/Network.mdx) | Represents the Mina blockchain running on a real network | -| [TestPublicKey](functions/TestPublicKey.mdx) | - | -| [currentSlot](functions/currentSlot.mdx) | - | -| [currentTransaction](functions/currentTransaction.mdx) | - | -| [faucet](functions/faucet.mdx) | Requests the [testnet faucet](https://faucet.minaprotocol.com/api/v1/faucet) to fund a public key. | -| [fetchActions](functions/fetchActions.mdx) | - | -| [fetchEvents](functions/fetchEvents.mdx) | - | -| [filterGroups](functions/filterGroups.mdx) | - | -| [getAccount](functions/getAccount.mdx) | - | -| [getActions](functions/getActions.mdx) | - | -| [getBalance](functions/getBalance.mdx) | - | -| [getNetworkConstants](functions/getNetworkConstants.mdx) | - | -| [getNetworkId](functions/getNetworkId.mdx) | - | -| [getNetworkState](functions/getNetworkState.mdx) | - | -| [getProofsEnabled](functions/getProofsEnabled.mdx) | - | -| [hasAccount](functions/hasAccount.mdx) | Checks if an account exists within the ledger. | -| [sender](functions/sender.mdx) | Returns the public key of the current transaction's sender account. | -| [setActiveInstance](functions/setActiveInstance.mdx) | Set the currently used Mina instance. | -| [transaction](functions/transaction.mdx) | Construct a smart contract transaction. Within the callback passed to this function, | -| [waitForFunding](functions/waitForFunding.mdx) | - | diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain.mdx deleted file mode 100644 index 66952eba9..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain.mdx +++ /dev/null @@ -1,329 +0,0 @@ -```ts -function LocalBlockchain(__namedParameters: { - "enforceTransactionLimits": true; - "proofsEnabled": true; - }): Promise<{ - "addAccount": (publicKey: PublicKey, balance: string) => void; - "getNetworkId": () => NetworkId; - "proofsEnabled": boolean; - "testAccounts": [TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey]; - "applyJsonTransaction": void; - "currentSlot": UInt32; - "fetchActions": Promise<{ - "actions": string[][]; - "hash": string; - }[]>; - "fetchEvents": Promise; - "getAccount": Account; - "getActions": { - "actions": string[][]; - "hash": string; - }[]; - "getNetworkConstants": { - "accountCreationFee": UInt64; - "genesisTimestamp": UInt64; - "slotTime": UInt64; - }; - "getNetworkState": PreconditionBaseTypes<{}>; - "hasAccount": boolean; - "incrementGlobalSlot": void; - "resetProofsEnabled": void; - "sendTransaction": PendingTransactionPromise; - "setBlockchainLength": void; - "setGlobalSlot": void; - "setProofsEnabled": void; - "setTotalCurrency": void; - "transaction": TransactionPromise; -}> -``` - -A mock Mina blockchain running locally and useful for testing. - -## Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.enforceTransactionLimits**: `undefined` \| `boolean`= `true` - -• **\_\_namedParameters.proofsEnabled**: `undefined` \| `boolean`= `true` - -## Returns - -`Promise`\<\{ - `"addAccount"`: (`publicKey`: [`PublicKey`](../../../classes/PublicKey.mdx), `balance`: `string`) => `void`; - `"getNetworkId"`: () => `NetworkId`; - `"proofsEnabled"`: `boolean`; - `"testAccounts"`: [[`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx)]; - `"applyJsonTransaction"`: `void`; - `"currentSlot"`: [`UInt32`](../../../classes/UInt32.mdx); - `"fetchActions"`: `Promise`\<\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[]\>; - `"fetchEvents"`: `Promise`\<`any`\>; - `"getAccount"`: `Account`; - `"getActions"`: \{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[]; - `"getNetworkConstants"`: \{ - `"accountCreationFee"`: [`UInt64`](../../../classes/UInt64.mdx); - `"genesisTimestamp"`: [`UInt64`](../../../classes/UInt64.mdx); - `"slotTime"`: [`UInt64`](../../../classes/UInt64.mdx); - \}; - `"getNetworkState"`: `PreconditionBaseTypes`\<\{\}\>; - `"hasAccount"`: `boolean`; - `"incrementGlobalSlot"`: `void`; - `"resetProofsEnabled"`: `void`; - `"sendTransaction"`: [`PendingTransactionPromise`](../type-aliases/PendingTransactionPromise.mdx); - `"setBlockchainLength"`: `void`; - `"setGlobalSlot"`: `void`; - `"setProofsEnabled"`: `void`; - `"setTotalCurrency"`: `void`; - `"transaction"`: [`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\>; - \}\> - -> ### addAccount() -> -> ```ts -> addAccount: (publicKey: PublicKey, balance: string) => void; -> ``` -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **balance**: `string` -> -> #### Returns -> -> `void` -> -> ### getNetworkId() -> -> ```ts -> getNetworkId: () => NetworkId; -> ``` -> -> #### Returns -> -> `NetworkId` -> -> ### proofsEnabled -> -> ```ts -> proofsEnabled: boolean; -> ``` -> -> ### testAccounts -> -> ```ts -> testAccounts: [TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey]; -> ``` -> -> ### applyJsonTransaction() -> -> #### Parameters -> -> • **json**: `string` -> -> #### Returns -> -> `void` -> -> ### currentSlot() -> -> #### Returns -> -> [`UInt32`](../../../classes/UInt32.mdx) -> -> ### fetchActions() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) -> -> • **tokenId?**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Promise`\<\{ -> `"actions"`: `string`[][]; -> `"hash"`: `string`; -> \}[]\> -> -> ### fetchEvents() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Promise`\<`any`\> -> -> ### getAccount() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Account` -> -> ### getActions() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) -> -> • **tokenId?**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> \{ -> `"actions"`: `string`[][]; -> `"hash"`: `string`; -> \}[] -> -> ### getNetworkConstants() -> -> #### Returns -> -> ```ts -> { -> "accountCreationFee": UInt64; -> "genesisTimestamp": UInt64; -> "slotTime": UInt64; -> } -> ``` -> -> ##### accountCreationFee -> -> ```ts -> accountCreationFee: UInt64; -> ``` -> -> ##### genesisTimestamp -> -> ```ts -> genesisTimestamp: UInt64; -> ``` -> -> ##### slotTime -> -> ```ts -> slotTime: UInt64; -> ``` -> -> Duration of 1 slot in millisecondw -> -> ### getNetworkState() -> -> #### Returns -> -> `PreconditionBaseTypes`\<\{\}\> -> -> ### hasAccount() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `boolean` -> -> ### incrementGlobalSlot() -> -> #### Parameters -> -> • **increment**: `number` \| [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### resetProofsEnabled() -> -> #### Returns -> -> `void` -> -> ### sendTransaction() -> -> #### Parameters -> -> • **txn**: [`Transaction`](../type-aliases/Transaction.mdx)\<`boolean`, `boolean`\> -> -> #### Returns -> -> [`PendingTransactionPromise`](../type-aliases/PendingTransactionPromise.mdx) -> -> ### setBlockchainLength() -> -> #### Parameters -> -> • **height**: [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### setGlobalSlot() -> -> #### Parameters -> -> • **slot**: `number` \| [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### setProofsEnabled() -> -> #### Parameters -> -> • **newProofsEnabled**: `boolean` -> -> #### Returns -> -> `void` -> -> ### setTotalCurrency() -> -> #### Parameters -> -> • **currency**: [`UInt64`](../../../classes/UInt64.mdx) -> -> #### Returns -> -> `void` -> -> ### transaction() -> -> #### Parameters -> -> • **sender**: [`FeePayerSpec`](../type-aliases/FeePayerSpec.mdx) -> -> • **f** -> -> #### Returns -> -> [`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> -> - -## Source - -[lib/mina/local-blockchain.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L72) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/Network.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/Network.mdx deleted file mode 100644 index d6d564d28..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/Network.mdx +++ /dev/null @@ -1,50 +0,0 @@ -## Network(graphqlEndpoint) - -```ts -function Network(graphqlEndpoint: string): Mina -``` - -Represents the Mina blockchain running on a real network - -### Parameters - -• **graphqlEndpoint**: `string` - -### Returns - -`Mina` - -### Source - -[lib/mina/mina.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L101) - -## Network(options) - -```ts -function Network(options: { - "archive": string | string[]; - "lightnetAccountManager": string; - "mina": string | string[]; - "networkId": NetworkId; - }): Mina -``` - -### Parameters - -• **options** - -• **options.archive?**: `string` \| `string`[] - -• **options.lightnetAccountManager?**: `string` - -• **options.mina**: `string` \| `string`[] - -• **options.networkId?**: `NetworkId` - -### Returns - -`Mina` - -### Source - -[lib/mina/mina.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L102) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey.mdx deleted file mode 100644 index 259d312bd..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function TestPublicKey(key: PrivateKey): TestPublicKey -``` - -## Parameters - -• **key**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -[`TestPublicKey`](../type-aliases/TestPublicKey.mdx) - -## Source - -[lib/mina/local-blockchain.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L51) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentSlot.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentSlot.mdx deleted file mode 100644 index e09e05f17..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentSlot.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -function currentSlot(): UInt32 -``` - -## Returns - -[`UInt32`](../../../classes/UInt32.mdx) - -The current slot number, according to the active Mina instance. - -## Source - -[lib/mina/mina-instance.ts:137](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L137) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction.mdx deleted file mode 100644 index be16e478e..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -function currentTransaction(): undefined | CurrentTransaction -``` - -## Returns - -`undefined` \| `CurrentTransaction` - -## Source - -[lib/mina/transaction-context.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction-context.ts#L16) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/faucet.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/faucet.mdx deleted file mode 100644 index a6a2ce9a2..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/faucet.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function faucet(pub: PublicKey, network: string): Promise -``` - -Requests the [testnet faucet](https://faucet.minaprotocol.com/api/v1/faucet) to fund a public key. - -## Parameters - -• **pub**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **network**: `string`= `'berkeley-qanet'` - -## Returns - -`Promise`\<`void`\> - -## Source - -[lib/mina/mina.ts:514](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L514) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions.mdx deleted file mode 100644 index 9a805406e..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions.mdx +++ /dev/null @@ -1,40 +0,0 @@ -```ts -function fetchActions( - publicKey: PublicKey, - actionStates?: ActionStates, - tokenId?: Field): Promise<{ - "actions": string[][]; - "hash": string; - }[] | { - "error": { - "statusCode": 404; - "statusText": string; - }; -}> -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -`Promise`\<\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[] \| \{ - `"error"`: \{ - `"statusCode"`: `404`; - `"statusText"`: `string`; - \}; - \}\> - -A list of emitted sequencing actions associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L197) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents.mdx deleted file mode 100644 index a208496f9..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents.mdx +++ /dev/null @@ -1,52 +0,0 @@ -```ts -function fetchEvents( - publicKey: PublicKey, - tokenId: Field, - filterOptions: EventActionFilterOptions): Promise<{ - "blockHash": event.blockInfo.stateHash; - "blockHeight": UInt32; - "chainStatus": event.blockInfo.chainStatus; - "events": { - "data": string[]; - "transactionInfo": { - "hash": string; - "memo": string; - "status": string; - }; - }[]; - "globalSlot": UInt32; - "parentBlockHash": event.blockInfo.parentHash; -}[]> -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId**: [`Field`](../../../classes/Field.mdx) - -• **filterOptions**: `EventActionFilterOptions`= `{}` - -## Returns - -`Promise`\<\{ - `"blockHash"`: `event.blockInfo.stateHash`; - `"blockHeight"`: [`UInt32`](../../../classes/UInt32.mdx); - `"chainStatus"`: `event.blockInfo.chainStatus`; - `"events"`: \{ - `"data"`: `string`[]; - `"transactionInfo"`: \{ - `"hash"`: `string`; - `"memo"`: `string`; - `"status"`: `string`; - \}; - \}[]; - `"globalSlot"`: [`UInt32`](../../../classes/UInt32.mdx); - `"parentBlockHash"`: `event.blockInfo.parentHash`; - \}[]\> - -A list of emitted events associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:186](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L186) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/filterGroups.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/filterGroups.mdx deleted file mode 100644 index 4ba689499..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/filterGroups.mdx +++ /dev/null @@ -1,43 +0,0 @@ -```ts -function filterGroups(xs: AuthorizationKind[]): { - "proof": proofCount; - "signedPair": pairs.pairs; - "signedSingle": singleCount; -} -``` - -## Parameters - -• **xs**: `AuthorizationKind`[] - -## Returns - -```ts -{ - "proof": proofCount; - "signedPair": pairs.pairs; - "signedSingle": singleCount; -} -``` - -### proof - -```ts -proof: number = proofCount; -``` - -### signedPair - -```ts -signedPair: number = pairs.pairs; -``` - -### signedSingle - -```ts -signedSingle: number = singleCount; -``` - -## Source - -[lib/mina/transaction-validation.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction-validation.ts#L130) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getAccount.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getAccount.mdx deleted file mode 100644 index 3c5422e30..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getAccount.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function getAccount(publicKey: PublicKey, tokenId?: Field): Account -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -[`Account`](../../../type-aliases/Account.mdx) - -The account data associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L144) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getActions.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getActions.mdx deleted file mode 100644 index 968626998..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getActions.mdx +++ /dev/null @@ -1,30 +0,0 @@ -```ts -function getActions( - publicKey: PublicKey, - actionStates?: ActionStates, - tokenId?: Field): { - "actions": string[][]; - "hash": string; - }[] -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[] - -A list of emitted sequencing actions associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L208) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getBalance.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getBalance.mdx deleted file mode 100644 index 245cee22f..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getBalance.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function getBalance(publicKey: PublicKey, tokenId?: Field): UInt64 -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -[`UInt64`](../../../classes/UInt64.mdx) - -The balance associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L179) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants.mdx deleted file mode 100644 index 4712c04f3..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -function getNetworkConstants(): NetworkConstants -``` - -## Returns - -[`NetworkConstants`](../type-aliases/NetworkConstants.mdx) - -Data associated with the current Mina network constants. - -## Source - -[lib/mina/mina-instance.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L165) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId.mdx deleted file mode 100644 index 64968a46e..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -function getNetworkId(): NetworkId -``` - -## Returns - -`NetworkId` - -The current Mina network ID. - -## Source - -[lib/mina/mina-instance.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L158) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState.mdx deleted file mode 100644 index 18ad9f221..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -function getNetworkState(): PreconditionBaseTypes<{}> -``` - -## Returns - -`PreconditionBaseTypes`\<\{\}\> - -Data associated with the current state of the Mina network. - -## Source - -[lib/mina/mina-instance.ts:172](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L172) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled.mdx deleted file mode 100644 index 85f89d3c9..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -function getProofsEnabled(): boolean -``` - -## Returns - -`boolean` - -## Source - -[lib/mina/mina-instance.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L216) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/hasAccount.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/hasAccount.mdx deleted file mode 100644 index 0d127946b..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/hasAccount.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function hasAccount(publicKey: PublicKey, tokenId?: Field): boolean -``` - -Checks if an account exists within the ledger. - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -`boolean` - -## Source - -[lib/mina/mina-instance.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L151) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/sender.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/sender.mdx deleted file mode 100644 index a583ba205..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/sender.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function sender(): PublicKey -``` - -Returns the public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -## Returns - -[`PublicKey`](../../../classes/PublicKey.mdx) - -## Source - -[lib/mina/mina.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L463) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance.mdx deleted file mode 100644 index 8bf21d538..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -function setActiveInstance(m: Mina): void -``` - -Set the currently used Mina instance. - -## Parameters - -• **m**: `Mina` - -## Returns - -`void` - -## Source - -[lib/mina/mina-instance.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L126) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/transaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/transaction.mdx deleted file mode 100644 index 16e01cd12..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/transaction.mdx +++ /dev/null @@ -1,49 +0,0 @@ -## transaction(sender, f) - -```ts -function transaction(sender: FeePayerSpec, f: () => Promise): TransactionPromise -``` - -Construct a smart contract transaction. Within the callback passed to this function, -you can call into the methods of smart contracts. - -``` -let tx = await Mina.transaction(sender, async () => { - await myZkapp.update(); - await someOtherZkapp.someOtherMethod(); -}); -``` - -### Parameters - -• **sender**: [`FeePayerSpec`](../type-aliases/FeePayerSpec.mdx) - -• **f** - -### Returns - -[`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> - -A transaction that can subsequently be submitted to the chain. - -### Source - -[lib/mina/transaction.ts:564](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L564) - -## transaction(f) - -```ts -function transaction(f: () => Promise): TransactionPromise -``` - -### Parameters - -• **f** - -### Returns - -[`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> - -### Source - -[lib/mina/transaction.ts:568](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L568) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding.mdx deleted file mode 100644 index bacf6f102..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function waitForFunding(address: string): Promise -``` - -## Parameters - -• **address**: `string` - -## Returns - -`Promise`\<`void`\> - -## Source - -[lib/mina/mina.ts:490](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L490) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README.mdx deleted file mode 100644 index faa0a1181..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README.mdx +++ /dev/null @@ -1,6 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [fromBase58](functions/fromBase58.mdx) | - | -| [random](functions/random.mdx) | - | diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58.mdx deleted file mode 100644 index 3634267bb..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function fromBase58(base58: string): TestPublicKey -``` - -## Parameters - -• **base58**: `string` - -## Returns - -[`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx) - -## Source - -[lib/mina/local-blockchain.ts:64](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L64) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random.mdx deleted file mode 100644 index ebc6518bd..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random.mdx +++ /dev/null @@ -1,19 +0,0 @@ -```ts -function random(count: N): N extends 1 ? TestPublicKey : TupleN -``` - -## Type parameters - -• **N** *extends* `number` = `1` - -## Parameters - -• **count**: `N`= `undefined` - -## Returns - -`N` *extends* `1` ? [`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx) : [`TupleN`](../../../../../type-aliases/TupleN.mdx)\<[`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx), `N`\> - -## Source - -[lib/mina/local-blockchain.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L55) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README.mdx deleted file mode 100644 index 699a90bd4..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README.mdx +++ /dev/null @@ -1,5 +0,0 @@ -## Index - -| Member | Description | -| :------ | :------ | -| [fromJSON](functions/fromJSON.mdx) | - | diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON.mdx deleted file mode 100644 index a67e36d70..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -function fromJSON(json: ZkappCommand): Transaction -``` - -## Parameters - -• **json**: `ZkappCommand` - -## Returns - -[`Transaction`](../../../type-aliases/Transaction.mdx)\<`false`, `false`\> - -## Source - -[lib/mina/transaction.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L85) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates.mdx deleted file mode 100644 index ee06e22c4..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates.mdx +++ /dev/null @@ -1,24 +0,0 @@ -```ts -type ActionStates: { - "endActionState": Field; - "fromActionState": Field; -}; -``` - -## Type declaration - -### endActionState? - -```ts -optional endActionState: Field; -``` - -### fromActionState? - -```ts -optional fromActionState: Field; -``` - -## Source - -[lib/mina/mina-instance.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L62) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec.mdx deleted file mode 100644 index 752cdf36d..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec.mdx +++ /dev/null @@ -1,14 +0,0 @@ -```ts -type FeePayerSpec: PublicKey | { - "fee": number | string | UInt64; - "memo": string; - "nonce": number; - "sender": PublicKey; - } | undefined; -``` - -Allows you to specify information about the fee payer account and the transaction. - -## Source - -[lib/mina/mina-instance.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L52) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction.mdx deleted file mode 100644 index 493ef72cf..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction.mdx +++ /dev/null @@ -1,37 +0,0 @@ -```ts -type IncludedTransaction: Pick & { - "status": "included"; -}; -``` - -Represents a transaction that has been successfully included in a block. - -## Type declaration - -### status - -```ts -status: "included"; -``` - -#### Example - -```ts -try { - const includedTx: IncludedTransaction = await pendingTransaction.wait(); - // If wait() resolves, it means the transaction was successfully included. - console.log(`Transaction ${includedTx.hash} included in a block.`); -} catch (error) { - // If wait() throws, the transaction was not included in a block. - console.error('Transaction failed to be included in a block:', error); -} -``` - -## Source - -[lib/mina/transaction.ts:258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L258) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants.mdx deleted file mode 100644 index 433b553e6..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants.mdx +++ /dev/null @@ -1,33 +0,0 @@ -```ts -type NetworkConstants: { - "accountCreationFee": UInt64; - "genesisTimestamp": UInt64; - "slotTime": UInt64; -}; -``` - -## Type declaration - -### accountCreationFee - -```ts -accountCreationFee: UInt64; -``` - -### genesisTimestamp - -```ts -genesisTimestamp: UInt64; -``` - -### slotTime - -```ts -slotTime: UInt64; -``` - -Duration of 1 slot in millisecondw - -## Source - -[lib/mina/mina-instance.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L67) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction.mdx deleted file mode 100644 index 8f1e364f1..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction.mdx +++ /dev/null @@ -1,151 +0,0 @@ -```ts -type PendingTransaction: Pick & { - "data": SendZkAppResponse; - "errors": string[]; - "hash": string; - "status": PendingTransactionStatus; - "safeWait": Promise; - "wait": Promise; -}; -``` - -Represents a transaction that has been submitted to the blockchain but has not yet reached a final state. -The [PendingTransaction](PendingTransaction.mdx) type extends certain functionalities from the base [Transaction](Transaction.mdx) type, -adding methods to monitor the transaction's progress towards being finalized (either included in a block or rejected). - -## Type declaration - -### data? - -```ts -optional data: SendZkAppResponse; -``` - -Optional. Contains response data from a ZkApp transaction submission. - -### errors - -```ts -errors: string[]; -``` - -An array of error messages related to the transaction processing. - -#### Example - -```ts -if (!pendingTransaction.status === 'rejected') { - console.error(`Transaction errors: ${pendingTransaction.errors.join(', ')}`); -} -``` - -### hash - -```ts -hash: string; -``` - -Returns the transaction hash as a string identifier. - -#### Example - -```ts -const txHash = pendingTransaction.hash; -console.log(`Transaction hash: ${txHash}`); -``` - -### status - -```ts -status: PendingTransactionStatus; -``` - -#### Example - -```ts -if (pendingTransaction.status === 'pending') { - console.log('Transaction accepted for processing by the Mina daemon.'); - try { - await pendingTransaction.wait(); - console.log('Transaction successfully included in a block.'); - } catch (error) { - console.error('Transaction was rejected or failed to be included in a block:', error); - } -} else { - console.error('Transaction was not accepted for processing by the Mina daemon.'); -} -``` - -### safeWait() - -Waits for the transaction to be included in a block. This method polls the Mina daemon to check the transaction's status - -#### Parameters - -• **options?** - -Configuration options for polling behavior. - -• **options.interval?**: `number` - -The time interval, in milliseconds, between each polling attempt. - -• **options.maxAttempts?**: `number` - -The maximum number of polling attempts. - -#### Returns - -`Promise`\<[`RejectedTransaction`](RejectedTransaction.mdx) \| [`IncludedTransaction`](IncludedTransaction.mdx)\> - -A promise that resolves to the transaction's final state. - -#### Example - -```ts -const transaction = await pendingTransaction.wait({ maxAttempts: 5, interval: 1000 }); -console.log(transaction.status); // 'included' or 'rejected' -``` - -### wait() - -Waits for the transaction to be included in a block. This method polls the Mina daemon to check the transaction's status, and throws an error if the transaction is rejected. - -#### Parameters - -• **options?** - -Configuration options for polling behavior. - -• **options.interval?**: `number` - -The interval, in milliseconds, between status checks. - -• **options.maxAttempts?**: `number` - -The maximum number of attempts to check the transaction status. - -#### Returns - -`Promise`\<[`IncludedTransaction`](IncludedTransaction.mdx)\> - -A promise that resolves to the transaction's final state or throws an error. - -#### Throws - -If the transaction is rejected or fails to finalize within the given attempts. - -#### Example - -```ts -try { - const transaction = await pendingTransaction.wait({ maxAttempts: 10, interval: 2000 }); - console.log('Transaction included in a block.'); -} catch (error) { - console.error('Transaction rejected or failed to finalize:', error); -} -``` - -## Source - -[lib/mina/transaction.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L157) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise.mdx deleted file mode 100644 index ac9f15bfe..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise.mdx +++ /dev/null @@ -1,22 +0,0 @@ -```ts -type PendingTransactionPromise: Promise & { - "wait": PendingTransaction["wait"]; -}; -``` - -A `Promise` with an additional `wait` method, which calls -into the inner `TransactionStatus`'s `wait` method upon its resolution. - -## Type declaration - -### wait - -```ts -wait: PendingTransaction["wait"]; -``` - -Equivalent to calling the resolved `PendingTransaction`'s `wait` method. - -## Source - -[lib/mina/transaction.ts:376](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L376) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus.mdx deleted file mode 100644 index 260b3617a..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type PendingTransactionStatus: "pending" | "rejected"; -``` - -## Source - -[lib/mina/transaction.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L151) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction.mdx deleted file mode 100644 index 04786407e..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction.mdx +++ /dev/null @@ -1,46 +0,0 @@ -```ts -type RejectedTransaction: Pick & { - "errors": string[]; - "status": "rejected"; -}; -``` - -Represents a transaction that has been rejected and not included in a blockchain block. - -## Type declaration - -### errors - -```ts -errors: string[]; -``` - -### status - -```ts -status: "rejected"; -``` - -#### Example - -```ts -try { - const txResult = await pendingTransaction.wait(); - // This line will not execute if the transaction is rejected, as `.wait()` will throw an error instead. - console.log(`Transaction ${txResult.hash} was successfully included in a block.`); -} catch (error) { - console.error(`Transaction ${error.transaction.hash} was rejected.`); - error.errors.forEach((error, i) => { - console.error(`Error ${i + 1}: ${error}`); - }); -} -``` - -## Source - -[lib/mina/transaction.ts:282](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L282) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey.mdx deleted file mode 100644 index 849a11bf1..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type TestPublicKey: PublicKey & { - "key": PrivateKey; -}; -``` - -## Type declaration - -### key - -```ts -key: PrivateKey; -``` - -## Source - -[lib/mina/local-blockchain.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L51) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction.mdx deleted file mode 100644 index c79315161..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction.mdx +++ /dev/null @@ -1,55 +0,0 @@ -```ts -type Transaction: TransactionCommon & { - "safeSend": Promise; - "send": PendingTransactionPromise; - } & Proven extends false ? { - "prove": Promise>; - } : { - "proofs": (Proof | undefined)[]; - } & Signed extends false ? { - "sign": Transaction; -} : {}; -``` - -Defines the structure and operations associated with a transaction. -This type encompasses methods for serializing the transaction, signing it, generating proofs, -and submitting it to the network. - -## Type declaration - -### safeSend() - -Sends the [Transaction](Transaction.mdx) to the network. Unlike the standard Transaction.send, this function does not throw an error if internal errors are detected. Instead, it returns a [PendingTransaction](PendingTransaction.mdx) if the transaction is successfully sent for processing or a [RejectedTransaction](RejectedTransaction.mdx) if it encounters errors during processing or is outright rejected by the Mina daemon. - -#### Returns - -`Promise`\<[`PendingTransaction`](PendingTransaction.mdx) \| [`RejectedTransaction`](RejectedTransaction.mdx)\> - -A promise that resolves to a [PendingTransaction](PendingTransaction.mdx) if the transaction is accepted for processing, or a [RejectedTransaction](RejectedTransaction.mdx) if the transaction fails or is rejected. - -#### Example - -```ts -const result = await transaction.safeSend(); -if (result.status === 'pending') { - console.log('Transaction sent successfully to the Mina daemon.'); -} else if (result.status === 'rejected') { - console.error('Transaction failed with errors:', result.errors); -} -``` - -### send() - -#### Returns - -[`PendingTransactionPromise`](PendingTransactionPromise.mdx) - -## Type parameters - -• **Proven** *extends* `boolean` - -• **Signed** *extends* `boolean` - -## Source - -[lib/mina/transaction.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L84) diff --git a/docs/zkapps/o1js-reference/namespaces/Mina/variables/activeInstance.mdx b/docs/zkapps/o1js-reference/namespaces/Mina/variables/activeInstance.mdx deleted file mode 100644 index bbb697616..000000000 --- a/docs/zkapps/o1js-reference/namespaces/Mina/variables/activeInstance.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -activeInstance: Mina; -``` - -## Source - -[lib/mina/mina-instance.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L108) diff --git a/docs/zkapps/o1js-reference/type-aliases/Account.mdx b/docs/zkapps/o1js-reference/type-aliases/Account.mdx deleted file mode 100644 index 14066aad2..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Account.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Account: Types.Account; -``` - -## Source - -[lib/mina/account.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account.ts#L19) diff --git a/docs/zkapps/o1js-reference/type-aliases/Bool.mdx b/docs/zkapps/o1js-reference/type-aliases/Bool.mdx deleted file mode 100644 index fed51d3d4..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Bool.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Bool: Bool; -``` - -## Source - -[lib/provable/wrapped.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L70) diff --git a/docs/zkapps/o1js-reference/type-aliases/BoolVar.mdx b/docs/zkapps/o1js-reference/type-aliases/BoolVar.mdx deleted file mode 100644 index 3561d1a25..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/BoolVar.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type BoolVar: FieldVar; -``` - -## Source - -[lib/provable/bool.ts:14](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L14) diff --git a/docs/zkapps/o1js-reference/type-aliases/Bytes.mdx b/docs/zkapps/o1js-reference/type-aliases/Bytes.mdx deleted file mode 100644 index 517f19fa4..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Bytes.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Bytes: InternalBytes; -``` - -## Source - -[lib/provable/wrapped-classes.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped-classes.ts#L16) diff --git a/docs/zkapps/o1js-reference/type-aliases/Cache.mdx b/docs/zkapps/o1js-reference/type-aliases/Cache.mdx deleted file mode 100644 index a09194734..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Cache.mdx +++ /dev/null @@ -1,79 +0,0 @@ -```ts -type Cache: { - "canWrite": boolean; - "debug": boolean; - "read": undefined | Uint8Array; - "write": void; -}; -``` - -Interface for storing and retrieving values, for caching. -`read()` and `write()` can just throw errors on failure. - -The data that will be passed to the cache for writing is exhaustively described by the [CacheHeader](CacheHeader.mdx) type. -It represents one of the following: -- The SRS. This is a deterministic lists of curve points (one per curve) that needs to be generated just once, - to be used for polynomial commitments. -- Lagrange basis commitments. Similar to the SRS, this will be created once for every power-of-2 circuit size. -- Prover and verifier keys for every compiled circuit. - -Per smart contract or ZkProgram, several different keys are created: -- a step prover key (`step-pk`) and verification key (`step-vk`) _for every method_. -- a wrap prover key (`wrap-pk`) and verification key (`wrap-vk`) for the entire contract. - -## Type declaration - -### canWrite - -```ts -canWrite: boolean; -``` - -Indicates whether the cache is writable. - -### debug? - -```ts -optional debug: boolean; -``` - -If `debug` is toggled, `read()` and `write()` errors are logged to the console. - -By default, cache errors are silent, because they don't necessarily represent an error condition, -but could just be a cache miss, or file system permissions incompatible with writing data. - -### read() - -Read a value from the cache. - -#### Parameters - -• **header**: [`CacheHeader`](CacheHeader.mdx) - -A small header to identify what is read from the cache. - -#### Returns - -`undefined` \| `Uint8Array` - -### write() - -Write a value to the cache. - -#### Parameters - -• **header**: [`CacheHeader`](CacheHeader.mdx) - -A small header to identify what is written to the cache. This will be used by `read()` to retrieve the data. - -• **value**: `Uint8Array` - -The value to write to the cache, as a byte array. - -#### Returns - -`void` - -## Source - -[lib/proof-system/cache.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L37) diff --git a/docs/zkapps/o1js-reference/type-aliases/CacheHeader.mdx b/docs/zkapps/o1js-reference/type-aliases/CacheHeader.mdx deleted file mode 100644 index a15c8c9c3..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/CacheHeader.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type CacheHeader: - | StepKeyHeader<"step-pk"> - | StepKeyHeader<"step-vk"> - | WrapKeyHeader<"wrap-pk"> - | WrapKeyHeader<"wrap-vk"> - | PlainHeader<"srs"> - | PlainHeader & CommonHeader; -``` - -A header that is passed to the caching layer, to support rich caching strategies. - -Both `uniqueId` and `programId` can safely be used as a file path. - -## Source - -[lib/proof-system/cache.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L106) diff --git a/docs/zkapps/o1js-reference/type-aliases/ConstantField.mdx b/docs/zkapps/o1js-reference/type-aliases/ConstantField.mdx deleted file mode 100644 index 122671122..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ConstantField.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type ConstantField: Field & { - "value": ConstantFieldVar; -}; -``` - -## Type declaration - -### value - -```ts -value: ConstantFieldVar; -``` - -## Source - -[lib/provable/field.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1246) diff --git a/docs/zkapps/o1js-reference/type-aliases/DeployArgs.mdx b/docs/zkapps/o1js-reference/type-aliases/DeployArgs.mdx deleted file mode 100644 index 23ce3a18b..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/DeployArgs.mdx +++ /dev/null @@ -1,12 +0,0 @@ -```ts -type DeployArgs: { - "verificationKey": { - "data": string; - "hash": string | Field; - }; - } | undefined; -``` - -## Source - -[lib/mina/zkapp.ts:1248](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1248) diff --git a/docs/zkapps/o1js-reference/type-aliases/Empty.mdx b/docs/zkapps/o1js-reference/type-aliases/Empty.mdx deleted file mode 100644 index 18a45f2e9..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Empty.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Empty: Undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L85) diff --git a/docs/zkapps/o1js-reference/type-aliases/FeatureFlags.mdx b/docs/zkapps/o1js-reference/type-aliases/FeatureFlags.mdx deleted file mode 100644 index 7f489f963..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/FeatureFlags.mdx +++ /dev/null @@ -1,66 +0,0 @@ -```ts -type FeatureFlags: { - "foreignFieldAdd": boolean | undefined; - "foreignFieldMul": boolean | undefined; - "lookup": boolean | undefined; - "rangeCheck0": boolean | undefined; - "rangeCheck1": boolean | undefined; - "rot": boolean | undefined; - "runtimeTables": boolean | undefined; - "xor": boolean | undefined; -}; -``` - -## Type declaration - -### foreignFieldAdd - -```ts -foreignFieldAdd: boolean | undefined; -``` - -### foreignFieldMul - -```ts -foreignFieldMul: boolean | undefined; -``` - -### lookup - -```ts -lookup: boolean | undefined; -``` - -### rangeCheck0 - -```ts -rangeCheck0: boolean | undefined; -``` - -### rangeCheck1 - -```ts -rangeCheck1: boolean | undefined; -``` - -### rot - -```ts -rot: boolean | undefined; -``` - -### runtimeTables - -```ts -runtimeTables: boolean | undefined; -``` - -### xor - -```ts -xor: boolean | undefined; -``` - -## Source - -[lib/proof-system/feature-flags.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/feature-flags.ts#L17) diff --git a/docs/zkapps/o1js-reference/type-aliases/Field.mdx b/docs/zkapps/o1js-reference/type-aliases/Field.mdx deleted file mode 100644 index 9aaac00b7..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Field.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Field: Field; -``` - -## Source - -[lib/provable/wrapped.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L42) diff --git a/docs/zkapps/o1js-reference/type-aliases/FlexibleProvable.mdx b/docs/zkapps/o1js-reference/type-aliases/FlexibleProvable.mdx deleted file mode 100644 index 17262b67d..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/FlexibleProvable.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -type FlexibleProvable: Provable | Struct; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:61](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L61) diff --git a/docs/zkapps/o1js-reference/type-aliases/FlexibleProvablePure.mdx b/docs/zkapps/o1js-reference/type-aliases/FlexibleProvablePure.mdx deleted file mode 100644 index 309301de6..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/FlexibleProvablePure.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -type FlexibleProvablePure: ProvablePure | StructPure; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L62) diff --git a/docs/zkapps/o1js-reference/type-aliases/Group.mdx b/docs/zkapps/o1js-reference/type-aliases/Group.mdx deleted file mode 100644 index 810c48167..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Group.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Group: Group; -``` - -## Source - -[lib/provable/wrapped.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L76) diff --git a/docs/zkapps/o1js-reference/type-aliases/InferProvable.mdx b/docs/zkapps/o1js-reference/type-aliases/InferProvable.mdx deleted file mode 100644 index 31859de28..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/InferProvable.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```ts -type InferProvable: GenericInferProvable; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/provable-derivers.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L65) diff --git a/docs/zkapps/o1js-reference/type-aliases/JsonProof.mdx b/docs/zkapps/o1js-reference/type-aliases/JsonProof.mdx deleted file mode 100644 index a9a8d63a1..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/JsonProof.mdx +++ /dev/null @@ -1,38 +0,0 @@ -```ts -type JsonProof: { - "maxProofsVerified": 0 | 1 | 2; - "proof": string; - "publicInput": string[]; - "publicOutput": string[]; -}; -``` - -## Type declaration - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -### proof - -```ts -proof: string; -``` - -### publicInput - -```ts -publicInput: string[]; -``` - -### publicOutput - -```ts -publicOutput: string[]; -``` - -## Source - -[lib/proof-system/zkprogram.ts:146](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L146) diff --git a/docs/zkapps/o1js-reference/type-aliases/MerkleListBase.mdx b/docs/zkapps/o1js-reference/type-aliases/MerkleListBase.mdx deleted file mode 100644 index 23c16ad34..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/MerkleListBase.mdx +++ /dev/null @@ -1,30 +0,0 @@ -```ts -type MerkleListBase: { - "data": Unconstrained[]>; - "hash": Field; -}; -``` - -Common base type for [MerkleList](../classes/MerkleList.mdx) and [MerkleListIterator](../classes/MerkleListIterator.mdx) - -## Type parameters - -• **T** - -## Type declaration - -### data - -```ts -data: Unconstrained[]>; -``` - -### hash - -```ts -hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L46) diff --git a/docs/zkapps/o1js-reference/type-aliases/MerkleListIteratorBase.mdx b/docs/zkapps/o1js-reference/type-aliases/MerkleListIteratorBase.mdx deleted file mode 100644 index 61e2b705d..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/MerkleListIteratorBase.mdx +++ /dev/null @@ -1,50 +0,0 @@ -```ts -type MerkleListIteratorBase: { - "currentHash": Field; - "currentIndex": Unconstrained; - "data": Unconstrained[]>; - "hash": Field; -}; -``` - -## Type parameters - -• **T** - -## Type declaration - -### currentHash - -```ts -currentHash: Field; -``` - -The merkle list hash of `[data[currentIndex], ..., data[length-1]]` (when hashing from right to left). - -For example: -- If `currentIndex === 0`, then `currentHash === this.hash` is the hash of the entire array. -- If `currentIndex === length`, then `currentHash === emptyHash` is the hash of an empty array. - -### currentIndex - -```ts -currentIndex: Unconstrained; -``` - -The index of the element that will be returned by the next call to `next()`. - -### data - -```ts -readonly data: Unconstrained[]>; -``` - -### hash - -```ts -readonly hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:383](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L383) diff --git a/docs/zkapps/o1js-reference/type-aliases/Option.mdx b/docs/zkapps/o1js-reference/type-aliases/Option.mdx deleted file mode 100644 index f3f84963a..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Option.mdx +++ /dev/null @@ -1,55 +0,0 @@ -```ts -type Option: { - "isSome": Bool; - "value": T; - } & { - "assertSome": T; - "orElse": T; -}; -``` - -## Type declaration - -### isSome - -```ts -isSome: Bool; -``` - -### value - -```ts -value: T; -``` - -## Type declaration - -### assertSome() - -#### Parameters - -• **message?**: `string` - -#### Returns - -`T` - -### orElse() - -#### Parameters - -• **defaultValue**: `T` \| `V` - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **V** = `any` - -## Source - -[lib/provable/option.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/option.ts#L37) diff --git a/docs/zkapps/o1js-reference/type-aliases/Provable.mdx b/docs/zkapps/o1js-reference/type-aliases/Provable.mdx deleted file mode 100644 index ababb2dea..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Provable.mdx +++ /dev/null @@ -1,190 +0,0 @@ -```ts -type Provable: { - "check": (value: T) => void; - "fromFields": (fields: Field[], aux: any[]) => T; - "fromValue": (x: TValue | T) => T; - "toAuxiliary": (value?: T) => any[]; - "toCanonical": (x: T) => T; - "toFields": (value: T) => Field[]; - "toValue": (x: T) => TValue; - "sizeInFields": number; -}; -``` - -`Provable` is the general interface for provable types in o1js. - -`Provable` describes how a type `T` is made up of [Field](../classes/Field.mdx) elements and "auxiliary" (non-provable) data. - -`Provable` is the required input type in several methods in o1js. -One convenient way to create a `Provable` is using `Struct`. - -All built-in provable types in o1js ([Field](../classes/Field.mdx), [Bool](../classes/Bool.mdx), etc.) are instances of `Provable` as well. - -Note: These methods are meant to be used by the library internally and are not directly when writing provable code. - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Type declaration - -### check() - -```ts -check: (value: T) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value**: `T` - -the element of type `T` to put assertions on. - -#### Returns - -`void` - -### fromFields() - -```ts -fromFields: (fields: Field[], aux: any[]) => T; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](../classes/Field.mdx)[] - -an array of [Field](../classes/Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -`T` - -### fromValue() - -```ts -fromValue: (x: TValue | T) => T; -``` - -Convert provable type from a normal JS type. - -#### Parameters - -• **x**: `TValue` \| `T` - -#### Returns - -`T` - -### toAuxiliary() - -```ts -toAuxiliary: (value?: T) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?**: `T` - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -#### Returns - -`any`[] - -### toCanonical()? - -```ts -optional toCanonical: (x: T) => T; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x**: `T` - -#### Returns - -`T` - -### toFields() - -```ts -toFields: (value: T) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../classes/Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value**: `T` - -the element of type `T` to generate the [Field](../classes/Field.mdx) array from. - -#### Returns - -[`Field`](../classes/Field.mdx)[] - -### toValue() - -```ts -toValue: (x: T) => TValue; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x**: `T` - -#### Returns - -`TValue` - -### sizeInFields() - -Return the size of the `T` type in terms of [Field](../classes/Field.mdx) type, as [Field](../classes/Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](../classes/Field.mdx) type. - -## Source - -[lib/provable/types/provable-intf.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L27) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableExtended.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableExtended.mdx deleted file mode 100644 index 30567b403..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableExtended.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -type ProvableExtended: Provable & ProvableExtension; -``` - -## Type parameters - -• **T** - -• **TValue** = `any` - -• **TJson** = `any` - -## Source - -[lib/provable/types/struct.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L49) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableHashable-1.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableHashable-1.mdx deleted file mode 100644 index 0bf40ac02..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableHashable-1.mdx +++ /dev/null @@ -1,31 +0,0 @@ -```ts -type ProvableHashable: ProvableWithEmpty & { - "toInput": (x: T) => HashInput; -}; -``` - -## Type declaration - -### toInput() - -```ts -toInput: (x: T) => HashInput; -``` - -#### Parameters - -• **x**: `T` - -#### Returns - -`HashInput` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L124) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableHashable.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableHashable.mdx deleted file mode 100644 index 9ea30d17e..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableHashable.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type ProvableHashable: Provable & Hashable; -``` - -## Type parameters - -• **T** - -• **V** = `any` - -## Source - -[lib/provable/crypto/poseidon.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L32) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvablePure.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvablePure.mdx deleted file mode 100644 index 99844a49e..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvablePure.mdx +++ /dev/null @@ -1,37 +0,0 @@ -```ts -type ProvablePure: Omit, "fromFields"> & { - "fromFields": (fields: Field[]) => T; -}; -``` - -`ProvablePure` is a special kind of [Provable](Provable.mdx) interface, where the "auxiliary" (non-provable) data is empty. -This means the type consists only of field elements, in that sense it is "pure". -Any instance of `ProvablePure` is also an instance of `Provable` where the "auxiliary" data is empty. - -Examples where `ProvablePure` is required are types of on-chain state, events and actions. - -## Type declaration - -### fromFields() - -```ts -fromFields: (fields: Field[]) => T; -``` - -#### Parameters - -• **fields**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L114) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableType.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableType.mdx deleted file mode 100644 index 223ac6c42..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableType.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type ProvableType: WithProvable>; -``` - -## Type parameters - -• **T** = `any` - -• **V** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L132) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableTypePure.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableTypePure.mdx deleted file mode 100644 index efe25fd15..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableTypePure.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type ProvableTypePure: WithProvable>; -``` - -## Type parameters - -• **T** = `any` - -• **V** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:133](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L133) diff --git a/docs/zkapps/o1js-reference/type-aliases/ProvableWithEmpty.mdx b/docs/zkapps/o1js-reference/type-aliases/ProvableWithEmpty.mdx deleted file mode 100644 index 12b775c67..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ProvableWithEmpty.mdx +++ /dev/null @@ -1,27 +0,0 @@ -```ts -type ProvableWithEmpty: Provable & { - "empty": () => T; -}; -``` - -## Type declaration - -### empty() - -```ts -empty: () => T; -``` - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L118) diff --git a/docs/zkapps/o1js-reference/type-aliases/Reducer.mdx b/docs/zkapps/o1js-reference/type-aliases/Reducer.mdx deleted file mode 100644 index ec0ebb109..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Reducer.mdx +++ /dev/null @@ -1,21 +0,0 @@ -```ts -type Reducer: { - "actionType": FlexibleProvablePure; -}; -``` - -## Type parameters - -• **Action** - -## Type declaration - -### actionType - -```ts -actionType: FlexibleProvablePure; -``` - -## Source - -[lib/mina/actions/reducer.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/reducer.ts#L17) diff --git a/docs/zkapps/o1js-reference/type-aliases/ScalarConst.mdx b/docs/zkapps/o1js-reference/type-aliases/ScalarConst.mdx deleted file mode 100644 index 3df2213e0..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ScalarConst.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type ScalarConst: [0, bigint]; -``` - -## Source - -[lib/provable/scalar.ts:20](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L20) diff --git a/docs/zkapps/o1js-reference/type-aliases/State.mdx b/docs/zkapps/o1js-reference/type-aliases/State.mdx deleted file mode 100644 index 3531c0034..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/State.mdx +++ /dev/null @@ -1,132 +0,0 @@ -```ts -type State: { - "fetch": Promise; - "fromAppState": A; - "get": A; - "getAndRequireEquals": A; - "requireEquals": void; - "requireEqualsIf": void; - "requireNothing": void; - "set": void; -}; -``` - -Gettable and settable state that can be checked for equality. - -## Type parameters - -• **A** - -## Type declaration - -### fetch() - -Asynchronously fetch the on-chain state. This is intended for getting the state outside a smart contract. - -#### Returns - -`Promise`\<`undefined` \| `A`\> - -### fromAppState() - -Get the state from the raw list of field elements on a zkApp account, for example: - -```ts -let myContract = new MyContract(address); -let account = Mina.getAccount(address); - -let x = myContract.x.fromAppState(account.zkapp!.appState); -``` - -#### Parameters - -• **appState**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -`A` - -### get() - -Get the current on-chain state. - -Caution: If you use this method alone inside a smart contract, it does not prove that your contract uses the current on-chain state. -To successfully prove that your contract uses the current on-chain state, you must add an additional `.requireEquals()` statement or use `.getAndRequireEquals()`: - -```ts -let x = this.x.get(); -this.x.requireEquals(x); -``` - -OR - -```ts -let x = this.x.getAndRequireEquals(); -``` - -#### Returns - -`A` - -### getAndRequireEquals() - -Get the current on-chain state and prove it really has to equal the on-chain state, -by adding a precondition which the verifying Mina node will check before accepting this transaction. - -#### Returns - -`A` - -### requireEquals() - -Prove that the on-chain state has to equal the given state, -by adding a precondition which the verifying Mina node will check before accepting this transaction. - -#### Parameters - -• **a**: `A` - -#### Returns - -`void` - -### requireEqualsIf() - -Require that the on-chain state has to equal the given state if the provided condition is true. - -If the condition is false, this is a no-op. -If the condition is true, this adds a precondition that the verifying Mina node will check before accepting this transaction. - -#### Parameters - -• **condition**: [`Bool`](../classes/Bool.mdx) - -• **a**: `A` - -#### Returns - -`void` - -### requireNothing() - -**DANGER ZONE**: Override the error message that warns you when you use `.get()` without adding a precondition. - -#### Returns - -`void` - -### set() - -Set the on-chain state to a new value. - -#### Parameters - -• **a**: `A` - -#### Returns - -`void` - -## Source - -[lib/mina/state.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L91) diff --git a/docs/zkapps/o1js-reference/type-aliases/Struct.mdx b/docs/zkapps/o1js-reference/type-aliases/Struct.mdx deleted file mode 100644 index bc9c9873d..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Struct.mdx +++ /dev/null @@ -1,21 +0,0 @@ -```ts -type Struct: ProvableExtended> & Constructor & { - "_isStruct": true; -}; -``` - -## Type declaration - -### \_isStruct - -```ts -_isStruct: true; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L140) diff --git a/docs/zkapps/o1js-reference/type-aliases/ToProvable.mdx b/docs/zkapps/o1js-reference/type-aliases/ToProvable.mdx deleted file mode 100644 index d4069df4c..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ToProvable.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type ToProvable: A extends { - "provable": infer P; - } ? P : A; -``` - -## Type parameters - -• **A** *extends* [`WithProvable`](WithProvable.mdx)\<`any`\> - -## Source - -[lib/provable/types/provable-intf.ts:135](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L135) diff --git a/docs/zkapps/o1js-reference/type-aliases/TransactionPromise.mdx b/docs/zkapps/o1js-reference/type-aliases/TransactionPromise.mdx deleted file mode 100644 index d65f56bc8..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/TransactionPromise.mdx +++ /dev/null @@ -1,34 +0,0 @@ -```ts -type TransactionPromise: Promise> & { - "send": PendingTransactionPromise; - } & Proven extends false ? { - "prove": TransactionPromise; - } : { - "proofs": Promise["proofs"]>; - } & Signed extends false ? { - "sign": TransactionPromise; -} : {}; -``` - -A `Promise` with some additional methods for making chained method calls -into the pending value upon its resolution. - -## Type declaration - -### send() - -Equivalent to calling the resolved `Transaction`'s `send` method. - -#### Returns - -[`PendingTransactionPromise`](../namespaces/Mina/type-aliases/PendingTransactionPromise.mdx) - -## Type parameters - -• **Proven** *extends* `boolean` - -• **Signed** *extends* `boolean` - -## Source - -[lib/mina/transaction.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L314) diff --git a/docs/zkapps/o1js-reference/type-aliases/TransactionStatus.mdx b/docs/zkapps/o1js-reference/type-aliases/TransactionStatus.mdx deleted file mode 100644 index f9b50e875..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/TransactionStatus.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type TransactionStatus: "INCLUDED" | "PENDING" | "UNKNOWN"; -``` - -INCLUDED: A transaction that is on the longest chain - -PENDING: A transaction either in the transition frontier or in transaction pool but is not on the longest chain - -UNKNOWN: The transaction has either been snarked, reached finality through consensus or has been dropped - -## Source - -[lib/mina/graphql.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/graphql.ts#L216) diff --git a/docs/zkapps/o1js-reference/type-aliases/TupleN.mdx b/docs/zkapps/o1js-reference/type-aliases/TupleN.mdx deleted file mode 100644 index 8e74abcdc..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/TupleN.mdx +++ /dev/null @@ -1,15 +0,0 @@ -```ts -type TupleN: N extends N ? number extends N ? [...T[]] : [...TupleRec] : never; -``` - -tuple type that has the length as generic parameter - -## Type parameters - -• **T** - -• **N** *extends* `number` - -## Source - -[lib/util/types.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/util/types.ts#L28) diff --git a/docs/zkapps/o1js-reference/type-aliases/Undefined.mdx b/docs/zkapps/o1js-reference/type-aliases/Undefined.mdx deleted file mode 100644 index cb5522b8e..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Undefined.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Undefined: undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L82) diff --git a/docs/zkapps/o1js-reference/type-aliases/VarField.mdx b/docs/zkapps/o1js-reference/type-aliases/VarField.mdx deleted file mode 100644 index 5dea52681..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/VarField.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type VarField: Field & { - "value": VarFieldVar; -}; -``` - -## Type declaration - -### value - -```ts -value: VarFieldVar; -``` - -## Source - -[lib/provable/field.ts:1242](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1242) diff --git a/docs/zkapps/o1js-reference/type-aliases/Void.mdx b/docs/zkapps/o1js-reference/type-aliases/Void.mdx deleted file mode 100644 index 3997cab41..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Void.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -type Void: undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L87) diff --git a/docs/zkapps/o1js-reference/type-aliases/WithHash.mdx b/docs/zkapps/o1js-reference/type-aliases/WithHash.mdx deleted file mode 100644 index b4c06ee5f..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/WithHash.mdx +++ /dev/null @@ -1,28 +0,0 @@ -```ts -type WithHash: { - "element": T; - "previousHash": Field; -}; -``` - -## Type parameters - -• **T** - -## Type declaration - -### element - -```ts -element: T; -``` - -### previousHash - -```ts -previousHash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L28) diff --git a/docs/zkapps/o1js-reference/type-aliases/WithProvable.mdx b/docs/zkapps/o1js-reference/type-aliases/WithProvable.mdx deleted file mode 100644 index 9cd658824..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/WithProvable.mdx +++ /dev/null @@ -1,13 +0,0 @@ -```ts -type WithProvable: { - "provable": A; - } | A; -``` - -## Type parameters - -• **A** - -## Source - -[lib/provable/types/provable-intf.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L130) diff --git a/docs/zkapps/o1js-reference/type-aliases/Witness.mdx b/docs/zkapps/o1js-reference/type-aliases/Witness.mdx deleted file mode 100644 index 8614845b9..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/Witness.mdx +++ /dev/null @@ -1,10 +0,0 @@ -```ts -type Witness: { - "isLeft": boolean; - "sibling": Field; - }[]; -``` - -## Source - -[lib/provable/merkle-tree.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L16) diff --git a/docs/zkapps/o1js-reference/type-aliases/ZkProgram.mdx b/docs/zkapps/o1js-reference/type-aliases/ZkProgram.mdx deleted file mode 100644 index 9aff8d3e4..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ZkProgram.mdx +++ /dev/null @@ -1,17 +0,0 @@ -```ts -type ZkProgram: ReturnType; -``` - -## Type parameters - -• **Config** *extends* \{ - `"methods"`: `{ [I in string]: Object }`; - `"publicInput"`: [`ProvableTypePure`](ProvableTypePure.mdx); - `"publicOutput"`: [`ProvableTypePure`](ProvableTypePure.mdx); - \} - -• **Methods** *extends* `{ [I in keyof Config["methods"]]: Method>, InferProvableOrVoid>, Config["methods"][I]> }` - -## Source - -[lib/proof-system/zkprogram.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L174) diff --git a/docs/zkapps/o1js-reference/type-aliases/ZkappPublicInput.mdx b/docs/zkapps/o1js-reference/type-aliases/ZkappPublicInput.mdx deleted file mode 100644 index eea6648be..000000000 --- a/docs/zkapps/o1js-reference/type-aliases/ZkappPublicInput.mdx +++ /dev/null @@ -1,36 +0,0 @@ -```ts -type ZkappPublicInput: { - "accountUpdate": Field; - "calls": Field; -}; -``` - -The public input for zkApps consists of certain hashes of the proving -account update (and its child updates) which is constructed during method execution. - -For SmartContract proving, a method is run twice: First outside the proof, to -obtain the public input, and once in the prover, which takes the public input -as input. The current transaction is hashed again inside the prover, which -asserts that the result equals the input public input, as part of the snark -circuit. The block producer will also hash the transaction they receive and -pass it as a public input to the verifier. Thus, the transaction is fully -constrained by the proof - the proof couldn't be used to attest to a different -transaction. - -## Type declaration - -### accountUpdate - -```ts -accountUpdate: Field; -``` - -### calls - -```ts -calls: Field; -``` - -## Source - -[lib/mina/account-update.ts:2050](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L2050) diff --git a/docs/zkapps/o1js-reference/variables/Account.mdx b/docs/zkapps/o1js-reference/variables/Account.mdx deleted file mode 100644 index ee0690269..000000000 --- a/docs/zkapps/o1js-reference/variables/Account.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -Account: GenericProvableExtended; -``` - -## Source - -[lib/mina/account.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account.ts#L19) diff --git a/docs/zkapps/o1js-reference/variables/Bool.mdx b/docs/zkapps/o1js-reference/variables/Bool.mdx deleted file mode 100644 index cd4352445..000000000 --- a/docs/zkapps/o1js-reference/variables/Bool.mdx +++ /dev/null @@ -1,33 +0,0 @@ -```ts -const Bool: typeof Bool & (...args: [boolean | FieldVar | Bool]) => Bool; -``` - -A boolean value. You can create it like this: - -## Example - -``` -const b = Bool(true); -``` - -You can also combine multiple Bools with boolean operations: - -## Example - -```ts -const c = Bool(false); - -const d = b.or(c).and(false).not(); - -d.assertTrue(); -``` - -Bools are often created by methods on other types such as `Field.equals()`: - -```ts -const b: Bool = Field(5).equals(6); -``` - -## Source - -[lib/provable/wrapped.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L70) diff --git a/docs/zkapps/o1js-reference/variables/Cache.mdx b/docs/zkapps/o1js-reference/variables/Cache.mdx deleted file mode 100644 index 0ec7fde05..000000000 --- a/docs/zkapps/o1js-reference/variables/Cache.mdx +++ /dev/null @@ -1,41 +0,0 @@ -```ts -Cache: { - "FileSystem": (cacheDirectory: string, debug?: boolean) => Cache; - "FileSystemDefault": Cache; - "None": Cache; -}; -``` - -## Type declaration - -### FileSystem() - -```ts -FileSystem: (cacheDirectory: string, debug?: boolean) => Cache; -``` - -#### Parameters - -• **cacheDirectory**: `string` - -• **debug?**: `boolean` - -#### Returns - -[`Cache`](../type-aliases/Cache.mdx) - -### FileSystemDefault - -```ts -FileSystemDefault: Cache; -``` - -### None - -```ts -None: Cache; -``` - -## Source - -[lib/proof-system/cache.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L37) diff --git a/docs/zkapps/o1js-reference/variables/Crypto.mdx b/docs/zkapps/o1js-reference/variables/Crypto.mdx deleted file mode 100644 index aa84bf879..000000000 --- a/docs/zkapps/o1js-reference/variables/Crypto.mdx +++ /dev/null @@ -1,35 +0,0 @@ -```ts -const Crypto: { - "CurveParams": CurveParams_; - "createCurve": {}; -}; -``` - -## Type declaration - -### CurveParams - -```ts -CurveParams: {} = CurveParams_; -``` - -Parameters defining an elliptic curve in short Weierstraß form -y^2 = x^3 + ax + b - -### createCurve() - -Create elliptic curve arithmetic methods. - -#### Parameters - -• **params**: `CurveParams` - -#### Returns - -```ts -{} -``` - -## Source - -[lib/provable/crypto/crypto.ts:8](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L8) diff --git a/docs/zkapps/o1js-reference/variables/Empty.mdx b/docs/zkapps/o1js-reference/variables/Empty.mdx deleted file mode 100644 index c4427326d..000000000 --- a/docs/zkapps/o1js-reference/variables/Empty.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -Empty: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L85) diff --git a/docs/zkapps/o1js-reference/variables/FeatureFlags.mdx b/docs/zkapps/o1js-reference/variables/FeatureFlags.mdx deleted file mode 100644 index 35b892fdc..000000000 --- a/docs/zkapps/o1js-reference/variables/FeatureFlags.mdx +++ /dev/null @@ -1,216 +0,0 @@ -```ts -FeatureFlags: { - "allMaybe": { - "foreignFieldAdd": undefined; - "foreignFieldMul": undefined; - "lookup": undefined; - "rangeCheck0": undefined; - "rangeCheck1": undefined; - "rot": undefined; - "runtimeTables": undefined; - "xor": undefined; - }; - "allNone": { - "foreignFieldAdd": false; - "foreignFieldMul": false; - "lookup": false; - "rangeCheck0": false; - "rangeCheck1": false; - "rot": false; - "runtimeTables": false; - "xor": false; - }; - "fromGates": featureFlagsFromGates; - "fromZkProgram": (program: AnalysableProgram) => Promise; - "fromZkProgramList": (programs: AnalysableProgram[]) => Promise; -}; -``` - -Feature flags indicate what custom gates are used in a proof of circuit. -Side loading, for example, requires a set of feature flags in advance (at compile time) in order to verify and side load proofs. -If the side loaded proofs and verification keys do not match the specified feature flag configurations, the verification will fail. -Flags specified as `undefined` are considered as `maybe` by Pickles. This means, proofs can be sided loaded that can, but don't have to, use a specific custom gate. -_Note:_ `Maybe` feature flags incur a proving overhead. - -## Type declaration - -### allMaybe - -```ts -allMaybe: { - "foreignFieldAdd": undefined; - "foreignFieldMul": undefined; - "lookup": undefined; - "rangeCheck0": undefined; - "rangeCheck1": undefined; - "rot": undefined; - "runtimeTables": undefined; - "xor": undefined; -}; -``` - -Returns a feature flag configuration where all flags are optional. - -### allMaybe.foreignFieldAdd - -```ts -foreignFieldAdd: undefined = undefined; -``` - -### allMaybe.foreignFieldMul - -```ts -foreignFieldMul: undefined = undefined; -``` - -### allMaybe.lookup - -```ts -lookup: undefined = undefined; -``` - -### allMaybe.rangeCheck0 - -```ts -rangeCheck0: undefined = undefined; -``` - -### allMaybe.rangeCheck1 - -```ts -rangeCheck1: undefined = undefined; -``` - -### allMaybe.rot - -```ts -rot: undefined = undefined; -``` - -### allMaybe.runtimeTables - -```ts -runtimeTables: undefined = undefined; -``` - -### allMaybe.xor - -```ts -xor: undefined = undefined; -``` - -### allNone - -```ts -allNone: { - "foreignFieldAdd": false; - "foreignFieldMul": false; - "lookup": false; - "rangeCheck0": false; - "rangeCheck1": false; - "rot": false; - "runtimeTables": false; - "xor": false; -}; -``` - -Returns a feature flag configuration where all flags are set to false. - -### allNone.foreignFieldAdd - -```ts -foreignFieldAdd: boolean = false; -``` - -### allNone.foreignFieldMul - -```ts -foreignFieldMul: boolean = false; -``` - -### allNone.lookup - -```ts -lookup: boolean = false; -``` - -### allNone.rangeCheck0 - -```ts -rangeCheck0: boolean = false; -``` - -### allNone.rangeCheck1 - -```ts -rangeCheck1: boolean = false; -``` - -### allNone.rot - -```ts -rot: boolean = false; -``` - -### allNone.runtimeTables - -```ts -runtimeTables: boolean = false; -``` - -### allNone.xor - -```ts -xor: boolean = false; -``` - -### fromGates() - -```ts -fromGates: (gates: Gate[]) => FeatureFlags = featureFlagsFromGates; -``` - -Given a list of gates, returns the feature flag configuration that the gates use. - -#### Parameters - -• **gates**: `Gate`[] - -#### Returns - -[`FeatureFlags`](../type-aliases/FeatureFlags.mdx) - -### fromZkProgram() - -```ts -fromZkProgram: (program: AnalysableProgram) => Promise; -``` - -Given a ZkProgram, return the feature flag configuration that fits the given program. -This function considers all methods of the specified ZkProgram and finds a configuration that fits all. - -#### Parameters - -• **program**: `AnalysableProgram` - -#### Returns - -`Promise`\<[`FeatureFlags`](../type-aliases/FeatureFlags.mdx)\> - -### fromZkProgramList() - -```ts -fromZkProgramList: (programs: AnalysableProgram[]) => Promise; -``` - -#### Parameters - -• **programs**: `AnalysableProgram`[] - -#### Returns - -`Promise`\<[`FeatureFlags`](../type-aliases/FeatureFlags.mdx)\> - -## Source - -[lib/proof-system/feature-flags.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/feature-flags.ts#L17) diff --git a/docs/zkapps/o1js-reference/variables/Field.mdx b/docs/zkapps/o1js-reference/variables/Field.mdx deleted file mode 100644 index fb8f725b3..000000000 --- a/docs/zkapps/o1js-reference/variables/Field.mdx +++ /dev/null @@ -1,50 +0,0 @@ -```ts -const Field: typeof Field & (...args: [ - | string - | number - | bigint - | FieldConst - | FieldVar - | Field]) => Field; -``` - -A [Field](Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). -Every other provable type is built using the [Field](Field.mdx) type. - -The field is the [pasta base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) of order 2^254 + 0x224698fc094cf91b992d30ed00000001 ([Field.ORDER](../classes/Field.mdx#order)). - -You can create a new Field from everything "field-like" (`bigint`, integer `number`, decimal `string`, `Field`). - -## Example - -``` -Field(10n); // Field construction from a bigint -Field(100); // Field construction from a number -Field("1"); // Field construction from a decimal string -``` - -**Beware**: Fields _cannot_ be constructed from fractional numbers or alphanumeric strings: -```ts -Field(3.141); // ERROR: Cannot convert a float to a field element -Field("abc"); // ERROR: Invalid argument "abc" -``` - -Creating a Field from a negative number can result in unexpected behavior if you are not familiar with [modular arithmetic](https://en.wikipedia.org/wiki/Modular_arithmetic). - -## Example - -``` -const x = Field(-1); // valid Field construction from negative number -const y = Field(Field.ORDER - 1n); // same as `x` -``` - -**Important**: All the functions defined on a Field (arithmetic, logic, etc.) take their arguments as "field-like". -A Field itself is also defined as a "field-like" element. - -## Param - -the value to convert to a [Field](Field.mdx) - -## Source - -[lib/provable/wrapped.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L42) diff --git a/docs/zkapps/o1js-reference/variables/Gadgets.mdx b/docs/zkapps/o1js-reference/variables/Gadgets.mdx deleted file mode 100644 index 9243ee893..000000000 --- a/docs/zkapps/o1js-reference/variables/Gadgets.mdx +++ /dev/null @@ -1,1607 +0,0 @@ -```ts -const Gadgets: { - "BLAKE2B": BLAKE2B; - "Field3": { - "provable": { - "fromValue": Field3; - "toValue": bigint; - }; - "from": Field3; - "isConstant": boolean; - "toBigint": bigint; - "toBigints": [...{ [i in string | number | symbol]: bigint }[]]; - }; - "ForeignField": { - "Sum": Sum; - "add": Field3; - "assertAlmostReduced": void; - "assertLessThan": void; - "assertLessThanOrEqual": void; - "assertMul": void; - "div": Field3; - "inv": Field3; - "mul": Field3; - "neg": Field3; - "sub": Field3; - "sum": Field3; - "toCanonical": Field3; - }; - "SHA256": SHA256; - "addMod32": (x: Field, y: Field) => Field; - "addMod64": (x: Field, y: Field) => Field; - "arrayGet": (array: Field[], index: Field) => Field; - "divMod32": (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; - }; - "divMod64": (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; - }; - "and": Field; - "compactMultiRangeCheck": [Field, Field, Field]; - "isDefinitelyInRangeN": Bool; - "leftShift32": Field; - "leftShift64": Field; - "multiRangeCheck": void; - "not": Field; - "or": Field; - "rangeCheck16": void; - "rangeCheck32": void; - "rangeCheck3x12": void; - "rangeCheck64": [Field, Field, Field, Field]; - "rangeCheck8": void; - "rangeCheckN": void; - "rightShift64": Field; - "rotate32": Field; - "rotate64": Field; - "xor": Field; -}; -``` - -## Type declaration - -### BLAKE2B - -```ts -BLAKE2B: { - get "IV": UInt64[]; - "hash": Bytes; -}; -``` - -Implementation of the [BLAKE2b hash function.](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2) Hash function with arbitrary length output. - -Applies the BLAKE2b hash function to a list of byte-sized elements. - -The function accepts [Bytes](../type-aliases/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]`, `bigint[]` or `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../type-aliases/Bytes.mdx) that conforms to the chosen digest length. - -#### Param - -[Bytes](../type-aliases/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Gadgets.BLAKE2b.hash(preimage); -``` - -### BLAKE2B.IV - -```ts -get IV(): UInt64[] -``` - -#### Returns - -[`UInt64`](../classes/UInt64.mdx)[] - -#### Source - -[lib/provable/gadgets/blake2b.ts:77](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/blake2b.ts#L77) - -### BLAKE2B.hash() - -#### Parameters - -• **data**: `FlexibleBytes` - -• **digestLength**: `number`= `64` - -#### Returns - -`Bytes` - -### Field3 - -```ts -Field3: { - "provable": { - "fromValue": Field3; - "toValue": bigint; - }; - "from": Field3; - "isConstant": boolean; - "toBigint": bigint; - "toBigints": [...{ [i in string | number | symbol]: bigint }[]]; -}; -``` - -### Field3.provable - -```ts -provable: { - "fromValue": Field3; - "toValue": bigint; -}; -``` - -`Provable` interface for `Field3 = [Field, Field, Field]`. - -Note: Witnessing this creates a plain tuple of field elements without any implicit -range checks. - -### Field3.provable.fromValue() - -#### Parameters - -• **x**: `bigint` \| `Field3` - -#### Returns - -`Field3` - -### Field3.provable.toValue() - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`bigint` - -### Field3.from() - -Turn a bigint into a 3-tuple of Fields - -#### Parameters - -• **x**: `bigint` \| `Field3` - -#### Returns - -`Field3` - -### Field3.isConstant() - -Check whether a 3-tuple of Fields is constant - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`boolean` - -### Field3.toBigint() - -Turn a 3-tuple of Fields into a bigint - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`bigint` - -### Field3.toBigints() - -Turn several 3-tuples of Fields into bigints - -#### Type parameters - -• **T** *extends* `Tuple`\<`Field3`\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: bigint \}[]] - -### ForeignField - -```ts -ForeignField: { - "Sum": Sum; - "add": Field3; - "assertAlmostReduced": void; - "assertLessThan": void; - "assertLessThanOrEqual": void; - "assertMul": void; - "div": Field3; - "inv": Field3; - "mul": Field3; - "neg": Field3; - "sub": Field3; - "sum": Field3; - "toCanonical": Field3; -}; -``` - -Gadgets for foreign field operations. - -A _foreign field_ is a finite field different from the native field of the proof system. - -The `ForeignField` namespace exposes operations like modular addition and multiplication, -which work for any finite field of size less than 2^259. - -Foreign field elements are represented as 3 limbs of native field elements. -Each limb holds 88 bits of the total, in little-endian order. - -All `ForeignField` gadgets expect that their input limbs are constrained to the range [0, 2^88). -Range checks on outputs are added by the gadget itself. - -### ForeignField.Sum() - -Lazy sum of Field3 elements, which can be used as input to Gadgets.ForeignField.assertMul. - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`Sum` - -### ForeignField.add() - -Foreign field addition: `x + y mod f` - -The modulus `f` does not need to be prime. - -Inputs and outputs are 3-tuples of native Fields. -Each input limb is assumed to be in the range [0, 2^88), and the gadget is invalid if this is not the case. -The result limbs are guaranteed to be in the same range. - -#### Parameters - -• **x**: `Field3` - -left summand - -• **y**: `Field3` - -right summand - -• **f**: `bigint` - -modulus - -#### Returns - -`Field3` - -x + y mod f - -#### Example - -```ts -let x = Provable.witness(Field3, () => 9n); -let y = Provable.witness(Field3, () => 10n); - -// range check x and y -Gadgets.multiRangeCheck(x); -Gadgets.multiRangeCheck(y); - -// compute x + y mod 17 -let z = ForeignField.add(x, y, 17n); - -Provable.log(z); // ['2', '0', '0'] = limb representation of 2 = 9 + 10 mod 17 -``` - -**Warning**: The gadget does not assume that inputs are reduced modulo f, -and does not prove that the result is reduced modulo f. -It only guarantees that the result is in the correct residue class. - -### ForeignField.assertAlmostReduced() - -Prove that each of the given Field3 elements is "almost" reduced modulo f, -i.e., satisfies the assumptions required by Gadgets.ForeignField.mul and other gadgets: -- each limb is in the range [0, 2^88) -- the most significant limb is less or equal than the modulus, x[2] ≤ f[2] - -**Note**: This method is most efficient when the number of input elements is a multiple of 3. - -#### Parameters - -• **xs**: `Field3`[] - -• **f**: `bigint` - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.skipMrc**: `undefined` \| `boolean`= `false` - -#### Returns - -`void` - -#### Throws - -if any of the assumptions is violated. - -#### Example - -```ts -let x = Provable.witness(Field3, () => 4n); -let y = Provable.witness(Field3, () => 5n); -let z = Provable.witness(Field3, () => 10n); - -ForeignField.assertAlmostReduced([x, y, z], f); - -// now we can use x, y, z as inputs to foreign field multiplication -let xy = ForeignField.mul(x, y, f); -let xyz = ForeignField.mul(xy, z, f); - -// since xy is an input to another multiplication, we need to prove that it is almost reduced again! -ForeignField.assertAlmostReduced([xy], f); // TODO: would be more efficient to batch this with 2 other elements -``` - -### ForeignField.assertLessThan() - -Prove that x < f for any constant f < 2^264, or for another `Field3` f. - -If f is a finite field modulus, this means that the given field element is fully reduced modulo f. -This is a stronger statement than [ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) -and also uses more constraints; it should not be needed in most use cases. - -**Note**: This assumes that the limbs of x are in the range [0, 2^88), in contrast to -[ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) which adds that check itself. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` \| `Field3` - -#### Returns - -`void` - -#### Throws - -if x is greater or equal to f. - -#### Example - -```ts -let x = Provable.witness(Field3, () => 0x1235n); - - // range check limbs of x -Gadgets.multiRangeCheck(x); - -// prove that x is fully reduced mod f -Gadgets.ForeignField.assertLessThan(x, f); -``` - -### ForeignField.assertLessThanOrEqual() - -Prove that x ≤ f for any constant f < 2^264, or for another `Field3` f. - -See [ForeignField.assertLessThan](../classes/ForeignField.mdx#assertlessthan) for details and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` \| `Field3` - -#### Returns - -`void` - -### ForeignField.assertMul() - -Optimized multiplication of sums in a foreign field, for example: `(x - y)*z = a + b + c mod f` - -Note: This is much more efficient than using Gadgets.ForeignField.add and Gadgets.ForeignField.sub separately to -compute the multiplication inputs and outputs, and then using Gadgets.ForeignField.mul to constrain the result. - -The sums passed into this method are "lazy sums" created with Gadgets.ForeignField.Sum. -You can also pass in plain Field3 elements. - -**Assumptions**: The assumptions on the _summands_ are analogous to the assumptions described in Gadgets.ForeignField.mul: -- each summand's limbs are in the range [0, 2^88) -- summands that are part of a multiplication input satisfy `x[2] <= f[2]` - -#### Parameters - -• **x**: `Field3` \| `Sum` - -• **y**: `Field3` \| `Sum` - -• **z**: `Field3` \| `Sum` - -• **f**: `bigint` - -#### Returns - -`void` - -#### Throws - -if the modulus is so large that the second assumption no longer suffices for validity of the multiplication. -For small sums and moduli < 2^256, this will not fail. - -#### Throws - -if the provided multiplication result is not correct modulo f. - -#### Example - -```ts -// range-check x, y, z, a, b, c -ForeignField.assertAlmostReduced([x, y, z], f); -Gadgets.multiRangeCheck(a); -Gadgets.multiRangeCheck(b); -Gadgets.multiRangeCheck(c); - -// create lazy input sums -let xMinusY = ForeignField.Sum(x).sub(y); -let aPlusBPlusC = ForeignField.Sum(a).add(b).add(c); - -// assert that (x - y)*z = a + b + c mod f -ForeignField.assertMul(xMinusY, z, aPlusBPlusC, f); -``` - -### ForeignField.div() - -Foreign field division: `x * y^(-1) mod f` - -See Gadgets.ForeignField.mul for assumptions on inputs and usage examples. - -This gadget adds an extra bound check on the result, so it can be used directly in another foreign field multiplication. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -Different than Gadgets.ForeignField.mul, this fails on unreduced input `x`, because it checks that `x === (x/y)*y` and the right side will be reduced. - -### ForeignField.inv() - -Foreign field inverse: `x^(-1) mod f` - -See Gadgets.ForeignField.mul for assumptions on inputs and usage examples. - -This gadget adds an extra bound check on the result, so it can be used directly in another foreign field multiplication. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -### ForeignField.mul() - -Foreign field multiplication: `x * y mod f` - -The modulus `f` does not need to be prime, but has to be smaller than 2^259. - -**Assumptions**: In addition to the assumption that input limbs are in the range [0, 2^88), as in all foreign field gadgets, -this assumes an additional bound on the inputs: `x * y < 2^264 * p`, where p is the native modulus. -We usually assert this bound by proving that `x[2] < f[2] + 1`, where `x[2]` is the most significant limb of x. -To do this, we use an 88-bit range check on `2^88 - x[2] - (f[2] + 1)`, and same for y. -The implication is that x and y are _almost_ reduced modulo f. - -All of the above assumptions are checked by Gadgets.ForeignField.assertAlmostReduced. - -**Warning**: This gadget does not add the extra bound check on the result. -So, to use the result in another foreign field multiplication, you have to add the bound check on it yourself, again. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Example - -```ts -// example modulus: secp256k1 prime -let f = (1n << 256n) - (1n << 32n) - 0b1111010001n; - -let x = Provable.witness(Field3, () => f - 1n); -let y = Provable.witness(Field3, () => f - 2n); - -// range check x, y and prove additional bounds x[2] <= f[2] -ForeignField.assertAlmostReduced([x, y], f); - -// compute x * y mod f -let z = ForeignField.mul(x, y, f); - -Provable.log(z); // ['2', '0', '0'] = limb representation of 2 = (-1)*(-2) mod f -``` - -### ForeignField.neg() - -Foreign field negation: `-x mod f = f - x` - -See [ForeignField.add](../classes/ForeignField.mdx#add) for assumptions and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -fails if `x > f`, where `f - x < 0`. - -### ForeignField.sub() - -Foreign field subtraction: `x - y mod f` - -See Gadgets.ForeignField.add for assumptions and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -fails if `x - y < -f`, where the result cannot be brought back to a positive number by adding `f` once. - -### ForeignField.sum() - -Foreign field sum: `xs[0] + signs[0] * xs[1] + ... + signs[n-1] * xs[n] mod f` - -This gadget takes a list of inputs and a list of signs (of size one less than the inputs), -and computes a chain of additions or subtractions, depending on the sign. -A sign is of type `1n | -1n`, where `1n` represents addition and `-1n` represents subtraction. - -**Note**: For 3 or more inputs, `sum()` uses fewer constraints than a sequence of `add()` and `sub()` calls, -because we can avoid range checks on intermediate results. - -See Gadgets.ForeignField.add for assumptions on inputs. - -#### Parameters - -• **xs**: `Field3`[] - -• **signs**: (`1n` \| `-1n`)[] - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Example - -```ts -let x = Provable.witness(Field3, () => 4n); -let y = Provable.witness(Field3, () => 5n); -let z = Provable.witness(Field3, () => 10n); - -// range check x, y, z -Gadgets.multiRangeCheck(x); -Gadgets.multiRangeCheck(y); -Gadgets.multiRangeCheck(z); - -// compute x + y - z mod 17 -let sum = ForeignField.sum([x, y, z], [1n, -1n], 17n); - -Provable.log(sum); // ['16', '0', '0'] = limb representation of 16 = 4 + 5 - 10 mod 17 -``` - -### ForeignField.toCanonical() - -Convert x, which may be unreduced, to a canonical representative xR < f -such that x = xR mod f - -Note: This method is complete, it works for all unreduced field elements. -It can therefore be used to protect against incompleteness of field operations in other places. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -### SHA256 - -```ts -SHA256: { - "compression": sha256Compression; - "createMessageSchedule": (M: UInt32[]) => UInt32[]; - "padding": (data: FlexibleBytes) => UInt32[][]; - get "initialState": UInt32[]; - "hash": Bytes; -}; -``` - -Implementation of the [SHA256 hash function.](https://en.wikipedia.org/wiki/SHA-2) Hash function with 256bit output. - -Applies the SHA2-256 hash function to a list of byte-sized elements. - -The function accepts [Bytes](../type-aliases/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]`, `bigint[]` or `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../type-aliases/Bytes.mdx) that conforms to the chosen bit length. - -#### Param - -[Bytes](../type-aliases/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Gadgets.SHA256.hash(preimage); -``` - -### SHA256.compression() - -```ts -compression: (H: UInt32[], W: UInt32[]) => UInt32[] = sha256Compression; -``` - -Performs the SHA-256 compression function on the given hash values and message schedule. - -#### Parameters - -• **H**: [`UInt32`](../classes/UInt32.mdx)[] - -The initial or intermediate hash values (8-element array of UInt32). - -• **W**: [`UInt32`](../classes/UInt32.mdx)[] - -The message schedule (64-element array of UInt32). - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -The updated intermediate hash values after compression. - -### SHA256.createMessageSchedule() - -```ts -createMessageSchedule: (M: UInt32[]) => UInt32[]; -``` - -Prepares the message schedule for the SHA-256 compression function from the given message block. - -#### Parameters - -• **M**: [`UInt32`](../classes/UInt32.mdx)[] - -The 512-bit message block (16-element array of UInt32). - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -The message schedule (64-element array of UInt32). - -### SHA256.padding() - -```ts -padding: (data: FlexibleBytes) => UInt32[][]; -``` - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[][] - -### SHA256.initialState - -```ts -get initialState(): UInt32[] -``` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -#### Source - -[lib/provable/gadgets/sha256.ts:100](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/sha256.ts#L100) - -### SHA256.hash() - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -`Bytes` - -### addMod32() - -```ts -addMod32: (x: Field, y: Field) => Field; -``` - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### addMod64() - -```ts -addMod64: (x: Field, y: Field) => Field; -``` - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### arrayGet() - -```ts -arrayGet: (array: Field[], index: Field) => Field; -``` - -Get value from array in O(n) rows. - -Assumes that index is in [0, n), returns an unconstrained result otherwise. - -Note: This saves 0.5*n constraints compared to equals() + switch() even if equals() were implemented optimally. - -#### Parameters - -• **array**: [`Field`](../classes/Field.mdx)[] - -• **index**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### divMod32() - -```ts -divMod32: (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; -}; -``` - -#### Parameters - -• **n**: [`Field`](../classes/Field.mdx) - -• **nBits**: `number`= `64` - -#### Returns - -```ts -{ - "quotient": Field; - "remainder": Field; -} -``` - -##### quotient - -```ts -quotient: Field; -``` - -##### remainder - -```ts -remainder: Field; -``` - -### divMod64() - -```ts -divMod64: (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; -}; -``` - -#### Parameters - -• **n**: [`Field`](../classes/Field.mdx) - -• **nBits**: `number`= `128` - -#### Returns - -```ts -{ - "quotient": Field; - "remainder": Field; -} -``` - -##### quotient - -```ts -quotient: Field; -``` - -##### remainder - -```ts -remainder: Field; -``` - -### and() - -Bitwise AND gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values -below (in the process it also invokes the Gadgets.xor gadget which will create additional constraints depending on `length`). - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -The `length` parameter lets you define how many bits should be compared. `length` is rounded -to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values -are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -**Note:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. -For example, with `length = 2` (`paddedLength = 16`), `and()` will fail for any input that is larger than `2**16`. - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -• **b**: [`Field`](../classes/Field.mdx) - -• **length**: `number` - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```typescript -let a = Field(3); // ... 000011 -let b = Field(5); // ... 000101 - -let c = Gadgets.and(a, b, 2); // ... 000001 -c.assertEquals(1); -``` - -### compactMultiRangeCheck() - -Compact multi-range check - -This is a variant of multiRangeCheck where the first two variables are passed in -combined form xy = x + 2^88*y. - -The gadget -- splits up xy into x and y -- proves that xy = x + 2^88*y -- proves that x, y, z are all in the range [0, 2^88). - -The split form [x, y, z] is returned. - -#### Parameters - -• **xy**: [`Field`](../classes/Field.mdx) - -• **z**: [`Field`](../classes/Field.mdx) - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -#### Example - -```ts -let [x, y] = Gadgets.compactMultiRangeCheck([xy, z]); -``` - -#### Throws - -Throws an error if `xy` exceeds 2*88 = 176 bits, or if z exceeds 88 bits. - -### isDefinitelyInRangeN() - -Returns a boolean which being true proves that x is in the range [0, 2^n). - -**Beware**: The output being false does **not** prove that x is not in the range [0, 2^n). -This should not be viewed as a standalone provable method but as an advanced helper function -for gadgets which need a weakened form of range check. - -#### Parameters - -• **n**: `number` - -The number of bits to be considered for the range check. - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be weakly range-checked. - -#### Returns - -[`Bool`](../classes/Bool.mdx) - -a Bool that is definitely only true if the input is in the range [0, 2^n), -but could also be false _even if_ the input is in the range [0, 2^n). - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -let definitelyInRange = Gadgets.isDefinitelyInRangeN(32, x); // could be true or false -``` - -### leftShift32() - -Performs a left shift operation on the provided [Field](Field.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 32 bits in size. - -The output is range checked to 32 bits. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the left. The amount should be between 0 and 32 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.leftShift32(x, 2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -### leftShift64() - -Performs a left shift operation on the provided [Field](Field.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the shift. -Therefore, to safely use `leftShift()`, you need to make sure that the values passed in are range checked to 64 bits. -For example, this can be done with Gadgets.rangeCheck64. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the left. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.leftShift64(x, 2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -leftShift64(xLarge, 32); // throws an error since input exceeds 64 bits -``` - -### multiRangeCheck() - -Multi-range check. - -Proves that x, y, z are all in the range [0, 2^88). - -This takes 4 rows, so it checks 88*3/4 = 66 bits per row. This is slightly more efficient -than 64-bit range checks, which can do 64 bits in 1 row. - -In particular, the 3x88-bit range check supports bigints up to 264 bits, which in turn is enough -to support foreign field multiplication with moduli up to 2^259. - -#### Parameters - -• **limbs**: `Field3` - -#### Returns - -`void` - -#### Example - -```ts -Gadgets.multiRangeCheck([x, y, z]); -``` - -#### Throws - -Throws an error if one of the input values exceeds 88 bits. - -### not() - -Bitwise NOT gate on [Field](Field.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate only operates over the amount -of bits specified by the `length` parameter. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -The `length` parameter lets you define how many bits to NOT. - -**Note:** Specifying a larger `length` parameter adds additional constraints. The operation will fail if the length or the input value is larger than 254. - -NOT is implemented in two different ways. If the `checked` parameter is set to `true` -the Gadgets.xor gadget is reused with a second argument to be an -all one bitmask the same length. This approach needs as many rows as an XOR would need -for a single negation. If the `checked` parameter is set to `false`, NOT is -implemented as a subtraction of the input from the all one bitmask. This -implementation is returned by default if no `checked` parameter is provided. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -The value to apply NOT to. The operation will fail if the value is larger than 254. - -• **length**: `number` - -The number of bits to be considered for the NOT operation. - -• **checked**: `boolean`= `false` - -Optional boolean to determine if the checked or unchecked not implementation is used. If it -is set to `true` the Gadgets.xor gadget is reused. If it is set to `false`, NOT is implemented - as a subtraction of the input from the all one bitmask. It is set to `false` by default if no parameter is provided. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```ts -// not-ing 4 bits with the unchecked version -let a = Field(0b0101); -let b = Gadgets.not(a,4,false); - -b.assertEquals(0b1010); - -// not-ing 4 bits with the checked version utilizing the xor gadget -let a = Field(0b0101); -let b = Gadgets.not(a,4,true); - -b.assertEquals(0b1010); -``` - -#### Throws - -Throws an error if the input value exceeds 254 bits. - -### or() - -Bitwise OR gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -The `length` parameter lets you define how many bits should be compared. `length` is rounded -to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values -are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -**Note:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. -For example, with `length = 2` (`paddedLength = 16`), `and()` will fail for any input that is larger than `2**16`. - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -• **b**: [`Field`](../classes/Field.mdx) - -• **length**: `number` - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```typescript -let a = Field.from(3); // ... 000011 -let b = Field.from(5); // ... 000101 - -let c = Gadgets.or(a, b, 16); // ... 000111 -c.assertEquals(7); -``` - -### rangeCheck16() - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -#### Returns - -`void` - -### rangeCheck32() - -Asserts that the input value is in the range [0, 2^32). - -This function proves that the provided field element can be represented with 32 bits. -If the field element exceeds 32 bits, an error is thrown. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -#### Returns - -`void` - -#### Throws - -Throws an error if the input value exceeds 32 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheck32(x); // successfully proves 32-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheck32(xLarge); // throws an error since input exceeds 32 bits -``` - -**Note**: Small "negative" field element inputs are interpreted as large integers close to the field size, -and don't pass the 32-bit check. If you want to prove that a value lies in the int32 range [-2^31, 2^31), -you could use `rangeCheck32(x.add(1n << 31n))`. - -### rangeCheck3x12() - -Checks that three [Field](Field.mdx) elements are in the range [0, 2^12) (using only one row). - -Internally, this gadget relies on the 12-bit [range check table](https://github.com/o1-labs/proof-systems/blob/master/kimchi/src/circuits/lookup/tables/mod.rs). -All three inputs are checked to be included in that table. - -It's possible to use this as a range check for bit lengths n < 12, by passing in _two values_. -- the value to be checked, `x`, to prove that x in [0, 2^12) -- x scaled by 2^(12 - n), to prove that either x in [0, 2^n) or `x * 2^(12 - n)` overflows the field size (which is excluded by the first check) - -Note that both of these checks are necessary to prove x in [0, 2^n). - -You can find more details about lookups in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=lookup%20gate#lookup) - -#### Parameters - -• **v0**: [`Field`](../classes/Field.mdx) - -The first [Field](Field.mdx) element to be checked. - -• **v1**: [`Field`](../classes/Field.mdx) - -The second [Field](Field.mdx) element to be checked. - -• **v2**: [`Field`](../classes/Field.mdx) - -The third [Field](Field.mdx) element to be checked. - -#### Returns - -`void` - -#### Throws - -Throws an error if one of the input values exceeds 2^12. - -#### Example - -```typescript -let a = Field(4000); -rangeCheck3x12(a, Field(0), Field(0)); // works, since `a` is less than 12 bits - -let aScaled = a.mul(1 << 4); // scale `a`, to assert that it's less than 8 bits -rangeCheck3x12(a, aScaled, Field(0)); // throws an error, since `a` is greater than 8 bits (and so `aScaled` is greater than 12 bits) -``` - -### rangeCheck64() - -Asserts that the input value is in the range [0, 2^64). - -This function proves that the provided field element can be represented with 64 bits. -If the field element exceeds 64 bits, an error is thrown. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheck64(x); // successfully proves 64-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheck64(xLarge); // throws an error since input exceeds 64 bits -``` - -**Note**: Small "negative" field element inputs are interpreted as large integers close to the field size, -and don't pass the 64-bit check. If you want to prove that a value lies in the int64 range [-2^63, 2^63), -you could use `rangeCheck64(x.add(1n << 63n))`. - -_Advanced usage_: This returns the 4 highest limbs of x, in reverse order, i.e. [x52, x40, x28, x16]. -This is useful if you want to do a range check for 52, 40, 28, or 16 bits instead of 64, -by constraining some of the returned limbs to be 0. - -### rangeCheck8() - -Asserts that the input value is in the range [0, 2^8). - -See Gadgets.rangeCheck64 for analogous details and usage examples. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -#### Returns - -`void` - -### rangeCheckN() - -Asserts that the input value is in the range [0, 2^n). `n` must be a multiple of 16. - -This function proves that the provided field element can be represented with `n` bits. -If the field element exceeds `n` bits, an error is thrown. - -#### Parameters - -• **n**: `number` - -The number of bits to be considered for the range check. - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -• **message?**: `string` - -Optional message to be displayed when the range check fails. - -#### Returns - -`void` - -#### Throws - -Throws an error if the input value exceeds `n` bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheckN(32, x); // successfully proves 32-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheckN(32, xLarge); // throws an error since input exceeds 32 bits -``` - -### rightShift64() - -Performs a right shift operation on the provided [Field](Field.mdx) element. -This is similar to the `>>` shift operation in JavaScript, where bits are moved to the right. -The `rightShift64` function utilizes the rotation method internally to implement this operation. - -* It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the shift. -To safely use `rightShift64()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the right. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.rightShift64(x, 2); // right shift by 2 bits -y.assertEquals(0b000011); // 3 in binary - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -rightShift64(xLarge, 32); // throws an error since input exceeds 64 bits -``` - -### rotate32() - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 32-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -**Important:** The gadget assumes that its input is at most 32 bits in size. - -If the input exceeds 32 bits, the gadget is invalid and fails to prove correct execution of the rotation. -To safely use `rotate32()`, you need to make sure that the value passed in is range-checked to 32 bits; -for example, using Gadgets.rangeCheck32. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to rotate. - -• **bits**: `number` - -amount of bits to rotate this [Field](Field.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 32 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); -const y = Gadgets.rotate32(x, 2, 'left'); // left rotation by 2 bits -const z = Gadgets.rotate32(x, 2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rotate32(xLarge, 32, "left"); // throws an error since input exceeds 32 bits -``` - -### rotate64() - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -**Important:** The gadget assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the rotation. -To safely use `rotate64()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to rotate. - -• **bits**: `number` - -amount of bits to rotate this [Field](Field.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); -const y = Gadgets.rotate64(x, 2, 'left'); // left rotation by 2 bits -const z = Gadgets.rotate64(x, 2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rotate64(xLarge, 32, "left"); // throws an error since input exceeds 64 bits -``` - -### xor() - -Bitwise XOR gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. Each XOR gate can verify 16 bit at most. If your input elements exceed 16 bit, another XOR gate will be added to the chain. - -The `length` parameter lets you define how many bits should be compared. `length` is rounded to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -It is also important to mention that specifying a smaller `length` allows the verifier to infer the length of the original input data (e.g. smaller than 16 bit if only one XOR gate has been used). -A zkApp developer should consider these implications when choosing the `length` parameter and carefully weigh the trade-off between increased amount of constraints and security. - -**Important:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. - -For example, with `length = 2` (`paddedLength = 16`), `xor()` will fail for any input that is larger than `2**16`. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to compare. - -• **b**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to compare. - -• **length**: `number` - -amount of bits to compare. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input values exceed `2^paddedLength - 1`. - -#### Example - -```ts -let a = Field(0b0101); -let b = Field(0b0011); - -let c = Gadgets.xor(a, b, 4); // xor-ing 4 bits -c.assertEquals(0b0110); -``` - -## Source - -[lib/provable/gadgets/gadgets.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/gadgets.ts#L39) diff --git a/docs/zkapps/o1js-reference/variables/Group.mdx b/docs/zkapps/o1js-reference/variables/Group.mdx deleted file mode 100644 index f40dbee0a..000000000 --- a/docs/zkapps/o1js-reference/variables/Group.mdx +++ /dev/null @@ -1,20 +0,0 @@ -```ts -const Group: typeof Group & (...args: [{ - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }]) => Group; -``` - -An element of a Group. - -## Source - -[lib/provable/wrapped.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L76) diff --git a/docs/zkapps/o1js-reference/variables/Hash.mdx b/docs/zkapps/o1js-reference/variables/Hash.mdx deleted file mode 100644 index 267224fcf..000000000 --- a/docs/zkapps/o1js-reference/variables/Hash.mdx +++ /dev/null @@ -1,406 +0,0 @@ -```ts -const Hash: { - "BLAKE2B": { - "hash": Bytes; - }; - "Keccak256": { - "hash": Bytes; - }; - "Keccak384": { - "hash": Bytes; - }; - "Keccak512": { - "hash": Bytes; - }; - "Poseidon": { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; - }; - "SHA2_256": { - "hash": Gadgets.SHA256.hash; - }; - "SHA3_256": { - "hash": Bytes; - }; - "SHA3_384": { - "hash": Bytes; - }; - "SHA3_512": { - "hash": Bytes; - }; - "hash": Poseidon.hash; -}; -``` - -A collection of hash functions which can be used in provable code. - -## Type declaration - -### BLAKE2B - -```ts -BLAKE2B: { - "hash": Bytes; -}; -``` - -### BLAKE2B.hash() - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak256 - -```ts -Keccak256: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 256 bits. - -### Keccak256.hash() - -Hashes the given bytes using Keccak-256. - -This is an alias for `Keccak.preNist(256, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak384 - -```ts -Keccak384: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 384 bits. - -### Keccak384.hash() - -Hashes the given bytes using Keccak-384. - -This is an alias for `Keccak.preNist(384, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak512 - -```ts -Keccak512: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 512 bits. - -### Keccak512.hash() - -Hashes the given bytes using Keccak-512. - -This is an alias for `Keccak.preNist(512, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Poseidon - -```ts -Poseidon: { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; -}; -``` - -### Poseidon.Sponge - -```ts -Sponge: typeof Sponge; -``` - -### Poseidon.Unsafe - -```ts -Unsafe: { - "hashToGroup": Group; -}; -``` - -### Poseidon.Unsafe.hashToGroup() - -Low-level version of `Poseidon.hashToGroup()`. - -**Warning**: This function is marked unsafe because its output is not deterministic. -It returns the square root of a value without constraining which of the two possible -square roots is chosen. This allows the prover to choose between two different hashes, -which can be a vulnerability if consuming code treats the output as unique. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### Poseidon.hash() - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.hashPacked() - -Hashes a provable type efficiently. - -```ts -let skHash = Poseidon.hashPacked(PrivateKey, secretKey); -``` - -Note: Instead of just doing `Poseidon.hash(value.toFields())`, this -uses the `toInput()` method on the provable type to pack the input into as few -field elements as possible. This saves constraints because packing has a much -lower per-field element cost than hashing. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<`Hashable`\<`T`\>\> - -• **value**: `T` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.hashToGroup() - -Hashes a list of field elements to a point on the Pallas curve. - -The output point is deterministic and its discrete log is not efficiently computable. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### Poseidon.hashWithPrefix() - -#### Parameters - -• **prefix**: `string` - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.initialState() - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### Poseidon.update() - -#### Parameters - -• **state**: [[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### SHA2\_256 - -```ts -SHA2_256: { - "hash": Gadgets.SHA256.hash; -}; -``` - -The SHA2 hash function with an output length of 256 bits. - -### SHA2\_256.hash() - -```ts -hash: (data: FlexibleBytes) => Bytes = Gadgets.SHA256.hash; -``` - -Hashes the given bytes using SHA2-256. - -This is an alias for `Gadgets.SHA256.hash(bytes)`.\ -See Gadgets.SHA256.hash for details and usage examples. - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -`Bytes` - -### SHA3\_256 - -```ts -SHA3_256: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 256 bits. - -### SHA3\_256.hash() - -Hashes the given bytes using SHA3-256. - -This is an alias for `Keccak.nistSha3(256, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### SHA3\_384 - -```ts -SHA3_384: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 384 bits. - -### SHA3\_384.hash() - -Hashes the given bytes using SHA3-384. - -This is an alias for `Keccak.nistSha3(384, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### SHA3\_512 - -```ts -SHA3_512: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 512 bits. - -### SHA3\_512.hash() - -Hashes the given bytes using SHA3-512. - -This is an alias for `Keccak.nistSha3(512, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### hash() - -```ts -hash: (input: Field[]) => Field = Poseidon.hash; -``` - -Hashes the given field elements using [Poseidon](https://eprint.iacr.org/2019/458.pdf). Alias for `Poseidon.hash()`. - -```ts -let hash = Hash.hash([a, b, c]); -``` - -**Important:** This is by far the most efficient hash function o1js has available in provable code. -Use it by default, if no compatibility concerns require you to use a different hash function. - -The Poseidon implementation operates over the native [Pallas base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) -and uses parameters generated specifically for the [Mina](https://minaprotocol.com) blockchain. - -We use a `rate` of 2, which means that 2 field elements are hashed per permutation. -A permutation causes 11 rows in the constraint system. - -You can find the full set of Poseidon parameters [here](https://github.com/o1-labs/o1js-bindings/blob/main/crypto/constants.ts). - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -## Source - -[lib/provable/crypto/hash.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/hash.ts#L11) diff --git a/docs/zkapps/o1js-reference/variables/Keccak.mdx b/docs/zkapps/o1js-reference/variables/Keccak.mdx deleted file mode 100644 index d3af8da0c..000000000 --- a/docs/zkapps/o1js-reference/variables/Keccak.mdx +++ /dev/null @@ -1,111 +0,0 @@ -```ts -const Keccak: { - "ethereum": Bytes; - "nistSha3": Bytes; - "preNist": Bytes; -}; -``` - -## Type declaration - -### ethereum() - -Ethereum-Compatible Keccak-256 Hash Function. -This is a specialized variant of Keccak.preNist configured for a 256-bit output length. - -Primarily used in Ethereum for hashing transactions, messages, and other types of payloads. - -The function accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) of length 32. Both input and output bytes are big-endian. - -#### Parameters - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Keccak.ethereum(preimage); -``` - -#### Returns - -`Bytes` - -### nistSha3() - -Implementation of [NIST SHA-3](https://csrc.nist.gov/pubs/fips/202/final) Hash Function. -Supports output lengths of 256, 384, or 512 bits. - -Applies the SHA-3 hash function to a list of big-endian byte-sized [Field](../classes/Field.mdx) elements, flexible to handle varying output lengths (256, 384, 512 bits) as specified. - -The function accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) that conforms to the chosen bit length. -Both input and output bytes are big-endian. - -#### Parameters - -• **len**: `256` \| `384` \| `512` - -Desired output length in bits. Valid options: 256, 384, 512. - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest256 = Keccak.nistSha3(256, preimage); -let digest384 = Keccak.nistSha3(384, preimage); -let digest512 = Keccak.nistSha3(512, preimage); -``` - -#### Returns - -`Bytes` - -### preNist() - -Implementation of [pre-NIST Keccak](https://keccak.team/keccak.html) hash function. -Supports output lengths of 256, 384, or 512 bits. - -Keccak won the SHA-3 competition and was slightly altered before being standardized as SHA-3 by NIST in 2015. -This variant was used in Ethereum before the NIST standardization, by specifying `len` as 256 bits you can obtain the same hash function as used by Ethereum Keccak.ethereum. - -The function applies the pre-NIST Keccak hash function to a list of byte-sized [Field](../classes/Field.mdx) elements and is flexible to handle varying output lengths (256, 384, 512 bits) as specified. - -Keccak.preNist accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) that conforms to the chosen bit length. -Both input and output bytes are big-endian. - -#### Parameters - -• **len**: `256` \| `384` \| `512` - -Desired output length in bits. Valid options: 256, 384, 512. - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest256 = Keccak.preNist(256, preimage); -let digest384 = Keccak.preNist(384, preimage); -let digest512= Keccak.preNist(512, preimage); -``` - -#### Returns - -`Bytes` - -## Source - -[lib/provable/crypto/keccak.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/keccak.ts#L11) diff --git a/docs/zkapps/o1js-reference/variables/Permissions.mdx b/docs/zkapps/o1js-reference/variables/Permissions.mdx deleted file mode 100644 index bc757e3bc..000000000 --- a/docs/zkapps/o1js-reference/variables/Permissions.mdx +++ /dev/null @@ -1,272 +0,0 @@ -```ts -Permissions: { - "VerificationKey": { - "impossibleDuringCurrentVersion": () => VerificationKeyPermission; - "none": () => VerificationKeyPermission; - "proofDuringCurrentVersion": () => VerificationKeyPermission; - "proofOrSignature": () => VerificationKeyPermission; - "signature": () => VerificationKeyPermission; - }; - "allImpossible": () => Permissions; - "default": () => Permissions; - "dummy": () => Permissions; - "fromJSON": (permissions: {}) => Permissions; - "fromString": (permission: AuthRequired) => AuthRequired; - "impossible": () => AuthRequired; - "initial": () => Permissions; - "none": () => AuthRequired; - "proof": () => AuthRequired; - "proofOrSignature": () => AuthRequired; - "signature": () => AuthRequired; -}; -``` - -## Type declaration - -### VerificationKey - -```ts -VerificationKey: { - "impossibleDuringCurrentVersion": () => VerificationKeyPermission; - "none": () => VerificationKeyPermission; - "proofDuringCurrentVersion": () => VerificationKeyPermission; - "proofOrSignature": () => VerificationKeyPermission; - "signature": () => VerificationKeyPermission; -}; -``` - -Special Verification key permissions. - -The difference to normal permissions is that `Permission.proof` and `Permission.impossible` are replaced by less restrictive permissions: -- `impossible` is replaced by `impossibleDuringCurrentVersion` -- `proof` is replaced by `proofDuringCurrentVersion` - -The issue is that a future hardfork which changes the proof system could mean that old verification keys can no longer -be used to verify proofs in the new proof system, and the zkApp would have to be redeployed to adapt the verification key. - -Having either `impossible` or `proof` would mean that these zkApps can't be upgraded after this hypothetical hardfork, and would become unusable. - -Such a future hardfork would manifest as an increment in the "transaction version" of zkApps, which you can check with (). - -The `impossibleDuringCurrentVersion` and `proofDuringCurrentVersion` have an additional `txnVersion` field. -These permissions follow the same semantics of not upgradable, or only upgradable with proofs, -_as long as_ the current transaction version is the same as the one on the permission. - -Once the current transaction version is higher than the one on the permission, the permission is treated as `signature`, -and the zkApp can be redeployed with a signature of the original account owner. - -### VerificationKey.impossibleDuringCurrentVersion() - -```ts -impossibleDuringCurrentVersion: () => VerificationKeyPermission; -``` - -Modification is impossible, as long as the network accepts the current [TransactionVersion](TransactionVersion.mdx). - -After a hardfork that increments the transaction version, the permission is treated as `signature`. - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.none() - -```ts -none: () => VerificationKeyPermission; -``` - -Modification is always permitted - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.proofDuringCurrentVersion() - -```ts -proofDuringCurrentVersion: () => VerificationKeyPermission; -``` - -Modification is permitted by zkapp proofs only; as long as the network accepts the current [TransactionVersion](TransactionVersion.mdx). - -After a hardfork that increments the transaction version, the permission is treated as `signature`. - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.proofOrSignature() - -```ts -proofOrSignature: () => VerificationKeyPermission; -``` - -Modification is permitted by zkapp proofs or signatures - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.signature() - -```ts -signature: () => VerificationKeyPermission; -``` - -Modification is permitted by signatures only, using the private key of the zkapp account - -#### Returns - -`VerificationKeyPermission` - -### allImpossible() - -```ts -allImpossible: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### default() - -```ts -default: () => Permissions; -``` - -Default permissions are: - - [Permissions.editState](../interfaces/Permissions.mdx#editstate) = Permission.proof - - [Permissions.send](../interfaces/Permissions.mdx#send) = Permission.signature - - [Permissions.receive](../interfaces/Permissions.mdx#receive) = Permission.none - - [Permissions.setDelegate](../interfaces/Permissions.mdx#setdelegate) = Permission.signature - - [Permissions.setPermissions](../interfaces/Permissions.mdx#setpermissions) = Permission.signature - - [Permissions.setVerificationKey](../interfaces/Permissions.mdx#setverificationkey) = Permission.signature - - [Permissions.setZkappUri](../interfaces/Permissions.mdx#setzkappuri) = Permission.signature - - [Permissions.editActionState](../interfaces/Permissions.mdx#editactionstate) = Permission.proof - - [Permissions.setTokenSymbol](../interfaces/Permissions.mdx#settokensymbol) = Permission.signature - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### dummy() - -```ts -dummy: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### fromJSON() - -```ts -fromJSON: (permissions: {}) => Permissions; -``` - -#### Parameters - -• **permissions** - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### fromString() - -```ts -fromString: (permission: AuthRequired) => AuthRequired; -``` - -#### Parameters - -• **permission**: `AuthRequired` - -#### Returns - -`AuthRequired` - -### impossible() - -```ts -impossible: () => AuthRequired; -``` - -Modification is impossible. - -#### Returns - -`AuthRequired` - -### initial() - -```ts -initial: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### none() - -```ts -none: () => AuthRequired; -``` - -Modification is always permitted - -#### Returns - -`AuthRequired` - -### proof() - -```ts -proof: () => AuthRequired; -``` - -Modification is permitted by zkapp proofs only - -#### Returns - -`AuthRequired` - -### proofOrSignature() - -```ts -proofOrSignature: () => AuthRequired; -``` - -Modification is permitted by zkapp proofs or signatures - -#### Returns - -`AuthRequired` - -### signature() - -```ts -signature: () => AuthRequired; -``` - -Modification is permitted by signatures only, using the private key of the zkapp account - -#### Returns - -`AuthRequired` - -## Source - -[lib/mina/account-update.ts:327](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L327) diff --git a/docs/zkapps/o1js-reference/variables/Poseidon.mdx b/docs/zkapps/o1js-reference/variables/Poseidon.mdx deleted file mode 100644 index 309bab61b..000000000 --- a/docs/zkapps/o1js-reference/variables/Poseidon.mdx +++ /dev/null @@ -1,132 +0,0 @@ -```ts -const Poseidon: { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; -}; -``` - -## Type declaration - -### Sponge - -```ts -Sponge: typeof Sponge; -``` - -### Unsafe - -```ts -Unsafe: { - "hashToGroup": Group; -}; -``` - -### Unsafe.hashToGroup() - -Low-level version of `Poseidon.hashToGroup()`. - -**Warning**: This function is marked unsafe because its output is not deterministic. -It returns the square root of a value without constraining which of the two possible -square roots is chosen. This allows the prover to choose between two different hashes, -which can be a vulnerability if consuming code treats the output as unique. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### hash() - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### hashPacked() - -Hashes a provable type efficiently. - -```ts -let skHash = Poseidon.hashPacked(PrivateKey, secretKey); -``` - -Note: Instead of just doing `Poseidon.hash(value.toFields())`, this -uses the `toInput()` method on the provable type to pack the input into as few -field elements as possible. This saves constraints because packing has a much -lower per-field element cost than hashing. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<`Hashable`\<`T`\>\> - -• **value**: `T` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### hashToGroup() - -Hashes a list of field elements to a point on the Pallas curve. - -The output point is deterministic and its discrete log is not efficiently computable. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### hashWithPrefix() - -#### Parameters - -• **prefix**: `string` - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### initialState() - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### update() - -#### Parameters - -• **state**: [[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -## Source - -[lib/provable/crypto/poseidon.ts:56](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L56) diff --git a/docs/zkapps/o1js-reference/variables/ProvableType.mdx b/docs/zkapps/o1js-reference/variables/ProvableType.mdx deleted file mode 100644 index 351cca264..000000000 --- a/docs/zkapps/o1js-reference/variables/ProvableType.mdx +++ /dev/null @@ -1,42 +0,0 @@ -```ts -ProvableType: { - "get": ToProvable; - "synthesize": T; -}; -``` - -## Type declaration - -### get() - -#### Type parameters - -• **A** *extends* `unknown` - -#### Parameters - -• **type**: `A` - -#### Returns - -[`ToProvable`](../type-aliases/ToProvable.mdx)\<`A`\> - -### synthesize() - -Create some value of type `T` from its provable type description. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`ProvableType`](../type-aliases/ProvableType.mdx)\<`T`, `any`\> - -#### Returns - -`T` - -## Source - -[lib/provable/types/provable-intf.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L132) diff --git a/docs/zkapps/o1js-reference/variables/TokenId.mdx b/docs/zkapps/o1js-reference/variables/TokenId.mdx deleted file mode 100644 index 6364f3b3c..000000000 --- a/docs/zkapps/o1js-reference/variables/TokenId.mdx +++ /dev/null @@ -1,52 +0,0 @@ -```ts -const TokenId: { - "default": Field; - "derive": Field; - "fromBase58": Field; - "toBase58": string; -}; -``` - -## Type declaration - -### default - -```ts -default: Field; -``` - -### derive() - -#### Parameters - -• **tokenOwner**: [`PublicKey`](../classes/PublicKey.mdx) - -• **parentTokenId**: [`Field`](../classes/Field.mdx)= `undefined` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### fromBase58() - -#### Parameters - -• **base58**: `string` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### toBase58() - -#### Parameters - -• **t**: [`Field`](../classes/Field.mdx) - -#### Returns - -`string` - -## Source - -[lib/mina/account-update.ts:666](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L666) diff --git a/docs/zkapps/o1js-reference/variables/TransactionVersion.mdx b/docs/zkapps/o1js-reference/variables/TransactionVersion.mdx deleted file mode 100644 index be3c296f6..000000000 --- a/docs/zkapps/o1js-reference/variables/TransactionVersion.mdx +++ /dev/null @@ -1,21 +0,0 @@ -```ts -const TransactionVersion: { - "current": () => UInt32; -}; -``` - -## Type declaration - -### current() - -```ts -current: () => UInt32; -``` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx) - -## Source - -[lib/mina/account-update.ts:119](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L119) diff --git a/docs/zkapps/o1js-reference/variables/TupleN.mdx b/docs/zkapps/o1js-reference/variables/TupleN.mdx deleted file mode 100644 index e5e643c91..000000000 --- a/docs/zkapps/o1js-reference/variables/TupleN.mdx +++ /dev/null @@ -1,67 +0,0 @@ -```ts -TupleN: { - "fromArray": TupleN; - "hasLength": tuple is TupleN; - "map": [...{ [i in string | number | symbol]: B }[]]; -}; -``` - -## Type declaration - -### fromArray() - -#### Type parameters - -• **T** - -• **N** *extends* `number` - -#### Parameters - -• **n**: `N` - -• **arr**: `T`[] - -#### Returns - -[`TupleN`](../type-aliases/TupleN.mdx)\<`T`, `N`\> - -### hasLength() - -#### Type parameters - -• **T** - -• **N** *extends* `number` - -#### Parameters - -• **n**: `N` - -• **tuple**: `T`[] - -#### Returns - -`tuple is TupleN` - -### map() - -#### Type parameters - -• **T** *extends* `Tuple`\<`any`\> - -• **B** - -#### Parameters - -• **tuple**: `T` - -• **f** - -#### Returns - -[...\{ [i in string \| number \| symbol]: B \}[]] - -## Source - -[lib/util/types.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/util/types.ts#L28) diff --git a/docs/zkapps/o1js-reference/variables/Undefined.mdx b/docs/zkapps/o1js-reference/variables/Undefined.mdx deleted file mode 100644 index 5faabafb6..000000000 --- a/docs/zkapps/o1js-reference/variables/Undefined.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -Undefined: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L82) diff --git a/docs/zkapps/o1js-reference/variables/Void.mdx b/docs/zkapps/o1js-reference/variables/Void.mdx deleted file mode 100644 index f6ee1cd95..000000000 --- a/docs/zkapps/o1js-reference/variables/Void.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -Void: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L87) diff --git a/docs/zkapps/o1js-reference/variables/ZkappPublicInput.mdx b/docs/zkapps/o1js-reference/variables/ZkappPublicInput.mdx deleted file mode 100644 index b321b7e4c..000000000 --- a/docs/zkapps/o1js-reference/variables/ZkappPublicInput.mdx +++ /dev/null @@ -1,30 +0,0 @@ -```ts -ZkappPublicInput: ProvablePureExtended<{ - "accountUpdate": Field; - "calls": Field; - }, { - "accountUpdate": Field; - "calls": Field; - }, { - "accountUpdate": Field; - "calls": Field; -}>; -``` - -## Type declaration - -### accountUpdate - -```ts -accountUpdate: Field = Field; -``` - -### calls - -```ts -calls: Field = Field; -``` - -## Source - -[lib/mina/account-update.ts:2050](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L2050) diff --git a/docs/zkapps/o1js-reference/variables/emptyHash.mdx b/docs/zkapps/o1js-reference/variables/emptyHash.mdx deleted file mode 100644 index 79a8088ba..000000000 --- a/docs/zkapps/o1js-reference/variables/emptyHash.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```ts -const emptyHash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:24](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L24) diff --git a/docs/zkapps/o1js/basic-concepts.mdx b/docs/zkapps/o1js/basic-concepts.mdx index a1fe10de0..4a3860c37 100644 --- a/docs/zkapps/o1js/basic-concepts.mdx +++ b/docs/zkapps/o1js/basic-concepts.mdx @@ -131,4 +131,4 @@ let sig = Signature.create(privKey, msg); // sign a message sig.verify(pubKey, msg); // Bool(true) ``` -For a full list, see the [o1js reference](../o1js-reference). +For a full list, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). diff --git a/docs/zkapps/o1js/foreign-fields.mdx b/docs/zkapps/o1js/foreign-fields.mdx index 3c0cb26c1..1c7b66686 100644 --- a/docs/zkapps/o1js/foreign-fields.mdx +++ b/docs/zkapps/o1js/foreign-fields.mdx @@ -22,7 +22,7 @@ Foreign fields are useful for implementing cryptographic algorithms in provable ## Why foreign fields? -The core data type in o1js is `Field` that represents the field that is _native to the proof system_. In other words, addition and multiplication of Fields are the fundamental operations upon which all provable code is built. Because a lot of cryptography uses finite fields, o1js natively supports several cryptographic algorithms with high efficiency. See classes and modules like [Poseidon](../o1js-reference/variables/Poseidon), [PublicKey](../o1js-reference/classes/PublicKey), [PrivateKey](../o1js-reference/classes/PrivateKey), [Signature](../o1js-reference/classes/Signature), and [Encryption](../o1js-reference/namespaces/Encryption). +The core data type in o1js is `Field` that represents the field that is _native to the proof system_. In other words, addition and multiplication of Fields are the fundamental operations upon which all provable code is built. Because a lot of cryptography uses finite fields, o1js natively supports several cryptographic algorithms with high efficiency. See classes and modules like [Poseidon](https://docs.o1labs.org/o1js/api-reference/variables/Poseidon), [PublicKey](https://docs.o1labs.org/o1js/api-reference/classes/PublicKey), [PrivateKey](https://docs.o1labs.org/o1js/api-reference/classes/PrivateKey), [Signature](https://docs.o1labs.org/o1js/api-reference/classes/Signature), and [Encryption](https://docs.o1labs.org/o1js/api-reference/namespaces/Encryption). However, these classes and modules are not compatible with the cryptography used in the wider world: `Signature.verify()` doesn't let you verify a signed JWT or email, and `Encryption.decrypt()` won't help you with your WhatsApp messages. That's because these methods use different finite fields than the native Field that was chosen primarily to enable efficient zk proofs. @@ -30,7 +30,7 @@ Here is where foreign fields come in: They let you perform algorithms that conne ## Basic usage -This section provides a brief overview of how to use foreign fields. For more details, refer to the [API reference](../o1js-reference/classes/ForeignField) or the doc comments on each method. +This section provides a brief overview of how to use foreign fields. For more details, refer to the [API reference](https://docs.o1labs.org/o1js/api-reference/classes/ForeignField) or the doc comments on each method. The entry point for using foreign fields is the `createForeignField()` function: @@ -102,7 +102,7 @@ let y = SmallField.from(5n); // convert from bigint or number y.toBigInt() === 5n; // convert to bigint ``` -As usual, you can find more information about each method in the [API reference](../o1js-reference/classes/ForeignField). +As usual, you can find more information about each method in the [API reference](https://docs.o1labs.org/o1js/api-reference/classes/ForeignField). ## Three kinds of foreign fields diff --git a/docs/zkapps/o1js/gadgets.mdx b/docs/zkapps/o1js/gadgets.mdx index f5a1ae963..30fdb8888 100644 --- a/docs/zkapps/o1js/gadgets.mdx +++ b/docs/zkapps/o1js/gadgets.mdx @@ -24,4 +24,4 @@ In o1js, you can import these provable and helper methods from the `Gadgets` nam - [Bitwise Operations](/zkapps/o1js/bitwise-operations) - [Foreign Field Arithmetic](/zkapps/o1js/ecdsa) -See the type declaration for [Gadgets](/zkapps/o1js-reference/variables/Gadgets) in the o1js Reference documentation. +See the type declaration for [Gadgets](https://docs.o1labs.org/o1js/api-reference/variables/Gadgets) in the o1js Reference documentation. diff --git a/docs/zkapps/o1js/indexed-merkle-map.mdx b/docs/zkapps/o1js/indexed-merkle-map.mdx index 93313af67..ca08c8f50 100644 --- a/docs/zkapps/o1js/indexed-merkle-map.mdx +++ b/docs/zkapps/o1js/indexed-merkle-map.mdx @@ -70,7 +70,7 @@ In this example, `IndexedMerkleMap31` is a Merkle map capable of holding up to 2 ### Indexed Merkle Map - API reference -For an example, see the `IndexedMerkleMap` [API reference](/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap) in o1js. +For an example, see the `IndexedMerkleMap` [API reference](https://docs.o1labs.org/o1js/api-reference/namespaces/Experimental/functions/IndexedMerkleMap) in o1js. ## Additional Resources diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index 656bfb4dd..d97400262 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -236,7 +236,7 @@ Since this code extends `SmartContract` that has its own initialization to perfo Then, `this.num.set(Field(3))` initializes the on-chain state `num` to a value of `3`. -You can optionally specify permissions. See [setPermissions](/zkapps/o1js-reference/classes/SmartContract) in the o1js Reference documentation. +You can optionally specify permissions. See [setPermissions](https://docs.o1labs.org/o1js/api-reference/classes/SmartContract) in the o1js Reference documentation. Finally, this code adds the `update()` function: @@ -272,7 +272,7 @@ Notice that `get()` and `set()` methods are used for retrieving and setting on-c - Similarly, using `set()` changes the transaction to indicate that changes to this particular on-chain state are updated only when the transaction is received by the Mina network if it contains a valid authorization (usually, a valid authorization is a proof). -The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available [methods](/zkapps/o1js-reference/classes/Field#methods) in the o1js Reference documentation. +The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available [methods](https://docs.o1labs.org/o1js/api-reference/classes/Field#methods) in the o1js Reference documentation. You remember that functions in your smart contract must operate on o1js compatible data types: `Field` types and other types built on top of `Field` types. Because a smart contract is really a zero knowledge circuit, functions from random npm packages work inside a smart contract only if the functions the contract provides operate on o1js-compatible data types. diff --git a/docs/zkapps/tutorials/05-common-types-and-functions.mdx b/docs/zkapps/tutorials/05-common-types-and-functions.mdx index d261406af..fb019aa3f 100644 --- a/docs/zkapps/tutorials/05-common-types-and-functions.mdx +++ b/docs/zkapps/tutorials/05-common-types-and-functions.mdx @@ -43,11 +43,11 @@ Ensure your environment meets the [Prerequisites](/zkapps/tutorials#prerequisite Five basic types are derived from Fields: -- [Bool](../o1js-reference/classes/Bool) -- [UInt32](../o1js-reference/classes/UInt32) -- [UInt64](../o1js-reference/classes/UInt64) -- [Int64](../o1js-reference/classes/Int64) -- [Character](../o1js-reference/classes/Character) +- [Bool](https://docs.o1labs.org/o1js/api-reference/classes/Bool) +- [UInt32](https://docs.o1labs.org/o1js/api-reference/classes/UInt32) +- [UInt64](https://docs.o1labs.org/o1js/api-reference/classes/UInt64) +- [Int64](https://docs.o1labs.org/o1js/api-reference/classes/Int64) +- [Character](https://docs.o1labs.org/o1js/api-reference/classes/Character) Each type has the usual programming language semantics. @@ -99,10 +99,10 @@ Fields in char1: 1 Four advanced types are: -- [CircuitString](../o1js-reference/classes/CircuitString) -- [PrivateKey](../o1js-reference/classes/PrivateKey) -- [PublicKey](../o1js-reference/classes/PublicKey) -- [Signature](../o1js-reference/classes/Signature) +- [CircuitString](https://docs.o1labs.org/o1js/api-reference/classes/CircuitString) +- [PrivateKey](https://docs.o1labs.org/o1js/api-reference/classes/PrivateKey) +- [PublicKey](https://docs.o1labs.org/o1js/api-reference/classes/PublicKey) +- [Signature](https://docs.o1labs.org/o1js/api-reference/classes/Signature) All arguments passed into smart contracts must be arguments o1js can consume. You cannot pass normal strings. Instead, you must pass in strings that are wrapped to be compatible with circuits. This is accomplished with `Struct`. @@ -161,7 +161,7 @@ There are 255 Fields in a private key and 256 Fields in a signature. If you are ## Struct -You can create your own compound data types with the special [Struct](../o1js-reference/functions/Struct) type. +You can create your own compound data types with the special [Struct](https://docs.o1labs.org/o1js/api-reference/functions/Struct) type. Define a Struct as one or more data types that o1js understands. For example, Field, higher-order types built into o1js based on Field, or other Struct types defined by you. You can also define methods on your Struct to act upon this data type. @@ -286,7 +286,7 @@ If a program is too large to fit into these constraints, it can be broken up int ## Merkle Trees -You can use [Merkle trees](../o1js-reference/classes/MerkleTree) to manage large amounts of data within a circuit. The power of Merkle trees is demonstrated in the [05-common-types-and-functions/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/05-common-types-and-functions/src) reference project for this tutorial. See the [BasicMerkleTreeContract.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/BasicMerkleTreeContract.ts) contract and [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/main.ts) that demonstrates how contracts interact with Merkle trees and how to construct them. +You can use [Merkle trees](https://docs.o1labs.org/o1js/api-reference/classes/MerkleTree) to manage large amounts of data within a circuit. The power of Merkle trees is demonstrated in the [05-common-types-and-functions/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/05-common-types-and-functions/src) reference project for this tutorial. See the [BasicMerkleTreeContract.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/BasicMerkleTreeContract.ts) contract and [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/main.ts) that demonstrates how contracts interact with Merkle trees and how to construct them. The first step is to import `MerkleTree`: @@ -307,7 +307,7 @@ const tree = new MerkleTree(height); The height variable determines how many leaves are available to the application. For example, a height of 20 leads to a tree with `2^(20-1)`, or 524,288 leaves. -Merkle trees in smart contracts are stored as the hash of the Merkle tree's root. Smart contract methods that update the Merkle root can take a _witness_ of the change as an argument. The [MerkleMapWitness](/zkapps/o1js-reference/classes/MerkleMapWitness) represents the Merkle path to the data for which inclusion is being proved. +Merkle trees in smart contracts are stored as the hash of the Merkle tree's root. Smart contract methods that update the Merkle root can take a _witness_ of the change as an argument. The [MerkleMapWitness](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMapWitness) represents the Merkle path to the data for which inclusion is being proved. A contract stores the root of a Merkle tree, where each leaf stores a number, and the smart contract has an `update` function that adds a number to the leaf. @@ -413,7 +413,7 @@ A more advanced example `LedgerContract` implements a basic ledger of tokens, in ## Merkle Map -See the API reference documentation for the [MerkleMap](../o1js-reference/classes/MerkleMap) class you can use to implement key-value stores. +See the API reference documentation for the [MerkleMap](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMap) class you can use to implement key-value stores. The API for Merkle Maps is similar to Merkle Trees, just instead of using an index to set a leaf, one uses a key: @@ -493,7 +493,7 @@ const txn1 = await Mina.transaction(deployerAccount, async () => { ... ``` -You use [MerkleMaps](/zkapps/o1js-reference/classes/MerkleMap) to implement many useful patterns. For example: +You use [MerkleMaps](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMap) to implement many useful patterns. For example: - A key value store from public keys to booleans, of token accounts to whether they've participated in a voted yet. - A nullifier that privately tracks if an input was used, without revealing it. diff --git a/docs/zkapps/tutorials/09-recursion.mdx b/docs/zkapps/tutorials/09-recursion.mdx index f698432ca..329d6b872 100644 --- a/docs/zkapps/tutorials/09-recursion.mdx +++ b/docs/zkapps/tutorials/09-recursion.mdx @@ -46,7 +46,7 @@ Recursive ZKPs also make it easy to allow multiple parties to construct transact ## ZkProgram Example -You build recursive zkApps with [ZkProgram](/zkapps/o1js-reference/functions/ZkProgram), the o1js general purpose API for creating zero knowledge proofs. A ZkProgram is similar to zkApp smart contracts but isn't tied to an on-chain account. +You build recursive zkApps with [ZkProgram](https://docs.o1labs.org/o1js/api-reference/functions/ZkProgram), the o1js general purpose API for creating zero knowledge proofs. A ZkProgram is similar to zkApp smart contracts but isn't tied to an on-chain account. Proofs generated using a ZkProgram can be passed into zkApp smart contracts for them to verify recursively. They can even be passed recursively into their own functions for off-chain recursive composition. diff --git a/docs/zkapps/tutorials/10-account-updates.mdx b/docs/zkapps/tutorials/10-account-updates.mdx index 91ddc51ed..9b7ff91ad 100644 --- a/docs/zkapps/tutorials/10-account-updates.mdx +++ b/docs/zkapps/tutorials/10-account-updates.mdx @@ -21,7 +21,7 @@ keywords: The fundamental data structure that Mina transactions are built from is called an _account update_. Account updates are a flexible and powerful data structure that can express all kinds of updates, events, and preconditions you use to develop smart contracts. -Each zkApp transaction constructed by o1js is composed of one or more [AccountUpdate](../o1js-reference/classes/AccountUpdate) classes, which are a set of instructions for the Mina network to perform, such as altering on-chain state, emitting an event, and so on. +Each zkApp transaction constructed by o1js is composed of one or more [AccountUpdate](https://docs.o1labs.org/o1js/api-reference/classes/AccountUpdate) classes, which are a set of instructions for the Mina network to perform, such as altering on-chain state, emitting an event, and so on. Each `AccountUpdate` can make assertions about its account, apply updates to its account, and make assertions about its child `AccountUpdates`. @@ -42,7 +42,7 @@ In this tutorial, you learn the essential account update features. The `AccountUpdate` class is a set of instructions for the Mina network. It includes preconditions (conditions that must be true for the account update to be applied) and a list of state updates that need to be authorized by a signature or proof. -Each [AccountUpdate](/zkapps/o1js-reference/classes/AccountUpdate) class has these components: +Each [AccountUpdate](https://docs.o1labs.org/o1js/api-reference/classes/AccountUpdate) class has these components: - `PublicKey`: The account address for the account update - `TokenId`: A unique hash representing the custom token. Defaults to the MINA TokenId (`1`). diff --git a/docs/zkapps/tutorials/index.mdx b/docs/zkapps/tutorials/index.mdx index df74e5cd9..af575b081 100644 --- a/docs/zkapps/tutorials/index.mdx +++ b/docs/zkapps/tutorials/index.mdx @@ -78,7 +78,7 @@ Line numbers are provided for convenience. To prevent copying line numbers and c ## Useful Resources -The API Reference docs are a detailed resource that is useful after you have familiarized yourself with the basics. See the [o1js Reference](/zkapps/o1js-reference) docs for an in-depth explanation of all the methods, properties, and interfaces available in o1js. +The API Reference docs are a detailed resource that is useful after you have familiarized yourself with the basics. See the [o1js Reference](https://docs.o1labs.org/o1js/api-reference/Introduction) docs for an in-depth explanation of all the methods, properties, and interfaces available in o1js. See the o1Labs blog at https://www.o1labs.org/blog/. For updates about o1js, see https://www.o1labs.org/blog?topics=o1js. diff --git a/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/how-to-write-a-zkapp.mdx b/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/how-to-write-a-zkapp.mdx index 8c0cbe208..033464cc8 100644 --- a/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/how-to-write-a-zkapp.mdx +++ b/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/how-to-write-a-zkapp.mdx @@ -276,7 +276,7 @@ A basic smart contract example is generated when you created a zk project. The h For guided steps to create your first zkApp, start with [Tutorial 1: Hello World](/zkapps/tutorials/hello-world). -For comprehensive details about the o1js API, see the [o1js reference](/zkapps/o1js-reference). +For comprehensive details about the o1js API, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). ## Next Steps diff --git a/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/smart-contracts.mdx b/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/smart-contracts.mdx index ac3299d4f..c7ef68249 100644 --- a/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/smart-contracts.mdx +++ b/docs/zkapps/writing-a-zkapp/introduction-to-zkapps/smart-contracts.mdx @@ -194,7 +194,7 @@ x.assertGt(y); // x > y x.assertGte(y); // x >= y ``` -For a full list, see the [o1js reference](/zkapps/o1js-reference). +For a full list, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). To modify the `increment()` method to accept a parameter: diff --git a/docusaurus.config.js b/docusaurus.config.js index 4d301adfd..e0157c5c9 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -280,10 +280,6 @@ module.exports = { from: '/exchange-operators/rosetta/samples/send-transactions', to: '/node-operators/rosetta/samples/send-transactions', }, - { - from: '/zkapps/snarkyjs-reference', - to: '/zkapps/o1js-reference', - }, { from: '/berkeley-upgrade/requirements', to: '/network-upgrades/berkeley/requirements', diff --git a/sidebars.js b/sidebars.js index 4db01d385..07094282d 100644 --- a/sidebars.js +++ b/sidebars.js @@ -230,1253 +230,6 @@ module.exports = { 'zkapps/tutorials/interacting-with-zkapps-server-side', ], }, - { - type: 'category', - label: 'o1js Reference', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/README', - label: 'Introduction', - }, - { - type: 'category', - label: 'Classes', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/AccountUpdate', - label: 'AccountUpdate', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/AccountUpdateForest', - label: 'AccountUpdateForest', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/AccountUpdateTree', - label: 'AccountUpdateTree', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/AlmostForeignField', - label: 'AlmostForeignField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/BaseMerkleWitness', - label: 'BaseMerkleWitness', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Bool', - label: 'Bool', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/CanonicalForeignField', - label: 'CanonicalForeignField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Character', - label: 'Character', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Circuit', - label: 'Circuit', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/CircuitString', - label: 'CircuitString', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/DynamicProof', - label: 'DynamicProof', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/EcdsaSignature', - label: 'EcdsaSignature', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Field', - label: 'Field', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/ForeignCurve', - label: 'ForeignCurve', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/ForeignField', - label: 'ForeignField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Group', - label: 'Group', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Hashed', - label: 'Hashed', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Int64', - label: 'Int64', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Keypair', - label: 'Keypair', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Ledger', - label: 'Ledger', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/MerkleList', - label: 'MerkleList', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/MerkleListIterator', - label: 'MerkleListIterator', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/MerkleMap', - label: 'MerkleMap', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/MerkleMapWitness', - label: 'MerkleMapWitness', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/MerkleTree', - label: 'MerkleTree', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Nullifier', - label: 'Nullifier', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Packed', - label: 'Packed', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/PrivateKey', - label: 'PrivateKey', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Proof', - label: 'Proof', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/ProofBase', - label: 'ProofBase', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/PublicKey', - label: 'PublicKey', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Scalar', - label: 'Scalar', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/ScalarField', - label: 'ScalarField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/SelfProof', - label: 'SelfProof', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Sign', - label: 'Sign', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Signature', - label: 'Signature', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/SmartContract', - label: 'SmartContract', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/TokenAccountUpdateIterator', - label: 'TokenAccountUpdateIterator', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/TokenContract', - label: 'TokenContract', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/TokenSymbol', - label: 'TokenSymbol', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/UInt32', - label: 'UInt32', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/UInt64', - label: 'UInt64', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/UInt8', - label: 'UInt8', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/Unconstrained', - label: 'Unconstrained', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/classes/VerificationKey', - label: 'VerificationKey', - }, - ], - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/Bytes', - label: 'Bytes', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/ConstantField', - label: 'ConstantField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/MerkleListBase', - label: 'MerkleListBase', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/MerkleWitness', - label: 'MerkleWitness', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/Option', - label: 'Option', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/Reducer', - label: 'Reducer', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/State', - label: 'State', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/Struct', - label: 'Struct', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/VarField', - label: 'VarField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/WithHash', - label: 'WithHash', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/ZkProgram', - label: 'ZkProgram', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/addCachedAccount', - label: 'addCachedAccount', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/assert', - label: 'assert', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/checkBitLength', - label: 'checkBitLength', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/checkZkappTransaction', - label: 'checkZkappTransaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/circuitMain', - label: 'circuitMain', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/conditionalSwap', - label: 'conditionalSwap', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/createEcdsa', - label: 'createEcdsa', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/createForeignCurve', - label: 'createForeignCurve', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/createForeignField', - label: 'createForeignField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/declareMethods', - label: 'declareMethods', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/declareState', - label: 'declareState', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/fetchAccount', - label: 'fetchAccount', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/fetchEvents', - label: 'fetchEvents', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/fetchLastBlock', - label: 'fetchLastBlock', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/fetchTransactionStatus', - label: 'fetchTransactionStatus', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/genericHash', - label: 'genericHash', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/initializeBindings', - label: 'initializeBindings', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/merkleListHash', - label: 'merkleListHash', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/method', - label: 'method', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/provable', - label: 'provable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/provablePure', - label: 'provablePure', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/public', - label: 'public', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/readVarMessage', - label: 'readVarMessage', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/sendZkapp', - label: 'sendZkapp', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint', - label: 'setArchiveGraphqlEndpoint', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/setGraphqlEndpoint', - label: 'setGraphqlEndpoint', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/setGraphqlEndpoints', - label: 'setGraphqlEndpoints', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/setNumberOfWorkers', - label: 'setNumberOfWorkers', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/state-1', - label: 'state-1', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/toConstantField', - label: 'toConstantField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/toFp', - label: 'toFp', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/verify', - label: 'verify', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/withHashes', - label: 'withHashes', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/functions/withMessage', - label: 'withMessage', - }, - ], - }, - { - type: 'category', - label: 'Interfaces', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/interfaces/Permissions', - label: 'Permissions', - }, - ], - }, - { - type: 'category', - label: 'Namespaces', - items: [ - { - type: 'category', - label: 'Crypto', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Crypto/README', - label: 'README', - }, - { - type: 'category', - label: 'Type-Aliases', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve', - label: 'Curve', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams', - label: 'CurveParams', - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Encryption', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/README', - label: 'README', - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/functions/decrypt', - label: 'decrypt', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes', - label: 'decryptBytes', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/functions/encrypt', - label: 'encrypt', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes', - label: 'encryptBytes', - }, - ], - }, - { - type: 'category', - label: 'Type-Aliases', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText', - label: 'CipherText', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes', - label: 'CipherTextBytes', - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Experimental', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/README', - label: 'README', - }, - { - type: 'category', - label: 'Classes', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer', - label: 'BatchReducer', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments', - label: 'OffchainStateCommitments', - }, - ], - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch', - label: 'ActionBatch', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap', - label: 'IndexedMerkleMap', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState', - label: 'OffchainState', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness', - label: 'memoizeWitness', - }, - ], - }, - { - type: 'category', - label: 'Type-Aliases', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch', - label: 'ActionBatch', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap', - label: 'IndexedMerkleMap', - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Lightnet', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Lightnet/README', - label: 'README', - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair', - label: 'acquireKeyPair', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs', - label: 'listAcquiredKeyPairs', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair', - label: 'releaseKeyPair', - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Mina', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/README', - label: 'README', - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain', - label: 'LocalBlockchain', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/Network', - label: 'Network', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey', - label: 'TestPublicKey', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/currentSlot', - label: 'currentSlot', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction', - label: 'currentTransaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/faucet', - label: 'faucet', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/fetchActions', - label: 'fetchActions', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents', - label: 'fetchEvents', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/filterGroups', - label: 'filterGroups', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getAccount', - label: 'getAccount', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getActions', - label: 'getActions', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getBalance', - label: 'getBalance', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants', - label: 'getNetworkConstants', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId', - label: 'getNetworkId', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState', - label: 'getNetworkState', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled', - label: 'getProofsEnabled', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/hasAccount', - label: 'hasAccount', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/sender', - label: 'sender', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance', - label: 'setActiveInstance', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/transaction', - label: 'transaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding', - label: 'waitForFunding', - }, - ], - }, - { - type: 'category', - label: 'Namespaces', - items: [ - { - type: 'category', - label: 'TestPublicKey', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README', - label: 'README', - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58', - label: 'fromBase58', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random', - label: 'random', - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Transaction', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README', - label: 'README', - }, - { - type: 'category', - label: 'Functions', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON', - label: 'fromJSON', - }, - ], - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Type-Aliases', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates', - label: 'ActionStates', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec', - label: 'FeePayerSpec', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction', - label: 'IncludedTransaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants', - label: 'NetworkConstants', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction', - label: 'PendingTransaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise', - label: 'PendingTransactionPromise', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus', - label: 'PendingTransactionStatus', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction', - label: 'RejectedTransaction', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey', - label: 'TestPublicKey', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction', - label: 'Transaction', - }, - ], - }, - { - type: 'category', - label: 'Variables', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/namespaces/Mina/variables/activeInstance', - label: 'activeInstance', - }, - ], - }, - ], - }, - ], - }, - { - type: 'category', - label: 'Type-Aliases', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Account', - label: 'Account', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Bool', - label: 'Bool', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/BoolVar', - label: 'BoolVar', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Bytes', - label: 'Bytes', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Cache', - label: 'Cache', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/CacheHeader', - label: 'CacheHeader', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ConstantField', - label: 'ConstantField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/DeployArgs', - label: 'DeployArgs', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Empty', - label: 'Empty', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/FeatureFlags', - label: 'FeatureFlags', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Field', - label: 'Field', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/FlexibleProvable', - label: 'FlexibleProvable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/FlexibleProvablePure', - label: 'FlexibleProvablePure', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Group', - label: 'Group', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/InferProvable', - label: 'InferProvable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/JsonProof', - label: 'JsonProof', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/MerkleListBase', - label: 'MerkleListBase', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/MerkleListIteratorBase', - label: 'MerkleListIteratorBase', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Option', - label: 'Option', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Provable', - label: 'Provable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableExtended', - label: 'ProvableExtended', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableHashable-1', - label: 'ProvableHashable-1', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableHashable', - label: 'ProvableHashable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvablePure', - label: 'ProvablePure', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableType', - label: 'ProvableType', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableTypePure', - label: 'ProvableTypePure', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ProvableWithEmpty', - label: 'ProvableWithEmpty', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Reducer', - label: 'Reducer', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ScalarConst', - label: 'ScalarConst', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/State', - label: 'State', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Struct', - label: 'Struct', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ToProvable', - label: 'ToProvable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/TransactionPromise', - label: 'TransactionPromise', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/TransactionStatus', - label: 'TransactionStatus', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/TupleN', - label: 'TupleN', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Undefined', - label: 'Undefined', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/VarField', - label: 'VarField', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Void', - label: 'Void', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/WithHash', - label: 'WithHash', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/WithProvable', - label: 'WithProvable', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/Witness', - label: 'Witness', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ZkProgram', - label: 'ZkProgram', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/type-aliases/ZkappPublicInput', - label: 'ZkappPublicInput', - }, - ], - }, - { - type: 'category', - label: 'Variables', - items: [ - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Account', - label: 'Account', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Bool', - label: 'Bool', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Cache', - label: 'Cache', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Crypto', - label: 'Crypto', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Empty', - label: 'Empty', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/FeatureFlags', - label: 'FeatureFlags', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Field', - label: 'Field', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Gadgets', - label: 'Gadgets', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Group', - label: 'Group', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Hash', - label: 'Hash', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Keccak', - label: 'Keccak', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Permissions', - label: 'Permissions', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Poseidon', - label: 'Poseidon', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/ProvableType', - label: 'ProvableType', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/TokenId', - label: 'TokenId', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/TransactionVersion', - label: 'TransactionVersion', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/TupleN', - label: 'TupleN', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Undefined', - label: 'Undefined', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/Void', - label: 'Void', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/ZkappPublicInput', - label: 'ZkappPublicInput', - }, - { - type: 'doc', - id: 'zkapps/o1js-reference/variables/emptyHash', - label: 'emptyHash', - }, - ], - }, - ], - }, 'zkapps/roadmap', 'zkapps/faq', 'zkapps/standards', @@ -1586,9 +339,7 @@ module.exports = { type: 'doc', id: 'node-operators/data-and-history/index', }, - items: [ - 'node-operators/data-and-history/rosetta', - ], + items: ['node-operators/data-and-history/rosetta'], }, { type: 'category', @@ -1658,9 +409,7 @@ module.exports = { { type: 'category', label: 'Developer Tools', - items: [ - 'mina-signer', - ], + items: ['mina-signer'], }, { type: 'category', diff --git a/static/llms-full.txt b/static/llms-full.txt index 36c82d8c1..56d166c9f 100644 --- a/static/llms-full.txt +++ b/static/llms-full.txt @@ -14803,7 +14803,7 @@ There are many approaches to building a smart contract. For the zkApp tutorials, ### Where can I find the o1js API reference documentation? -See the autogenerated [o1js reference](/zkapps/o1js-reference) documentation with doc comments, like the [Provable](/zkapps/o1js-reference/type-aliases/Provable) module. +See the autogenerated [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction) documentation with doc comments, like the [Provable](https://docs.o1labs.org/o1js/api-reference/type-aliases/Provable) module. ### What is ZkProgram? @@ -14813,8 +14813,8 @@ A general-purpose API for creating zk proofs. A ZkProgram is similar to a zkApp Use the appropriate module to work with the live network or with historical archive nodes: -- [getActions](/zkapps/o1js-reference/namespaces/Mina/functions/getActions) works with the blockchain network -- [fetchActions](/zkapps/o1js-reference/namespaces/Mina/functions/fetchActions) works with archive nodes +- [getActions](https://docs.o1labs.org/o1js/api-reference/namespaces/Mina/functions/getActions) works with the blockchain network +- [fetchActions](https://docs.o1labs.org/o1js/api-reference/namespaces/Mina/functions/fetchActions) works with archive nodes ### Does o1js compile my JavaScript code to an arithmetic circuit? @@ -14899,7 +14899,7 @@ It allows the method to be invoked by a user interacting with the smart contract ### How can you enforce that an account update must be signed by the account owner? -Use the `requireSignature` command. See the [requireSignature](/zkapps/o1js-reference/classes/SmartContract#requiresignature) Method reference. +Use the `requireSignature` command. See the [requireSignature](https://docs.o1labs.org/o1js/api-reference/classes/SmartContract#requiresignature) Method reference. ### How do I configure who has the authority to interact and make changes to a specific part of an account? @@ -16116,46052 +16116,6 @@ You can follow the instructions about linking your repo to Vercel and deploying Make sure that running `npm run build` locally works before deploying. If it doesn't, fix the error locally, then push your changes to git, and they will be automatically redeployed. ---- -url: /zkapps/o1js-reference/README ---- - -# o1js   [![npm version](https://img.shields.io/npm/v/o1js.svg?style=flat)](https://www.npmjs.com/package/o1js) [![npm](https://img.shields.io/npm/dm/o1js)](https://www.npmjs.com/package/o1js) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md) - -ℹ️ **o1js** is an evolution of [SnarkyJS](https://www.npmjs.com/package/snarkyjs) which saw -49 updated versions over two years of development with 43,141 downloads. - -This name change to o1js reflects the evolution of our vision for the premiere toolkit used by developers to build zero knowledge-enabled applications, while paying homage to our technology's recursive proof generation capabilities. - -Your favorite functionality stays the same and transitioning to o1js is a quick and easy process: - -- To update zkApp-cli, run the following command: - - `npm i -g zkapp-cli@latest` - -- To remove the now-deprecated SnarkyJS package and install o1js, run the following command: - - `npm remove snarkyjs && npm install o1js` - -- For existing zkApps, make sure to update your imports from `snarkyjs` to `o1js` -- No need to redeploy, you are good to go! - -## o1js - -o1js helps developers build apps powered by zero knowledge (zk) cryptography. - -The easiest way to write zk programs is using o1js. - -o1js is a TypeScript library for [zk-SNARKs](https://minaprotocol.com/blog/what-are-zk-snarks) and zkApps. You can use o1js to write zk smart contracts based on zero-knowledge proofs for the Mina Protocol. - -o1js is automatically included when you create a project using the [zkApp CLI](https://www.npmjs.com/package/zkapp-cli). - -## Learn More - -- To learn more about developing zkApps, see the [zkApp Developers](https://docs.minaprotocol.com/zkapps) docs. - -- For guided steps building and using zkApps, see the [zkApp Developers Tutorials](https://docs.minaprotocol.com/zkapps/tutorials/hello-world). - -- To meet other developers building zkApps with o1js, participate in the [#zkapps-developers](https://discord.com/channels/484437221055922177/915745847692636181) channel on Mina Protocol Discord. - -- For a list of changes between versions, see the [CHANGELOG](https://github.com/o1-labs/o1js/blob/main/CHANGELOG.md). - -- To stay up to date with o1js, see the [O(1) Labs Blog](https://www.o1labs.org/blog?topics=o1js). - -## Contributing - -o1js is an open source project. We appreciate all community contributions to o1js! - -See the [Contributing guidelines](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md) for ways you can contribute. - -## Development Workflow - -For guidance on building o1js from source and understanding the development workflow, see [o1js README-dev](https://github.com/o1-labs/o1js/blob/main/README-dev.md). - -## Community Packages - -High-quality community packages from open source developers are available for your project. - -- **o1js-elgamal** A partially homomorphic encryption library for o1js based on Elgamal encryption: [GitHub](https://github.com/Trivo25/o1js-elgamal) and [npm](https://www.npmjs.com/package/o1js-elgamal) -- **o1js-pack** A library for o1js that allows a zkApp developer to pack extra data into a single Field. [GitHub](https://github.com/45930/o1js-pack) and [npm](https://www.npmjs.com/package/o1js-pack) -- **zk-regex-o1js** A CLI tool for compiling ZK Regex circuits in o1js. [Github](https://github.com/Shigoto-dev19/zk-regex-o1js) and [npm](https://www.npmjs.com/package/zk-regex-o1js) - -To include your package, see [Creating high-quality community packages](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md#creating-high-quality-community-packages). - -| Member | Description | -| :------ | :------ | -| [Crypto](namespaces/Crypto/README.mdx) | - | -| [Encryption](namespaces/Encryption/README.mdx) | - | -| [Experimental](namespaces/Experimental/README.mdx) | This module exposes APIs that are unstable, in the sense that the API surface is expected to change. | -| [Lightnet](namespaces/Lightnet/README.mdx) | - | -| [Mina](namespaces/Mina/README.mdx) | - | -| [AccountUpdate](classes/AccountUpdate.mdx) | An [AccountUpdate](classes/AccountUpdate.mdx) is a set of instructions for the Mina network. | -| [AccountUpdateForest](classes/AccountUpdateForest.mdx) | Class which represents a forest (list of trees) of account updates, | -| [AccountUpdateTree](classes/AccountUpdateTree.mdx) | Class which represents a tree of account updates, | -| [AlmostForeignField](classes/AlmostForeignField.mdx) | - | -| [BaseMerkleWitness](classes/BaseMerkleWitness.mdx) | The [BaseMerkleWitness](classes/BaseMerkleWitness.mdx) class defines a circuit-compatible base class for [Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof). | -| [Bool](classes/Bool.mdx) | A boolean value. You can use it like this: | -| [CanonicalForeignField](classes/CanonicalForeignField.mdx) | - | -| [Character](classes/Character.mdx) | - | -| [Circuit](classes/Circuit.mdx) | - | -| [CircuitString](classes/CircuitString.mdx) | - | -| [DynamicProof](classes/DynamicProof.mdx) | The `DynamicProof` class enables circuits to verify proofs using in-ciruit verfication keys. | -| [EcdsaSignature](classes/EcdsaSignature.mdx) | - | -| [Field](classes/Field.mdx) | A [Field](classes/Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). | -| [ForeignCurve](classes/ForeignCurve.mdx) | - | -| [ForeignField](classes/ForeignField.mdx) | - | -| [Group](classes/Group.mdx) | An element of a Group. | -| [Hashed](classes/Hashed.mdx) | `Hashed` represents a type `T` by its hash. | -| [Int64](classes/Int64.mdx) | A 64 bit signed integer with values ranging from -18,446,744,073,709,551,615 to 18,446,744,073,709,551,615. | -| [Keypair](classes/Keypair.mdx) | - | -| [Ledger](classes/Ledger.mdx) | Represents the Mina ledger. | -| [MerkleList](classes/MerkleList.mdx) | Dynamic-length list which is represented as a single hash | -| [MerkleListIterator](classes/MerkleListIterator.mdx) | MerkleListIterator helps iterating through a Merkle list. | -| [MerkleMap](classes/MerkleMap.mdx) | - | -| [MerkleMapWitness](classes/MerkleMapWitness.mdx) | - | -| [MerkleTree](classes/MerkleTree.mdx) | A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in which every leaf is the cryptography hash of a piece of data, | -| [Nullifier](classes/Nullifier.mdx) | Nullifiers are used as a public commitment to a specific anonymous account, | -| [Packed](classes/Packed.mdx) | `Packed` is a "packed" representation of any type `T`. | -| [PrivateKey](classes/PrivateKey.mdx) | A signing key. You can generate one via [PrivateKey.random](classes/PrivateKey.mdx#random). | -| [Proof](classes/Proof.mdx) | - | -| [ProofBase](classes/ProofBase.mdx) | - | -| [PublicKey](classes/PublicKey.mdx) | A public key, which is also an address on the Mina network. | -| [Scalar](classes/Scalar.mdx) | Represents a [Scalar](classes/Scalar.mdx). | -| [ScalarField](classes/ScalarField.mdx) | ForeignField representing the scalar field of Pallas and the base field of Vesta | -| [SelfProof](classes/SelfProof.mdx) | - | -| [Sign](classes/Sign.mdx) | - | -| [Signature](classes/Signature.mdx) | A Schnorr [Signature](classes/Signature.mdx) over the Pasta Curves. | -| [SmartContract](classes/SmartContract.mdx) | The main zkapp class. To write a zkapp, extend this class as such: | -| [TokenAccountUpdateIterator](classes/TokenAccountUpdateIterator.mdx) | Data structure to represent a forest of account updates that is being iterated over, | -| [TokenContract](classes/TokenContract.mdx) | Base token contract which | -| [TokenSymbol](classes/TokenSymbol.mdx) | - | -| [UInt32](classes/UInt32.mdx) | A 32 bit unsigned integer with values ranging from 0 to 4,294,967,295. | -| [UInt64](classes/UInt64.mdx) | A 64 bit unsigned integer with values ranging from 0 to 18,446,744,073,709,551,615. | -| [UInt8](classes/UInt8.mdx) | A 8 bit unsigned integer with values ranging from 0 to 255. | -| [Unconstrained](classes/Unconstrained.mdx) | Container which holds an unconstrained value. This can be used to pass values | -| [VerificationKey](classes/VerificationKey.mdx) | - | -| [Permissions](interfaces/Permissions.mdx) | Permissions specify how specific aspects of the zkapp account are allowed | -| [Account](type-aliases/Account.mdx) | - | -| [Bool](type-aliases/Bool.mdx) | - | -| [BoolVar](type-aliases/BoolVar.mdx) | - | -| [Bytes](type-aliases/Bytes.mdx) | - | -| [Cache](type-aliases/Cache.mdx) | Interface for storing and retrieving values, for caching. | -| [CacheHeader](type-aliases/CacheHeader.mdx) | A header that is passed to the caching layer, to support rich caching strategies. | -| [ConstantField](type-aliases/ConstantField.mdx) | - | -| [DeployArgs](type-aliases/DeployArgs.mdx) | - | -| [Empty](type-aliases/Empty.mdx) | - | -| [FeatureFlags](type-aliases/FeatureFlags.mdx) | - | -| [Field](type-aliases/Field.mdx) | - | -| [FlexibleProvable](type-aliases/FlexibleProvable.mdx) | - | -| [FlexibleProvablePure](type-aliases/FlexibleProvablePure.mdx) | - | -| [Group](type-aliases/Group.mdx) | - | -| [InferProvable](type-aliases/InferProvable.mdx) | - | -| [JsonProof](type-aliases/JsonProof.mdx) | - | -| [MerkleListBase](type-aliases/MerkleListBase.mdx) | Common base type for [MerkleList](classes/MerkleList.mdx) and [MerkleListIterator](classes/MerkleListIterator.mdx) | -| [MerkleListIteratorBase](type-aliases/MerkleListIteratorBase.mdx) | - | -| [Option](type-aliases/Option.mdx) | - | -| [Provable](type-aliases/Provable.mdx) | `Provable` is the general interface for provable types in o1js. | -| [ProvableExtended](type-aliases/ProvableExtended.mdx) | - | -| [ProvableHashable](type-aliases/ProvableHashable.mdx) | - | -| [ProvableHashable](type-aliases/ProvableHashable-1.mdx) | - | -| [ProvablePure](type-aliases/ProvablePure.mdx) | `ProvablePure` is a special kind of [Provable](type-aliases/Provable.mdx) interface, where the "auxiliary" (non-provable) data is empty. | -| [ProvableType](type-aliases/ProvableType.mdx) | - | -| [ProvableTypePure](type-aliases/ProvableTypePure.mdx) | - | -| [ProvableWithEmpty](type-aliases/ProvableWithEmpty.mdx) | - | -| [Reducer](type-aliases/Reducer.mdx) | - | -| [ScalarConst](type-aliases/ScalarConst.mdx) | - | -| [State](type-aliases/State.mdx) | Gettable and settable state that can be checked for equality. | -| [Struct](type-aliases/Struct.mdx) | - | -| [ToProvable](type-aliases/ToProvable.mdx) | - | -| [TransactionPromise](type-aliases/TransactionPromise.mdx) | A `Promise` with some additional methods for making chained method calls | -| [TransactionStatus](type-aliases/TransactionStatus.mdx) | INCLUDED: A transaction that is on the longest chain | -| [TupleN](type-aliases/TupleN.mdx) | tuple type that has the length as generic parameter | -| [Undefined](type-aliases/Undefined.mdx) | - | -| [VarField](type-aliases/VarField.mdx) | - | -| [Void](type-aliases/Void.mdx) | - | -| [WithHash](type-aliases/WithHash.mdx) | - | -| [WithProvable](type-aliases/WithProvable.mdx) | - | -| [Witness](type-aliases/Witness.mdx) | - | -| [ZkProgram](type-aliases/ZkProgram.mdx) | - | -| [ZkappPublicInput](type-aliases/ZkappPublicInput.mdx) | The public input for zkApps consists of certain hashes of the proving | -| [Account](variables/Account.mdx) | - | -| [Bool](variables/Bool.mdx) | A boolean value. You can create it like this: | -| [Cache](variables/Cache.mdx) | - | -| [Crypto](variables/Crypto.mdx) | - | -| [Empty](variables/Empty.mdx) | - | -| [FeatureFlags](variables/FeatureFlags.mdx) | Feature flags indicate what custom gates are used in a proof of circuit. | -| [Field](variables/Field.mdx) | A [Field](variables/Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). | -| [Gadgets](variables/Gadgets.mdx) | - | -| [Group](variables/Group.mdx) | An element of a Group. | -| [Hash](variables/Hash.mdx) | A collection of hash functions which can be used in provable code. | -| [Keccak](variables/Keccak.mdx) | - | -| [Permissions](variables/Permissions.mdx) | - | -| [Poseidon](variables/Poseidon.mdx) | - | -| [ProvableType](variables/ProvableType.mdx) | - | -| [TokenId](variables/TokenId.mdx) | - | -| [TransactionVersion](variables/TransactionVersion.mdx) | - | -| [TupleN](variables/TupleN.mdx) | - | -| [Undefined](variables/Undefined.mdx) | - | -| [Void](variables/Void.mdx) | - | -| [ZkappPublicInput](variables/ZkappPublicInput.mdx) | - | -| [emptyHash](variables/emptyHash.mdx) | - | -| [Bytes](functions/Bytes.mdx) | A provable type representing an array of bytes. | -| [ConstantField](functions/ConstantField.mdx) | - | -| [MerkleListBase](functions/MerkleListBase.mdx) | - | -| [MerkleWitness](functions/MerkleWitness.mdx) | Returns a circuit-compatible Witness for a specific Tree height. | -| [Option](functions/Option.mdx) | Define an optional version of a provable type. | -| [Reducer](functions/Reducer.mdx) | - | -| [State](functions/State.mdx) | - | -| [Struct](functions/Struct.mdx) | `Struct` lets you declare composite types for use in o1js circuits. | -| [VarField](functions/VarField.mdx) | - | -| [WithHash](functions/WithHash.mdx) | - | -| [ZkProgram](functions/ZkProgram.mdx) | - | -| [addCachedAccount](functions/addCachedAccount.mdx) | Adds an account to the local cache, indexed by a GraphQL endpoint. | -| [assert](functions/assert.mdx) | Assert that a statement is true. If the statement is false, throws an error with the given message. | -| [checkBitLength](functions/checkBitLength.mdx) | - | -| [checkZkappTransaction](functions/checkZkappTransaction.mdx) | - | -| [circuitMain](functions/circuitMain.mdx) | - | -| [conditionalSwap](functions/conditionalSwap.mdx) | - | -| [createEcdsa](functions/createEcdsa.mdx) | Create a class [EcdsaSignature](classes/EcdsaSignature.mdx) for verifying ECDSA signatures on the given curve. | -| [createForeignCurve](functions/createForeignCurve.mdx) | Create a class representing an elliptic curve group, which is different from the native [Group](classes/Group.mdx). | -| [createForeignField](functions/createForeignField.mdx) | Create a class representing a prime order finite field, which is different from the native [Field](classes/Field.mdx). | -| [declareMethods](functions/declareMethods.mdx) | `declareMethods` can be used in place of the `@method` decorator | -| [declareState](functions/declareState.mdx) | `declareState` can be used in place of the `@state` decorator to declare on-chain state on a SmartContract. | -| [fetchAccount](functions/fetchAccount.mdx) | Gets account information on the specified publicKey by performing a GraphQL query | -| [fetchEvents](functions/fetchEvents.mdx) | Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API. | -| [fetchLastBlock](functions/fetchLastBlock.mdx) | Fetches the last block on the Mina network. | -| [fetchTransactionStatus](functions/fetchTransactionStatus.mdx) | Fetches the status of a transaction. | -| [genericHash](functions/genericHash.mdx) | - | -| [initializeBindings](functions/initializeBindings.mdx) | A function that has to finish before any bindings exports can be used. | -| [merkleListHash](functions/merkleListHash.mdx) | - | -| [method](functions/method.mdx) | A decorator to use in a zkApp to mark a method as provable. | -| [provable](functions/provable.mdx) | - | -| [provablePure](functions/provablePure.mdx) | - | -| [public\_](functions/public.mdx) | - | -| [readVarMessage](functions/readVarMessage.mdx) | - | -| [sendZkapp](functions/sendZkapp.mdx) | Sends a zkApp command (transaction) to the specified GraphQL endpoint. | -| [setArchiveGraphqlEndpoint](functions/setArchiveGraphqlEndpoint.mdx) | Sets up a GraphQL endpoint to be used for fetching information from an Archive Node. | -| [setGraphqlEndpoint](functions/setGraphqlEndpoint.mdx) | - | -| [setGraphqlEndpoints](functions/setGraphqlEndpoints.mdx) | - | -| [setNumberOfWorkers](functions/setNumberOfWorkers.mdx) | Set the number of workers to use for parallelizing the proof generation. By default the number of workers is set to the number of physical CPU cores on your machine, but there may be some instances where you want to set the number of workers manually. Some machines may have a large number of cores, but not enough memory to support that many workers. In that case, you can set the number of workers to a lower number to avoid running out of memory. On the other hand, some machines with heterogeneous cores may benefit from setting the number of workers to a lower number to avoid contention between core types if load-link/store-conditional multithreading is used. Feel free to experiment and see what works best for your use case. Maybe you can squeeze slightly more performance out by tweaking this value :) | -| [state](functions/state-1.mdx) | A decorator to use within a zkapp to indicate what will be stored on-chain. | -| [toConstantField](functions/toConstantField.mdx) | - | -| [toFp](functions/toFp.mdx) | - | -| [verify](functions/verify.mdx) | - | -| [withHashes](functions/withHashes.mdx) | - | -| [withMessage](functions/withMessage.mdx) | - | - ---- -url: /zkapps/o1js-reference/classes/AccountUpdate ---- - -An [AccountUpdate](AccountUpdate.mdx) is a set of instructions for the Mina network. -It includes Preconditions and a list of state updates, which need to -be authorized by either a [Signature](Signature.mdx) or [Proof](Proof.mdx). - -## Implements - -- `AccountUpdate` - -## Constructors - -### new AccountUpdate() - -```ts -new AccountUpdate(body: Body, authorization?: {}): AccountUpdate -``` - -#### Parameters - -• **body**: `Body` - -• **authorization?** - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L703) - -## Properties - -### account - -```ts -account: Account; -``` - -#### Source - -[lib/mina/account-update.ts:694](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L694) - -*** - -### authorization - -```ts -authorization: {}; -``` - -#### Implementation of - -`Types.AccountUpdate.authorization` - -#### Source - -[lib/mina/account-update.ts:691](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L691) - -*** - -### body - -```ts -body: Body; -``` - -#### Implementation of - -`Types.AccountUpdate.body` - -#### Source - -[lib/mina/account-update.ts:690](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L690) - -*** - -### currentSlot - -```ts -currentSlot: CurrentSlot; -``` - -#### Source - -[lib/mina/account-update.ts:696](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L696) - -*** - -### id - -```ts -id: number; -``` - -#### Source - -[lib/mina/account-update.ts:684](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L684) - -*** - -### label - -```ts -label: string = ''; -``` - -A human-readable label for the account update, indicating how that update -was created. Can be modified by applications to add richer information. - -#### Source - -[lib/mina/account-update.ts:689](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L689) - -*** - -### lazyAuthorization - -```ts -lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined; -``` - -#### Source - -[lib/mina/account-update.ts:692](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L692) - -*** - -### network - -```ts -network: Network; -``` - -#### Source - -[lib/mina/account-update.ts:695](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L695) - -*** - -### Actions - -```ts -static Actions: { - "emptyActionState": Field; - "fromList": Events; - "hash": Field; - "pushEvent": Events; - "updateSequenceState": Field; -}; -``` - -#### emptyActionState() - -##### Returns - -[`Field`](Field.mdx) - -#### fromList() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -`Events` - -#### hash() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -[`Field`](Field.mdx) - -#### pushEvent() - -##### Parameters - -• **actions**: `Events` - -• **action**: [`Field`](Field.mdx)[] - -##### Returns - -`Events` - -#### updateSequenceState() - -##### Parameters - -• **state**: [`Field`](Field.mdx) - -• **sequenceEventsHash**: [`Field`](Field.mdx) - -##### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:700](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L700) - -*** - -### Events - -```ts -static Events: { - "fromList": Events; - "hash": Field; - "pushEvent": Events; -}; -``` - -#### fromList() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -`Events` - -#### hash() - -##### Parameters - -• **events**: `Event`[] - -##### Returns - -[`Field`](Field.mdx) - -#### pushEvent() - -##### Parameters - -• **events**: `Events` - -• **event**: [`Field`](Field.mdx)[] - -##### Returns - -`Events` - -#### Source - -[lib/mina/account-update.ts:701](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L701) - -*** - -### MayUseToken - -```ts -static MayUseToken: { - "InheritFromParent": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "No": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "ParentsOwnToken": { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; - }; - "isInheritFromParent": (a: AccountUpdate) => Bool; - "isNo": (__namedParameters: AccountUpdate) => Bool; - "isParentsOwnToken": (a: AccountUpdate) => Bool; - "type": BaseMayUseToken; -}; -``` - -#### InheritFromParent - -```ts -InheritFromParent: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### InheritFromParent.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### InheritFromParent.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### No - -```ts -No: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### No.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### No.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### ParentsOwnToken - -```ts -ParentsOwnToken: { - "inheritFromParent": Bool; - "parentsOwnToken": Bool; -}; -``` - -#### ParentsOwnToken.inheritFromParent - -```ts -inheritFromParent: Bool; -``` - -#### ParentsOwnToken.parentsOwnToken - -```ts -parentsOwnToken: Bool; -``` - -#### isInheritFromParent() - -```ts -isInheritFromParent: (a: AccountUpdate) => Bool; -``` - -##### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### isNo() - -```ts -isNo: (__namedParameters: AccountUpdate) => Bool; -``` - -##### Parameters - -• **\_\_namedParameters**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### isParentsOwnToken() - -```ts -isParentsOwnToken: (a: AccountUpdate) => Bool; -``` - -##### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### type - -```ts -type: {} = BaseMayUseToken; -``` - -#### Source - -[lib/mina/account-update.ts:1235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1235) - -*** - -### check() - -```ts -static check: (x: AccountUpdate) => void = Types.AccountUpdate.check; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1187) - -*** - -### sizeInFields() - -```ts -static sizeInFields: () => number = Types.AccountUpdate.sizeInFields; -``` - -#### Returns - -`number` - -#### Source - -[lib/mina/account-update.ts:1174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1174) - -*** - -### toFields() - -```ts -static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1175](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1175) - -*** - -### toInput() - -```ts -static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/mina/account-update.ts:1183](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1183) - -*** - -### toValue() - -```ts -static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue; -``` - -#### Parameters - -• **x**: `AccountUpdate` - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:1195](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1195) - -## Accessors - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:785](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L785) - -*** - -### balanceChange - -```ts -get balanceChange(): Int64 -``` - -```ts -set balanceChange(x: Int64): void -``` - -#### Parameters - -• **x**: [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/mina/account-update.ts:800](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L800) - -*** - -### publicKey - -```ts -get publicKey(): PublicKey -``` - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Source - -[lib/mina/account-update.ts:875](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L875) - -*** - -### tokenId - -```ts -get tokenId(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:732](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L732) - -*** - -### update - -```ts -get update(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/mina/account-update.ts:807](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L807) - -## Methods - -### approve() - -```ts -approve(child: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Makes another [AccountUpdate](AccountUpdate.mdx) a child of this one. - -The parent-child relationship means that the child becomes part of the "statement" -of the parent, and goes into the commitment that is authorized by either a signature -or a proof. - -For a proof in particular, child account updates are contained in the public input -of the proof that authorizes the parent account update. - -#### Parameters - -• **child**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:773](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L773) - -*** - -### extractTree() - -```ts -extractTree(): AccountUpdateTree -``` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Source - -[lib/mina/account-update.ts:1021](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1021) - -*** - -### hash() - -```ts -hash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/account-update.ts:977](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L977) - -*** - -### isDummy() - -```ts -isDummy(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/mina/account-update.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1047) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if this account update should be signed by the account -owner, instead of not having any authorization. - -If you use this and are not relying on a wallet to sign your transaction, -then you should use the following code before sending your transaction: - -```ts -let tx = await Mina.transaction(...); // create transaction as usual, using `requireSignature()` somewhere -tx.sign([privateKey]); // pass the private key of this account to `sign()`! -``` - -Note that an account's [Permissions](../variables/Permissions.mdx) determine which updates have to -be (can be) authorized by a signature. - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:894](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L894) - -*** - -### send() - -```ts -send(__namedParameters: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:736](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L736) - -*** - -### toJSON() - -```ts -toJSON(): AccountUpdate -``` - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:966](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L966) - -*** - -### toPretty() - -```ts -toPretty(): any -``` - -Returns a JSON representation of only the fields that differ from the -default [AccountUpdate](AccountUpdate.mdx). - -#### Returns - -`any` - -#### Source - -[lib/mina/account-update.ts:1241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1241) - -*** - -### toPrettyLayout() - -```ts -toPrettyLayout(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1015](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1015) - -*** - -### toPublicInput() - -```ts -toPublicInput(__namedParameters: { - "accountUpdates": AccountUpdate[]; - }): ZkappPublicInput -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.accountUpdates**: [`AccountUpdate`](AccountUpdate.mdx)[] - -#### Returns - -[`ZkappPublicInput`](../type-aliases/ZkappPublicInput.mdx) - -#### Source - -[lib/mina/account-update.ts:985](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L985) - -*** - -### assertBetween() - -```ts -static assertBetween( - property: OrIgnore>, - lower: T, - upper: T): void -``` - -Constrain a property to lie between lower and upper bounds. - -#### Type parameters - -• **T** - -#### Parameters - -• **property**: `OrIgnore`\<`ClosedInterval`\<`T`\>\> - -The property to constrain - -• **lower**: `T` - -The lower bound - -• **upper**: `T` - -The upper bound - -Example: To constrain the account balance of a SmartContract to lie between -0 and 20 MINA, you can use - -```ts -\@method onlyRunsWhenBalanceIsLow() { - let lower = UInt64.zero; - let upper = UInt64.from(20e9); - AccountUpdate.assertBetween(this.self.body.preconditions.account.balance, lower, upper); - // ... -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:835](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L835) - -*** - -### assertEquals() - -```ts -static assertEquals(property: OrIgnore>, value: T): void -``` - -Fix a property to a certain value. - -#### Type parameters - -• **T** *extends* `object` - -#### Parameters - -• **property**: `OrIgnore`\<`T` \| `ClosedInterval`\<`T`\>\> - -The property to constrain - -• **value**: `T` - -The value it is fixed to - -Example: To fix the account nonce of a SmartContract to 0, you can use - -```ts -\@method onlyRunsWhenNonceIsZero() { - AccountUpdate.assertEquals(this.self.body.preconditions.account.nonce, UInt32.zero); - // ... -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:862](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L862) - -*** - -### attachToTransaction() - -```ts -static attachToTransaction(accountUpdate: AccountUpdate): void -``` - -Attach account update to the current transaction --- if in a smart contract, to its children - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1107](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1107) - -*** - -### clone() - -```ts -static clone(accountUpdate: AccountUpdate): AccountUpdate -``` - -Clones the [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:718](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L718) - -*** - -### create() - -```ts -static create(publicKey: PublicKey, tokenId?: Field): AccountUpdate -``` - -Creates an account update. If this is inside a transaction, the account -update becomes part of the transaction. If this is inside a smart contract -method, the account update will not only become part of the transaction, -but also becomes available for the smart contract to modify, in a way that -becomes part of the proof. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1072](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1072) - -*** - -### createIf() - -```ts -static createIf( - condition: Bool, - publicKey: PublicKey, - tokenId?: Field): AccountUpdate -``` - -Create an account update that is added to the transaction only if a condition is met. - -See [AccountUpdate.create](AccountUpdate.mdx#create) for more information. In this method, you can pass in -a condition that determines whether the account update should be added to the transaction. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1094](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1094) - -*** - -### createSigned() - -```ts -static createSigned(publicKey: PublicKey, tokenId?: Field): AccountUpdate -``` - -Creates an account update, like [AccountUpdate.create](AccountUpdate.mdx#create), but also -makes sure this account update will be authorized with a signature. - -If you use this and are not relying on a wallet to sign your transaction, -then you should use the following code before sending your transaction: - -```ts -let tx = await Mina.transaction(...); // create transaction as usual, using `createSigned()` somewhere -tx.sign([privateKey]); // pass the private key of this account to `sign()`! -``` - -Note that an account's [Permissions](../variables/Permissions.mdx) determine which updates have to -be (can be) authorized by a signature. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1143) - -*** - -### default() - -```ts -static default(address: PublicKey, tokenId?: Field): AccountUpdate -``` - -Create an account update from a public key and an optional token id. - -**Important**: This method is different from `AccountUpdate.create()`, in that it really just creates the account update object. -It does not attach the update to the current transaction or smart contract. -Use this method for lower-level operations with account updates. - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1038](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1038) - -*** - -### defaultFeePayer() - -```ts -static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **nonce**: [`UInt32`](UInt32.mdx) - -#### Returns - -`FeePayerUnsigned` - -#### Source - -[lib/mina/account-update.ts:1051](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1051) - -*** - -### dummy() - -```ts -static dummy(): AccountUpdate -``` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1042](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1042) - -*** - -### dummyFeePayer() - -```ts -static dummyFeePayer(): FeePayerUnsigned -``` - -#### Returns - -`FeePayerUnsigned` - -#### Source - -[lib/mina/account-update.ts:1060](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1060) - -*** - -### empty() - -```ts -static empty(): AccountUpdate -``` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1184](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1184) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **\_\_namedParameters**: `any`[] - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1188](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1188) - -*** - -### fromJSON() - -```ts -static fromJSON(json: AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **json**: `AccountUpdate` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:972](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L972) - -*** - -### fromValue() - -```ts -static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **value**: `AccountUpdate` \| `AccountUpdate` \| [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/account-update.ts:1196](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1196) - -*** - -### fundNewAccount() - -```ts -static fundNewAccount(feePayer: PublicKey, numberOfAccounts: number): AccountUpdate -``` - -Use this method to pay the account creation fee for another account (or, multiple accounts using the optional second argument). - -Beware that you _don't_ need to specify the account that is created! -Instead, the protocol will automatically identify that accounts need to be created, -and require that the net balance change of the transaction covers the account creation fee. - -#### Parameters - -• **feePayer**: [`PublicKey`](PublicKey.mdx) - -the address of the account that pays the fee - -• **numberOfAccounts**: `number`= `1` - -the number of new accounts to fund (default: 1) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -they [AccountUpdate](AccountUpdate.mdx) for the account which pays the fee - -#### Source - -[lib/mina/account-update.ts:1164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1164) - -*** - -### getNonce() - -```ts -static getNonce(accountUpdate: FeePayerUnsigned | AccountUpdate): UInt32 -``` - -#### Parameters - -• **accountUpdate**: `FeePayerUnsigned` \| [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/mina/account-update.ts:918](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L918) - -*** - -### setValue() - -```ts -static setValue(maybeValue: SetOrKeep, value: T): void -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **maybeValue**: `SetOrKeep`\<`T`\> - -• **value**: `T` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:811](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L811) - -*** - -### signFeePayerInPlace() - -```ts -static signFeePayerInPlace(feePayer: FeePayerUnsigned): void -``` - -#### Parameters - -• **feePayer**: `FeePayerUnsigned` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L912) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(a?: AccountUpdate): (any[] | { - "id": number; - "label": string; - "lazyAuthorization": undefined | LazySignature | LazyProof | LazyNone; - })[] -``` - -#### Parameters - -• **a?**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -(`any`[] \| \{ - `"id"`: `number`; - `"label"`: `string`; - `"lazyAuthorization"`: `undefined` \| `LazySignature` \| `LazyProof` \| `LazyNone`; - \})[] - -#### Source - -[lib/mina/account-update.ts:1176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1176) - -*** - -### toJSON() - -```ts -static toJSON(a: AccountUpdate): AccountUpdate -``` - -#### Parameters - -• **a**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`AccountUpdate` - -#### Source - -[lib/mina/account-update.ts:969](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L969) - -*** - -### unlink() - -```ts -static unlink(accountUpdate: AccountUpdate): void -``` - -Disattach an account update from where it's currently located in the transaction - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1124) - -*** - -### witness() - -```ts -static witness( - resultType: FlexibleProvable, - compute: () => Promise<{ - "accountUpdate": AccountUpdate; - "result": T; - }>, - __namedParameters: { - "skipCheck": false; - }): Promise<{ - "accountUpdate": AccountUpdate; - "result": T; -}> -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **resultType**: [`FlexibleProvable`](../type-aliases/FlexibleProvable.mdx)\<`T`\> - -• **compute** - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.skipCheck**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"accountUpdate"`: [`AccountUpdate`](AccountUpdate.mdx); - `"result"`: `T`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: AccountUpdate; -> ``` -> -> ##### result -> -> ```ts -> result: T; -> ``` -> - -#### Source - -[lib/mina/account-update.ts:1219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1219) - ---- -url: /zkapps/o1js-reference/classes/AccountUpdateForest ---- - -Class which represents a forest (list of trees) of account updates, -in a compressed way which allows iterating and selectively witnessing the account updates. - -The (recursive) type signature is: -``` -type AccountUpdateForest = MerkleList; -type AccountUpdateTree = { - accountUpdate: Hashed; - children: AccountUpdateForest; -}; -``` - -## Extends - -- [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}, `this`\> - -## Constructors - -### new AccountUpdateForest() - -```ts -new AccountUpdateForest(__namedParameters: MerkleListBase<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }>): AccountUpdateForest -``` - -#### Parameters - -• **\_\_namedParameters**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`constructor`](MerkleList.mdx#constructors) - -#### Source - -[lib/provable/merkle-list.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L84) - -## Properties - -### data - -```ts -data: Unconstrained; - "id": RandomId; -}>[]>; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`data`](MerkleList.mdx#data) - -#### Source - -[lib/provable/merkle-list.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L82) - -*** - -### hash - -```ts -hash: Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`hash`](MerkleList.mdx#hash) - -#### Source - -[lib/provable/merkle-list.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L81) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_emptyHash`](MerkleList.mdx#_emptyhash) - -#### Source - -[lib/provable/merkle-list.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L350) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_innerProvable`](MerkleList.mdx#_innerprovable) - -#### Source - -[lib/provable/merkle-list.ts:353](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L353) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, t: any) => Field; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_nextHash`](MerkleList.mdx#_nexthash) - -#### Source - -[lib/provable/merkle-list.ts:349](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L349) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`_provable`](MerkleList.mdx#_provable) - -#### Source - -[lib/provable/merkle-list.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L352) - -*** - -### provable - -```ts -static provable: { - "check": void; - "empty": AccountUpdateForest; - "fromFields": AccountUpdateForest; - "fromValue": AccountUpdateForest; - "sizeInFields": number; - "toAuxiliary": any[]; - "toFields": Field[]; - "toInput": HashInput; - "toValue": any; -}; -``` - -#### check() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`void` - -#### empty() - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### fromFields() - -##### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **aux**: `any`[] - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### fromValue() - -##### Parameters - -• **value**: `any` - -##### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### sizeInFields() - -##### Returns - -`number` - -#### toAuxiliary() - -##### Parameters - -• **value?**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`any`[] - -#### toFields() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -[`Field`](Field.mdx)[] - -#### toInput() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`HashInput` - -#### toValue() - -##### Parameters - -• **value**: [`AccountUpdateForest`](AccountUpdateForest.mdx) \| [`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -##### Returns - -`any` - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).provable` - -#### Source - -[lib/mina/account-update.ts:1379](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1379) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleList -``` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) - -#### Source - -[lib/provable/merkle-list.ts:355](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L355) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:372](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L372) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L367) - -## Methods - -### clone() - -```ts -clone(): MerkleList<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`clone`](MerkleList.mdx#clone) - -#### Source - -[lib/provable/merkle-list.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L223) - -*** - -### forEach() - -```ts -forEach(length: number, callback: (element: { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }, isDummy: Bool, i: number) => void): void -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -#### Parameters - -• **length**: `number` - -• **callback** - -#### Returns - -`void` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`forEach`](MerkleList.mdx#foreach) - -#### Source - -[lib/provable/merkle-list.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L237) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`isEmpty`](MerkleList.mdx#isempty) - -#### Source - -[lib/provable/merkle-list.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L89) - -*** - -### lengthUnconstrained() - -```ts -lengthUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`number`\> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`lengthUnconstrained`](MerkleList.mdx#lengthunconstrained) - -#### Source - -[lib/provable/merkle-list.ts:267](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L267) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; - }): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value** - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>= `undefined` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`Field`](Field.mdx) - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`nextHash`](MerkleList.mdx#nexthash) - -#### Source - -[lib/provable/merkle-list.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L359) - -*** - -### pop() - -```ts -pop(): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`pop`](MerkleList.mdx#pop) - -#### Source - -[lib/provable/merkle-list.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L155) - -*** - -### popExn() - -```ts -popExn(): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popExn`](MerkleList.mdx#popexn) - -#### Source - -[lib/provable/merkle-list.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L140) - -*** - -### popIf() - -```ts -popIf(condition: Bool): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popIf`](MerkleList.mdx#popif) - -#### Source - -[lib/provable/merkle-list.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L174) - -*** - -### popIfUnsafe() - -```ts -popIfUnsafe(shouldPop: Bool): { - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -#### Parameters - -• **shouldPop**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: MerkleListBase; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`popIfUnsafe`](MerkleList.mdx#popifunsafe) - -#### Source - -[lib/provable/merkle-list.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L200) - -*** - -### push() - -```ts -push(update: AccountUpdate | AccountUpdateTreeBase): void -``` - -Push a new element to the list. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| `AccountUpdateTreeBase` - -#### Returns - -`void` - -#### Overrides - -[`MerkleList`](MerkleList.mdx).[`push`](MerkleList.mdx#push) - -#### Source - -[lib/mina/account-update.ts:1381](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1381) - -*** - -### pushIf() - -```ts -pushIf(condition: Bool, update: AccountUpdate | AccountUpdateTreeBase): void -``` - -Push a new element to the list, if the `condition` is true. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| `AccountUpdateTreeBase` - -#### Returns - -`void` - -#### Overrides - -[`MerkleList`](MerkleList.mdx).[`pushIf`](MerkleList.mdx#pushif) - -#### Source - -[lib/mina/account-update.ts:1386](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1386) - -*** - -### startIterating() - -```ts -startIterating(): MerkleListIterator<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`startIterating`](MerkleList.mdx#startiterating) - -#### Source - -[lib/provable/merkle-list.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L251) - -*** - -### startIteratingFromLast() - -```ts -startIteratingFromLast(): MerkleListIterator<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}> -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}\> - -> ##### accountUpdate -> -> ```ts -> accountUpdate: Hashed = HashedAccountUpdate; -> ``` -> -> ##### children -> -> ```ts -> children: MerkleListBase; -> ``` -> -> ##### id -> -> ```ts -> id: number = RandomId; -> ``` -> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`startIteratingFromLast`](MerkleList.mdx#startiteratingfromlast) - -#### Source - -[lib/provable/merkle-list.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L256) - -*** - -### toArrayUnconstrained() - -```ts -toArrayUnconstrained(): Unconstrained<{ - "accountUpdate": HashedAccountUpdate; - "children": MerkleListBase; - "id": RandomId; -}[]> -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<\{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`AccountUpdateTreeBase`\>; - `"id"`: `RandomId`; - \}[]\> - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`toArrayUnconstrained`](MerkleList.mdx#toarrayunconstrained) - -#### Source - -[lib/provable/merkle-list.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L261) - -*** - -### toFlatArray() - -```ts -toFlatArray(mutate: boolean, depth: number): AccountUpdate[] -``` - -#### Parameters - -• **mutate**: `boolean`= `true` - -• **depth**: `number`= `0` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1398](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1398) - -*** - -### assertConstant() - -```ts -static assertConstant(forest: AccountUpdateForestBase): void -``` - -#### Parameters - -• **forest**: `AccountUpdateForestBase` - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1429](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1429) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleList & { - "empty": () => MerkleList; - "from": (array: T[]) => MerkleList; - "fromReverse": (array: T[]) => MerkleList; - "provable": ProvableHashable>; -} -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) & \{ - `"empty"`: () => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"fromReverse"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleList`](MerkleList.mdx)\<`T`\>\>; - \} - -#### Inherited from - -[`MerkleList`](MerkleList.mdx).[`create`](MerkleList.mdx#create) - -#### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -#### Source - -[lib/provable/merkle-list.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L283) - -*** - -### empty() - -```ts -static empty(): AccountUpdateForest -``` - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).empty` - -#### Source - -[lib/mina/account-update.ts:1442](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1442) - -*** - -### from() - -```ts -static from(array: AccountUpdateTreeBase[]): AccountUpdateForest -``` - -#### Parameters - -• **array**: `AccountUpdateTreeBase`[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).from` - -#### Source - -[lib/mina/account-update.ts:1445](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1445) - -*** - -### fromFlatArray() - -```ts -static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest -``` - -#### Parameters - -• **updates**: [`AccountUpdate`](AccountUpdate.mdx)[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Source - -[lib/mina/account-update.ts:1393](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1393) - -*** - -### fromReverse() - -```ts -static fromReverse(array: AccountUpdateTreeBase[]): AccountUpdateForest -``` - -#### Parameters - -• **array**: `AccountUpdateTreeBase`[] - -#### Returns - -[`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Overrides - -`MerkleList.create( - AccountUpdateTreeBase, - merkleListHash -).fromReverse` - -#### Source - -[lib/mina/account-update.ts:1448](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1448) - -*** - -### toFlatArray() - -```ts -static toFlatArray( - forest: AccountUpdateForestBase, - mutate: boolean, - depth: number): AccountUpdate[] -``` - -#### Parameters - -• **forest**: `AccountUpdateForestBase` - -• **mutate**: `boolean`= `true` - -• **depth**: `number`= `0` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx)[] - -#### Source - -[lib/mina/account-update.ts:1402](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1402) - ---- -url: /zkapps/o1js-reference/classes/AccountUpdateTree ---- - -Class which represents a tree of account updates, -in a compressed way which allows iterating and selectively witnessing the account updates. - -The (recursive) type signature is: -``` -type AccountUpdateTree = { - accountUpdate: Hashed; - children: AccountUpdateForest; -}; -type AccountUpdateForest = MerkleList; -``` - -## Extends - -- \{ - `"accountUpdate"`: `HashedAccountUpdate`; - `"children"`: `AccountUpdateForest`; - `"id"`: `RandomId`; - \} - -## Constructors - -### new AccountUpdateTree() - -```ts -new AccountUpdateTree(value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }): AccountUpdateTree -``` - -#### Parameters - -• **value** - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L280) - -## Properties - -### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).accountUpdate` - -#### Source - -[lib/mina/account-update.ts:1468](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1468) - -*** - -### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).children` - -#### Source - -[lib/mina/account-update.ts:1469](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1469) - -*** - -### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).id` - -#### Source - -[lib/mina/account-update.ts:1467](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1467) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L280) - -*** - -### check() - -```ts -static check: (value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -`void` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### fromValue() - -```ts -static fromValue: (x: any) => { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -}; -``` - -Convert provable type from a normal JS type. - -#### Parameters - -• **x**: `any` - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.accountUpdate?**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children?**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id?**: `number`= `RandomId` - -#### Returns - -`any`[] - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -```ts -{ - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; -} -``` - -##### accountUpdate - -```ts -accountUpdate: Hashed = HashedAccountUpdate; -``` - -##### children - -```ts -children: AccountUpdateForest = AccountUpdateForest; -``` - -##### id - -```ts -id: number = RandomId; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **value.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **value.id**: `number`= `RandomId` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L283) - -*** - -### toValue() - -```ts -static toValue: (x: { - "accountUpdate": HashedAccountUpdate; - "children": AccountUpdateForest; - "id": RandomId; - }) => any; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.accountUpdate**: [`Hashed`](Hashed.mdx)\<[`AccountUpdate`](AccountUpdate.mdx)\>= `HashedAccountUpdate` - -• **x.children**: [`AccountUpdateForest`](AccountUpdateForest.mdx)= `AccountUpdateForest` - -• **x.id**: `number`= `RandomId` - -#### Returns - -`any` - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree, hash?: Field): void -``` - -Add an [AccountUpdate](AccountUpdate.mdx) or [AccountUpdateTree](AccountUpdateTree.mdx) to the children of this tree's root. - -See [AccountUpdate.approve](AccountUpdate.mdx#approve). - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/account-update.ts:1488](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1488) - -*** - -### empty() - -```ts -static empty(): AccountUpdateTree -``` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Overrides - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).empty` - -#### Source - -[lib/mina/account-update.ts:1504](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1504) - -*** - -### from() - -```ts -static from(update: AccountUpdate | AccountUpdateTree, hash?: Field): AccountUpdateTree -``` - -Create a tree of account updates which only consists of a root. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Source - -[lib/mina/account-update.ts:1474](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1474) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[], aux: any): AccountUpdateTree -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -• **aux**: `any` - -#### Returns - -[`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Overrides - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).fromFields` - -#### Source - -[lib/mina/account-update.ts:1501](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L1501) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`StructNoJson({ - id: RandomId, - accountUpdate: HashedAccountUpdate, - children: AccountUpdateForest, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/classes/AlmostForeignField ---- - -## Extends - -- `ForeignFieldWithMul` - -## Constructors - -### new AlmostForeignField() - -```ts -new AlmostForeignField(x: - | string - | number - | bigint - | Field3 - | AlmostForeignField): AlmostForeignField -``` - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Overrides - -`ForeignFieldWithMul.constructor` - -#### Source - -[lib/provable/foreign-field.ts:487](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L487) - -## Properties - -### type - -```ts -type: "AlmostReduced" | "FullyReduced" = 'AlmostReduced'; -``` - -#### Source - -[lib/provable/foreign-field.ts:485](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L485) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`ForeignFieldWithMul.value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Overrides - -`ForeignFieldWithMul._provable` - -#### Source - -[lib/provable/foreign-field.ts:491](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L491) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`ForeignFieldWithMul._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<[`AlmostForeignField`](AlmostForeignField.mdx), `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:494](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L494) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`ForeignFieldWithMul.assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### div() - -```ts -div(y: number | bigint | AlmostForeignField): AlmostForeignField -``` - -Division in the finite field, i.e. `x*y^(-1) mod p` where `y^(-1)` is the finite field inverse. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.div` - -#### Example - -```ts -let z = x.div(y); // x/y mod p -z.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/foreign-field.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L461) - -*** - -### equals() - -```ts -equals(y: number | bigint): Bool -``` - -Check equality with a constant value. - -#### Parameters - -• **y**: `number` \| `bigint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isXZero = x.equals(0); -``` - -#### Source - -[lib/provable/foreign-field.ts:521](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L521) - -*** - -### inv() - -```ts -inv(): AlmostForeignField -``` - -Multiplicative inverse in the finite field - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.inv` - -#### Example - -```ts -let z = x.inv(); // 1/x mod p -z.mul(x).assertEquals(1); -``` - -#### Source - -[lib/provable/foreign-field.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L447) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`ForeignFieldWithMul.isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### mul() - -```ts -mul(y: number | bigint | AlmostForeignField): UnreducedForeignField -``` - -Finite field multiplication - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.mul` - -#### Example - -```ts -x.mul(y); // x*y mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:433](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L433) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`ForeignFieldWithMul.toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Overrides - -`ForeignFieldWithMul.check` - -#### Source - -[lib/provable/foreign-field.ts:499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L499) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### unsafeFrom() - -```ts -static unsafeFrom(x: ForeignField): AlmostForeignField -``` - -Coerce the input to an [AlmostForeignField](AlmostForeignField.mdx) without additional assertions. - -**Warning:** Only use if you know what you're doing. - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:509](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L509) - ---- -url: /zkapps/o1js-reference/classes/BaseMerkleWitness ---- - -The [BaseMerkleWitness](BaseMerkleWitness.mdx) class defines a circuit-compatible base class for [Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof). - -## Extends - -- `CircuitValue` - -## Constructors - -### new BaseMerkleWitness() - -```ts -new BaseMerkleWitness(witness: Witness): BaseMerkleWitness -``` - -Takes a [Witness](../type-aliases/Witness.mdx) and turns it into a circuit-compatible Witness. - -#### Parameters - -• **witness**: [`Witness`](../type-aliases/Witness.mdx) - -Witness. - -#### Returns - -[`BaseMerkleWitness`](BaseMerkleWitness.mdx) - -A circuit-compatible Witness. - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/merkle-tree.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L187) - -## Properties - -### isLeft - -```ts -isLeft: Bool[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L177) - -*** - -### path - -```ts -path: Field[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L176) - -*** - -### height - -```ts -static height: number; -``` - -#### Source - -[lib/provable/merkle-tree.ts:175](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L175) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### calculateIndex() - -```ts -calculateIndex(): Field -``` - -Calculates the index of the leaf node that belongs to this Witness. - -#### Returns - -[`Field`](Field.mdx) - -Index of the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:221](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L221) - -*** - -### calculateRoot() - -```ts -calculateRoot(leaf: Field): Field -``` - -Calculates a root depending on the leaf value. - -#### Parameters - -• **leaf**: [`Field`](Field.mdx) - -Value of the leaf node that belongs to this Witness. - -#### Returns - -[`Field`](Field.mdx) - -The calculated root. - -#### Source - -[lib/provable/merkle-tree.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L204) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### height() - -```ts -height(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/merkle-tree.ts:178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L178) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) - ---- -url: /zkapps/o1js-reference/classes/Bool ---- - -A boolean value. You can use it like this: - -``` -const x = new Bool(true); -``` - -You can also combine multiple booleans via [[`not`]], [[`and`]], [[`or`]]. - -Use [[assertEquals]] to enforce the value of a Bool. - -## Constructors - -### new Bool() - -```ts -new Bool(x: boolean | FieldVar | Bool): Bool -``` - -#### Parameters - -• **x**: `boolean` \| `FieldVar` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L33) - -## Properties - -### value - -```ts -value: FieldVar; -``` - -#### Source - -[lib/provable/bool.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L31) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": Bool; -}; -``` - -#### fromField() - -Converts a [Field](Field.mdx) into a [Bool](Bool.mdx). This is an **unsafe** operation -as it assumes that the field element is either 0 or 1 (which might not be true). - -Only use this if you have already constrained the Field element to be 0 or 1. - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -a [Field](Field.mdx) - -##### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:373](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L373) - -*** - -### sizeInBytes - -```ts -static sizeInBytes: number = 1; -``` - -#### Source - -[lib/provable/bool.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L367) - -## Methods - -### and() - -```ts -and(y: boolean | Bool): Bool -``` - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) to AND with this [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is set to true only if -this [Bool](Bool.mdx) and `y` are also true. - -#### Source - -[lib/provable/bool.ts:73](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L73) - -*** - -### assertEquals() - -```ts -assertEquals(y: boolean | Bool, message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is equal to `y`. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L114) - -*** - -### assertFalse() - -```ts -assertFalse(message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is `false`. - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:145](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L145) - -*** - -### assertTrue() - -```ts -assertTrue(message?: string): void -``` - -Proves that this [Bool](Bool.mdx) is `true`. - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:131](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L131) - -*** - -### equals() - -```ts -equals(y: boolean | Bool): Bool -``` - -Returns true if this [Bool](Bool.mdx) is equal to `y`. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:160](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L160) - -*** - -### implies() - -```ts -implies(y: boolean | Bool): Bool -``` - -Whether this Bool implies another Bool `y`. - -This is the same as `x.not().or(y)`: if `x` is true, then `y` must be true for the implication to be true. - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isZero = x.equals(0); -let lessThan10 = x.lessThan(10); -assert(isZero.implies(lessThan10), 'x = 0 implies x < 10'); -``` - -#### Source - -[lib/provable/bool.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L106) - -*** - -### isConstant() - -```ts -isConstant(): this is Object -``` - -#### Returns - -`this is Object` - -#### Source - -[lib/provable/bool.ts:45](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L45) - -*** - -### not() - -```ts -not(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is the negation of this [Bool](Bool.mdx). - -#### Source - -[lib/provable/bool.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L59) - -*** - -### or() - -```ts -or(y: boolean | Bool): Bool -``` - -#### Parameters - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -a [Bool](Bool.mdx) to OR with this [Bool](Bool.mdx). - -#### Returns - -[`Bool`](Bool.mdx) - -a new [Bool](Bool.mdx) that is set to true if either -this [Bool](Bool.mdx) or `y` is true. - -#### Source - -[lib/provable/bool.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L86) - -*** - -### sizeInFields() - -```ts -sizeInFields(): number -``` - -Returns the size of this type. - -#### Returns - -`number` - -#### Source - -[lib/provable/bool.ts:185](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L185) - -*** - -### toBoolean() - -```ts -toBoolean(): boolean -``` - -This converts the [Bool](Bool.mdx) to a JS `boolean`. -This can only be called on non-witness values. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L216) - -*** - -### toField() - -```ts -toField(): Field -``` - -Converts a [Bool](Bool.mdx) to a [Field](Field.mdx). `false` becomes 0 and `true` becomes 1. - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/bool.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L52) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Serializes this [Bool](Bool.mdx) into [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/bool.ts:192](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L192) - -*** - -### toJSON() - -```ts -toJSON(): boolean -``` - -Serialize the [Bool](Bool.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L208) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [Bool](Bool.mdx) to a string, e.g. for printing. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Returns - -`string` - -#### Source - -[lib/provable/bool.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L200) - -*** - -### and() - -```ts -static and(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Boolean AND operation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L244) - -*** - -### assertEqual() - -```ts -static assertEqual(x: Bool, y: boolean | Bool): void -``` - -Asserts if both [Bool](Bool.mdx) are equal. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:264](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L264) - -*** - -### check() - -```ts -static check(x: Bool): void -``` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/bool.ts:369](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L369) - -*** - -### empty() - -```ts -static empty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:344](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L344) - -*** - -### equal() - -```ts -static equal(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Checks two [Bool](Bool.mdx) for equality. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:275](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L275) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: number[]): Bool -``` - -#### Parameters - -• **bytes**: `number`[] - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L356) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Bool -``` - -Creates a data structure from an array of serialized [Field](Field.mdx) elements. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:299](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L299) - -*** - -### fromJSON() - -```ts -static fromJSON(b: boolean): Bool -``` - -Deserialize a JSON structure into a [Bool](Bool.mdx). -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Parameters - -• **b**: `boolean` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:333](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L333) - -*** - -### fromValue() - -```ts -static fromValue(b: boolean | Bool): Bool -``` - -`Provable.fromValue()` - -#### Parameters - -• **b**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:316](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L316) - -*** - -### not() - -```ts -static not(x: boolean | Bool): Bool -``` - -Boolean negation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:234](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L234) - -*** - -### or() - -```ts -static or(x: boolean | Bool, y: boolean | Bool): Bool -``` - -Boolean OR operation. - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -• **y**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/bool.ts:254](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L254) - -*** - -### readBytes() - -```ts -static readBytes(bytes: number[], offset: NonNegativeInteger): [Bool, number] -``` - -#### Type parameters - -• **N** *extends* `number` - -#### Parameters - -• **bytes**: `number`[] - -• **offset**: `NonNegativeInteger`\<`N`\> - -#### Returns - -[[`Bool`](Bool.mdx), `number`] - -#### Source - -[lib/provable/bool.ts:360](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L360) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Returns the size of this type. - -#### Returns - -`number` - -#### Source - -[lib/provable/bool.ts:340](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L340) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(_?: Bool): [] -``` - -Static method to serialize a [Bool](Bool.mdx) into its auxiliary data. - -#### Parameters - -• **\_?**: [`Bool`](Bool.mdx) - -#### Returns - -[] - -#### Source - -[lib/provable/bool.ts:292](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L292) - -*** - -### toBytes() - -```ts -static toBytes(b: Bool): number[] -``` - -#### Parameters - -• **b**: [`Bool`](Bool.mdx) - -#### Returns - -`number`[] - -#### Source - -[lib/provable/bool.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L352) - -*** - -### toField() - -```ts -static toField(x: boolean | Bool): Field -``` - -#### Parameters - -• **x**: `boolean` \| [`Bool`](Bool.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/bool.ts:227](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L227) - -*** - -### toFields() - -```ts -static toFields(x: Bool): Field[] -``` - -Static method to serialize a [Bool](Bool.mdx) into an array of [Field](Field.mdx) elements. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/bool.ts:285](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L285) - -*** - -### toInput() - -```ts -static toInput(x: Bool): { - "packed": [Field, number][]; -} -``` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -```ts -{ - "packed": [Field, number][]; -} -``` - -##### packed - -```ts -packed: [Field, number][]; -``` - -#### Source - -[lib/provable/bool.ts:348](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L348) - -*** - -### toJSON() - -```ts -static toJSON(x: Bool): boolean -``` - -Serialize a [Bool](Bool.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Field. - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L325) - -*** - -### toValue() - -```ts -static toValue(x: Bool): boolean -``` - -`Provable.toValue()` - -#### Parameters - -• **x**: [`Bool`](Bool.mdx) - -#### Returns - -`boolean` - -#### Source - -[lib/provable/bool.ts:309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L309) - ---- -url: /zkapps/o1js-reference/classes/CanonicalForeignField ---- - -## Extends - -- `ForeignFieldWithMul` - -## Constructors - -### new CanonicalForeignField() - -```ts -new CanonicalForeignField(x: - | string - | number - | bigint - | Field3 - | CanonicalForeignField): CanonicalForeignField -``` - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Overrides - -`ForeignFieldWithMul.constructor` - -#### Source - -[lib/provable/foreign-field.ts:529](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L529) - -## Properties - -### type - -```ts -type: "FullyReduced"; -``` - -#### Source - -[lib/provable/foreign-field.ts:527](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L527) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`ForeignFieldWithMul.value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`ForeignFieldWithMul._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Overrides - -`ForeignFieldWithMul._provable` - -#### Source - -[lib/provable/foreign-field.ts:533](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L533) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`ForeignFieldWithMul._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<[`CanonicalForeignField`](CanonicalForeignField.mdx), `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:536](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L536) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`ForeignFieldWithMul.assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### div() - -```ts -div(y: number | bigint | AlmostForeignField): AlmostForeignField -``` - -Division in the finite field, i.e. `x*y^(-1) mod p` where `y^(-1)` is the finite field inverse. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.div` - -#### Example - -```ts -let z = x.div(y); // x/y mod p -z.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/foreign-field.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L461) - -*** - -### equals() - -```ts -equals(y: number | bigint | CanonicalForeignField): Bool -``` - -Check equality with a ForeignField-like value. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let isEqual = x.equals(y); -``` - -Note: This method only exists on canonical fields; on unreduced fields, it would be easy to -misuse, because not being exactly equal does not imply being unequal modulo p. - -#### Source - -[lib/provable/foreign-field.ts:566](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L566) - -*** - -### inv() - -```ts -inv(): AlmostForeignField -``` - -Multiplicative inverse in the finite field - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.inv` - -#### Example - -```ts -let z = x.inv(); // 1/x mod p -z.mul(x).assertEquals(1); -``` - -#### Source - -[lib/provable/foreign-field.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L447) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`ForeignFieldWithMul.isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### mul() - -```ts -mul(y: number | bigint | AlmostForeignField): UnreducedForeignField -``` - -Finite field multiplication - -#### Parameters - -• **y**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.mul` - -#### Example - -```ts -x.mul(y); // x*y mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:433](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L433) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`ForeignFieldWithMul.toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`ForeignFieldWithMul.toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`ForeignFieldWithMul.assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Overrides - -`ForeignFieldWithMul.check` - -#### Source - -[lib/provable/foreign-field.ts:541](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L541) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`ForeignFieldWithMul.from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`ForeignFieldWithMul.random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`ForeignFieldWithMul.sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### unsafeFrom() - -```ts -static unsafeFrom(x: ForeignField): CanonicalForeignField -``` - -Coerce the input to a [CanonicalForeignField](CanonicalForeignField.mdx) without additional assertions. - -**Warning:** Only use if you know what you're doing. - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:551](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L551) - ---- -url: /zkapps/o1js-reference/classes/Character ---- - -## Extends - -- \{ - `"value"`: `Field`; - \} - -## Constructors - -### new Character() - -```ts -new Character(value: number | Field): Character -``` - -#### Parameters - -• **value**: `number` \| [`Field`](Field.mdx) - -#### Returns - -[`Character`](Character.mdx) - -#### Overrides - -`Struct({ value: Field }).constructor` - -#### Source - -[lib/provable/string.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L13) - -## Properties - -### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).value` - -#### Source - -[lib/provable/string.ts:12](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L12) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ value: Field })._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### empty() - -```ts -static empty: () => { - "value": Field; -}; -``` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "value": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: `string`= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "value": Field; - } | { - "value": Field; - }) => { - "value": Field; - } & (value: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ value: Field }).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "value": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.value?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ value: Field }).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "value": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ value: Field }).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: string = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: bigint = Field; -``` - -#### Inherited from - -`Struct({ value: Field }).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### isNull() - -```ts -isNull(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/string.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L17) - -*** - -### toField() - -```ts -toField(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L21) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/string.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L25) - -*** - -### check() - -```ts -static check(c: { - "value": Field; - }): void -``` - -#### Parameters - -• **c** - -• **c.value**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Overrides - -`Struct({ value: Field }).check` - -#### Source - -[lib/provable/string.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L36) - -*** - -### fromString() - -```ts -static fromString(str: string): Character -``` - -#### Parameters - -• **str**: `string` - -#### Returns - -[`Character`](Character.mdx) - -#### Source - -[lib/provable/string.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L30) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ value: Field }).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - -*** - -### toInput() - -```ts -static toInput(c: { - "value": Field; - }): HashInput -``` - -#### Parameters - -• **c** - -• **c.value**: [`Field`](Field.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`Struct({ value: Field }).toInput` - -#### Source - -[lib/provable/string.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L40) - ---- -url: /zkapps/o1js-reference/classes/Circuit ---- - -## Constructors - -### new Circuit() - -```ts -new Circuit(): Circuit -``` - -#### Returns - -[`Circuit`](Circuit.mdx) - -## Properties - -### \_main - -```ts -static _main: CircuitData; -``` - -#### Source - -[lib/proof-system/circuit.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L22) - -## Methods - -### generateKeypair() - -```ts -static generateKeypair(): Promise -``` - -Generates a proving key and a verification key for this circuit. - -#### Returns - -`Promise`\<[`Keypair`](Keypair.mdx)\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -``` - -#### Source - -[lib/proof-system/circuit.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L31) - -*** - -### prove() - -```ts -static prove( - privateInput: any[], - publicInput: any[], -keypair: Keypair): Promise -``` - -Proves a statement using the private input, public input, and the [Keypair](Keypair.mdx) of the circuit. - -#### Parameters - -• **privateInput**: `any`[] - -• **publicInput**: `any`[] - -• **keypair**: [`Keypair`](Keypair.mdx) - -#### Returns - -`Promise`\<`Proof`\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const proof = await MyCircuit.prove(privateInput, publicInput, keypair); -``` - -#### Source - -[lib/proof-system/circuit.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L51) - -*** - -### verify() - -```ts -static verify( - publicInput: any[], - verificationKey: VerificationKey, -proof: Proof): Promise -``` - -Verifies a proof using the public input, the proof, and the initial [Keypair](Keypair.mdx) of the circuit. - -#### Parameters - -• **publicInput**: `any`[] - -• **verificationKey**: `VerificationKey` - -• **proof**: `Proof` - -#### Returns - -`Promise`\<`boolean`\> - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const proof = await MyCircuit.prove(privateInput, publicInput, keypair); -const isValid = await MyCircuit.verify(publicInput, keypair.vk, proof); -``` - -#### Source - -[lib/proof-system/circuit.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L82) - ---- -url: /zkapps/o1js-reference/classes/CircuitString ---- - -## Extends - -- \{ - `"values"`: [`Character`](Character.mdx)[]; - \} - -## Constructors - -### new CircuitString() - -```ts -new CircuitString(value: { - "values": Character[]; - }): CircuitString -``` - -#### Parameters - -• **value** - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Inherited from - -`Struct(RawCircuitString).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).values` - -#### Source - -[lib/provable/string.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L65) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct(RawCircuitString)._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "values": Character[]; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -`void` - -#### Inherited from - -`Struct(RawCircuitString).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "values": Character[]; -}; -``` - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "values": Character[]; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "values": { - "value": Field; - }[]; - }) => { - "values": Character[]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: \{ - `"value"`: `Field`; - \}[]= `undefined` - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: string | { - "values": Character[]; - }) => { - "values": Character[]; - } & (value: string | { - "values": Character[]; - }) => { - "values": Character[]; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct(RawCircuitString).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### maxLength - -```ts -static maxLength: number = DEFAULT_STRING_LENGTH; -``` - -#### Source - -[lib/provable/string.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L72) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "values": Character[]; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.values?**: [`Character`](Character.mdx)[] - -#### Returns - -`any`[] - -#### Inherited from - -`Struct(RawCircuitString).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "values": Character[]; - }) => { - "values": Character[]; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "values": Character[]; -} -``` - -##### values - -```ts -values: Character[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "values": Character[]; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.values**: [`Character`](Character.mdx)[] - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct(RawCircuitString).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "values": Character[]; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "values": Character[]; - }) => { - "values": { - "value": Field; - }[]; -}; -``` - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -```ts -{ - "values": { - "value": Field; - }[]; -} -``` - -##### values - -```ts -values: { - "value": Field; - }[]; -``` - -#### Inherited from - -`Struct(RawCircuitString).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "values": Character[]; - }) => string; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.values**: [`Character`](Character.mdx)[] - -#### Returns - -`string` - -#### Inherited from - -`Struct(RawCircuitString).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### append() - -```ts -append(str: CircuitString): CircuitString -``` - -appends another string to this one, returns the result and proves that it fits -within the `maxLength` of this string (the other string can have a different maxLength) - -#### Parameters - -• **str**: [`CircuitString`](CircuitString.mdx) - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L121) - -*** - -### computeLengthAndMask() - -```ts -computeLengthAndMask(): { - "length": Field; - "mask": Bool[]; -} -``` - -#### Returns - -```ts -{ - "length": Field; - "mask": Bool[]; -} -``` - -##### length - -```ts -length: Field; -``` - -##### mask - -```ts -mask: Bool[]; -``` - -#### Source - -[lib/provable/string.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L84) - -*** - -### equals() - -```ts -equals(other: CircuitString): Bool -``` - -returns true if `this` has the same value as `other` - -#### Parameters - -• **other**: [`CircuitString`](CircuitString.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/string.ts:113](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L113) - -*** - -### hash() - -```ts -hash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:147](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L147) - -*** - -### length() - -```ts -length(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/string.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L106) - -*** - -### lengthMask() - -```ts -lengthMask(): Bool[] -``` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Source - -[lib/provable/string.ts:103](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L103) - -*** - -### maxLength() - -```ts -maxLength(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/string.ts:79](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L79) - -*** - -### substring() - -```ts -substring(start: number, end: number): CircuitString -``` - -#### Parameters - -• **start**: `number` - -• **end**: `number` - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L151) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/string.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L155) - -*** - -### fromCharacters() - -```ts -static fromCharacters(chars: Character[]): CircuitString -``` - -#### Parameters - -• **chars**: [`Character`](Character.mdx)[] - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L75) - -*** - -### fromString() - -```ts -static fromString(str: string): CircuitString -``` - -#### Parameters - -• **str**: `string` - -#### Returns - -[`CircuitString`](CircuitString.mdx) - -#### Source - -[lib/provable/string.ts:159](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/string.ts#L159) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct(RawCircuitString).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/classes/DynamicProof ---- - -The `DynamicProof` class enables circuits to verify proofs using in-ciruit verfication keys. -This is opposed to the baked-in verification keys of the `Proof` class. - -In order to use this, a subclass of DynamicProof that specifies the public input and output types along with the maxProofsVerified number has to be created. - -```ts -export class SideloadedProgramProof extends DynamicProof { - static publicInputType = MyStruct; - static publicOutputType = Field; - static maxProofsVerified = 0 as const; -} -``` - -The `maxProofsVerified` constant is a product of the child circuit and indicates the maximum number that that circuit verifies itself. -If you are unsure about what that is for you, you should use `2`. - -Any `DynamicProof` subclass can be used as private input to ZkPrograms or SmartContracts along with a `VerificationKey` input. -```ts -proof.verify(verificationKey) -``` - -NOTE: In the case of `DynamicProof`s, the circuit makes no assertions about the verificationKey used on its own. -This is the responsibility of the application developer and should always implement appropriate checks. -This pattern differs a lot from the usage of normal `Proof`, where the verification key is baked into the compiled circuit. - -## See - -src/examples/zkprogram/dynamic-keys-merkletree.ts for an example of how this can be done using merkle trees - -Assertions generally only happen using the vk hash that is part of the `VerificationKey` struct along with the raw vk data as auxiliary data. -When using verify() on a `DynamicProof`, Pickles makes sure that the verification key data matches the hash. -Therefore all manual assertions have to be made on the vk's hash and it can be assumed that the vk's data is checked to match the hash if it is used with verify(). - -## Extends - -- [`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -## Type parameters - -• **Input** - -• **Output** - -## Constructors - -### new DynamicProof() - -```ts -new DynamicProof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): DynamicProof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`DynamicProof`](DynamicProof.mdx)\<`Input`, `Output`\> - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`constructor`](ProofBase.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`maxProofsVerified`](ProofBase.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`proof`](ProofBase.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInput`](ProofBase.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutput`](ProofBase.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`shouldVerify`](ProofBase.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### usedVerificationKey? - -```ts -optional usedVerificationKey: VerificationKey; -``` - -#### Source - -[lib/proof-system/proof.ts:235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L235) - -*** - -### featureFlags - -```ts -static featureFlags: FeatureFlags = FeatureFlags.allNone; -``` - -As the name indicates, feature flags are features of the proof system. - -If we want to side load proofs and verification keys, we first have to tell Pickles what _shape_ of proofs it should expect. - -For example, if we want to side load proofs that use foreign field arithmetic custom gates, we have to make Pickles aware of that by defining -these custom gates. - -_Note:_ Only proofs that use the exact same composition of custom gates which were expected by Pickles can be verified using side loading. -If you want to verify _any_ proof, no matter what custom gates it uses, you can use FeatureFlags.allMaybe. Please note that this might incur a significant overhead. - -You can also toggle specific feature flags manually by specifying them here. -Alternatively, you can use FeatureFlags.fromZkProgram to compute the set of feature flags that are compatible with a given program. - -#### Source - -[lib/proof-system/proof.ts:222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L222) - -*** - -### maxProofsVerified - -```ts -static maxProofsVerified: 0 | 1 | 2; -``` - -#### Source - -[lib/proof-system/proof.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L204) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInputType`](ProofBase.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutputType`](ProofBase.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`DynamicProof`](DynamicProof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L309) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`toJSON`](ProofBase.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(vk: VerificationKey): void -``` - -Verifies this DynamicProof using a given verification key - -#### Parameters - -• **vk**: [`VerificationKey`](VerificationKey.mdx) - -The verification key this proof will be verified against - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L241) - -*** - -### verifyIf() - -```ts -verifyIf(vk: VerificationKey, condition: Bool): void -``` - -#### Parameters - -• **vk**: [`VerificationKey`](VerificationKey.mdx) - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:245](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L245) - -*** - -### dummy() - -```ts -static dummy( - this: S, - publicInput: InferProvable, - publicOutput: InferProvable, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **publicInput**: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\> - -• **publicOutput**: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\> - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<`InstanceType`\<`S`\>\> - -#### Source - -[lib/proof-system/proof.ts:274](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L274) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`DynamicProof`](DynamicProof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Source - -[lib/proof-system/proof.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L250) - -*** - -### fromProof() - -```ts -static fromProof(this: S, proof: Proof, InferProvable>): InstanceType -``` - -Converts a Proof into a DynamicProof carrying over all relevant data. -This method can be used to convert a Proof computed by a ZkProgram -into a DynamicProof that is accepted in a circuit that accepts DynamicProofs - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`DynamicProof`](DynamicProof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **proof**: [`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\> - -#### Returns - -`InstanceType`\<`S`\> - -#### Source - -[lib/proof-system/proof.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L294) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) - -*** - -### tag() - -```ts -static tag(): { - "name": string; -} -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Overrides - -`ProofBase.tag` - -#### Source - -[lib/proof-system/proof.ts:224](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L224) - ---- -url: /zkapps/o1js-reference/classes/EcdsaSignature ---- - -## Constructors - -### new EcdsaSignature() - -```ts -new EcdsaSignature(signature: { - "r": number | bigint | Field3 | AlmostForeignField; - "s": number | bigint | Field3 | AlmostForeignField; - }): EcdsaSignature -``` - -Create a new [EcdsaSignature](EcdsaSignature.mdx) from an object containing the scalars r and s. - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. Please refer to the [ForeignField](ForeignField.mdx) constructor comments for more details. - -#### Parameters - -• **signature** - -• **signature.r**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **signature.s**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L39) - -## Properties - -### r - -```ts -r: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L31) - -*** - -### s - -```ts -s: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L32) - -*** - -### \_Curve? - -```ts -static optional _Curve: typeof ForeignCurve; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:220](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L220) - -*** - -### \_provable? - -```ts -static optional _provable: ProvablePureExtended; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:221](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L221) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof EcdsaSignature -``` - -#### Returns - -*typeof* [`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:217](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L217) - -*** - -### Curve - -```ts -get static Curve(): typeof ForeignCurve -``` - -The [ForeignCurve](ForeignCurve.mdx) on which the ECDSA signature is defined. - -#### Returns - -*typeof* [`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L230) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -`Provable` - -#### Returns - -`ProvablePureExtended`\<[`EcdsaSignature`](EcdsaSignature.mdx), \{ - `"r"`: `bigint`; - `"s"`: `bigint`; - \}, \{ - `"r"`: `string`; - `"s"`: `string`; - \}\> - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L237) - -## Methods - -### toBigInt() - -```ts -toBigInt(): { - "r": bigint; - "s": bigint; -} -``` - -Convert this signature to an object with bigint fields. - -#### Returns - -```ts -{ - "r": bigint; - "s": bigint; -} -``` - -##### r - -```ts -r: bigint; -``` - -##### s - -```ts -s: bigint; -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L67) - -*** - -### verify() - -```ts -verify(message: Bytes, publicKey: FlexiblePoint): Bool -``` - -Verify the ECDSA signature given the message (an array of bytes) and public key (a [Curve](EcdsaSignature.mdx#curve) point). - -**Important:** This method returns a [Bool](Bool.mdx) which indicates whether the signature is valid. -So, to actually prove validity of a signature, you need to assert that the result is true. - -#### Parameters - -• **message**: `Bytes` - -• **publicKey**: `FlexiblePoint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Throws - -if one of the signature scalars is zero or if the public key is not on the curve. - -#### Example - -```ts -// create classes for your curve -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} -class Scalar extends Secp256k1.Scalar {} -class Ecdsa extends createEcdsa(Secp256k1) {} - -let message = 'my message'; -let messageBytes = new TextEncoder().encode(message); - -// outside provable code: create inputs -let privateKey = Scalar.random(); -let publicKey = Secp256k1.generator.scale(privateKey); -let signature = Ecdsa.sign(messageBytes, privateKey.toBigInt()); - -// ... -// in provable code: create input witnesses (or use method inputs, or constants) -let pk = Provable.witness(Secp256k1, () => publicKey); -let msg = Provable.witness(Provable.Array(Field, 9), () => messageBytes.map(Field)); -let sig = Provable.witness(Ecdsa, () => signature); - -// verify signature -let isValid = sig.verify(msg, pk); -isValid.assertTrue('signature verifies'); -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L105) - -*** - -### verifyEthers() - -```ts -verifyEthers(message: Bytes, publicKey: FlexiblePoint): Bool -``` - -Verify an ECDSA signature generated by the ethers.js library, given the message (as a byte array) and a public key (a [Curve](EcdsaSignature.mdx#curve) point). -The message digest used for signing follows the format defined in EIP-191, with the Ethereum-specific prefix. - -**Important:** This method returns a [Bool](Bool.mdx) which indicates whether the signature is valid. -So, to actually prove validity of a signature, you need to assert that the result is true. - -**Note:** This method is specifically designed to verify signatures generated by ethers.js. -Ensure that the curve being used is Secp256k1, as demonstrated in the example. - -#### Parameters - -• **message**: `Bytes` - -The original message as a byte array. - -• **publicKey**: `FlexiblePoint` - -The public key as a point on the Secp256k1 elliptic curve. - -#### Returns - -[`Bool`](Bool.mdx) - -- A [Bool](Bool.mdx) indicating the validity of the signature. - -#### Throws - -An error will be thrown if one of the signature scalars is zero or if the public key does not lie on the curve. - -#### Example - -```ts - - -// create the class for Secp256k1 curve -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} -class Ecdsa extends createEcdsa(Secp256k1) {} - -// outside provable code: create inputs -let message = 'my message'; -let signatureRaw = await wallet.signMessage(message); -let compressedPublicKey = wallet.signingKey.compressedPublicKey; - -// this also works for uncompressed public keys (wallet.signingKey.publicKey) -let publicKey = Secp256k1.fromEthers(compressedPublicKey.slice(2)); -let signature = Ecdsa.fromHex(signatureRaw); - -// ... -// in provable code: create input witnesses (or use method inputs, or constants) -// and verify the signature -let isValid = signature.verifyEthers(Bytes.fromString(message), publicKey); -isValid.assertTrue('signature verifies'); -``` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L151) - -*** - -### verifySignedHash() - -```ts -verifySignedHash(msgHash: bigint | AlmostForeignField, publicKey: FlexiblePoint): Bool -``` - -Verify the ECDSA signature given the message hash (a [Scalar](Scalar.mdx)) and public key (a [Curve](EcdsaSignature.mdx#curve) point). - -This is a building block of [EcdsaSignature.verify](EcdsaSignature.mdx#verify), where the input message is also hashed. -In contrast, this method just takes the message hash (a curve scalar) as input, giving you flexibility in -choosing the hashing algorithm. - -#### Parameters - -• **msgHash**: `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **publicKey**: `FlexiblePoint` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L170) - -*** - -### check() - -```ts -static check(signature: EcdsaSignature): void -``` - -#### Parameters - -• **signature**: [`EcdsaSignature`](EcdsaSignature.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:209](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L209) - -*** - -### from() - -```ts -static from(signature: FlexibleSignature): EcdsaSignature -``` - -Coerce the input to a [EcdsaSignature](EcdsaSignature.mdx). - -#### Parameters - -• **signature**: `FlexibleSignature` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L50) - -*** - -### fromHex() - -```ts -static fromHex(rawSignature: string): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) from a raw 130-char hex string as used in -[Ethereum transactions](https://ethereum.org/en/developers/docs/transactions/#typed-transaction-envelope). - -#### Parameters - -• **rawSignature**: `string` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L59) - -*** - -### sign() - -```ts -static sign(message: Uint8Array | (number | bigint)[], privateKey: bigint): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) by signing a message with a private key. - -Note: This method is not provable, and only takes JS bigints as input. - -#### Parameters - -• **message**: `Uint8Array` \| (`number` \| `bigint`)[] - -• **privateKey**: `bigint` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L189) - -*** - -### signHash() - -```ts -static signHash(msgHash: bigint, privateKey: bigint): EcdsaSignature -``` - -Create an [EcdsaSignature](EcdsaSignature.mdx) by signing a message hash with a private key. - -This is a building block of [EcdsaSignature.sign](EcdsaSignature.mdx#sign), where the input message is also hashed. -In contrast, this method just takes the message hash (a curve scalar) as input, giving you flexibility in -choosing the hashing algorithm. - -Note: This method is not provable, and only takes JS bigints as input. - -#### Parameters - -• **msgHash**: `bigint` - -• **privateKey**: `bigint` - -#### Returns - -[`EcdsaSignature`](EcdsaSignature.mdx) - -#### Source - -[lib/provable/crypto/foreign-ecdsa.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L204) - ---- -url: /zkapps/o1js-reference/classes/Field ---- - -A [Field](Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). -Every other provable type is built using the [Field](Field.mdx) type. - -The field is the [pasta base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) of order 2^254 + 0x224698fc094cf91b992d30ed00000001 ([Field.ORDER](Field.mdx#order)). - -You can create a new Field from everything "field-like" (`bigint`, integer `number`, decimal `string`, `Field`). - -## Example - -``` -Field(10n); // Field construction from a big integer -Field(100); // Field construction from a number -Field("1"); // Field construction from a decimal string -``` - -**Beware**: Fields _cannot_ be constructed from fractional numbers or alphanumeric strings: -```ts -Field(3.141); // ERROR: Cannot convert a float to a field element -Field("abc"); // ERROR: Invalid argument "abc" -``` - -Creating a Field from a negative number can result in unexpected behavior if you are not familiar with [modular arithmetic](https://en.wikipedia.org/wiki/Modular_arithmetic). - -## Example - -``` -const x = Field(-1); // Valid Field construction from negative number -const y = Field(Field.ORDER - 1n); // equivalent to `x` -``` - -**Important**: All the functions defined on a Field (arithmetic, logic, etc.) take their arguments as "field-like". A Field itself is also defined as a "field-like" element. - -## Param - -the value to convert to a [Field](Field.mdx) - -## Constructors - -### new Field() - -```ts -new Field(x: - | string - | number - | bigint - | FieldConst - | FieldVar - | Field): Field -``` - -Coerce anything "field-like" (bigint, number, string, and [Field](Field.mdx)) to a Field. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldConst` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L97) - -## Properties - -### value - -```ts -value: FieldVar; -``` - -#### Source - -[lib/provable/field.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L86) - -*** - -### ORDER - -```ts -static ORDER: bigint = Fp.modulus; -``` - -The order of the pasta curve that [Field](Field.mdx) type build on as a `bigint`. -Order of the [Field](Field.mdx) is 28948022309329048855892746252171976963363056481941560715954676764349967630337. - -#### Source - -[lib/provable/field.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L92) - -*** - -### sizeInBits - -```ts -static sizeInBits: number = Fp.sizeInBits; -``` - -The size of a [Field](Field.mdx) element in bits - 255. - -#### Source - -[lib/provable/field.ts:1127](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1127) - -*** - -### sizeInBytes - -```ts -static sizeInBytes: number = BinableFp.sizeInBytes; -``` - -The size of a [Field](Field.mdx) element in bytes - 32. - -#### Source - -[lib/provable/field.ts:1122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1122) - -## Methods - -### add() - -```ts -add(y: string | number | bigint | Field): Field -``` - -Add a field-like value to this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular addition of the two value. - -#### Example - -```ts -const x = Field(3); -const sum = x.add(5); - -sum.assertEquals(Field(8)); -``` - -**Warning**: This is a modular addition in the pasta field. - -#### Example - -```ts -const x = Field(1); -const sum = x.add(Field(-7)); - -// If you try to print sum - `console.log(sum.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 + (-7) circles around the field to become p - 6. -// You can use the reverse operation of addition (subtraction) to prove the sum is calculated correctly. - -sum.sub(x).assertEquals(Field(-7)); -sum.sub(Field(-7)).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L250) - -*** - -### assertBool() - -```ts -assertBool(message?: string): Bool -``` - -Prove that this [Field](Field.mdx) is equal to 0 or 1. -Returns the Field wrapped in a [Bool](Bool.mdx). - -If the assertion fails, the code throws an error. - -#### Parameters - -• **message?**: `string` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/field.ts:780](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L780) - -*** - -### assertEquals() - -```ts -assertEquals(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is equal another "field-like" value. -Calling this function is equivalent to `Field(...).equals(...).assertEquals(Bool(true))`. -See [Field.equals](Field.mdx#equals) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L208) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is greater than another "field-like" value. - -Note: This uses fewer constraints than `x.greaterThan(y).assertTrue()`. -See [Field.greaterThan](Field.mdx#greaterthan) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:714](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L714) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is greater than or equal to another "field-like" value. - -Note: This uses fewer constraints than `x.greaterThanOrEqual(y).assertTrue()`. -See [Field.greaterThanOrEqual](Field.mdx#greaterthanorequal) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:729](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L729) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is less than another "field-like" value. - -Note: This uses fewer constraints than `x.lessThan(y).assertTrue()`. -See [lessThan](Field.mdx#lessthan) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:664](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L664) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) is less than or equal to another "field-like" value. - -Note: This uses fewer constraints than `x.lessThanOrEqual(y).assertTrue()`. -See [Field.lessThanOrEqual](Field.mdx#lessthanorequal) for more details. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:689](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L689) - -*** - -### assertNotEquals() - -```ts -assertNotEquals(y: string | number | bigint | Field, message?: string): void -``` - -Assert that this [Field](Field.mdx) does not equal another field-like value. - -Note: This uses fewer constraints than `x.equals(y).assertFalse()`. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Example - -```ts -x.assertNotEquals(0, "expect x to be non-zero"); -``` - -#### Source - -[lib/provable/field.ts:746](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L746) - -*** - -### div() - -```ts -div(y: string | number | bigint | Field): Field -``` - -Divide another "field-like" value through this [Field](Field.mdx). - -Proves that the denominator is non-zero, or throws a "Division by zero" error. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular division of the two value. - -#### Example - -```ts -const x = Field(6); -const quotient = x.div(Field(3)); - -quotient.assertEquals(Field(2)); -``` - -**Warning**: This is a modular division in the pasta field. You can think this as the reverse operation of modular multiplication. - -#### Example - -```ts -const x = Field(2); -const y = Field(5); - -const quotient = x.div(y); - -// If you try to print quotient - `console.log(quotient.toBigInt())` - you will realize that it prints a very big integer because this is a modular inverse. -// You can use the reverse operation of division (multiplication) to prove the quotient is calculated correctly. - -quotient.mul(y).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:442](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L442) - -*** - -### equals() - -```ts -equals(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is equal another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is equal another "field-like" value. - -#### Example - -```ts -Field(5).equals(5).assertEquals(Bool(true)); -``` - -#### Source - -[lib/provable/field.ts:522](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L522) - -*** - -### greaterThan() - -```ts -greaterThan(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is greater than another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is greater than another "field-like" value. - -#### Example - -```ts -let isTrue = Field(5).greaterThan(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(2).greaterThan(Field(1).div(3); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:625](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L625) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is greater than or equal another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is greater than or equal another "field-like" value. - -#### Example - -```ts -let isTrue = Field(3).greaterThanOrEqual(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(2).greaterThanOrEqual(Field(1).div(3); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:649](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L649) - -*** - -### inv() - -```ts -inv(): Field -``` - -[Modular inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of this [Field](Field.mdx) element. -Equivalent to 1 divided by this [Field](Field.mdx), in the sense of modular arithmetic. - -Proves that this Field is non-zero, or throws a "Division by zero" error. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element that is equivalent to one divided by this element. - -#### Example - -```ts -const someField = Field(42); -const inverse = someField.inv(); -inverse.assertEquals(Field(1).div(someField)); // This statement is always true regardless of the value of `someField` -``` - -**Warning**: This is a modular inverse. See [div](Field.mdx#div) method for more details. - -#### Source - -[lib/provable/field.ts:396](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L396) - -*** - -### isConstant() - -```ts -isConstant(): this is Object -``` - -Check whether this [Field](Field.mdx) element is a hard-coded constant in the constraint system. -If a [Field](Field.mdx) is constructed outside a zkApp method, it is a constant. - -#### Returns - -`this is Object` - -A `boolean` showing if this [Field](Field.mdx) is a constant or not. - -#### Example - -```ts -console.log(Field(42).isConstant()); // true -``` - -#### Example - -```ts -\@method myMethod(x: Field) { - console.log(x.isConstant()); // false -} -``` - -#### Source - -[lib/provable/field.ts:142](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L142) - -*** - -### isEven() - -```ts -isEven(): Bool -``` - -Checks if this [Field](Field.mdx) is even. Returns `true` for even elements and `false` for odd elements. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -let a = Field(5); -a.isEven(); // false - -let b = Field(4); -b.isEven(); // true -``` - -#### Source - -[lib/provable/field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L339) - -*** - -### isOdd() - -```ts -isOdd(): Bool -``` - -Checks if this [Field](Field.mdx) is odd. Returns `true` for odd elements and `false` for even elements. - -See [Field.isEven](Field.mdx#iseven) for examples. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/field.ts:323](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L323) - -*** - -### lessThan() - -```ts -lessThan(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is less than another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used prove to the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is less than another "field-like" value. - -#### Example - -```ts -let isTrue = Field(2).lessThan(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behavior when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(3).lessThan(Field(1).div(2)); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:571](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L571) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: string | number | bigint | Field): Bool -``` - -Check if this [Field](Field.mdx) is less than or equal to another "field-like" value. -Returns a [Bool](Bool.mdx), which is a provable type and can be used to prove the validity of this statement. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -A [Bool](Bool.mdx) representing if this [Field](Field.mdx) is less than or equal another "field-like" value. - -#### Example - -```ts -let isTrue = Field(3).lessThanOrEqual(3); -``` - -**Warning**: As this method compares the bigint value of a [Field](Field.mdx), it can result in unexpected behaviour when used with negative inputs or modular division. - -#### Example - -```ts -let isFalse = Field(1).div(3).lessThanOrEqual(Field(1).div(2)); // in fact, 1/3 > 1/2 -``` - -#### Source - -[lib/provable/field.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L598) - -*** - -### mul() - -```ts -mul(y: string | number | bigint | Field): Field -``` - -Multiply another "field-like" value with this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular difference of the two value. - -#### Example - -```ts -const x = Field(3); -const product = x.mul(Field(5)); - -product.assertEquals(Field(15)); -``` - -#### Source - -[lib/provable/field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L358) - -*** - -### neg() - -```ts -neg(): Field -``` - -Negate a [Field](Field.mdx). This is equivalent to multiplying the [Field](Field.mdx) by -1. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element that is equivalent to the element multiplied by -1. - -#### Example - -```ts -const negOne = Field(1).neg(); -negOne.assertEquals(-1); -``` - -#### Example - -```ts -const someField = Field(42); -someField.neg().assertEquals(someField.mul(Field(-1))); // This statement is always true regardless of the value of `someField` -``` - -**Warning**: This is a modular negation. For details, see the [sub](Field.mdx#sub) method. - -#### Source - -[lib/provable/field.ts:278](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L278) - -*** - -### seal() - -```ts -seal(): VarField | ConstantField -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -In o1js, addition and scaling (multiplication of variables by a constant) of variables is represented as an AST - [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree). For example, the expression `x.add(y).mul(2)` is represented as `Scale(2, Add(x, y))`. - - A new internal variable is created only when the variable is needed in a multiplicative or any higher level constraint (for example multiplication of two [Field](Field.mdx) elements) to represent the operation. - -The `seal()` function tells o1js to stop building an AST and create a new variable right away. - -#### Returns - -[`VarField`](../type-aliases/VarField.mdx) \| [`ConstantField`](../type-aliases/ConstantField.mdx) - -A [Field](Field.mdx) element that is equal to the result of AST that was previously on this [Field](Field.mdx) element. - -#### Source - -[lib/provable/field.ts:872](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L872) - -*** - -### sqrt() - -```ts -sqrt(): Field -``` - -Take the square root of this [Field](Field.mdx) element. - -Proves that the Field element has a square root in the finite field, or throws if it doesn't. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the square root of the [Field](Field.mdx) element. - -#### Example - -```ts -let z = x.sqrt(); -z.mul(z).assertEquals(x); // true for every `x` -``` - -**Warning**: This is a modular square root, which is any number z that satisfies z*z = x (mod p). -Note that, if a square root z exists, there also exists a second one, -z (which is different if z != 0). -Therefore, this method leaves an adversarial prover the choice between two different values to return. - -#### Source - -[lib/provable/field.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L492) - -*** - -### square() - -```ts -square(): Field -``` - -Square this [Field](Field.mdx) element. - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the multiplication of the [Field](Field.mdx) element with itself. - -#### Example - -```ts -const someField = Field(7); -const square = someField.square(); - -square.assertEquals(someField.mul(someField)); // This statement is always true regardless of the value of `someField` -``` - -** Warning: This is a modular multiplication. See `mul()` method for more details. - -#### Source - -[lib/provable/field.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L463) - -*** - -### sub() - -```ts -sub(y: string | number | bigint | Field): Field -``` - -Subtract another "field-like" value from this [Field](Field.mdx) element. - -#### Parameters - -• **y**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element equivalent to the modular difference of the two value. - -#### Example - -```ts -const x = Field(3); -const difference = x.sub(5); - -difference.assertEquals(Field(-2)); -``` - -**Warning**: This is a modular subtraction in the pasta field. - -#### Example - -```ts -const x = Field(1); -const difference = x.sub(Field(2)); - -// If you try to print difference - `console.log(difference.toBigInt())` - you will realize that it prints a very big integer because this is modular arithmetic, and 1 - 2 circles around the field to become p - 1. -// You can use the reverse operation of subtraction (addition) to prove the difference is calculated correctly. -difference.add(Field(2)).assertEquals(x); -``` - -#### Source - -[lib/provable/field.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L314) - -*** - -### toAuxiliary() - -```ts -toAuxiliary(): [] -``` - -This function is the implementation of Provable.toAuxiliary for the [Field](Field.mdx) type. - -As the primitive [Field](Field.mdx) type has no auxiliary data associated with it, this function will always return an empty array. - -#### Returns - -[] - -#### Source - -[lib/provable/field.ts:1005](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1005) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Serialize the [Field](Field.mdx) to a bigint, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the bigint representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`bigint` - -A bigint equivalent to the bigint representation of the Field. - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toBigInt()); -``` - -#### Source - -[lib/provable/field.ts:176](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L176) - -*** - -### toBits() - -```ts -toBits(length: number): Bool[] -``` - -Returns an array of [Bool](Bool.mdx) elements representing [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of this [Field](Field.mdx) element. - -If you use the optional `length` argument, proves that the field element fits in `length` bits. -The `length` has to be between 0 and 254 and the method throws if it isn't. - -**Warning**: The cost of this operation in a zk proof depends on the `length` you specify, -which by default is 254 bits. Prefer to pass a smaller `length` if possible. - -#### Parameters - -• **length**: `number`= `254` - -the number of bits to fit the element. If the element does not fit in `length` bits, the functions throws an error. - -#### Returns - -[`Bool`](Bool.mdx)[] - -An array of [Bool](Bool.mdx) element representing little endian binary representation of this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:810](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L810) - -*** - -### toConstant() - -```ts -toConstant(): ConstantField -``` - -Create a [Field](Field.mdx) element equivalent to this [Field](Field.mdx) element's value, -but is a constant. -See [Field.isConstant](Field.mdx#isconstant) for more information about what is a constant [Field](Field.mdx). - -#### Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -A constant [Field](Field.mdx) element equivalent to this [Field](Field.mdx) element. - -#### Example - -```ts -const someField = Field(42); -someField.toConstant().assertEquals(someField); // Always true -``` - -#### Source - -[lib/provable/field.ts:159](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L159) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -This function is the implementation of Provable.toFields for the [Field](Field.mdx) type. - -The result will be always an array of length 1, where the first and only element equals the [Field](Field.mdx) itself. - -#### Returns - -[`Field`](Field.mdx)[] - -A [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:996](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L996) - -*** - -### toJSON() - -```ts -toJSON(): string -``` - -Serialize the [Field](Field.mdx) to a JSON string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the JSON string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`string` - -A string equivalent to the JSON representation of the [Field](Field.mdx). - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toJSON()); -``` - -#### Source - -[lib/provable/field.ts:1028](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1028) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [Field](Field.mdx) to a string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Returns - -`string` - -A string equivalent to the string representation of the Field. - -#### Example - -```ts -const someField = Field(42); -console.log(someField.toString()); -``` - -#### Source - -[lib/provable/field.ts:194](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L194) - -*** - -### check() - -```ts -static check(): void -``` - -This function is the implementation of Provable.check in [Field](Field.mdx) type. - -As any field element can be a [Field](Field.mdx), this function does not create any assertions, so it does nothing. - -#### Returns - -`void` - -#### Source - -[lib/provable/field.ts:966](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L966) - -*** - -### empty() - -```ts -static empty(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:1011](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1011) - -*** - -### from() - -```ts -static from(x: string | number | bigint | Field): Field -``` - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:119](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L119) - -*** - -### fromBits() - -```ts -static fromBits(bits: (boolean | Bool)[]): Field -``` - -Convert a bit array into a [Field](Field.mdx) element using [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) - -The method throws if the given bits do not fit in a single Field element. In this case, no more than 254 bits are allowed because some 255 bit integers do not fit into a single Field element. - -**Important**: If the given `bytes` array is an array of `booleans` or [Bool](Bool.mdx) elements that all are `constant`, the resulting [Field](Field.mdx) element will be a constant as well. Or else, if the given array is a mixture of constants and variables of [Bool](Bool.mdx) type, the resulting [Field](Field.mdx) will be a variable as well. - -#### Parameters - -• **bits**: (`boolean` \| [`Bool`](Bool.mdx))[] - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) element matching the [little endian binary representation](https://en.wikipedia.org/wiki/Endianness) of the given `bytes` array. - -#### Source - -[lib/provable/field.ts:843](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L843) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: number[]): Field -``` - -Coerce a new [Field](Field.mdx) element using the [little-endian](https://en.wikipedia.org/wiki/Endianness) representation of the given `bytes` array. -Note that the given `bytes` array may have at most 32 elements as the [Field](Field.mdx) is a `finite-field` in the order of [Field.ORDER](Field.mdx#order). - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the byte representation of the [Field](Field.mdx). - -#### Parameters - -• **bytes**: `number`[] - -The bytes array to coerce the [Field](Field.mdx) from. - -#### Returns - -[`Field`](Field.mdx) - -A new [Field](Field.mdx) element created using the [little-endian](https://en.wikipedia.org/wiki/Endianness) representation of the given `bytes` array. - -#### Source - -[lib/provable/field.ts:1115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1115) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Field -``` - -Implementation of Provable.fromFields for the [Field](Field.mdx) type. - -**Warning**: This function is designed for internal use. It is not intended to be used by a zkApp developer. - -Creates a [Field](Field.mdx) from an array of Fields of length 1. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of length 1 serialized from [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx) - -The first [Field](Field.mdx) element of the given array. - -#### Source - -[lib/provable/field.ts:955](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L955) - -*** - -### fromJSON() - -```ts -static fromJSON(json: string): Field -``` - -Deserialize a JSON string containing a "field-like" value into a [Field](Field.mdx) element. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the [Field](Field.mdx). - -#### Parameters - -• **json**: `string` - -#### Returns - -[`Field`](Field.mdx) - -A [Field](Field.mdx) coerced from the given JSON string. - -#### Source - -[lib/provable/field.ts:1060](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1060) - -*** - -### fromValue() - -```ts -static fromValue(x: string | number | bigint | Field): Field -``` - -`Provable.fromValue()` - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/field.ts:985](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L985) - -*** - -### random() - -```ts -static random(): Field -``` - -A random [Field](Field.mdx) element. - -#### Returns - -[`Field`](Field.mdx) - -A random [Field](Field.mdx) element. - -#### Example - -```ts -console.log(Field.random().toBigInt()); // Run this code twice! -``` - -#### Source - -[lib/provable/field.ts:894](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L894) - -*** - -### readBytes() - -```ts -static readBytes(bytes: number[], offset: NonNegativeInteger): [Field, number] -``` - -Part of the `Binable` interface. - -**Warning**: This function is for internal use. It is not intended to be used by a zkApp developer. - -#### Type parameters - -• **N** *extends* `number` - -#### Parameters - -• **bytes**: `number`[] - -• **offset**: `NonNegativeInteger`\<`N`\> - -#### Returns - -[[`Field`](Field.mdx), `number`] - -#### Source - -[lib/provable/field.ts:1098](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1098) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -This function is the implementation of Provable.sizeInFields for the [Field](Field.mdx) type. - -Size of the [Field](Field.mdx) type is 1, as it is the primitive type. -This function returns a regular number, so you cannot use it to prove something on chain. You can use it during debugging or to understand the memory complexity of some type. - -#### Returns - -`number` - -A number representing the size of the [Field](Field.mdx) type in terms of [Field](Field.mdx) type itself. - -#### Example - -```ts -console.log(Field.sizeInFields()); // Prints 1 -``` - -#### Source - -[lib/provable/field.ts:940](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L940) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -This function is the implementation of Provable.toAuxiliary for the [Field](Field.mdx) type. - -As the primitive [Field](Field.mdx) type has no auxiliary data associated with it, this function will always return an empty array. - -#### Returns - -[] - -#### Source - -[lib/provable/field.ts:923](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L923) - -*** - -### toBigint() - -```ts -static toBigint(x: Field): bigint -``` - -Convert a [Field](Field.mdx) element to a bigint. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/field.ts:978](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L978) - -*** - -### toBytes() - -```ts -static toBytes(x: Field): number[] -``` - -Create an array of digits equal to the [little-endian](https://en.wikipedia.org/wiki/Endianness) byte order of the given [Field](Field.mdx) element. -Note that the array has always 32 elements as the [Field](Field.mdx) is a `finite-field` in the order of [Field.ORDER](Field.mdx#order). - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`number`[] - -An array of digits equal to the [little-endian](https://en.wikipedia.org/wiki/Endianness) byte order of the given [Field](Field.mdx) element. - -#### Source - -[lib/provable/field.ts:1089](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1089) - -*** - -### toFields() - -```ts -static toFields(x: Field): Field[] -``` - -This function is the implementation of Provable.toFields for the [Field](Field.mdx) type. - -Static function to serializes a [Field](Field.mdx) into an array of [Field](Field.mdx) elements. -This will be always an array of length 1, where the first and only element equals the given parameter itself. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -A [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/field.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L912) - -*** - -### toInput() - -```ts -static toInput(x: Field): { - "fields": Field[]; -} -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -This function is the implementation of `ProvableExtended.toInput()` for the [Field](Field.mdx) type. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -```ts -{ - "fields": Field[]; -} -``` - -An object where the `fields` key is a [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -##### fields - -```ts -fields: Field[]; -``` - -#### Source - -[lib/provable/field.ts:1074](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1074) - -*** - -### toJSON() - -```ts -static toJSON(x: Field): string -``` - -Serialize the given [Field](Field.mdx) element to a JSON string, e.g. for printing. Trying to print a [Field](Field.mdx) without this function will directly stringify the Field object, resulting in unreadable output. - -**Warning**: This operation does _not_ affect the circuit and can't be used to prove anything about the JSON string representation of the [Field](Field.mdx). Use the operation only during debugging. - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`string` - -A string equivalent to the JSON representation of the given [Field](Field.mdx). - -#### Example - -```ts -const someField = Field(42); -console.log(Field.toJSON(someField)); -``` - -#### Source - -[lib/provable/field.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1047) - -*** - -### toValue() - -```ts -static toValue(x: Field): bigint -``` - -`Provable.toValue()` - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/field.ts:971](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L971) - ---- -url: /zkapps/o1js-reference/classes/ForeignCurve ---- - -## Constructors - -### new ForeignCurve() - -```ts -new ForeignCurve(g: { - "x": number | bigint | Field3 | AlmostForeignField; - "y": number | bigint | Field3 | AlmostForeignField; - }): ForeignCurve -``` - -Create a new [ForeignCurve](ForeignCurve.mdx) from an object representing the (affine) x and y coordinates. - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. Please refer to the [ForeignField](ForeignField.mdx) constructor comments for more details. - -#### Parameters - -• **g** - -• **g.x**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -• **g.y**: `number` \| `bigint` \| `Field3` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let x = new ForeignCurve({ x: 1n, y: 1n }); -``` - -**Important**: By design, there is no way for a `ForeignCurve` to represent the zero point. - -**Warning**: This fails for a constant input which does not represent an actual point on the curve. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L49) - -## Properties - -### x - -```ts -x: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L32) - -*** - -### y - -```ts -y: AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L33) - -*** - -### \_Bigint? - -```ts -static optional _Bigint: {}; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:362](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L362) - -*** - -### \_Field? - -```ts -static optional _Field: typeof AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:363](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L363) - -*** - -### \_Scalar? - -```ts -static optional _Scalar: typeof AlmostForeignField; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:364](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L364) - -*** - -### \_provable? - -```ts -static optional _provable: ProvablePureExtended; -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:365](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L365) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignCurve -``` - -#### Returns - -*typeof* [`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L359) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -The size of the curve's base field. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:203](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L203) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -Curve arithmetic on JS bigints. - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:374](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L374) - -*** - -### Field - -```ts -get static Field(): typeof AlmostForeignField -``` - -The base field of this curve as a [ForeignField](ForeignField.mdx). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:381](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L381) - -*** - -### Scalar - -```ts -get static Scalar(): typeof AlmostForeignField -``` - -The scalar field of this curve as a [ForeignField](ForeignField.mdx). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L388) - -*** - -### generator - -```ts -get static generator(): ForeignCurve -``` - -The constant generator point. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:191](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L191) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -The size of the curve's base field. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L197) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -`Provable` - -#### Returns - -`ProvablePureExtended`\<[`ForeignCurve`](ForeignCurve.mdx), \{ - `"x"`: `bigint`; - `"y"`: `bigint`; - \}, \{ - `"x"`: `string`; - `"y"`: `string`; - \}\> - -#### Source - -[lib/provable/crypto/foreign-curve.ts:395](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L395) - -## Methods - -### add() - -```ts -add(h: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Elliptic curve addition. - -```ts -let r = p.add(q); // r = p + q -``` - -**Important**: this is _incomplete addition_ and does not handle the degenerate cases: -- Inputs are equal, `g = h` (where you would use [double](ForeignCurve.mdx#double)). - In this case, the result of this method is garbage and can be manipulated arbitrarily by a malicious prover. -- Inputs are inverses of each other, `g = -h`, so that the result would be the zero point. - In this case, the proof fails. - -If you want guaranteed soundness regardless of the input, use [addSafe](ForeignCurve.mdx#addsafe) instead. - -#### Parameters - -• **h**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the inputs are inverses of each other. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:243](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L243) - -*** - -### addSafe() - -```ts -addSafe(h: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Safe elliptic curve addition. - -This is the same as [add](ForeignCurve.mdx#add), but additionally proves that the inputs are not equal. -Therefore, the method is guaranteed to either fail or return a valid addition result. - -**Beware**: this is more expensive than [add](ForeignCurve.mdx#add), and is still incomplete in that -it does not succeed on equal or inverse inputs. - -#### Parameters - -• **h**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the inputs are equal or inverses of each other. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L261) - -*** - -### assertInSubgroup() - -```ts -assertInSubgroup(): void -``` - -Assert that this point lies in the subgroup defined by `order*P = 0`. - -Note: this is a no-op if the curve has cofactor equal to 1. Otherwise -it performs the full scalar multiplication `order*P` and is expensive. - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:341](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L341) - -*** - -### assertOnCurve() - -```ts -assertOnCurve(): void -``` - -Assert that this point lies on the elliptic curve, which means it satisfies the equation -`y^2 = x^3 + ax + b` - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L325) - -*** - -### double() - -```ts -double(): ForeignCurve -``` - -Elliptic curve doubling. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let r = p.double(); // r = 2 * p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L280) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this curve point is constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L212) - -*** - -### negate() - -```ts -negate(): ForeignCurve -``` - -Elliptic curve negation. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Example - -```ts -let r = p.negate(); // r = -p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L294) - -*** - -### scale() - -```ts -scale(scalar: number | bigint | AlmostForeignField): ForeignCurve -``` - -Elliptic curve scalar multiplication, where the scalar is represented as a [ForeignField](ForeignField.mdx) element. - -**Important**: this proves that the result of the scalar multiplication is not the zero point. - -#### Parameters - -• **scalar**: `number` \| `bigint` \| [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Throws - -if the scalar multiplication results in the zero point; for example, if the scalar is zero. - -#### Example - -```ts -let r = p.scale(s); // r = s * p -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:310](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L310) - -*** - -### toBigint() - -```ts -toBigint(): GroupAffine -``` - -Convert this curve point to a point with bigint coordinates. - -#### Returns - -`GroupAffine` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L219) - -*** - -### assertInSubgroup() - -```ts -static assertInSubgroup(g: ForeignCurve): void -``` - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:329](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L329) - -*** - -### assertOnCurve() - -```ts -static assertOnCurve(g: ForeignCurve): void -``` - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L317) - -*** - -### check() - -```ts -static check(g: ForeignCurveNotNeeded): void -``` - -Check that this is a valid element of the target subgroup of the curve: -- Check that the coordinates are valid field elements -- Use [()](ForeignCurve.mdx#assertoncurve-1) to check that the point lies on the curve -- If the curve has cofactor unequal to 1, use [()](ForeignCurve.mdx#assertinsubgroup-1). - -#### Parameters - -• **g**: `ForeignCurveNotNeeded` - -#### Returns - -`void` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:351](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L351) - -*** - -### from() - -```ts -static from(g: ForeignCurve | FlexiblePoint): ForeignCurve -``` - -Coerce the input to a [ForeignCurve](ForeignCurve.mdx). - -#### Parameters - -• **g**: [`ForeignCurve`](ForeignCurve.mdx) \| `FlexiblePoint` - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -#### Source - -[lib/provable/crypto/foreign-curve.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L65) - -*** - -### fromEthers() - -```ts -static fromEthers(hex: string): ForeignCurve -``` - -Create a new [ForeignCurve](ForeignCurve.mdx) instance from an Ethereum public key in hex format, which may be either compressed or uncompressed. -This method is designed to handle the parsing of public keys as used by the ethers.js library. - -The input should represent the affine x and y coordinates of the point, in hexadecimal format. -Compressed keys are 33 bytes long and begin with 0x02 or 0x03, while uncompressed keys are 65 bytes long and begin with 0x04. - -**Warning:** This method is specifically designed for use with the Secp256k1 curve. Using it with other curves may result in incorrect behavior or errors. -Ensure that the curve setup matches Secp256k1, as shown in the example, to avoid unintended issues. - -#### Parameters - -• **hex**: `string` - -The public key as a hexadecimal string (without the "0x" prefix). - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -A new instance of the curve representing the given public key. - -#### Example - -```ts - - -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} - -const wallet = Wallet.createRandom(); - -const publicKey = Secp256k1.fromEthers(wallet.publicKey.slice(2)); -``` - -#### Source - -[lib/provable/crypto/foreign-curve.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L143) - -*** - -### fromHex() - -```ts -static fromHex(hex: string): ForeignCurve -``` - -Parses a hexadecimal string representing an uncompressed elliptic curve point and coerces it into a [ForeignCurve](ForeignCurve.mdx) point. - -The method extracts the x and y coordinates from the provided hex string and verifies that the resulting point lies on the curve. - -**Note:** This method only supports uncompressed elliptic curve points, which are 65 bytes in total (1-byte prefix + 32 bytes for x + 32 bytes for y). - -#### Parameters - -• **hex**: `string` - -The hexadecimal string representing the uncompressed elliptic curve point. - -#### Returns - -[`ForeignCurve`](ForeignCurve.mdx) - -- A point on the foreign curve, parsed from the given hexadecimal string. - -#### Throws - -- Throws an error if the input is not a valid public key. - -#### Example - -```ts -class Secp256k1 extends createForeignCurve(Crypto.CurveParams.Secp256k1) {} - -const publicKeyHex = '04f8b8db25c619d0c66b2dc9e97ecbafafae...'; // Example hex string for uncompressed point -const point = Secp256k1.fromHex(publicKeyHex); -``` - -**Important:** This method is only designed to handle uncompressed elliptic curve points in hex format. - -#### Source - -[lib/provable/crypto/foreign-curve.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L92) - ---- -url: /zkapps/o1js-reference/classes/ForeignField ---- - -## Constructors - -### new ForeignField() - -```ts -new ForeignField(x: - | string - | number - | bigint - | Field3 - | ForeignField): ForeignField -``` - -Create a new [ForeignField](ForeignField.mdx) from a bigint, number, string or another ForeignField. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Example - -```ts -let x = new ForeignField(5); -``` - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. - -- When constructing from another [ForeignField](ForeignField.mdx) instance, ensure the modulus matches. If not, check the modulus using `Gadgets.ForeignField.assertLessThan()` and handle appropriately. -- When constructing from a Field3 array, ensure all elements are valid Field elements and range checked. -- Ensure constants are correctly reduced to the modulus of the field. - -#### Source - -[lib/provable/foreign-field.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L101) - -## Properties - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: any = undefined; -``` - -#### Source - -[lib/provable/foreign-field.ts:414](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L414) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): any -``` - -`Provable`, see [Provable](../type-aliases/Provable.mdx) - -#### Returns - -`any` - -#### Source - -[lib/provable/foreign-field.ts:419](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L419) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(_: ForeignField): void -``` - -#### Parameters - -• **\_**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/foreign-field.ts:410](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L410) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - ---- -url: /zkapps/o1js-reference/classes/Group ---- - -An element of a Group. - -## Constructors - -### new Group() - -```ts -new Group(__namedParameters: { - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }): Group -``` - -Coerces anything group-like to a [Group](Group.mdx). - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **\_\_namedParameters.y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L50) - -## Properties - -### x - -```ts -x: Field; -``` - -#### Source - -[lib/provable/group.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L21) - -*** - -### y - -```ts -y: Field; -``` - -#### Source - -[lib/provable/group.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L22) - -## Accessors - -### generator - -```ts -get static generator(): Group -``` - -The generator `g` of the Group. - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L27) - -*** - -### zero - -```ts -get static zero(): Group -``` - -Unique representation of the `zero` element of the Group (the identity element of addition in this Group). - -**Note**: The `zero` element is represented as `(0, 0)`. - -```typescript -// g + -g = 0 -g.add(g.neg()).assertEquals(zero); -// g + 0 = g -g.add(zero).assertEquals(g); -``` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:43](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L43) - -## Methods - -### add() - -```ts -add(g: Group): Group -``` - -Adds this [Group](Group.mdx) element to another [Group](Group.mdx) element. - -```ts -let g1 = Group({ x: -1, y: 2}) -let g2 = g1.add(g1) -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L97) - -*** - -### addNonZero() - -```ts -addNonZero(g2: Group, allowZeroOutput: boolean): Group -``` - -Lower-level variant of [add](Group.mdx#add) which doesn't handle the case where one of the operands is zero, and -asserts that the output is non-zero. - -Optionally, zero outputs can be allowed by setting `allowZeroOutput` to `true`. - -**Warning**: If one of the inputs is zero, the result will be garbage and the proof useless. -This case has to be prevented or handled separately by the caller of this method. - -#### Parameters - -• **g2**: [`Group`](Group.mdx) - -• **allowZeroOutput**: `boolean`= `false` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L136) - -*** - -### assertEquals() - -```ts -assertEquals(g: Group, message?: string): void -``` - -Assert that this [Group](Group.mdx) element equals another [Group](Group.mdx) element. -Throws an error if the assertion fails. - -```ts -g1.assertEquals(g2); -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/group.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L200) - -*** - -### equals() - -```ts -equals(g: Group): Bool -``` - -Check if this [Group](Group.mdx) element equals another [Group](Group.mdx) element. -Returns a [Bool](Bool.mdx). - -```ts -g1.equals(g1); // Bool(true) -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/group.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L216) - -*** - -### isZero() - -```ts -isZero(): Bool -``` - -Checks if this element is the `zero` element `{x: 0, y: 0}`. - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/group.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L84) - -*** - -### neg() - -```ts -neg(): Group -``` - -Negates this [Group](Group.mdx). Under the hood, it simply negates the `y` coordinate and leaves the `x` coordinate as is. - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L165) - -*** - -### scale() - -```ts -scale(s: number | bigint | Field | Scalar): Group -``` - -Elliptic curve scalar multiplication. Scales the [Group](Group.mdx) element `n`-times by itself, where `n` is the [Scalar](Scalar.mdx). - -```typescript -let s = Scalar(5); -let 5g = g.scale(s); -``` - -#### Parameters - -• **s**: `number` \| `bigint` \| [`Field`](Field.mdx) \| [`Scalar`](Scalar.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L179) - -*** - -### sub() - -```ts -sub(g: Group): Group -``` - -Subtracts another [Group](Group.mdx) element from this one. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L158) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an array containing this [Group](Group.mdx) element as an array of [Field](Field.mdx) elements. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/group.ts:253](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L253) - -*** - -### toJSON() - -```ts -toJSON(): { - "x": string; - "y": string; -} -``` - -Serializes this [Group](Group.mdx) element to a JSON object. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Returns - -```ts -{ - "x": string; - "y": string; -} -``` - -##### x - -```ts -x: string; -``` - -##### y - -```ts -y: string; -``` - -#### Source - -[lib/provable/group.ts:238](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L238) - -*** - -### check() - -```ts -static check(g: Group): unknown -``` - -Checks that a [Group](Group.mdx) element is constraint properly by checking that the element is on the curve. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -`unknown` - -#### Source - -[lib/provable/group.ts:330](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L330) - -*** - -### empty() - -```ts -static empty(): Group -``` - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L356) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | FieldVar - | Field, y: - | string - | number - | bigint - | FieldVar - | Field): Group -``` - -Coerces two x and y coordinates into a [Group](Group.mdx) element. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:260](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L260) - -*** - -### fromFields() - -```ts -static fromFields(__namedParameters: Field[]): Group -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Deserializes a [Group](Group.mdx) element from a list of field elements. - -#### Parameters - -• **\_\_namedParameters**: [`Field`](Field.mdx)[] - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:290](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L290) - -*** - -### fromJSON() - -```ts -static fromJSON(__namedParameters: { - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }): Group -``` - -Deserializes a JSON-like structure to a [Group](Group.mdx) element. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -• **\_\_namedParameters.y**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`Field`](Field.mdx) - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L317) - -*** - -### fromValue() - -```ts -static fromValue(g: Group | { - "x": number | bigint | Field; - "y": number | bigint | Field; - }): Group -``` - -#### Parameters - -• **g**: [`Group`](Group.mdx) \| \{ - `"x"`: `number` \| `bigint` \| [`Field`](Field.mdx); - `"y"`: `number` \| `bigint` \| [`Field`](Field.mdx); - \} - -#### Returns - -[`Group`](Group.mdx) - -#### Source - -[lib/provable/group.ts:227](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L227) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns 2. - -#### Returns - -`number` - -#### Source - -[lib/provable/group.ts:299](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L299) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(g?: Group): never[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an empty array. - -#### Parameters - -• **g?**: [`Group`](Group.mdx) - -#### Returns - -`never`[] - -#### Source - -[lib/provable/group.ts:281](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L281) - -*** - -### toFields() - -```ts -static toFields(g: Group): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns an array containing a [Group](Group.mdx) element as an array of [Field](Field.mdx) elements. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/group.ts:272](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L272) - -*** - -### toInput() - -```ts -static toInput(x: Group): { - "fields": Field[]; -} -``` - -#### Parameters - -• **x**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "fields": Field[]; -} -``` - -##### fields - -```ts -fields: Field[]; -``` - -#### Source - -[lib/provable/group.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L350) - -*** - -### toJSON() - -```ts -static toJSON(g: Group): { - "x": string; - "y": string; -} -``` - -Serializes a [Group](Group.mdx) element to a JSON object. - -This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element. - -#### Parameters - -• **g**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "x": string; - "y": string; -} -``` - -##### x - -```ts -x: string; -``` - -##### y - -```ts -y: string; -``` - -#### Source - -[lib/provable/group.ts:308](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L308) - -*** - -### toValue() - -```ts -static toValue(__namedParameters: Group): { - "x": bigint; - "y": bigint; -} -``` - -#### Parameters - -• **\_\_namedParameters**: [`Group`](Group.mdx) - -#### Returns - -```ts -{ - "x": bigint; - "y": bigint; -} -``` - -##### x - -```ts -x: bigint; -``` - -##### y - -```ts -y: bigint; -``` - -#### Source - -[lib/provable/group.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/group.ts#L223) - ---- -url: /zkapps/o1js-reference/classes/Hashed ---- - -`Hashed` represents a type `T` by its hash. - -Since a hash is only a single field element, this can be more efficient in provable code -where the number of constraints depends on the number of field elements per value. - -For example, `Provable.if(bool, x, y)` takes O(n) constraints, where n is the number of field -elements in x and y. With Hashed, this is reduced to O(1). - -The downside is that you will pay the overhead of hashing your values, so it helps to experiment -in which parts of your code a hashed representation is beneficial. - -Usage: - -```ts -// define a hashed type from a type -let HashedType = Hashed.create(MyType); - -// hash a value -let hashed = HashedType.hash(value); - -// ... operations on hashes, more efficient than on plain values ... - -// unhash to get the original value -let value = hashed.unhash(); -``` - -**Warning**: When wrapping a type with `Hashed`, make sure that that type is safe to automatically _pack_ -and _unpack_ in provable code. In particular, do not use `Hashed` with types that define a custom `toInput()` -(specifying a certain bit packing) but no corresponding `check()` method (that constrains the bit lengths of the packed parts). - -## Type parameters - -• **T** - -## Constructors - -### new Hashed() - -```ts -new Hashed(hash: Field, value: Unconstrained): Hashed -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Hashed`](Hashed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L241) - -## Properties - -### hash - -```ts -hash: Field; -``` - -#### Source - -[lib/provable/packed.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L204) - -*** - -### value - -```ts -value: Unconstrained; -``` - -#### Source - -[lib/provable/packed.ts:205](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L205) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/packed.ts:288](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L288) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/packed.ts:287](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L287) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof Hashed -``` - -#### Returns - -*typeof* [`Hashed`](Hashed.mdx) - -#### Source - -[lib/provable/packed.ts:290](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L290) - -*** - -### innerProvable - -```ts -get static innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`any`\> - -#### Source - -[lib/provable/packed.ts:294](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L294) - -## Methods - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/packed.ts:282](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L282) - -*** - -### unhash() - -```ts -unhash(): T -``` - -Unwrap a value from its hashed variant. - -#### Returns - -`T` - -#### Source - -[lib/provable/packed.ts:270](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L270) - -*** - -### \_hash() - -```ts -static _hash(_: any): Field -``` - -#### Parameters - -• **\_**: `any` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/packed.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L246) - -*** - -### create() - -```ts -static create(type: WithProvable>, hash?: (t: T) => Field): typeof Hashed & { - "provable": ProvableHashable>; - "empty": Hashed; -} -``` - -Create a hashed representation of `type`. You can then use `HashedType.hash(x)` to wrap a value in a `Hashed`. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **hash?** - -#### Returns - -*typeof* [`Hashed`](Hashed.mdx) & \{ - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`Hashed`](Hashed.mdx)\<`T`\>\>; - `"empty"`: [`Hashed`](Hashed.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/packed.ts:210](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L210) - -*** - -### hash() - -```ts -static hash(value: T, hash?: Field): Hashed -``` - -Wrap a value, and represent it by its hash in provable code. - -```ts -let hashed = HashedType.hash(value); -``` - -Optionally, if you already have the hash, you can pass it in and avoid recomputing it. - -#### Type parameters - -• **T** - -#### Parameters - -• **value**: `T` - -• **hash?**: [`Field`](Field.mdx) - -#### Returns - -[`Hashed`](Hashed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L259) - ---- -url: /zkapps/o1js-reference/classes/Int64 ---- - -A 64 bit signed integer with values ranging from -18,446,744,073,709,551,615 to 18,446,744,073,709,551,615. - -## Extends - -- `CircuitValue` - -## Implements - -- `BalanceChange` - -## Constructors - -### new Int64() - -```ts -new Int64(magnitude: UInt64, sgn?: Sign): Int64 -``` - -#### Parameters - -• **magnitude**: [`UInt64`](UInt64.mdx) - -The magnitude of the integer as a UInt64. - -• **sgn?**: [`Sign`](Sign.mdx)= `Sign.one` - -The sign of the integer. Default is positive (Sign.one). - -#### Returns - -[`Int64`](Int64.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Deprecated - -Use [Int64.create](Int64.mdx#create) for safe creation. - -WARNING: This constructor allows for ambiguous representation of zero (both +0 and -0). -This can lead to unexpected behavior in operations like [()](Int64.mdx#ispositive) and [()](Int64.mdx#mod). - -Security Implications: -1. A malicious prover could choose either positive or negative zero. -2. Arithmetic operations that result in 0 may allow an attacker to arbitrarily choose the sign. -3. This ambiguity could be exploited in protocols using Int64s for calculations like PNL tracking. - -Recommended Fix: -Use Int64.create() which enforces a canonical representation of zero, or -explicitly handle the zero case in operations like mod(). - -#### Source - -[lib/provable/int.ts:1141](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1141) - -## Properties - -### magnitude - -```ts -magnitude: UInt64; -``` - -#### Implementation of - -`BalanceChange.magnitude` - -#### Source - -[lib/provable/int.ts:1100](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1100) - -*** - -### sgn - -```ts -sgn: Sign; -``` - -#### Implementation of - -`BalanceChange.sgn` - -#### Source - -[lib/provable/int.ts:1101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1101) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromObject": Int64; -}; -``` - -#### fromObject() - -##### Parameters - -• **obj** - -• **obj.magnitude**: [`UInt64`](UInt64.mdx) - -• **obj.sgn**: [`Sign`](Sign.mdx) - -##### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1206](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1206) - -## Accessors - -### minusOne - -```ts -get static minusOne(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `-1`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1258) - -*** - -### one - -```ts -get static one(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `1`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1252](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1252) - -*** - -### zero - -```ts -get static zero(): Int64 -``` - -Static method to create a [Int64](Int64.mdx) with value `0`. - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1246) - -## Methods - -### add() - -```ts -add(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.add` - -#### Source - -[lib/provable/int.ts:1309](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1309) - -*** - -### assertEquals() - -```ts -assertEquals(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64, message?: string): void -``` - -Asserts that two values are equal. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Implementation of - -`BalanceChange.assertEquals` - -#### Overrides - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/int.ts:1391](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1391) - -*** - -### div() - -```ts -div(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Integer division with canonical zero representation. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -The divisor. Can be an Int64, number, string, bigint, UInt64, or UInt32. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 representing the quotient, with canonical zero representation. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -*`z`* such that *`z * y <= x`. -On negative numbers, this rounds towards zero. - -This method guarantees that all results, including zero, have a consistent -representation, eliminating potential ambiguities in zero handling. - -#### Implementation of - -`BalanceChange.div` - -#### Source - -[lib/provable/int.ts:1341](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1341) - -*** - -### equals() - -```ts -equals(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Bool -``` - -Checks if two values are equal. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.equals` - -#### Overrides - -`CircuitValue.equals` - -#### Source - -[lib/provable/int.ts:1384](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1384) - -*** - -### fromObject() - -```ts -fromObject(obj: { - "magnitude": string | number | bigint | UInt64; - "sgn": bigint | Sign; - }): Int64 -``` - -#### Parameters - -• **obj** - -• **obj.magnitude**: `string` \| `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **obj.sgn**: `bigint` \| [`Sign`](Sign.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.fromObject` - -#### Source - -[lib/provable/int.ts:1212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1212) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Implementation of - -`BalanceChange.isConstant` - -#### Overrides - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/int.ts:1235](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1235) - -*** - -### isNegative() - -```ts -isNegative(): Bool -``` - -Checks if the value is negative (x < 0). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.isNegative` - -#### Source - -[lib/provable/int.ts:1424](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1424) - -*** - -### isNonNegative() - -```ts -isNonNegative(): Bool -``` - -Checks if the value is non-negative (x >= 0). - -#### Returns - -[`Bool`](Bool.mdx) - -#### Implementation of - -`BalanceChange.isNonNegative` - -#### Source - -[lib/provable/int.ts:1416](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1416) - -*** - -### isPositive() - -```ts -isPositive(): Bool -``` - -Checks if the value is strictly positive (x > 0). - -#### Returns - -[`Bool`](Bool.mdx) - -True if the value is greater than zero, false otherwise. - -#### Implementation of - -`BalanceChange.isPositive` - -#### Remarks - -This method considers zero as non-positive. It ensures consistency -with the mathematical definition of "positive" as strictly greater than zero. -This differs from some other methods which may treat zero as non-negative. - -#### Source - -[lib/provable/int.ts:1409](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1409) - -*** - -### mod() - -```ts -mod(y: - | string - | number - | bigint - | UInt64 - | UInt32): Int64 -``` - -Calculates the integer remainder of this Int64 divided by the given value. - -The result `z` satisfies the following conditions: -1. 0 ≤ z < |y| -2. x - z is divisible by y - -Note: This method follows the "truncate toward zero" convention for negative numbers. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -The divisor. Will be converted to UInt64 if not already. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance representing the remainder. - -#### Implementation of - -`BalanceChange.mod` - -#### Example - -```ts -const x1 = Int64.from(17); -const y1 = UInt64.from(5); -console.log(x1.mod(y1).toString()); // Output: 2 -``` - -#### Throws - -Implicitly, if y is zero or negative. - -#### Source - -[lib/provable/int.ts:1369](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1369) - -*** - -### mul() - -```ts -mul(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.mul` - -#### Source - -[lib/provable/int.ts:1323](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1323) - -*** - -### neg() - -```ts -neg(): Int64 -``` - -Negates the current Int64 value. - -This method returns a new Int64 instance with the opposite sign of the current value. -If the current value is zero, it returns zero. - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance with the negated value. - -#### Implementation of - -`BalanceChange.neg` - -#### Example - -```ts -Int64.from(5).neg(); -``` - -#### See - - - Int64#from for creating Int64 instances - - Int64#zero for the zero constant - -#### Throws - -Implicitly, if the internal Provable.if condition fails - -#### Source - -[lib/provable/int.ts:1298](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1298) - -*** - -### sub() - -```ts -sub(y: - | string - | number - | bigint - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Implementation of - -`BalanceChange.sub` - -#### Source - -[lib/provable/int.ts:1316](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1316) - -*** - -### toBigint() - -```ts -toBigint(): bigint -``` - -Turns the [Int64](Int64.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Implementation of - -`BalanceChange.toBigint` - -#### Source - -[lib/provable/int.ts:1222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1222) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Implementation of - -`BalanceChange.toConstant` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toField() - -```ts -toField(): Field -``` - -Returns the [Field](../variables/Field.mdx) value. - -#### Returns - -[`Field`](Field.mdx) - -#### Implementation of - -`BalanceChange.toField` - -#### Source - -[lib/provable/int.ts:1265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1265) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Implementation of - -`BalanceChange.toFields` - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Implementation of - -`BalanceChange.toJSON` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [Int64](Int64.mdx) into a string. - -#### Returns - -`string` - -#### Implementation of - -`BalanceChange.toString` - -#### Source - -[lib/provable/int.ts:1231](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1231) - -*** - -### check() - -```ts -static check(__namedParameters: { - "magnitude": UInt64; - "sgn": Sign; - }): void -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.magnitude**: [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.sgn**: [`Sign`](Sign.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:1428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1428) - -*** - -### create() - -```ts -static create(magnitude: UInt64, sign: Sign): Int64 -``` - -Safely creates a new Int64 instance, enforcing canonical representation of zero. -This is the recommended way to create Int64 instances. - -#### Parameters - -• **magnitude**: [`UInt64`](UInt64.mdx) - -The magnitude of the integer as a UInt64 - -• **sign**: [`Sign`](Sign.mdx)= `Sign.one` - -#### Returns - -[`Int64`](Int64.mdx) - -A new Int64 instance with a canonical representation. - -#### Example - -```ts -const x = Int64.create(0); // canonical representation of zero -``` - -#### Source - -[lib/provable/int.ts:1158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1158) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | Field - | UInt64 - | UInt32 - | Int64): Int64 -``` - -Creates a new [Int64](Int64.mdx). - -Check the range if the argument is a constant. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`Field`](Field.mdx) - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1198](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1198) - -*** - -### fromField() - -```ts -static fromField(x: Field): Int64 -``` - -Static method to create a [Int64](Int64.mdx) from a [Field](../variables/Field.mdx). - -#### Parameters - -• **x**: [`Field`](Field.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1271](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1271) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromUnsigned() - -```ts -static fromUnsigned(x: UInt64 | UInt32): Int64 -``` - -Creates a new [Int64](Int64.mdx) from a [Field](../variables/Field.mdx). - -**Does not** check if the [Field](../variables/Field.mdx) is within range. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`Int64`](Int64.mdx) - -#### Source - -[lib/provable/int.ts:1188](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1188) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) - ---- -url: /zkapps/o1js-reference/classes/Keypair ---- - -## Constructors - -### new Keypair() - -```ts -new Keypair(value: unknown): Keypair -``` - -#### Parameters - -• **value**: `unknown` - -#### Returns - -[`Keypair`](Keypair.mdx) - -#### Source - -[lib/proof-system/circuit.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L104) - -## Properties - -### value - -```ts -value: unknown; -``` - -#### Source - -[lib/proof-system/circuit.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L102) - -## Methods - -### constraintSystem() - -```ts -constraintSystem(): Gate[] -``` - -Returns a low-level JSON representation of the [Circuit](Circuit.mdx) from its [Keypair](Keypair.mdx): -a list of gates, each of which represents a row in a table, with certain coefficients and wires to other (row, column) pairs - -#### Returns - -`Gate`[] - -#### Example - -```ts -const keypair = await MyCircuit.generateKeypair(); -const json = MyProvable.witnessFromKeypair(keypair); -``` - -#### Source - -[lib/proof-system/circuit.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L123) - -*** - -### verificationKey() - -```ts -verificationKey(): VerificationKey -``` - -#### Returns - -`VerificationKey` - -#### Source - -[lib/proof-system/circuit.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L108) - ---- -url: /zkapps/o1js-reference/classes/Ledger ---- - -Represents the Mina ledger. - -## Constructors - -### new Ledger() - -```ts -new Ledger(): Ledger -``` - -#### Returns - -[`Ledger`](Ledger.mdx) - -## Methods - -### addAccount() - -```ts -addAccount(publicKey: MlPublicKey, balance: string): void -``` - -Adds an account and its balance to the ledger. - -#### Parameters - -• **publicKey**: `MlPublicKey` - -• **balance**: `string` - -#### Returns - -`void` - -#### Source - -[snarky.d.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L492) - -*** - -### applyJsonTransaction() - -```ts -applyJsonTransaction( - txJson: string, - accountCreationFee: string, - networkState: string): void -``` - -Applies a JSON transaction to the ledger. - -#### Parameters - -• **txJson**: `string` - -• **accountCreationFee**: `string` - -• **networkState**: `string` - -#### Returns - -`void` - -#### Source - -[snarky.d.ts:497](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L497) - -*** - -### getAccount() - -```ts -getAccount(publicKey: MlPublicKey, tokenId: FieldConst): undefined | Account -``` - -Returns an account. - -#### Parameters - -• **publicKey**: `MlPublicKey` - -• **tokenId**: `FieldConst` - -#### Returns - -`undefined` \| `Account` - -#### Source - -[snarky.d.ts:506](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L506) - -*** - -### create() - -```ts -static create(): Ledger -``` - -Creates a fresh ledger. - -#### Returns - -[`Ledger`](Ledger.mdx) - -#### Source - -[snarky.d.ts:487](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L487) - ---- -url: /zkapps/o1js-reference/classes/MerkleList ---- - -Dynamic-length list which is represented as a single hash - -Supported operations are [()](MerkleList.mdx#push) and [()](MerkleList.mdx#pop) and some variants thereof. - -A Merkle list is generic over its element types, so before using it you must create a subclass for your element type: - -```ts -class MyList extends MerkleList.create(MyType) {} - -// now use it -let list = MyList.empty(); - -list.push(new MyType(...)); - -let element = list.pop(); -``` - -Internal detail: `push()` adds elements to the _start_ of the internal array and `pop()` removes them from the start. -This is so that the hash which represents the list is consistent with [MerkleListIterator](MerkleListIterator.mdx), -and so a `MerkleList` can be used as input to `MerkleListIterator.startIterating(list)` -(which will then iterate starting from the last pushed element). - -## Extended by - -- [`AccountUpdateForest`](AccountUpdateForest.mdx) - -## Type parameters - -• **T** - -## Implements - -- [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\> - -## Constructors - -### new MerkleList() - -```ts -new MerkleList(__namedParameters: MerkleListBase): MerkleList -``` - -#### Parameters - -• **\_\_namedParameters**: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\> - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L84) - -## Properties - -### data - -```ts -data: Unconstrained[]>; -``` - -#### Implementation of - -`MerkleListBase.data` - -#### Source - -[lib/provable/merkle-list.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L82) - -*** - -### hash - -```ts -hash: Field; -``` - -#### Implementation of - -`MerkleListBase.hash` - -#### Source - -[lib/provable/merkle-list.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L81) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L350) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/merkle-list.ts:353](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L353) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, t: any) => Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:349](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L349) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/merkle-list.ts:352](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L352) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleList -``` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) - -#### Source - -[lib/provable/merkle-list.ts:355](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L355) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:372](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L372) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:367](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L367) - -## Methods - -### clone() - -```ts -clone(): MerkleList -``` - -#### Returns - -[`MerkleList`](MerkleList.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:223](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L223) - -*** - -### forEach() - -```ts -forEach(length: number, callback: (element: T, isDummy: Bool, i: number) => void): void -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -#### Parameters - -• **length**: `number` - -• **callback** - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:237](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L237) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L89) - -*** - -### lengthUnconstrained() - -```ts -lengthUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`number`\> - -#### Source - -[lib/provable/merkle-list.ts:267](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L267) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: T): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: `T` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:359](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L359) - -*** - -### pop() - -```ts -pop(): T -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L155) - -*** - -### popExn() - -```ts -popExn(): T -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L140) - -*** - -### popIf() - -```ts -popIf(condition: Bool): T -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L174) - -*** - -### popIfUnsafe() - -```ts -popIfUnsafe(shouldPop: Bool): T -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -#### Parameters - -• **shouldPop**: [`Bool`](Bool.mdx) - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:200](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L200) - -*** - -### push() - -```ts -push(element: T): void -``` - -Push a new element to the list. - -#### Parameters - -• **element**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:96](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L96) - -*** - -### pushIf() - -```ts -pushIf(condition: Bool, element: T): void -``` - -Push a new element to the list, if the `condition` is true. - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **element**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L108) - -*** - -### startIterating() - -```ts -startIterating(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L251) - -*** - -### startIteratingFromLast() - -```ts -startIteratingFromLast(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L256) - -*** - -### toArrayUnconstrained() - -```ts -toArrayUnconstrained(): Unconstrained -``` - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`[]\> - -#### Source - -[lib/provable/merkle-list.ts:261](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L261) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleList & { - "empty": () => MerkleList; - "from": (array: T[]) => MerkleList; - "fromReverse": (array: T[]) => MerkleList; - "provable": ProvableHashable>; -} -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleList`](MerkleList.mdx) & \{ - `"empty"`: () => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"fromReverse"`: (`array`: `T`[]) => [`MerkleList`](MerkleList.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleList`](MerkleList.mdx)\<`T`\>\>; - \} - -#### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -#### Source - -[lib/provable/merkle-list.ts:283](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L283) - ---- -url: /zkapps/o1js-reference/classes/MerkleListIterator ---- - -MerkleListIterator helps iterating through a Merkle list. -This works similar to calling `list.pop()` or `list.push()` repeatedly, but maintaining the entire list instead of removing elements. - -The core methods that support iteration are [()](MerkleListIterator.mdx#next) and [()](MerkleListIterator.mdx#previous). - -```ts -let iterator = MerkleListIterator.startIterating(list); - -let firstElement = iterator.next(); -``` - -We maintain two commitments: -- One to the entire array, to be able to prove that we end iteration at the correct point. -- One to the array from the current index until the end, to efficiently step forward. - -## Type parameters - -• **T** - -## Implements - -- [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\> - -## Constructors - -### new MerkleListIterator() - -```ts -new MerkleListIterator(value: MerkleListIteratorBase): MerkleListIterator -``` - -#### Parameters - -• **value**: [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\> - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:426](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L426) - -## Properties - -### currentHash - -```ts -currentHash: Field; -``` - -#### Implementation of - -`MerkleListIteratorBase.currentHash` - -#### Source - -[lib/provable/merkle-list.ts:423](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L423) - -*** - -### currentIndex - -```ts -currentIndex: Unconstrained; -``` - -#### Implementation of - -`MerkleListIteratorBase.currentIndex` - -#### Source - -[lib/provable/merkle-list.ts:424](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L424) - -*** - -### data - -```ts -readonly data: Unconstrained[]>; -``` - -#### Implementation of - -`MerkleListIteratorBase.data` - -#### Source - -[lib/provable/merkle-list.ts:419](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L419) - -*** - -### hash - -```ts -readonly hash: Field; -``` - -#### Implementation of - -`MerkleListIteratorBase.hash` - -#### Source - -[lib/provable/merkle-list.ts:420](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L420) - -*** - -### \_emptyHash - -```ts -static _emptyHash: undefined | Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:722](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L722) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/merkle-list.ts:725](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L725) - -*** - -### \_nextHash - -```ts -static _nextHash: undefined | (hash: Field, value: any) => Field; -``` - -#### Source - -[lib/provable/merkle-list.ts:721](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L721) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/merkle-list.ts:724](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L724) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof MerkleListIterator -``` - -#### Returns - -*typeof* [`MerkleListIterator`](MerkleListIterator.mdx) - -#### Source - -[lib/provable/merkle-list.ts:727](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L727) - -*** - -### Unsafe - -```ts -get Unsafe(): { - "next": { - "element": T; - "isDummy": Bool; - }; - "previous": { - "element": T; - "isDummy": Bool; - }; -} -``` - -Low-level APIs for advanced uses - -#### Returns - -```ts -{ - "next": { - "element": T; - "isDummy": Bool; - }; - "previous": { - "element": T; - "isDummy": Bool; - }; -} -``` - -##### next() - -Version of next which doesn't guarantee anything about -the returned element in case the iterator is at the end. - -Instead, the `isDummy` flag is also returned so that this case can -be handled in a custom way. - -###### Returns - -```ts -{ - "element": T; - "isDummy": Bool; -} -``` - -###### element - -```ts -element: T; -``` - -###### isDummy - -```ts -isDummy: Bool; -``` - -##### previous() - -Version of previous which doesn't guarantee anything about -the returned element in case the iterator is at the start. - -Instead, the `isDummy` flag is also returned so that this case can -be handled in a custom way. - -###### Returns - -```ts -{ - "element": T; - "isDummy": Bool; -} -``` - -###### element - -```ts -element: T; -``` - -###### isDummy - -```ts -isDummy: Bool; -``` - -#### Source - -[lib/provable/merkle-list.ts:556](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L556) - -*** - -### innerProvable - -```ts -get innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:744](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L744) - -*** - -### emptyHash - -```ts -get static emptyHash(): Field -``` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:739](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L739) - -## Methods - -### \_index() - -```ts -_index(direction: "next" | "previous", i?: number): number -``` - -#### Parameters - -• **direction**: `"next"` \| `"previous"` - -• **i?**: `number` - -#### Returns - -`number` - -#### Source - -[lib/provable/merkle-list.ts:483](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L483) - -*** - -### \_updateIndex() - -```ts -_updateIndex(direction: "next" | "previous"): void -``` - -#### Parameters - -• **direction**: `"next"` \| `"previous"` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:491](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L491) - -*** - -### assertAtEnd() - -```ts -assertAtEnd(message?: string): void -``` - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:452](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L452) - -*** - -### assertAtStart() - -```ts -assertAtStart(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:430](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L430) - -*** - -### clone() - -```ts -clone(): MerkleListIterator -``` - -#### Returns - -[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> - -#### Source - -[lib/provable/merkle-list.ts:613](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L613) - -*** - -### isAtEnd() - -```ts -isAtEnd(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:434](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L434) - -*** - -### isAtStart() - -```ts -isAtStart(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/merkle-list.ts:459](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L459) - -*** - -### jumpToEnd() - -```ts -jumpToEnd(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:438](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L438) - -*** - -### jumpToEndIf() - -```ts -jumpToEndIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:443](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L443) - -*** - -### jumpToStart() - -```ts -jumpToStart(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L463) - -*** - -### jumpToStartIf() - -```ts -jumpToStartIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-list.ts:470](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L470) - -*** - -### next() - -```ts -next(): T -``` - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:529](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L529) - -*** - -### nextHash() - -```ts -nextHash(hash: Field, value: T): Field -``` - -#### Parameters - -• **hash**: [`Field`](Field.mdx) - -• **value**: `T` - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/provable/merkle-list.ts:731](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L731) - -*** - -### previous() - -```ts -previous(): T -``` - -#### Returns - -`T` - -#### Source - -[lib/provable/merkle-list.ts:498](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L498) - -*** - -### create() - -```ts -static create( - type: WithProvable>, - nextHash: (hash: Field, value: T) => Field, - emptyHash_: Field): typeof MerkleListIterator & { - "empty": () => MerkleListIterator; - "from": (array: T[]) => MerkleListIterator; - "provable": ProvableHashable>; - "startIterating": (list: MerkleListBase) => MerkleListIterator; - "startIteratingFromLast": (list: MerkleListBase) => MerkleListIterator; -} -``` - -Create a Merkle array type - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\>\> - -• **nextHash**= `undefined` - -• **emptyHash\_**: [`Field`](Field.mdx)= `emptyHash` - -#### Returns - -*typeof* [`MerkleListIterator`](MerkleListIterator.mdx) & \{ - `"empty"`: () => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>\>; - `"startIterating"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"startIteratingFromLast"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/merkle-list.ts:627](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L627) - -*** - -### createFromList() - -```ts -static createFromList(merkleList: typeof MerkleList): (value: MerkleListIteratorBase) => MerkleListIterator & { - "empty": () => MerkleListIterator; - "from": (array: T[]) => MerkleListIterator; - "provable": ProvableHashable>; - "startIterating": (list: MerkleListBase) => MerkleListIterator; - "startIteratingFromLast": (list: MerkleListBase) => MerkleListIterator; -} -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **merkleList**: *typeof* [`MerkleList`](MerkleList.mdx) - -#### Returns - -(`value`: [`MerkleListIteratorBase`](../type-aliases/MerkleListIteratorBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\> & \{ - `"empty"`: () => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"from"`: (`array`: `T`[]) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>\>; - `"startIterating"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - `"startIteratingFromLast"`: (`list`: [`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>) => [`MerkleListIterator`](MerkleListIterator.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/merkle-list.ts:712](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L712) - ---- -url: /zkapps/o1js-reference/classes/MerkleMap ---- - -## Constructors - -### new MerkleMap() - -```ts -new MerkleMap(): MerkleMap -``` - -Creates a new, empty Merkle Map. - -#### Returns - -[`MerkleMap`](MerkleMap.mdx) - -A new MerkleMap - -#### Example - -```ts -const merkleMap = new MerkleMap(); -``` - -#### Source - -[lib/provable/merkle-map.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L21) - -## Properties - -### tree - -```ts -tree: MerkleTree; -``` - -#### Source - -[lib/provable/merkle-map.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L11) - -## Methods - -### \_keyToIndex() - -```ts -_keyToIndex(key: Field): bigint -``` - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/merkle-map.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L25) - -*** - -### get() - -```ts -get(key: Field): Field -``` - -Returns a value given a key. Values are by default Field(0). - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to get the value from. - -#### Returns - -[`Field`](Field.mdx) - -The value stored at the key. - -#### Example - -```ts -const key = Field(5); -const value = merkleMap.get(key); -console.log(value); // Output: the value at key 5 or Field(0) if key does not exist -``` - -#### Source - -[lib/provable/merkle-map.ts:71](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L71) - -*** - -### getRoot() - -```ts -getRoot(): Field -``` - -Returns the root of the Merkle Map. - -#### Returns - -[`Field`](Field.mdx) - -The root of the Merkle Map. - -#### Example - -```ts -const root = merkleMap.getRoot(); -``` - -#### Source - -[lib/provable/merkle-map.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L84) - -*** - -### getWitness() - -```ts -getWitness(key: Field): MerkleMapWitness -``` - -Returns a circuit-compatible witness (also known as [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof)) for the given key. - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to make a witness for. - -#### Returns - -[`MerkleMapWitness`](MerkleMapWitness.mdx) - -A MerkleMapWitness, which can be used to assert changes to the MerkleMap, and the witness's key. - -#### Example - -```ts -const key = Field(5); -const witness = merkleMap.getWitness(key); -``` - -#### Source - -[lib/provable/merkle-map.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L98) - -*** - -### set() - -```ts -set(key: Field, value: Field): void -``` - -Sets a key of the merkle map to a given value. - -#### Parameters - -• **key**: [`Field`](Field.mdx) - -The key to set in the map. - -• **value**: [`Field`](Field.mdx) - -The value to set. - -#### Returns - -`void` - -#### Example - -```ts -const key = Field(5); -const value = Field(10); -merkleMap.set(key, value); -``` - -#### Source - -[lib/provable/merkle-map.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L55) - ---- -url: /zkapps/o1js-reference/classes/MerkleMapWitness ---- - -## Extends - -- `CircuitValue` - -## Constructors - -### new MerkleMapWitness() - -```ts -new MerkleMapWitness(isLefts: Bool[], siblings: Field[]): MerkleMapWitness -``` - -#### Parameters - -• **isLefts**: [`Bool`](Bool.mdx)[] - -• **siblings**: [`Field`](Field.mdx)[] - -#### Returns - -[`MerkleMapWitness`](MerkleMapWitness.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/merkle-map.ts:110](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L110) - -## Properties - -### isLefts - -```ts -isLefts: Bool[]; -``` - -#### Source - -[lib/provable/merkle-map.ts:107](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L107) - -*** - -### siblings - -```ts -siblings: Field[]; -``` - -#### Source - -[lib/provable/merkle-map.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L108) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### computeRootAndKey() - -```ts -computeRootAndKey(value: Field): Field[] -``` - -Computes the merkle tree root for a given value and the key for this witness - -#### Parameters - -• **value**: [`Field`](Field.mdx) - -The value to compute the root for. - -#### Returns - -[`Field`](Field.mdx)[] - -A tuple of the computed merkle root, and the key that is connected to the path updated by this witness. - -#### Source - -[lib/provable/merkle-map.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-map.ts#L121) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) - ---- -url: /zkapps/o1js-reference/classes/MerkleTree ---- - -A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in which every leaf is the cryptography hash of a piece of data, -and every node is the hash of the concatenation of its two child nodes. - -A Merkle Tree allows developers to easily and securely verify the integrity of large amounts of data. - -Take a look at our [documentation](https://docs.minaprotocol.com/en/zkapps) on how to use Merkle Trees in combination with zkApps and zero knowledge programming! - -Levels are indexed from leaves (level 0) to root (level N - 1). - -## Constructors - -### new MerkleTree() - -```ts -new MerkleTree(height: number): MerkleTree -``` - -Creates a new, empty [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree). - -#### Parameters - -• **height**: `number` - -The height of Merkle Tree. - -#### Returns - -[`MerkleTree`](MerkleTree.mdx) - -A new MerkleTree - -#### Source - -[lib/provable/merkle-tree.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L37) - -## Properties - -### height - -```ts -readonly height: number; -``` - -The height of Merkle Tree. - -#### Source - -[lib/provable/merkle-tree.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L37) - -*** - -### nodes - -```ts -nodes: Record> = {}; -``` - -#### Source - -[lib/provable/merkle-tree.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L29) - -*** - -### zeroes - -```ts -zeroes: Field[]; -``` - -#### Source - -[lib/provable/merkle-tree.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L30) - -## Accessors - -### leafCount - -```ts -get leafCount(): bigint -``` - -Returns the amount of leaf nodes. - -#### Returns - -`bigint` - -Amount of leaf nodes. - -#### Source - -[lib/provable/merkle-tree.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L166) - -## Methods - -### clone() - -```ts -clone(): MerkleTree -``` - -Return a new MerkleTree with the same contents as this one. - -#### Returns - -[`MerkleTree`](MerkleTree.mdx) - -#### Source - -[lib/provable/merkle-tree.ts:48](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L48) - -*** - -### fill() - -```ts -fill(leaves: Field[]): void -``` - -Fills all leaves of the tree. - -#### Parameters - -• **leaves**: [`Field`](Field.mdx)[] - -Values to fill the leaves with. - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-tree.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L156) - -*** - -### getLeaf() - -```ts -getLeaf(key: bigint): Field -``` - -Returns a leaf at a given index. - -#### Parameters - -• **key**: `bigint` - -#### Returns - -[`Field`](Field.mdx) - -The data of the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:71](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L71) - -*** - -### getNode() - -```ts -getNode(level: number, index: bigint): Field -``` - -Returns a node which lives at a given index and level. - -#### Parameters - -• **level**: `number` - -Level of the node. - -• **index**: `bigint` - -Index of the node. - -#### Returns - -[`Field`](Field.mdx) - -The data of the node. - -#### Source - -[lib/provable/merkle-tree.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L62) - -*** - -### getRoot() - -```ts -getRoot(): Field -``` - -Returns the root of the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree). - -#### Returns - -[`Field`](Field.mdx) - -The root of the Merkle Tree. - -#### Source - -[lib/provable/merkle-tree.ts:79](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L79) - -*** - -### getWitness() - -```ts -getWitness(index: bigint): Witness -``` - -Returns the witness (also known as [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof)) for the leaf at the given index. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -#### Returns - -[`Witness`](../type-aliases/Witness.mdx) - -The witness that belongs to the leaf. - -#### Source - -[lib/provable/merkle-tree.ts:117](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L117) - -*** - -### setLeaf() - -```ts -setLeaf(index: bigint, leaf: Field): void -``` - -Sets the value of a leaf node at a given index to a given value. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -• **leaf**: [`Field`](Field.mdx) - -New value. - -#### Returns - -`void` - -#### Source - -[lib/provable/merkle-tree.ts:94](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L94) - -*** - -### validate() - -```ts -validate(index: bigint): boolean -``` - -Checks if the witness that belongs to the leaf at the given index is a valid witness. - -#### Parameters - -• **index**: `bigint` - -Position of the leaf node. - -#### Returns - -`boolean` - -True if the witness for the leaf node is valid. - -#### Source - -[lib/provable/merkle-tree.ts:139](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L139) - ---- -url: /zkapps/o1js-reference/classes/Nullifier ---- - -Nullifiers are used as a public commitment to a specific anonymous account, -to forbid actions like double spending, or allow a consistent identity between anonymous actions. - -RFC: https://github.com/o1-labs/o1js/issues/756 - -Paper: https://eprint.iacr.org/2022/1255.pdf - -## Extends - -- \{ - `"private"`: \{ - `"c"`: `Field`; - `"g_r"`: `Group`; - `"h_m_pk_r"`: `Group`; - \}; - `"public"`: \{ - `"nullifier"`: `Group`; - `"s"`: `Scalar`; - \}; - `"publicKey"`: `Group`; - \} - -## Constructors - -### new Nullifier() - -```ts -new Nullifier(value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }): Nullifier -``` - -#### Parameters - -• **value** - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -[`Nullifier`](Nullifier.mdx) - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -#### c - -```ts -c: Field = Field; -``` - -#### g\_r - -```ts -g_r: Group = Group; -``` - -#### h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).private` - -#### Source - -[lib/provable/crypto/nullifier.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L26) - -*** - -### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -#### nullifier - -```ts -nullifier: Group = Group; -``` - -#### s - -```ts -s: Scalar = Scalar; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).public` - -#### Source - -[lib/provable/crypto/nullifier.ts:22](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L22) - -*** - -### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).publicKey` - -#### Source - -[lib/provable/crypto/nullifier.ts:21](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L21) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -`void` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - } | { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - } & (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.private?**= `undefined` - -• **value.private.c?**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r?**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r?**: [`Group`](Group.mdx)= `Group` - -• **value.public?**= `undefined` - -• **value.public.nullifier?**: [`Group`](Group.mdx)= `Group` - -• **value.public.s?**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey?**: [`Group`](Group.mdx)= `Group` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: Field = Field; -``` - -##### private.g\_r - -```ts -g_r: Group = Group; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: Group = Group; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: Group = Group; -``` - -##### public.s - -```ts -s: Scalar = Scalar; -``` - -##### publicKey - -```ts -publicKey: Group = Group; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.private**= `undefined` - -• **value.private.c**: [`Field`](Field.mdx)= `Field` - -• **value.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **value.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **value.public**= `undefined` - -• **value.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **value.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **value.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: string = Field; -``` - -##### private.g\_r - -```ts -g_r: { - "x": string; - "y": string; - } = Group; -``` - -##### private.g\_r.x - -```ts -x: string; -``` - -##### private.g\_r.y - -```ts -y: string; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: { - "x": string; - "y": string; - } = Group; -``` - -##### private.h\_m\_pk\_r.x - -```ts -x: string; -``` - -##### private.h\_m\_pk\_r.y - -```ts -y: string; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: { - "x": string; - "y": string; - } = Group; -``` - -##### public.nullifier.x - -```ts -x: string; -``` - -##### public.nullifier.y - -```ts -y: string; -``` - -##### public.s - -```ts -s: string = Scalar; -``` - -##### publicKey - -```ts -publicKey: { - "x": string; - "y": string; - } = Group; -``` - -##### publicKey.x - -```ts -x: string; -``` - -##### publicKey.y - -```ts -y: string; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; - }) => { - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.private**= `undefined` - -• **x.private.c**: [`Field`](Field.mdx)= `Field` - -• **x.private.g\_r**: [`Group`](Group.mdx)= `Group` - -• **x.private.h\_m\_pk\_r**: [`Group`](Group.mdx)= `Group` - -• **x.public**= `undefined` - -• **x.public.nullifier**: [`Group`](Group.mdx)= `Group` - -• **x.public.s**: [`Scalar`](Scalar.mdx)= `Scalar` - -• **x.publicKey**: [`Group`](Group.mdx)= `Group` - -#### Returns - -```ts -{ - "private": { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; - }; - "public": { - "nullifier": Group; - "s": Scalar; - }; - "publicKey": Group; -} -``` - -##### private - -```ts -private: { - "c": Field; - "g_r": Group; - "h_m_pk_r": Group; -}; -``` - -##### private.c - -```ts -c: bigint = Field; -``` - -##### private.g\_r - -```ts -g_r: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### private.g\_r.x - -```ts -x: bigint; -``` - -##### private.g\_r.y - -```ts -y: bigint; -``` - -##### private.h\_m\_pk\_r - -```ts -h_m_pk_r: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### private.h\_m\_pk\_r.x - -```ts -x: bigint; -``` - -##### private.h\_m\_pk\_r.y - -```ts -y: bigint; -``` - -##### public - -```ts -public: { - "nullifier": Group; - "s": Scalar; -}; -``` - -##### public.nullifier - -```ts -nullifier: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### public.nullifier.x - -```ts -x: bigint; -``` - -##### public.nullifier.y - -```ts -y: bigint; -``` - -##### public.s - -```ts -s: bigint = Scalar; -``` - -##### publicKey - -```ts -publicKey: { - "x": bigint; - "y": bigint; - } = Group; -``` - -##### publicKey.x - -```ts -x: bigint; -``` - -##### publicKey.y - -```ts -y: bigint; -``` - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### assertUnused() - -```ts -assertUnused(witness: MerkleMapWitness, root: Field): void -``` - -Checks if the Nullifier has been used before. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -• **root**: [`Field`](Field.mdx) - -#### Returns - -`void` - -#### Example - -```ts -// asserts that the nullifier has not been used before, throws an error otherwise -nullifier.assertUnused(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:128](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L128) - -*** - -### getPublicKey() - -```ts -getPublicKey(): PublicKey -``` - -Returns the [PublicKey](PublicKey.mdx) that is associated with this Nullifier. - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Example - -```ts -let pk = nullifier.getPublicKey(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L157) - -*** - -### isUnused() - -```ts -isUnused(witness: MerkleMapWitness, root: Field): Bool -``` - -Returns the state of the Nullifier. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -• **root**: [`Field`](Field.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// returns a Bool based on whether or not the nullifier has been used before -let isUnused = nullifier.isUnused(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L108) - -*** - -### key() - -```ts -key(): Field -``` - -The key of the nullifier, which belongs to a unique message and a public key. -Used as an index in Merkle trees. - -#### Returns - -[`Field`](Field.mdx) - -#### Example - -```ts -// returns the key of the nullifier which can be used as index in a Merkle tree/map -let key = nullifier.key(); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:95](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L95) - -*** - -### setUsed() - -```ts -setUsed(witness: MerkleMapWitness): Field -``` - -Sets the Nullifier, returns the new Merkle root. - -#### Parameters - -• **witness**: [`MerkleMapWitness`](MerkleMapWitness.mdx) - -#### Returns - -[`Field`](Field.mdx) - -#### Example - -```ts -// calculates the new root of the Merkle tree in which the nullifier is set to used -let newRoot = nullifier.setUsed(witness); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L143) - -*** - -### verify() - -```ts -verify(message: Field[]): void -``` - -Verifies that the Nullifier belongs to a specific message. Throws an error if the Nullifier is incorrect. - -#### Parameters - -• **message**: [`Field`](Field.mdx)[] - -#### Returns - -`void` - -#### Example - -```ts -let nullifierMessage = [voteId, ...otherData]; -// throws an error if the nullifier is invalid or doesn't belong to this specific message -nullifier.verify(nullifierMessage); -``` - -#### Source - -[lib/provable/crypto/nullifier.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L47) - -*** - -### createTestNullifier() - -```ts -static createTestNullifier(message: Field[], sk: PrivateKey): Nullifier -``` - -_Note_: This is *not* the recommended way to create a Nullifier in production. Please use mina-signer to create Nullifiers. -Also, this function cannot be run within provable code to avoid unintended creations of Nullifiers - a Nullifier should never be created inside proveable code (e.g. a smart contract) directly, but rather created inside the users wallet (or other secure enclaves, so the private key never leaves that enclave). - -PLUME: An ECDSA Nullifier Scheme for Unique -Pseudonymity within Zero Knowledge Proofs -https://eprint.iacr.org/2022/1255.pdf chapter 3 page 14 - -#### Parameters - -• **message**: [`Field`](Field.mdx)[] - -• **sk**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`Nullifier` - -#### Source - -[lib/provable/crypto/nullifier.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L170) - -*** - -### fromJSON() - -```ts -static fromJSON(json: Nullifier): Nullifier -``` - -#### Parameters - -• **json**: `Nullifier` - -#### Returns - -[`Nullifier`](Nullifier.mdx) - -#### Overrides - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).fromJSON` - -#### Source - -[lib/provable/crypto/nullifier.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/nullifier.ts#L32) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - publicKey: Group, - public: { - nullifier: Group, - s: Scalar, - }, - private: { - c: Field, - g_r: Group, - h_m_pk_r: Group, - }, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/classes/Packed ---- - -`Packed` is a "packed" representation of any type `T`. - -"Packed" means that field elements which take up fewer than 254 bits are packed together into -as few field elements as possible. - -For example, you can pack several Bools (1 bit) or UInt32s (32 bits) into a single field element. - -Using a packed representation can make sense in provable code where the number of constraints -depends on the number of field elements per value. - -For example, `Provable.if(bool, x, y)` takes O(n) constraints, where n is the number of field -elements in x and y. - -Usage: - -```ts -// define a packed type from a type -let PackedType = Packed.create(MyType); - -// pack a value -let packed = PackedType.pack(value); - -// ... operations on packed values, more efficient than on plain values ... - -// unpack a value -let value = packed.unpack(); -``` - -**Warning**: Packing only makes sense where packing actually reduces the number of field elements. -For example, it doesn't make sense to pack a _single_ Bool, because it will be 1 field element before -and after packing. On the other hand, it does makes sense to pack a type that holds 10 or 20 Bools. - -**Warning**: When wrapping a type with `Packed`, make sure that that type is safe to automatically _pack_ -and _unpack_ in provable code. In particular, do not use `Packed` with types that define a custom `toInput()` -(specifying a certain bit packing) but no corresponding `check()` method (that constrains the bit lengths of the packed parts). - -## Type parameters - -• **T** - -## Constructors - -### new Packed() - -```ts -new Packed(packed: Field[], value: Unconstrained): Packed -``` - -#### Parameters - -• **packed**: [`Field`](Field.mdx)[] - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Packed`](Packed.mdx)\<`T`\> - -#### Source - -[lib/provable/packed.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L115) - -## Properties - -### packed - -```ts -packed: Field[]; -``` - -#### Source - -[lib/provable/packed.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L51) - -*** - -### value - -```ts -value: Unconstrained; -``` - -#### Source - -[lib/provable/packed.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L52) - -*** - -### \_innerProvable - -```ts -static _innerProvable: undefined | ProvableHashable; -``` - -#### Source - -[lib/provable/packed.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L144) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvableHashable>; -``` - -#### Source - -[lib/provable/packed.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L143) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof Packed -``` - -#### Returns - -*typeof* [`Packed`](Packed.mdx) - -#### Source - -[lib/provable/packed.ts:146](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L146) - -*** - -### innerProvable - -```ts -get static innerProvable(): ProvableHashable -``` - -#### Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`any`\> - -#### Source - -[lib/provable/packed.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L150) - -## Methods - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/packed.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L138) - -*** - -### unpack() - -```ts -unpack(): T -``` - -Unpack a value. - -#### Returns - -`T` - -#### Source - -[lib/provable/packed.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L123) - -*** - -### create() - -```ts -static create(type: WithProvable>): typeof Packed & { - "provable": ProvableHashable, V>; - "pack": Packed; -} -``` - -Create a packed representation of `type`. You can then use `PackedType.pack(x)` to pack a value. - -#### Type parameters - -• **T** - -• **V** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`, `V`\>\> - -#### Returns - -*typeof* [`Packed`](Packed.mdx) & \{ - `"provable"`: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`Packed`](Packed.mdx)\<`T`\>, `V`\>; - `"pack"`: [`Packed`](Packed.mdx)\<`T`\>; - \} - -#### Source - -[lib/provable/packed.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/packed.ts#L57) - ---- -url: /zkapps/o1js-reference/classes/PrivateKey ---- - -A signing key. You can generate one via [PrivateKey.random](PrivateKey.mdx#random). - -## Extends - -- `CircuitValue` - -## Constructors - -### new PrivateKey() - -```ts -new PrivateKey(s: Scalar): PrivateKey -``` - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/crypto/signature.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L25) - -## Properties - -### s - -```ts -s: Scalar; -``` - -#### Source - -[lib/provable/crypto/signature.ts:23](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L23) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [PrivateKey](PrivateKey.mdx) into a base58 string. - -#### Returns - -`string` - -a base58 encoded string - -#### Source - -[lib/provable/crypto/signature.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L105) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this [PrivateKey](PrivateKey.mdx) to a bigint - -#### Returns - -`bigint` - -#### Source - -[lib/provable/crypto/signature.ts:68](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L68) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toPublicKey() - -```ts -toPublicKey(): PublicKey -``` - -Derives the associated public key. - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L87) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromBase58() - -```ts -static fromBase58(privateKeyBase58: string): PrivateKey -``` - -Decodes a base58 string into a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **privateKeyBase58**: `string` - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:96](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L96) - -*** - -### fromBigInt() - -```ts -static fromBigInt(sk: bigint): PrivateKey -``` - -Create a [PrivateKey](PrivateKey.mdx) from a bigint - -**Warning**: Private keys should be sampled from secure randomness with sufficient entropy. -Be careful that you don't use this method to create private keys that were sampled insecurely. - -#### Parameters - -• **sk**: `bigint` - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:78](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L78) - -*** - -### fromBits() - -```ts -static fromBits(bs: Bool[]): PrivateKey -``` - -Deserializes a list of bits into a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **bs**: [`Bool`](Bool.mdx)[] - -a list of [Bool](../variables/Bool.mdx). - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:61](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L61) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, v: bigint | PrivateKey): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `bigint` \| [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/crypto/signature.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L121) - -*** - -### random() - -```ts -static random(): PrivateKey -``` - -Generate a random private key. - -You can obtain the associated public key via [toPublicKey](PrivateKey.mdx#topublickey). -And generate signatures via [Signature.create](Signature.mdx#create). - -Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, -and can be safely used to generate a real private key. - -#### Returns - -[`PrivateKey`](PrivateKey.mdx) - -a new [PrivateKey](PrivateKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L40) - -*** - -### randomKeypair() - -```ts -static randomKeypair(): { - "privateKey": PrivateKey; - "publicKey": PublicKey; -} -``` - -Create a random keypair `{ privateKey: PrivateKey, publicKey: PublicKey }`. - -Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, -and can be safely used to generate a real keypair. - -#### Returns - -```ts -{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -} -``` - -##### privateKey - -```ts -privateKey: PrivateKey; -``` - -##### publicKey - -```ts -publicKey: PublicKey; -``` - -#### Source - -[lib/provable/crypto/signature.ts:50](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L50) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toBase58() - -```ts -static toBase58(privateKey: { - "s": Scalar; - }): string -``` - -Static method to encode a [PrivateKey](PrivateKey.mdx) into a base58 string. - -#### Parameters - -• **privateKey** - -• **privateKey.s**: [`Scalar`](Scalar.mdx) - -#### Returns - -`string` - -a base58 encoded string - -#### Source - -[lib/provable/crypto/signature.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L114) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(v: PrivateKey): bigint -``` - -#### Parameters - -• **v**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/crypto/signature.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L118) - ---- -url: /zkapps/o1js-reference/classes/Proof ---- - -## Extends - -- [`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -## Type parameters - -• **Input** - -• **Output** - -## Constructors - -### new Proof() - -```ts -new Proof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): Proof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`Proof`](Proof.mdx)\<`Input`, `Output`\> - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`constructor`](ProofBase.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`maxProofsVerified`](ProofBase.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`proof`](ProofBase.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInput`](ProofBase.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutput`](ProofBase.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`shouldVerify`](ProofBase.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicInputType`](ProofBase.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicOutputType`](ProofBase.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`tag`](ProofBase.mdx#tag) - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`Proof`](Proof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L165) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`toJSON`](ProofBase.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(): void -``` - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L98) - -*** - -### verifyIf() - -```ts -verifyIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Source - -[lib/proof-system/proof.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L101) - -*** - -### dummy() - -```ts -static dummy( - publicInput: Input, - publicOutput: OutPut, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -Dummy proof. This can be useful for ZkPrograms that handle the base case in the same -method as the inductive case, using a pattern like this: - -```ts -method(proof: SelfProof, isRecursive: Bool) { - proof.verifyIf(isRecursive); - // ... -} -``` - -To use such a method in the base case, you need a dummy proof: - -```ts -let dummy = await MyProof.dummy(publicInput, publicOutput, 1); -await myProgram.myMethod(dummy, Bool(false)); -``` - -**Note**: The types of `publicInput` and `publicOutput`, as well as the `maxProofsVerified` parameter, -must match your ZkProgram. `maxProofsVerified` is the maximum number of proofs that any of your methods take as arguments. - -#### Type parameters - -• **Input** - -• **OutPut** - -#### Parameters - -• **publicInput**: `Input` - -• **publicOutput**: `OutPut` - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<`Input`, `OutPut`\>\> - -#### Source - -[lib/proof-system/proof.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L150) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`Proof`](Proof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Source - -[lib/proof-system/proof.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L105) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`ProofBase`](ProofBase.mdx).[`publicFields`](ProofBase.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) - ---- -url: /zkapps/o1js-reference/classes/ProofBase ---- - -## Extended by - -- [`Proof`](Proof.mdx) -- [`DynamicProof`](DynamicProof.mdx) - -## Type parameters - -• **Input** = `any` - -• **Output** = `any` - -## Constructors - -### new ProofBase() - -```ts -new ProofBase(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": Input; - "publicOutput": Output; -}): ProofBase -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `Input` - -• **\_\_namedParameters.publicOutput**: `Output` - -#### Returns - -[`ProofBase`](ProofBase.mdx)\<`Input`, `Output`\> - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: Input; -``` - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: Output; -``` - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): Provable -``` - -#### Returns - -`Provable`\<`any`\> - -#### Source - -[lib/proof-system/proof.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L66) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) - ---- -url: /zkapps/o1js-reference/classes/PublicKey ---- - -A public key, which is also an address on the Mina network. -You can derive a [PublicKey](PublicKey.mdx) directly from a [PrivateKey](PrivateKey.mdx). - -## Extends - -- `CircuitValue` - -## Constructors - -### new PublicKey() - -```ts -new PublicKey(...props: any[]): PublicKey -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### isOdd - -```ts -isOdd: Bool; -``` - -#### Source - -[lib/provable/crypto/signature.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L138) - -*** - -### x - -```ts -x: Field; -``` - -#### Source - -[lib/provable/crypto/signature.ts:137](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L137) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### isEmpty() - -```ts -isEmpty(): Bool -``` - -Checks if a [PublicKey](PublicKey.mdx) is empty. - -#### Returns - -[`Bool`](Bool.mdx) - -a [Bool](../variables/Bool.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:193](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L193) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [PublicKey](PublicKey.mdx) in base58 format. - -#### Returns - -`string` - -a base58 encoded [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:211](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L211) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toGroup() - -```ts -toGroup(): Group -``` - -Returns the [Group](../variables/Group.mdx) representation of this [PublicKey](PublicKey.mdx). - -#### Returns - -[`Group`](Group.mdx) - -A [Group](../variables/Group.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L144) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -Creates an empty [PublicKey](PublicKey.mdx). - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -an empty [PublicKey](PublicKey.mdx) - -#### Overrides - -`CircuitValue.empty` - -#### Source - -[lib/provable/crypto/signature.ts:185](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L185) - -*** - -### from() - -```ts -static from(g: { - "isOdd": boolean | Bool; - "x": bigint | Field; - }): PublicKey -``` - -Creates a [PublicKey](PublicKey.mdx) from a JSON structure element. - -#### Parameters - -• **g** - -• **g.isOdd**: `boolean` \| [`Bool`](Bool.mdx) - -• **g.x**: `bigint` \| [`Field`](Field.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L177) - -*** - -### fromBase58() - -```ts -static fromBase58(publicKeyBase58: string): PublicKey -``` - -Decodes a base58 encoded [PublicKey](PublicKey.mdx) into a [PublicKey](PublicKey.mdx). - -#### Parameters - -• **publicKeyBase58**: `string` - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:202](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L202) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromGroup() - -```ts -static fromGroup(__namedParameters: Group): PublicKey -``` - -Creates a [PublicKey](PublicKey.mdx) from a [Group](../variables/Group.mdx) element. - -#### Parameters - -• **\_\_namedParameters**: [`Group`](Group.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:161](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L161) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, publicKey: string): InstanceType -``` - -Deserializes a JSON string into a [PublicKey](PublicKey.mdx). - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **publicKey**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -a JSON string - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/crypto/signature.ts:239](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L239) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromPrivateKey() - -```ts -static fromPrivateKey(__namedParameters: PrivateKey): PublicKey -``` - -Derives a [PublicKey](PublicKey.mdx) from a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **\_\_namedParameters**: [`PrivateKey`](PrivateKey.mdx) - -#### Returns - -[`PublicKey`](PublicKey.mdx) - -a [PublicKey](PublicKey.mdx). - -#### Source - -[lib/provable/crypto/signature.ts:169](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L169) - -*** - -### fromValue() - -```ts -static fromValue(this: T, __namedParameters: { - "isOdd": boolean | Bool; - "x": bigint | Field; -}): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **\_\_namedParameters** - -• **\_\_namedParameters.isOdd**: `boolean` \| [`Bool`](Bool.mdx) - -• **\_\_namedParameters.x**: `bigint` \| [`Field`](Field.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/crypto/signature.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L246) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toBase58() - -```ts -static toBase58(__namedParameters: PublicKey): string -``` - -Static method to encode a [PublicKey](PublicKey.mdx) into base58 format. - -#### Parameters - -• **\_\_namedParameters**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -`string` - -a base58 encoded [PublicKey](PublicKey.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L219) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(publicKey: PublicKey): string -``` - -Serializes a [PublicKey](PublicKey.mdx) into its JSON representation. - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -`string` - -a JSON string - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/crypto/signature.ts:231](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L231) - -*** - -### toValue() - -```ts -static toValue(__namedParameters: PublicKey): { - "isOdd": boolean; - "x": bigint; -} -``` - -#### Parameters - -• **\_\_namedParameters**: [`PublicKey`](PublicKey.mdx) - -#### Returns - -```ts -{ - "isOdd": boolean; - "x": bigint; -} -``` - -##### isOdd - -```ts -isOdd: boolean; -``` - -##### x - -```ts -x: bigint; -``` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/crypto/signature.ts:243](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L243) - ---- -url: /zkapps/o1js-reference/classes/Scalar ---- - -Represents a [Scalar](Scalar.mdx). - -## Implements - -- `ShiftedScalar` - -## Properties - -### high254 - -```ts -high254: Field; -``` - -#### Implementation of - -`ShiftedScalar.high254` - -#### Source - -[lib/provable/scalar.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L32) - -*** - -### lowBit - -```ts -lowBit: Bool; -``` - -We represent a scalar s in shifted form t = s - 2^255 mod q, -split into its low bit (t & 1) and high 254 bits (t >> 1). -The reason is that we can efficiently compute the scalar multiplication `(t + 2^255) * P = s * P`. - -#### Implementation of - -`ShiftedScalar.lowBit` - -#### Source - -[lib/provable/scalar.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L31) - -*** - -### ORDER - -```ts -static ORDER: bigint = Fq.modulus; -``` - -#### Source - -[lib/provable/scalar.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L34) - -## Methods - -### add() - -```ts -add(y: Scalar): Scalar -``` - -Add scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:143](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L143) - -*** - -### div() - -```ts -div(y: Scalar): Scalar -``` - -Divide scalar field elements. -Throws if the denominator is zero. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:180](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L180) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Check whether this [Scalar](Scalar.mdx) is a hard-coded constant in the constraint system. -If a [Scalar](Scalar.mdx) is constructed outside provable code, it is a constant. - -#### Returns - -`boolean` - -#### Source - -[lib/provable/scalar.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L75) - -*** - -### mul() - -```ts -mul(y: Scalar): Scalar -``` - -Multiply scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:167](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L167) - -*** - -### neg() - -```ts -neg(): Scalar -``` - -Negate a scalar field element. - -**Warning**: This method is not available for provable code. - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L132) - -*** - -### sub() - -```ts -sub(y: Scalar): Scalar -``` - -Subtract scalar field elements. - -**Warning**: This method is not available for provable code. - -#### Parameters - -• **y**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:155](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L155) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this [Scalar](Scalar.mdx) into a bigint - -#### Returns - -`bigint` - -#### Source - -[lib/provable/scalar.ts:95](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L95) - -*** - -### toConstant() - -```ts -toConstant(): Scalar -``` - -Convert this [Scalar](Scalar.mdx) into a constant if it isn't already. - -If the scalar is a variable, this only works inside `asProver` or `witness` blocks. - -See FieldVar for an explanation of constants vs. variables. - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L87) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Serialize this Scalar to Field elements. - -**Warning**: This function is for internal usage. It returns 255 field elements -which represent the Scalar in a shifted, bitwise format. -The fields are not constrained to be boolean. - -Check out [Scalar.toFieldsCompressed](Scalar.mdx#tofieldscompressed) for a user-friendly serialization -that can be used outside proofs. - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/scalar.ts:233](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L233) - -*** - -### toFieldsCompressed() - -```ts -toFieldsCompressed(): { - "field": Field; - "highBit": Bool; -} -``` - -Serialize a Scalar into a Field element plus one bit, where the bit is represented as a Bool. - -**Warning**: This method is not available for provable code. - -Note: Since the Scalar field is slightly larger than the base Field, an additional high bit -is needed to represent all Scalars. However, for a random Scalar, the high bit will be `false` with overwhelming probability. - -#### Returns - -```ts -{ - "field": Field; - "highBit": Bool; -} -``` - -##### field - -```ts -field: Field; -``` - -##### highBit - -```ts -highBit: Bool; -``` - -#### Source - -[lib/provable/scalar.ts:196](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L196) - -*** - -### toJSON() - -```ts -toJSON(): string -``` - -Serializes this Scalar to a string - -#### Returns - -`string` - -#### Source - -[lib/provable/scalar.ts:325](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L325) - -*** - -### check() - -```ts -static check(s: Scalar): void -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -`void` - -#### Source - -[lib/provable/scalar.ts:287](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L287) - -*** - -### empty() - -```ts -static empty(): Scalar -``` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:337](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L337) - -*** - -### from() - -```ts -static from(s: string | number | bigint | Scalar): Scalar -``` - -Create a constant [Scalar](Scalar.mdx) from a bigint, number, string or Scalar. - -If the input is too large, it is reduced modulo the scalar field size. - -#### Parameters - -• **s**: `string` \| `number` \| `bigint` \| [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L46) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): Scalar -``` - -Creates a Scalar from an array of [Bool](Bool.mdx). -This method is provable. - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L105) - -*** - -### fromField() - -```ts -static fromField(s: Field): Scalar -``` - -Provable method to convert a [Field](Field.mdx) into a [Scalar](Scalar.mdx). - -This is always possible and unambiguous, since the scalar field is larger than the base field. - -#### Parameters - -• **s**: [`Field`](Field.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L66) - -*** - -### fromFields() - -```ts -static fromFields(fields: Field[]): Scalar -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Creates a data structure from an array of serialized [Field](Field.mdx) elements. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L265) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): Scalar -``` - -Deserialize a JSON structure into a [Scalar](Scalar.mdx). -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Scalar. - -#### Parameters - -• **x**: `string` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:333](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L333) - -*** - -### fromShiftedScalar() - -```ts -static fromShiftedScalar(s: ShiftedScalar): Scalar -``` - -Provable method to convert a ShiftedScalar to a [Scalar](Scalar.mdx). - -#### Parameters - -• **s**: `ShiftedScalar` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L57) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint): Scalar -``` - -#### Parameters - -• **x**: `bigint` - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:307](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L307) - -*** - -### random() - -```ts -static random(): Scalar -``` - -Returns a random [Scalar](Scalar.mdx). -Randomness can not be proven inside a circuit! - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:121](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L121) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Returns the size of this type in [Field](Field.mdx) elements. - -#### Returns - -`number` - -#### Source - -[lib/provable/scalar.ts:280](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L280) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): never[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Serialize a [Scalar](Scalar.mdx) into its auxiliary data, which are empty. - -#### Returns - -`never`[] - -#### Source - -[lib/provable/scalar.ts:256](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L256) - -*** - -### toCanonical() - -```ts -static toCanonical(s: Scalar): Scalar -``` - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar.ts:295](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L295) - -*** - -### toFields() - -```ts -static toFields(x: Scalar): Field[] -``` - -Part of the [Provable](../type-aliases/Provable.mdx) interface. - -Serialize a [Scalar](Scalar.mdx) into an array of [Field](Field.mdx) elements. - -**Warning**: This function is for internal usage. It returns 255 field elements -which represent the Scalar in a shifted, bitwise format. -The fields are not constrained to be boolean. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`Field`](Field.mdx)[] - -#### Source - -[lib/provable/scalar.ts:219](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L219) - -*** - -### toInput() - -```ts -static toInput(x: Scalar): HashInput -``` - -**Warning**: This function is mainly for internal use. Normally it is not intended to be used by a zkApp developer. - -This function is the implementation of `ProvableExtended.toInput()` for the [Scalar](Scalar.mdx) type. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`HashInput` - -An object where the `fields` key is a [Field](Field.mdx) array of length 1 created from this [Field](Field.mdx). - -#### Source - -[lib/provable/scalar.ts:247](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L247) - -*** - -### toJSON() - -```ts -static toJSON(x: Scalar): string -``` - -Serialize a [Scalar](Scalar.mdx) to a JSON string. -This operation does _not_ affect the circuit and can't be used to prove anything about the string representation of the Scalar. - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`string` - -#### Source - -[lib/provable/scalar.ts:317](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L317) - -*** - -### toValue() - -```ts -static toValue(x: Scalar): bigint -``` - -#### Parameters - -• **x**: [`Scalar`](Scalar.mdx) - -#### Returns - -`bigint` - -#### Source - -[lib/provable/scalar.ts:303](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L303) - ---- -url: /zkapps/o1js-reference/classes/ScalarField ---- - -ForeignField representing the scalar field of Pallas and the base field of Vesta - -## Extends - -- `UnreducedForeignField`\<`this`\> - -## Constructors - -### new ScalarField() - -```ts -new ScalarField(x: - | string - | number - | bigint - | Field3 - | ForeignField): ScalarField -``` - -Create a new [ForeignField](ForeignField.mdx) from a bigint, number, string or another ForeignField. - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `Field3` - \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`ScalarField`](ScalarField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).constructor` - -#### Example - -```ts -let x = new ForeignField(5); -``` - -Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants. - -- When constructing from another [ForeignField](ForeignField.mdx) instance, ensure the modulus matches. If not, check the modulus using `Gadgets.ForeignField.assertLessThan()` and handle appropriately. -- When constructing from a Field3 array, ensure all elements are valid Field elements and range checked. -- Ensure constants are correctly reduced to the modulus of the field. - -#### Source - -[lib/provable/foreign-field.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L101) - -## Properties - -### type - -```ts -type: "Unreduced" | "AlmostReduced" | "FullyReduced" = 'Unreduced'; -``` - -#### Inherited from - -`createForeignField(Fq.modulus).type` - -#### Source - -[lib/provable/foreign-field.ts:469](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L469) - -*** - -### value - -```ts -value: Field3; -``` - -The internal representation of a foreign field element, as a tuple of 3 limbs. - -#### Inherited from - -`createForeignField(Fq.modulus).value` - -#### Source - -[lib/provable/foreign-field.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L49) - -*** - -### \_Bigint - -```ts -static _Bigint: undefined | {} = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._Bigint` - -#### Source - -[lib/provable/foreign-field.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L27) - -*** - -### \_modulus - -```ts -static _modulus: undefined | bigint = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._modulus` - -#### Source - -[lib/provable/foreign-field.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L28) - -*** - -### \_provable - -```ts -static _provable: undefined | ProvablePureExtended = undefined; -``` - -#### Inherited from - -`createForeignField(Fq.modulus)._provable` - -#### Source - -[lib/provable/foreign-field.ts:471](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L471) - -*** - -### \_variants - -```ts -static _variants: undefined | { - "almostReduced": typeof AlmostForeignField; - "canonical": typeof CanonicalForeignField; - "unreduced": typeof UnreducedForeignField; - } = undefined; -``` - -Sibling classes that represent different ranges of field elements. - -#### Inherited from - -`createForeignField(Fq.modulus)._variants` - -#### Source - -[lib/provable/foreign-field.ts:58](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L58) - -## Accessors - -### Constructor - -```ts -get Constructor(): typeof ForeignField -``` - -#### Returns - -*typeof* [`ForeignField`](ForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L51) - -*** - -### modulus - -```ts -get modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L39) - -*** - -### AlmostReduced - -```ts -get static AlmostReduced(): typeof AlmostForeignField -``` - -Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))). - -#### Returns - -*typeof* [`AlmostForeignField`](AlmostForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L76) - -*** - -### Bigint - -```ts -get static Bigint(): {} -``` - -#### Returns - -```ts -{} -``` - -#### Source - -[lib/provable/foreign-field.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L31) - -*** - -### Canonical - -```ts -get static Canonical(): typeof CanonicalForeignField -``` - -Constructor for field elements that are fully reduced, i.e. lie in the range [0, p). - -#### Returns - -*typeof* [`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Source - -[lib/provable/foreign-field.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L83) - -*** - -### Unreduced - -```ts -get static Unreduced(): typeof UnreducedForeignField -``` - -Constructor for unreduced field elements. - -#### Returns - -*typeof* `UnreducedForeignField` - -#### Source - -[lib/provable/foreign-field.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L69) - -*** - -### modulus - -```ts -get static modulus(): bigint -``` - -#### Returns - -`bigint` - -#### Source - -[lib/provable/foreign-field.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L35) - -*** - -### provable - -```ts -get static provable(): ProvablePureExtended -``` - -#### Returns - -`ProvablePureExtended`\<`UnreducedForeignField`, `bigint`, `string`\> - -#### Source - -[lib/provable/foreign-field.ts:474](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L474) - -*** - -### sizeInBits - -```ts -get static sizeInBits(): number -``` - -#### Returns - -`number` - -#### Source - -[lib/provable/foreign-field.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L42) - -## Methods - -### add() - -```ts -add(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field addition - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).add` - -#### Example - -```ts -x.add(2); // x + 2 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:218](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L218) - -*** - -### assertAlmostReduced() - -```ts -assertAlmostReduced(): AlmostForeignField -``` - -Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -Returns the field element as a [AlmostForeignField](AlmostForeignField.mdx). - -For a more efficient version of this for multiple field elements, see [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1). - -Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is [assertCanonical](ForeignField.mdx#assertcanonical). -You should typically use [assertAlmostReduced](ForeignField.mdx#assertalmostreduced-1) though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods. - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:173](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L173) - -*** - -### assertCanonical() - -```ts -assertCanonical(): CanonicalForeignField -``` - -Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus. - -Returns the field element as a [CanonicalForeignField](CanonicalForeignField.mdx). - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).assertCanonical` - -#### Source - -[lib/provable/foreign-field.ts:204](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L204) - -*** - -### assertEquals() - -#### assertEquals(y, message) - -```ts -assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField -``` - -Assert equality with a ForeignField-like value - -##### Parameters - -• **y**: `number` \| `bigint` \| [`CanonicalForeignField`](CanonicalForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Example - -```ts -x.assertEquals(0, "x is zero"); -``` - -Since asserting equality can also serve as a range check, -this method returns `x` with the appropriate type: - -##### Example - -```ts -let xChecked = x.assertEquals(1, "x is 1"); -xChecked satisfies CanonicalForeignField; -``` - -##### Source - -[lib/provable/foreign-field.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L296) - -#### assertEquals(y, message) - -```ts -assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField -``` - -##### Parameters - -• **y**: [`AlmostForeignField`](AlmostForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:300](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L300) - -#### assertEquals(y, message) - -```ts -assertEquals(y: ForeignField, message?: string): ForeignField -``` - -##### Parameters - -• **y**: [`ForeignField`](ForeignField.mdx) - -• **message?**: `string` - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).assertEquals` - -##### Source - -[lib/provable/foreign-field.ts:301](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L301) - -*** - -### assertLessThan() - -```ts -assertLessThan(c: number | bigint, message?: string): void -``` - -Assert that this field element is less than a constant c: `x < c`. - -The constant must satisfy `0 <= c < 2^264`, otherwise an error is thrown. - -#### Parameters - -• **c**: `number` \| `bigint` - -• **message?**: `string` - -#### Returns - -`void` - -#### Inherited from - -`createForeignField(Fq.modulus).assertLessThan` - -#### Example - -```ts -x.assertLessThan(10); -``` - -#### Source - -[lib/provable/foreign-field.ts:339](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L339) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -Checks whether this field element is a constant. - -See FieldVar to understand constants vs variables. - -#### Returns - -`boolean` - -#### Inherited from - -`createForeignField(Fq.modulus).isConstant` - -#### Source - -[lib/provable/foreign-field.ts:136](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L136) - -*** - -### neg() - -```ts -neg(): AlmostForeignField -``` - -Finite field negation - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).neg` - -#### Example - -```ts -x.neg(); // -x mod p = p - x -``` - -#### Source - -[lib/provable/foreign-field.ts:229](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L229) - -*** - -### sub() - -```ts -sub(y: number | bigint | ForeignField): UnreducedForeignField -``` - -Finite field subtraction - -#### Parameters - -• **y**: `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).sub` - -#### Example - -```ts -x.sub(1); // x - 1 mod p -``` - -#### Source - -[lib/provable/foreign-field.ts:244](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L244) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Convert this field element to a bigint. - -#### Returns - -`bigint` - -#### Inherited from - -`createForeignField(Fq.modulus).toBigInt` - -#### Source - -[lib/provable/foreign-field.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L156) - -*** - -### toBits() - -```ts -toBits(length?: number): Bool[] -``` - -Unpack a field element to its bits, as a [Bool](Bool.mdx)[] array. - -This method is provable! - -#### Parameters - -• **length?**: `number` - -#### Returns - -[`Bool`](Bool.mdx)[] - -#### Inherited from - -`createForeignField(Fq.modulus).toBits` - -#### Source - -[lib/provable/foreign-field.ts:358](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L358) - -*** - -### toConstant() - -```ts -toConstant(): ForeignField -``` - -Convert this field element to a constant. - -See FieldVar to understand constants vs variables. - -**Warning**: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code. - -#### Returns - -[`ForeignField`](ForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).toConstant` - -#### Source - -[lib/provable/foreign-field.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L148) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -Instance version of `Provable.toFields`, see Provable.toFields - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`createForeignField(Fq.modulus).toFields` - -#### Source - -[lib/provable/foreign-field.ts:406](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L406) - -*** - -### toScalar() - -```ts -toScalar(): Scalar -``` - -Provable method to convert a [ScalarField](ScalarField.mdx) into a [Scalar](Scalar.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar-field.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L16) - -*** - -### assertAlmostReduced() - -```ts -static assertAlmostReduced(...xs: T): [...{ [i in string | number | symbol]: AlmostForeignField }[]] -``` - -Assert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus. - -This is most efficient than when checking a multiple of 3 field elements at once. - -#### Type parameters - -• **T** *extends* `Tuple`\<[`ForeignField`](ForeignField.mdx)\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: AlmostForeignField \}[]] - -#### Inherited from - -`createForeignField(Fq.modulus).assertAlmostReduced` - -#### Source - -[lib/provable/foreign-field.ts:187](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L187) - -*** - -### check() - -```ts -static check(x: ForeignField): void -``` - -#### Parameters - -• **x**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -`void` - -#### Inherited from - -`createForeignField(Fq.modulus).check` - -#### Source - -[lib/provable/foreign-field.ts:479](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L479) - -*** - -### from() - -#### from(x) - -```ts -static from(x: string | number | bigint): CanonicalForeignField -``` - -Coerce the input to a [ForeignField](ForeignField.mdx). - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` - -##### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).from` - -##### Source - -[lib/provable/foreign-field.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L124) - -#### from(x) - -```ts -static from(x: string | number | bigint | ForeignField): ForeignField -``` - -##### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`ForeignField`](ForeignField.mdx) - -##### Returns - -[`ForeignField`](ForeignField.mdx) - -##### Inherited from - -`createForeignField(Fq.modulus).from` - -##### Source - -[lib/provable/foreign-field.ts:125](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L125) - -*** - -### fromBits() - -```ts -static fromBits(bits: Bool[]): AlmostForeignField -``` - -Create a field element from its bits, as a `Bool[]` array. - -This method is provable! - -#### Parameters - -• **bits**: [`Bool`](Bool.mdx)[] - -#### Returns - -[`AlmostForeignField`](AlmostForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).fromBits` - -#### Source - -[lib/provable/foreign-field.ts:388](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L388) - -*** - -### fromScalar() - -```ts -static fromScalar(s: Scalar): ScalarField -``` - -Converts this [Scalar](Scalar.mdx) into a [ScalarField](ScalarField.mdx) - -#### Parameters - -• **s**: [`Scalar`](Scalar.mdx) - -#### Returns - -[`ScalarField`](ScalarField.mdx) - -#### Source - -[lib/provable/scalar-field.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L34) - -*** - -### random() - -```ts -static random(): CanonicalForeignField -``` - -#### Returns - -[`CanonicalForeignField`](CanonicalForeignField.mdx) - -#### Inherited from - -`createForeignField(Fq.modulus).random` - -#### Source - -[lib/provable/foreign-field.ts:399](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L399) - -*** - -### sum() - -```ts -static sum(xs: (number | bigint | ForeignField)[], operations: (-1 | 1)[]): UnreducedForeignField -``` - -Sum (or difference) of multiple finite field elements. - -#### Parameters - -• **xs**: (`number` \| `bigint` \| [`ForeignField`](ForeignField.mdx))[] - -• **operations**: (`-1` \| `1`)[] - -#### Returns - -`UnreducedForeignField` - -#### Inherited from - -`createForeignField(Fq.modulus).sum` - -#### Example - -```ts -let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1 -z.assertEquals(2); -``` - -This method expects a list of ForeignField-like values, `x0,...,xn`, -and a list of "operations" `op1,...,opn` where every op is 1 or -1 (plus or minus), -and returns - -`x0 + op1*x1 + ... + opn*xn` - -where the sum is computed in finite field arithmetic. - -**Important:** For more than two summands, this is significantly more efficient -than chaining calls to [ForeignField.add](ForeignField.mdx#add) and [ForeignField.sub](ForeignField.mdx#sub). - -#### Source - -[lib/provable/foreign-field.ts:269](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L269) - -*** - -### toScalar() - -```ts -static toScalar(field: ForeignField): Scalar -``` - -#### Parameters - -• **field**: [`ForeignField`](ForeignField.mdx) - -#### Returns - -[`Scalar`](Scalar.mdx) - -#### Source - -[lib/provable/scalar-field.ts:20](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar-field.ts#L20) - ---- -url: /zkapps/o1js-reference/classes/SelfProof ---- - -## Extends - -- [`Proof`](Proof.mdx)\<`PublicInput`, `PublicOutput`\> - -## Type parameters - -• **PublicInput** - -• **PublicOutput** - -## Constructors - -### new SelfProof() - -```ts -new SelfProof(__namedParameters: { - "maxProofsVerified": 0 | 1 | 2; - "proof": unknown; - "publicInput": PublicInput; - "publicOutput": PublicOutput; -}): SelfProof -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.maxProofsVerified**: `0` \| `1` \| `2` - -• **\_\_namedParameters.proof**: `unknown` - -• **\_\_namedParameters.publicInput**: `PublicInput` - -• **\_\_namedParameters.publicOutput**: `PublicOutput` - -#### Returns - -[`SelfProof`](SelfProof.mdx)\<`PublicInput`, `PublicOutput`\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`constructor`](Proof.mdx#constructors) - -#### Source - -[lib/proof-system/proof.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L49) - -## Properties - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`maxProofsVerified`](Proof.mdx#maxproofsverified) - -#### Source - -[lib/proof-system/proof.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L36) - -*** - -### proof - -```ts -proof: unknown; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`proof`](Proof.mdx#proof) - -#### Source - -[lib/proof-system/proof.ts:35](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L35) - -*** - -### publicInput - -```ts -publicInput: PublicInput; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicInput`](Proof.mdx#publicinput) - -#### Source - -[lib/proof-system/proof.ts:33](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L33) - -*** - -### publicOutput - -```ts -publicOutput: PublicOutput; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicOutput`](Proof.mdx#publicoutput) - -#### Source - -[lib/proof-system/proof.ts:34](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L34) - -*** - -### shouldVerify - -```ts -shouldVerify: Bool; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`shouldVerify`](Proof.mdx#shouldverify) - -#### Source - -[lib/proof-system/proof.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L37) - -*** - -### publicInputType - -```ts -static publicInputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicInputType`](Proof.mdx#publicinputtype) - -#### Source - -[lib/proof-system/proof.ts:25](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L25) - -*** - -### publicOutputType - -```ts -static publicOutputType: FlexibleProvablePure; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicOutputType`](Proof.mdx#publicoutputtype) - -#### Source - -[lib/proof-system/proof.ts:26](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L26) - -*** - -### tag() - -```ts -static tag: () => { - "name": string; -}; -``` - -#### Returns - -```ts -{ - "name": string; -} -``` - -##### name - -```ts -name: string; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`tag`](Proof.mdx#tag) - -#### Source - -[lib/proof-system/proof.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L27) - -## Accessors - -### provable - -```ts -get static provable(): ProvableProof, any, any> -``` - -#### Returns - -`ProvableProof`\<[`Proof`](Proof.mdx)\<`any`, `any`\>, `any`, `any`\> - -#### Source - -[lib/proof-system/proof.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L165) - -## Methods - -### publicFields() - -```ts -publicFields(): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicFields`](Proof.mdx#publicfields) - -#### Source - -[lib/proof-system/proof.ts:92](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L92) - -*** - -### toJSON() - -```ts -toJSON(): JsonProof -``` - -#### Returns - -[`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Inherited from - -[`Proof`](Proof.mdx).[`toJSON`](Proof.mdx#tojson) - -#### Source - -[lib/proof-system/proof.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L39) - -*** - -### verify() - -```ts -verify(): void -``` - -#### Returns - -`void` - -#### Inherited from - -[`Proof`](Proof.mdx).[`verify`](Proof.mdx#verify) - -#### Source - -[lib/proof-system/proof.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L98) - -*** - -### verifyIf() - -```ts -verifyIf(condition: Bool): void -``` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -#### Returns - -`void` - -#### Inherited from - -[`Proof`](Proof.mdx).[`verifyIf`](Proof.mdx#verifyif) - -#### Source - -[lib/proof-system/proof.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L101) - -*** - -### dummy() - -```ts -static dummy( - publicInput: Input, - publicOutput: OutPut, - maxProofsVerified: 0 | 1 | 2, -domainLog2: number): Promise> -``` - -Dummy proof. This can be useful for ZkPrograms that handle the base case in the same -method as the inductive case, using a pattern like this: - -```ts -method(proof: SelfProof, isRecursive: Bool) { - proof.verifyIf(isRecursive); - // ... -} -``` - -To use such a method in the base case, you need a dummy proof: - -```ts -let dummy = await MyProof.dummy(publicInput, publicOutput, 1); -await myProgram.myMethod(dummy, Bool(false)); -``` - -**Note**: The types of `publicInput` and `publicOutput`, as well as the `maxProofsVerified` parameter, -must match your ZkProgram. `maxProofsVerified` is the maximum number of proofs that any of your methods take as arguments. - -#### Type parameters - -• **Input** - -• **OutPut** - -#### Parameters - -• **publicInput**: `Input` - -• **publicOutput**: `OutPut` - -• **maxProofsVerified**: `0` \| `1` \| `2` - -• **domainLog2**: `number`= `14` - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<`Input`, `OutPut`\>\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`dummy`](Proof.mdx#dummy) - -#### Source - -[lib/proof-system/proof.ts:150](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L150) - -*** - -### fromJSON() - -```ts -static fromJSON(this: S, __namedParameters: JsonProof): Promise, InferProvable>> -``` - -#### Type parameters - -• **S** *extends* `Subclass`\<*typeof* [`Proof`](Proof.mdx)\> - -#### Parameters - -• **this**: `S` - -• **\_\_namedParameters**: [`JsonProof`](../type-aliases/JsonProof.mdx) - -#### Returns - -`Promise`\<[`Proof`](Proof.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicInputType"`\]\>, [`InferProvable`](../type-aliases/InferProvable.mdx)\<`S`\[`"publicOutputType"`\]\>\>\> - -#### Inherited from - -[`Proof`](Proof.mdx).[`fromJSON`](Proof.mdx#fromjson) - -#### Source - -[lib/proof-system/proof.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L105) - -*** - -### publicFields() - -```ts -static publicFields(value: ProofBase): { - "input": Field[]; - "output": Field[]; -} -``` - -#### Parameters - -• **value**: [`ProofBase`](ProofBase.mdx)\<`any`, `any`\> - -#### Returns - -```ts -{ - "input": Field[]; - "output": Field[]; -} -``` - -##### input - -```ts -input: Field[]; -``` - -##### output - -```ts -output: Field[]; -``` - -#### Inherited from - -[`Proof`](Proof.mdx).[`publicFields`](Proof.mdx#publicfields-1) - -#### Source - -[lib/proof-system/proof.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/proof.ts#L84) - ---- -url: /zkapps/o1js-reference/classes/Sign ---- - -## Extends - -- `CircuitValue` - -## Constructors - -### new Sign() - -```ts -new Sign(...props: any[]): Sign -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`Sign`](Sign.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:1034](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1034) - -## Accessors - -### minusOne - -```ts -get static minusOne(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1039](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1039) - -*** - -### one - -```ts -get static one(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1036](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1036) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### isNegative() - -```ts -isNegative(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:1071](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1071) - -*** - -### isPositive() - -```ts -isPositive(): Bool -``` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:1068](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1068) - -*** - -### mul() - -```ts -mul(y: Sign): Sign -``` - -#### Parameters - -• **y**: [`Sign`](Sign.mdx) - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1065](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1065) - -*** - -### neg() - -```ts -neg(): Sign -``` - -#### Returns - -[`Sign`](Sign.mdx) - -#### Source - -[lib/provable/int.ts:1062](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1062) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:1075](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1075) - -*** - -### check() - -```ts -static check(x: Sign): void -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:1042](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1042) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.empty` - -#### Source - -[lib/provable/int.ts:1046](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1046) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: "Positive" | "Negative"): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `"Positive"` \| `"Negative"` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:1057](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1057) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | Sign): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`Sign`](Sign.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:1083](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1083) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: Sign): HashInput -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:1049](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1049) - -*** - -### toJSON() - -```ts -static toJSON(x: Sign): "Positive" | "Negative" -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`"Positive"` \| `"Negative"` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:1052](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1052) - -*** - -### toValue() - -```ts -static toValue(x: Sign): Sign -``` - -#### Parameters - -• **x**: [`Sign`](Sign.mdx) - -#### Returns - -`Sign` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:1079](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1079) - ---- -url: /zkapps/o1js-reference/classes/Signature ---- - -A Schnorr [Signature](Signature.mdx) over the Pasta Curves. - -## Extends - -- `CircuitValue` - -## Constructors - -### new Signature() - -```ts -new Signature(...props: any[]): Signature -``` - -#### Parameters - -• ...**props**: `any`[] - -#### Returns - -[`Signature`](Signature.mdx) - -#### Inherited from - -`CircuitValue.constructor` - -#### Source - -[lib/provable/types/circuit-value.ts:13](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L13) - -## Properties - -### r - -```ts -r: Field; -``` - -#### Source - -[lib/provable/crypto/signature.ts:258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L258) - -*** - -### s - -```ts -s: Scalar; -``` - -#### Source - -[lib/provable/crypto/signature.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L259) - -## Methods - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### toBase58() - -```ts -toBase58(): string -``` - -Encodes a [Signature](Signature.mdx) in base58 format. - -#### Returns - -`string` - -#### Source - -[lib/provable/crypto/signature.ts:321](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L321) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### verify() - -```ts -verify(publicKey: PublicKey, msg: Field[]): Bool -``` - -Verifies the [Signature](Signature.mdx) using a message and the corresponding [PublicKey](PublicKey.mdx). - -#### Parameters - -• **publicKey**: [`PublicKey`](PublicKey.mdx) - -• **msg**: [`Field`](Field.mdx)[] - -#### Returns - -[`Bool`](Bool.mdx) - -a [Bool](../variables/Bool.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:296](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L296) - -*** - -### check() - -```ts -static check(this: T, v: InstanceType): void -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.check` - -#### Source - -[lib/provable/types/circuit-value.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L163) - -*** - -### create() - -```ts -static create(privKey: PrivateKey, msg: Field[]): Signature -``` - -Signs a message using a [PrivateKey](PrivateKey.mdx). - -#### Parameters - -• **privKey**: [`PrivateKey`](PrivateKey.mdx) - -• **msg**: [`Field`](Field.mdx)[] - -#### Returns - -[`Signature`](Signature.mdx) - -a [Signature](Signature.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:265](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L265) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### fromBase58() - -```ts -static fromBase58(signatureBase58: string): Signature -``` - -Decodes a base58 encoded signature into a [Signature](Signature.mdx). - -#### Parameters - -• **signatureBase58**: `string` - -#### Returns - -[`Signature`](Signature.mdx) - -#### Source - -[lib/provable/crypto/signature.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/signature.ts#L314) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L208) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(this: T, value: any): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `any` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/types/circuit-value.ts:98](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L98) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(this: T, v: InstanceType): HashInput -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`HashInput` - -#### Inherited from - -`CircuitValue.toInput` - -#### Source - -[lib/provable/types/circuit-value.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L63) - -*** - -### toJSON() - -```ts -static toJSON(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L197) - -*** - -### toValue() - -```ts -static toValue(this: T, v: InstanceType): any -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toValue` - -#### Source - -[lib/provable/types/circuit-value.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L89) - ---- -url: /zkapps/o1js-reference/classes/SmartContract ---- - -The main zkapp class. To write a zkapp, extend this class as such: - -``` -class YourSmartContract extends SmartContract { - // your smart contract code here -} -``` - -## Extends - -- `SmartContractBase` - -## Constructors - -### new SmartContract() - -```ts -new SmartContract(address: PublicKey, tokenId?: Field): SmartContract -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`SmartContract`](SmartContract.mdx) - -#### Overrides - -`SmartContractBase.constructor` - -#### Source - -[lib/mina/zkapp.ts:614](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L614) - -## Properties - -### address - -```ts -address: PublicKey; -``` - -#### Source - -[lib/mina/zkapp.ts:579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L579) - -*** - -### events - -```ts -events: {} = {}; -``` - -A list of event types that can be emitted using this.emitEvent()`. - -#### Index signature - - \[`key`: `string`\]: [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -#### Source - -[lib/mina/zkapp.ts:979](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L979) - -*** - -### sender - -```ts -sender: { - "self": SmartContract; - "getAndRequireSignature": PublicKey; - "getUnconstrained": PublicKey; -}; -``` - -#### self - -```ts -self: SmartContract; -``` - -#### getAndRequireSignature() - -Return a public key that is forced to sign this transaction. - -Note: This doesn't prove that the return value is the transaction sender, but it proves that whoever created -the transaction controls the private key associated with the returned public key. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### getUnconstrained() - -The public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -**Warning**: The fact that this public key equals the current sender is not part of the proof. -A malicious prover could use any other public key without affecting the validity of the proof. - -Consider using `this.sender.getAndRequireSignature()` if you need to prove that the sender controls this account. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Source - -[lib/mina/zkapp.ts:868](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L868) - -*** - -### tokenId - -```ts -tokenId: Field; -``` - -#### Source - -[lib/mina/zkapp.ts:580](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L580) - -*** - -### \_maxProofsVerified? - -```ts -static optional _maxProofsVerified: 0 | 2 | 1; -``` - -#### Source - -[lib/mina/zkapp.ts:599](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L599) - -*** - -### \_methodMetadata? - -```ts -static optional _methodMetadata: Record; -``` - -#### Source - -[lib/mina/zkapp.ts:589](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L589) - -*** - -### \_methods? - -```ts -static optional _methods: MethodInterface[]; -``` - -#### Source - -[lib/mina/zkapp.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L588) - -*** - -### \_provers? - -```ts -static optional _provers: Prover[]; -``` - -#### Source - -[lib/mina/zkapp.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L598) - -*** - -### \_verificationKey? - -```ts -static optional _verificationKey: { - "data": string; - "hash": Field; -}; -``` - -#### data - -```ts -data: string; -``` - -#### hash - -```ts -hash: Field; -``` - -#### Source - -[lib/mina/zkapp.ts:600](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L600) - -## Accessors - -### account - -```ts -get account(): Account -``` - -Current account of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Account` - -#### Source - -[lib/mina/zkapp.ts:920](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L920) - -*** - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -Balance of this [SmartContract](SmartContract.mdx). - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:973](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L973) - -*** - -### currentSlot - -```ts -get currentSlot(): CurrentSlot -``` - -Current global slot on the network. This is the slot at which this transaction is included in a block. Since we cannot know this value -at the time of transaction construction, this only has the `assertBetween()` method but no `get()` (impossible to implement) -or `assertEquals()` (confusing, because the developer can't know the exact slot at which this will be included either) - -#### Returns - -`CurrentSlot` - -#### Source - -[lib/mina/zkapp.ts:934](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L934) - -*** - -### network - -```ts -get network(): Network -``` - -Current network state of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Network` - -#### Source - -[lib/mina/zkapp.ts:926](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L926) - -*** - -### self - -```ts -get self(): AccountUpdate -``` - -Returns the current [AccountUpdate](AccountUpdate.mdx) associated to this [SmartContract](SmartContract.mdx). - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:823](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L823) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Approve an account update or tree / forest of updates. Doing this means you include the account update in the zkApp's public input, -which allows you to read and use its content in a proof, make assertions about it, and modify it. - -```ts -`@method` myApprovingMethod(update: AccountUpdate) { - this.approve(update); - - // read balance on the account (for example) - let balance = update.account.balance.getAndRequireEquals(); -} -``` - -Under the hood, "approving" just means that the account update is made a child of the zkApp in the -tree of account updates that forms the transaction. Similarly, if you pass in an [AccountUpdateTree](AccountUpdateTree.mdx), -the entire tree will become a subtree of the zkApp's account update. - -Passing in a forest is a bit different, because it means you set the entire children of the zkApp's account update -at once. `approve()` will fail if the zkApp's account update already has children, to prevent you from accidentally -excluding important information from the public input. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:959](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L959) - -*** - -### deploy() - -```ts -deploy(__namedParameters: { - "verificationKey": { - "data": string; - "hash": string | Field; - }; -}): Promise -``` - -Deploys a [SmartContract](SmartContract.mdx). - -```ts -let tx = await Mina.transaction(sender, async () => { - AccountUpdate.fundNewAccount(sender); - await zkapp.deploy(); -}); -tx.sign([senderKey, zkAppKey]); -``` - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.verificationKey?** - -• **\_\_namedParameters.verificationKey.data**: `string` - -• **\_\_namedParameters.verificationKey.hash**: `string` \| [`Field`](Field.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/zkapp.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L703) - -*** - -### emitEvent() - -```ts -emitEvent(type: K, event: any): void -``` - -Emits an event. Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:1030](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1030) - -*** - -### emitEventIf() - -```ts -emitEventIf( - condition: Bool, - type: K, - event: any): void -``` - -Conditionally emits an event. - -Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:987](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L987) - -*** - -### fetchEvents() - -```ts -fetchEvents(start?: UInt32, end?: UInt32): Promise<{ - "blockHash": string; - "blockHeight": UInt32; - "chainStatus": string; - "event": { - "data": ProvablePure; - "transactionInfo": { - "transactionHash": string; - "transactionMemo": string; - "transactionStatus": string; - }; - }; - "globalSlot": UInt32; - "parentBlockHash": string; - "type": string; -}[]> -``` - -Asynchronously fetches events emitted by this [SmartContract](SmartContract.mdx) and returns an array of events with their corresponding types. - -#### Parameters - -• **start?**: [`UInt32`](UInt32.mdx)= `undefined` - -The start height of the events to fetch. - -• **end?**: [`UInt32`](UInt32.mdx) - -The end height of the events to fetch. If not provided, fetches events up to the latest height. - -#### Returns - -`Promise`\<\{ - `"blockHash"`: `string`; - `"blockHeight"`: [`UInt32`](UInt32.mdx); - `"chainStatus"`: `string`; - `"event"`: \{ - `"data"`: [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`any`\>; - `"transactionInfo"`: \{ - `"transactionHash"`: `string`; - `"transactionMemo"`: `string`; - `"transactionStatus"`: `string`; - \}; - \}; - `"globalSlot"`: [`UInt32`](UInt32.mdx); - `"parentBlockHash"`: `string`; - `"type"`: `string`; - \}[]\> - -A promise that resolves to an array of objects, each containing the event type and event data for the specified range. - -#### Async - -#### Throws - -If there is an error fetching events from the Mina network. - -#### Example - -```ts -const startHeight = UInt32.from(1000); -const endHeight = UInt32.from(2000); -const events = await myZkapp.fetchEvents(startHeight, endHeight); -console.log(events); -``` - -#### Source - -[lib/mina/zkapp.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1047) - -*** - -### init() - -```ts -init(): void -``` - -`SmartContract.init()` will be called only when a [SmartContract](SmartContract.mdx) will be first deployed, not for redeployment. -This method can be overridden as follows -``` -class MyContract extends SmartContract { - init() { - super.init(); - this.account.permissions.set(...); - this.x.set(Field(1)); - } -} -``` - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:771](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L771) - -*** - -### newSelf() - -```ts -newSelf(methodName?: string): AccountUpdate -``` - -Same as `SmartContract.self` but explicitly creates a new [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **methodName?**: `string` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:858](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L858) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if the account update created by this SmartContract should be signed by the account owner, -instead of authorized with a proof. - -Note that the smart contract's [Permissions](../variables/Permissions.mdx) determine which updates have to be (can be) authorized by a signature. - -If you only want to avoid creating proofs for quicker testing, we advise you to -use `LocalBlockchain({ proofsEnabled: false })` instead of `requireSignature()`. Setting -`proofsEnabled` to `false` allows you to test your transactions with the same authorization flow as in production, -with the only difference being that quick mock proofs are filled in instead of real proofs. - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:804](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L804) - -*** - -### send() - -```ts -send(args: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **args** - -• **args.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **args.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:963](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L963) - -*** - -### skipAuthorization() - -```ts -skipAuthorization(): void -``` - -Use this command if the account update created by this SmartContract should have no authorization on it, -instead of being authorized with a proof. - -WARNING: This is a method that should rarely be useful. If you want to disable proofs for quicker testing, take a look -at `LocalBlockchain({ proofsEnabled: false })`, which causes mock proofs to be created and doesn't require changing the -authorization flow. - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:816](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L816) - -*** - -### Proof() - -```ts -static Proof(): typeof __class -``` - -Returns a Proof type that belongs to this [SmartContract](SmartContract.mdx). - -#### Returns - -*typeof* `__class` - -#### Source - -[lib/mina/zkapp.ts:605](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L605) - -*** - -### analyzeMethods() - -```ts -static analyzeMethods(__namedParameters: { - "printSummary": false; - }): Promise> -``` - -This function is run internally before compiling a smart contract, to collect metadata about what each of your -smart contract methods does. - -For external usage, this function can be handy because calling it involves running all methods in the same "mode" as `compile()` does, -so it serves as a quick-to-run check for whether your contract can be compiled without errors, which can greatly speed up iterating. - -`analyzeMethods()` will also return the number of `rows` of each of your method circuits (i.e., the number of constraints in the underlying proof system), -which is a good indicator for circuit size and the time it will take to create proofs. -To inspect the created circuit in detail, you can look at the returned `gates`. - -Note: If this function was already called before, it will short-circuit and just return the metadata collected the first time. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.printSummary**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<`Record`\<`string`, \{ - `"actions"`: `number`; - `"digest"`: `string`; - `"gates"`: `Gate`[]; - `"rows"`: `number`; - \}\>\> - -an object, keyed by method name, each entry containing: - - `rows` the size of the constraint system created by this method - - `digest` a digest of the method circuit - - `actions` the number of actions the method dispatches - - `gates` the constraint system, represented as an array of gates - -#### Source - -[lib/mina/zkapp.ts:1178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1178) - -*** - -### compile() - -```ts -static compile(__namedParameters: { - "cache": Cache.FileSystemDefault; - "forceRecompile": false; - }): Promise<{ - "provers": Prover[]; - "verificationKey": { - "data": string; - "hash": Field; - }; - "verify": (statement: Statement, proof: unknown) => Promise; -}> -``` - -Compile your smart contract. - -This generates both the prover functions, needed to create proofs for running `@method`s, -and the verification key, needed to deploy your zkApp. - -Although provers and verification key are returned by this method, they are also cached internally and used when needed, -so you don't actually have to use the return value of this function. - -Under the hood, "compiling" means calling into the lower-level [Pickles and Kimchi libraries](https://o1-labs.github.io/proof-systems/kimchi/overview.html) to -create multiple prover & verifier indices (one for each smart contract method as part of a "step circuit" and one for the "wrap circuit" which recursively wraps -it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**, -up to several minutes if your circuit is large or your hardware is not optimal for these operations. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.cache**: `undefined` \| [`Cache`](../type-aliases/Cache.mdx)= `Cache.FileSystemDefault` - -• **\_\_namedParameters.forceRecompile**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"provers"`: `Prover`[]; - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](Field.mdx); - \}; - `"verify"`: (`statement`: `Statement`\<`FieldConst`\>, `proof`: `unknown`) => `Promise`\<`boolean`\>; - \}\> - -> ##### provers -> -> ```ts -> provers: Prover[]; -> ``` -> -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> -> ##### verify() -> -> ```ts -> verify: (statement: Statement, proof: unknown) => Promise; -> ``` -> -> ###### Parameters -> -> • **statement**: `Statement`\<`FieldConst`\> -> -> • **proof**: `unknown` -> -> ###### Returns -> -> `Promise`\<`boolean`\> -> - -#### Source - -[lib/mina/zkapp.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L642) - -*** - -### digest() - -```ts -static digest(): Promise -``` - -Computes a hash of your smart contract, which will reliably change _whenever one of your method circuits changes_. -This digest is quick to compute. it is designed to help with deciding whether a contract should be re-compiled or -a cached verification key can be used. - -#### Returns - -`Promise`\<`string`\> - -the digest, as a hex string - -#### Source - -[lib/mina/zkapp.ts:683](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L683) - -*** - -### runOutsideCircuit() - -```ts -static runOutsideCircuit(run: () => void): void -``` - -#### Parameters - -• **run** - -#### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:1153](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1153) - ---- -url: /zkapps/o1js-reference/classes/TokenAccountUpdateIterator ---- - -Data structure to represent a forest of account updates that is being iterated over, -in the context of a token manager contract. - -The iteration is done in a depth-first manner. - -```ts -let forest: AccountUpdateForest = ...; -let tokenIterator = TokenAccountUpdateIterator.create(forest, tokenId); - -// process the first 5 account updates in the tree -for (let i = 0; i < 5; i++) { - let { accountUpdate, usesThisToken } = tokenIterator.next(); - // ... do something with the account update ... -} -``` - -**Important**: Since this is specifically used by token manager contracts to process their entire subtree -of account updates, the iterator skips subtrees that don't inherit token permissions and can therefore definitely not use the token. - -So, the assumption is that the consumer of this iterator is only interested in account updates that use the token. -We still can't avoid processing some account updates that don't use the token, therefore the iterator returns a boolean -`usesThisToken` alongside each account update. - -## Constructors - -### new TokenAccountUpdateIterator() - -```ts -new TokenAccountUpdateIterator( - forest: MerkleListIterator, - mayUseToken: MayUseToken, - selfToken: Field): TokenAccountUpdateIterator -``` - -#### Parameters - -• **forest**: [`MerkleListIterator`](MerkleListIterator.mdx)\<`AccountUpdateTreeBase`\> - -• **mayUseToken**: `MayUseToken` - -• **selfToken**: [`Field`](Field.mdx) - -#### Returns - -[`TokenAccountUpdateIterator`](TokenAccountUpdateIterator.mdx) - -#### Source - -[lib/mina/token/forest-iterator.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L59) - -## Properties - -### currentLayer - -```ts -currentLayer: Layer; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L55) - -*** - -### selfToken - -```ts -selfToken: Field; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L57) - -*** - -### unfinishedParentLayers - -```ts -unfinishedParentLayers: MerkleList; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:56](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L56) - -## Methods - -### assertFinished() - -```ts -assertFinished(message?: string): void -``` - -#### Parameters - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/mina/token/forest-iterator.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L140) - -*** - -### next() - -```ts -next(): { - "accountUpdate": update; - "usesThisToken": Bool; -} -``` - -Make a single step along a tree of account updates. - -This function is guaranteed to visit each account update in the tree that uses the token -exactly once, when called repeatedly. - -The method makes a best effort to avoid visiting account updates that are not using the token, -and in particular, to avoid returning dummy updates. -However, neither can be ruled out. We're returning `{ update, usesThisToken: Bool }` and let the -caller handle the irrelevant case where `usesThisToken` is false. - -#### Returns - -```ts -{ - "accountUpdate": update; - "usesThisToken": Bool; -} -``` - -##### accountUpdate - -```ts -accountUpdate: AccountUpdate = update; -``` - -##### usesThisToken - -```ts -usesThisToken: Bool; -``` - -#### Source - -[lib/mina/token/forest-iterator.ts:88](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L88) - -*** - -### create() - -```ts -static create(forest: AccountUpdateForest, selfToken: Field): TokenAccountUpdateIterator -``` - -#### Parameters - -• **forest**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -• **selfToken**: [`Field`](Field.mdx) - -#### Returns - -[`TokenAccountUpdateIterator`](TokenAccountUpdateIterator.mdx) - -#### Source - -[lib/mina/token/forest-iterator.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/forest-iterator.ts#L69) - ---- -url: /zkapps/o1js-reference/classes/TokenContract ---- - -Base token contract which -- implements the `Approvable` API, with the `approveBase()` method left to be defined by subclasses -- implements the `Transferable` API as a wrapper around the `Approvable` API - -## Extends - -- [`SmartContract`](SmartContract.mdx) - -## Constructors - -### new TokenContract() - -```ts -new TokenContract(address: PublicKey, tokenId?: Field): TokenContract -``` - -#### Parameters - -• **address**: [`PublicKey`](PublicKey.mdx) - -• **tokenId?**: [`Field`](Field.mdx) - -#### Returns - -[`TokenContract`](TokenContract.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`constructor`](SmartContract.mdx#constructors) - -#### Source - -[lib/mina/zkapp.ts:614](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L614) - -## Properties - -### address - -```ts -address: PublicKey; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`address`](SmartContract.mdx#address) - -#### Source - -[lib/mina/zkapp.ts:579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L579) - -*** - -### events - -```ts -events: {} = {}; -``` - -A list of event types that can be emitted using this.emitEvent()`. - -#### Index signature - - \[`key`: `string`\]: [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`events`](SmartContract.mdx#events) - -#### Source - -[lib/mina/zkapp.ts:979](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L979) - -*** - -### sender - -```ts -sender: { - "self": SmartContract; - "getAndRequireSignature": PublicKey; - "getUnconstrained": PublicKey; -}; -``` - -#### self - -```ts -self: SmartContract; -``` - -#### getAndRequireSignature() - -Return a public key that is forced to sign this transaction. - -Note: This doesn't prove that the return value is the transaction sender, but it proves that whoever created -the transaction controls the private key associated with the returned public key. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### getUnconstrained() - -The public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -**Warning**: The fact that this public key equals the current sender is not part of the proof. -A malicious prover could use any other public key without affecting the validity of the proof. - -Consider using `this.sender.getAndRequireSignature()` if you need to prove that the sender controls this account. - -##### Returns - -[`PublicKey`](PublicKey.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`sender`](SmartContract.mdx#sender) - -#### Source - -[lib/mina/zkapp.ts:868](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L868) - -*** - -### tokenId - -```ts -tokenId: Field; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`tokenId`](SmartContract.mdx#tokenid) - -#### Source - -[lib/mina/zkapp.ts:580](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L580) - -*** - -### MAX\_ACCOUNT\_UPDATES - -```ts -static MAX_ACCOUNT_UPDATES: number = 9; -``` - -The maximum number of account updates using the token in a single -transaction that this contract supports. - -#### Source - -[lib/mina/token/token-contract.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L29) - -*** - -### \_maxProofsVerified? - -```ts -static optional _maxProofsVerified: 0 | 2 | 1; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_maxProofsVerified`](SmartContract.mdx#_maxproofsverified) - -#### Source - -[lib/mina/zkapp.ts:599](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L599) - -*** - -### \_methodMetadata? - -```ts -static optional _methodMetadata: Record; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_methodMetadata`](SmartContract.mdx#_methodmetadata) - -#### Source - -[lib/mina/zkapp.ts:589](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L589) - -*** - -### \_methods? - -```ts -static optional _methods: MethodInterface[]; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_methods`](SmartContract.mdx#_methods) - -#### Source - -[lib/mina/zkapp.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L588) - -*** - -### \_provers? - -```ts -static optional _provers: Prover[]; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_provers`](SmartContract.mdx#_provers) - -#### Source - -[lib/mina/zkapp.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L598) - -*** - -### \_verificationKey? - -```ts -static optional _verificationKey: { - "data": string; - "hash": Field; -}; -``` - -#### data - -```ts -data: string; -``` - -#### hash - -```ts -hash: Field; -``` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`_verificationKey`](SmartContract.mdx#_verificationkey) - -#### Source - -[lib/mina/zkapp.ts:600](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L600) - -## Accessors - -### account - -```ts -get account(): Account -``` - -Current account of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Account` - -#### Source - -[lib/mina/zkapp.ts:920](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L920) - -*** - -### balance - -```ts -get balance(): { - "addInPlace": void; - "subInPlace": void; -} -``` - -Balance of this [SmartContract](SmartContract.mdx). - -#### Returns - -```ts -{ - "addInPlace": void; - "subInPlace": void; -} -``` - -##### addInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -##### subInPlace() - -###### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`Int64`](Int64.mdx) - -###### Returns - -`void` - -#### Source - -[lib/mina/zkapp.ts:973](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L973) - -*** - -### currentSlot - -```ts -get currentSlot(): CurrentSlot -``` - -Current global slot on the network. This is the slot at which this transaction is included in a block. Since we cannot know this value -at the time of transaction construction, this only has the `assertBetween()` method but no `get()` (impossible to implement) -or `assertEquals()` (confusing, because the developer can't know the exact slot at which this will be included either) - -#### Returns - -`CurrentSlot` - -#### Source - -[lib/mina/zkapp.ts:934](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L934) - -*** - -### internal - -```ts -get internal(): { - "burn": AccountUpdate; - "mint": AccountUpdate; - "send": AccountUpdate; -} -``` - -Helper methods to use from within a token contract. - -#### Returns - -```ts -{ - "burn": AccountUpdate; - "mint": AccountUpdate; - "send": AccountUpdate; -} -``` - -##### burn() - -Burn token balance on `address`. Returns the burn account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.address**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -##### mint() - -Mints token balance to `address`. Returns the mint account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.address**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -##### send() - -Move token balance from `from` to `to`. Returns the `to` account update. - -###### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **\_\_namedParameters.from**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -• **\_\_namedParameters.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -###### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/token/token-contract.ts:77](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L77) - -*** - -### network - -```ts -get network(): Network -``` - -Current network state of the [SmartContract](SmartContract.mdx). - -#### Returns - -`Network` - -#### Source - -[lib/mina/zkapp.ts:926](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L926) - -*** - -### self - -```ts -get self(): AccountUpdate -``` - -Returns the current [AccountUpdate](AccountUpdate.mdx) associated to this [SmartContract](SmartContract.mdx). - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Source - -[lib/mina/zkapp.ts:823](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L823) - -## Methods - -### approve() - -```ts -approve(update: AccountUpdate | AccountUpdateTree | AccountUpdateForest): void -``` - -Approve an account update or tree / forest of updates. Doing this means you include the account update in the zkApp's public input, -which allows you to read and use its content in a proof, make assertions about it, and modify it. - -```ts -`@method` myApprovingMethod(update: AccountUpdate) { - this.approve(update); - - // read balance on the account (for example) - let balance = update.account.balance.getAndRequireEquals(); -} -``` - -Under the hood, "approving" just means that the account update is made a child of the zkApp in the -tree of account updates that forms the transaction. Similarly, if you pass in an [AccountUpdateTree](AccountUpdateTree.mdx), -the entire tree will become a subtree of the zkApp's account update. - -Passing in a forest is a bit different, because it means you set the entire children of the zkApp's account update -at once. `approve()` will fail if the zkApp's account update already has children, to prevent you from accidentally -excluding important information from the public input. - -#### Parameters - -• **update**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) \| [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`approve`](SmartContract.mdx#approve) - -#### Source - -[lib/mina/zkapp.ts:959](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L959) - -*** - -### approveAccountUpdate() - -```ts -approveAccountUpdate(accountUpdate: AccountUpdate | AccountUpdateTree): Promise -``` - -Approve a single account update (with arbitrarily many children). - -#### Parameters - -• **accountUpdate**: [`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L144) - -*** - -### approveAccountUpdates() - -```ts -approveAccountUpdates(accountUpdates: (AccountUpdate | AccountUpdateTree)[]): Promise -``` - -Approve a list of account updates (with arbitrarily many children). - -#### Parameters - -• **accountUpdates**: ([`AccountUpdate`](AccountUpdate.mdx) \| [`AccountUpdateTree`](AccountUpdateTree.mdx))[] - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L152) - -*** - -### approveBase() - -```ts -abstract approveBase(forest: AccountUpdateForest): Promise -``` - -#### Parameters - -• **forest**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L84) - -*** - -### checkZeroBalanceChange() - -```ts -checkZeroBalanceChange(updates: AccountUpdateForest): void -``` - -Use `forEachUpdate()` to prove that the total balance change of child account updates is zero. - -This is provided out of the box as it is both a good example, and probably the most common implementation, of `approveBase()`. - -#### Parameters - -• **updates**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -#### Returns - -`void` - -#### Source - -[lib/mina/token/token-contract.ts:128](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L128) - -*** - -### deploy() - -```ts -deploy(args?: DeployArgs): Promise -``` - -Deploys a [TokenContract](TokenContract.mdx). - -In addition to base smart contract deployment, this adds two steps: -- set the `access` permission to `proofOrSignature()`, to prevent against unauthorized token operations - - not doing this would imply that anyone can bypass token contract authorization and simply mint themselves tokens -- require the zkapp account to be new, using the `isNew` precondition. - this guarantees that the access permission is set from the very start of the existence of this account. - creating the zkapp account before deployment would otherwise be a security vulnerability that is too easy to introduce. - -Note that because of the `isNew` precondition, the zkapp account must not be created prior to calling `deploy()`. - -If the contract needs to be re-deployed, you can switch off this behaviour by overriding the `isNew` precondition: -```ts -async deploy() { - await super.deploy(); - // DON'T DO THIS ON THE INITIAL DEPLOYMENT! - this.account.isNew.requireNothing(); -} -``` - -#### Parameters - -• **args?**: [`DeployArgs`](../type-aliases/DeployArgs.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Overrides - -[`SmartContract`](SmartContract.mdx).[`deploy`](SmartContract.mdx#deploy) - -#### Source - -[lib/mina/token/token-contract.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L52) - -*** - -### deriveTokenId() - -```ts -deriveTokenId(): Field -``` - -Returns the `tokenId` of the token managed by this contract. - -#### Returns - -[`Field`](Field.mdx) - -#### Source - -[lib/mina/token/token-contract.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L70) - -*** - -### emitEvent() - -```ts -emitEvent(type: K, event: any): void -``` - -Emits an event. Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`emitEvent`](SmartContract.mdx#emitevent) - -#### Source - -[lib/mina/zkapp.ts:1030](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1030) - -*** - -### emitEventIf() - -```ts -emitEventIf( - condition: Bool, - type: K, - event: any): void -``` - -Conditionally emits an event. - -Events will be emitted as a part of the transaction and can be collected by archive nodes. - -#### Type parameters - -• **K** *extends* `string` \| `number` - -#### Parameters - -• **condition**: [`Bool`](Bool.mdx) - -• **type**: `K` - -• **event**: `any` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`emitEventIf`](SmartContract.mdx#emiteventif) - -#### Source - -[lib/mina/zkapp.ts:987](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L987) - -*** - -### fetchEvents() - -```ts -fetchEvents(start?: UInt32, end?: UInt32): Promise<{ - "blockHash": string; - "blockHeight": UInt32; - "chainStatus": string; - "event": { - "data": ProvablePure; - "transactionInfo": { - "transactionHash": string; - "transactionMemo": string; - "transactionStatus": string; - }; - }; - "globalSlot": UInt32; - "parentBlockHash": string; - "type": string; -}[]> -``` - -Asynchronously fetches events emitted by this [SmartContract](SmartContract.mdx) and returns an array of events with their corresponding types. - -#### Parameters - -• **start?**: [`UInt32`](UInt32.mdx)= `undefined` - -The start height of the events to fetch. - -• **end?**: [`UInt32`](UInt32.mdx) - -The end height of the events to fetch. If not provided, fetches events up to the latest height. - -#### Returns - -`Promise`\<\{ - `"blockHash"`: `string`; - `"blockHeight"`: [`UInt32`](UInt32.mdx); - `"chainStatus"`: `string`; - `"event"`: \{ - `"data"`: [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`any`\>; - `"transactionInfo"`: \{ - `"transactionHash"`: `string`; - `"transactionMemo"`: `string`; - `"transactionStatus"`: `string`; - \}; - \}; - `"globalSlot"`: [`UInt32`](UInt32.mdx); - `"parentBlockHash"`: `string`; - `"type"`: `string`; - \}[]\> - -A promise that resolves to an array of objects, each containing the event type and event data for the specified range. - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`fetchEvents`](SmartContract.mdx#fetchevents) - -#### Async - -#### Throws - -If there is an error fetching events from the Mina network. - -#### Example - -```ts -const startHeight = UInt32.from(1000); -const endHeight = UInt32.from(2000); -const events = await myZkapp.fetchEvents(startHeight, endHeight); -console.log(events); -``` - -#### Source - -[lib/mina/zkapp.ts:1047](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1047) - -*** - -### forEachUpdate() - -```ts -forEachUpdate(updates: AccountUpdateForest, callback: (update: AccountUpdate, usesToken: Bool) => void): void -``` - -Iterate through the account updates in `updates` and apply `callback` to each. - -This method is provable and is suitable as a base for implementing `approveUpdates()`. - -#### Parameters - -• **updates**: [`AccountUpdateForest`](AccountUpdateForest.mdx) - -• **callback** - -#### Returns - -`void` - -#### Source - -[lib/mina/token/token-contract.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L91) - -*** - -### init() - -```ts -init(): void -``` - -`SmartContract.init()` will be called only when a [SmartContract](SmartContract.mdx) will be first deployed, not for redeployment. -This method can be overridden as follows -``` -class MyContract extends SmartContract { - init() { - super.init(); - this.account.permissions.set(...); - this.x.set(Field(1)); - } -} -``` - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`init`](SmartContract.mdx#init) - -#### Source - -[lib/mina/zkapp.ts:771](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L771) - -*** - -### newSelf() - -```ts -newSelf(methodName?: string): AccountUpdate -``` - -Same as `SmartContract.self` but explicitly creates a new [AccountUpdate](AccountUpdate.mdx). - -#### Parameters - -• **methodName?**: `string` - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`newSelf`](SmartContract.mdx#newself) - -#### Source - -[lib/mina/zkapp.ts:858](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L858) - -*** - -### requireSignature() - -```ts -requireSignature(): void -``` - -Use this command if the account update created by this SmartContract should be signed by the account owner, -instead of authorized with a proof. - -Note that the smart contract's [Permissions](../variables/Permissions.mdx) determine which updates have to be (can be) authorized by a signature. - -If you only want to avoid creating proofs for quicker testing, we advise you to -use `LocalBlockchain({ proofsEnabled: false })` instead of `requireSignature()`. Setting -`proofsEnabled` to `false` allows you to test your transactions with the same authorization flow as in production, -with the only difference being that quick mock proofs are filled in instead of real proofs. - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`requireSignature`](SmartContract.mdx#requiresignature) - -#### Source - -[lib/mina/zkapp.ts:804](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L804) - -*** - -### send() - -```ts -send(args: { - "amount": number | bigint | UInt64; - "to": PublicKey | AccountUpdate | SmartContract; - }): AccountUpdate -``` - -#### Parameters - -• **args** - -• **args.amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -• **args.to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) \| [`SmartContract`](SmartContract.mdx) - -#### Returns - -[`AccountUpdate`](AccountUpdate.mdx) - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`send`](SmartContract.mdx#send) - -#### Source - -[lib/mina/zkapp.ts:963](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L963) - -*** - -### skipAuthorization() - -```ts -skipAuthorization(): void -``` - -Use this command if the account update created by this SmartContract should have no authorization on it, -instead of being authorized with a proof. - -WARNING: This is a method that should rarely be useful. If you want to disable proofs for quicker testing, take a look -at `LocalBlockchain({ proofsEnabled: false })`, which causes mock proofs to be created and doesn't require changing the -authorization flow. - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`skipAuthorization`](SmartContract.mdx#skipauthorization) - -#### Source - -[lib/mina/zkapp.ts:816](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L816) - -*** - -### transfer() - -```ts -transfer( - from: PublicKey | AccountUpdate, - to: PublicKey | AccountUpdate, -amount: number | bigint | UInt64): Promise -``` - -Transfer `amount` of tokens from `from` to `to`. - -#### Parameters - -• **from**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) - -• **to**: [`PublicKey`](PublicKey.mdx) \| [`AccountUpdate`](AccountUpdate.mdx) - -• **amount**: `number` \| `bigint` \| [`UInt64`](UInt64.mdx) - -#### Returns - -`Promise`\<`void`\> - -#### Source - -[lib/mina/token/token-contract.ts:164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/token/token-contract.ts#L164) - -*** - -### Proof() - -```ts -static Proof(): typeof __class -``` - -Returns a Proof type that belongs to this [SmartContract](SmartContract.mdx). - -#### Returns - -*typeof* `__class` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`Proof`](SmartContract.mdx#proof) - -#### Source - -[lib/mina/zkapp.ts:605](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L605) - -*** - -### analyzeMethods() - -```ts -static analyzeMethods(__namedParameters: { - "printSummary": false; - }): Promise> -``` - -This function is run internally before compiling a smart contract, to collect metadata about what each of your -smart contract methods does. - -For external usage, this function can be handy because calling it involves running all methods in the same "mode" as `compile()` does, -so it serves as a quick-to-run check for whether your contract can be compiled without errors, which can greatly speed up iterating. - -`analyzeMethods()` will also return the number of `rows` of each of your method circuits (i.e., the number of constraints in the underlying proof system), -which is a good indicator for circuit size and the time it will take to create proofs. -To inspect the created circuit in detail, you can look at the returned `gates`. - -Note: If this function was already called before, it will short-circuit and just return the metadata collected the first time. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.printSummary**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<`Record`\<`string`, \{ - `"actions"`: `number`; - `"digest"`: `string`; - `"gates"`: `Gate`[]; - `"rows"`: `number`; - \}\>\> - -an object, keyed by method name, each entry containing: - - `rows` the size of the constraint system created by this method - - `digest` a digest of the method circuit - - `actions` the number of actions the method dispatches - - `gates` the constraint system, represented as an array of gates - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`analyzeMethods`](SmartContract.mdx#analyzemethods) - -#### Source - -[lib/mina/zkapp.ts:1178](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1178) - -*** - -### compile() - -```ts -static compile(__namedParameters: { - "cache": Cache.FileSystemDefault; - "forceRecompile": false; - }): Promise<{ - "provers": Prover[]; - "verificationKey": { - "data": string; - "hash": Field; - }; - "verify": (statement: Statement, proof: unknown) => Promise; -}> -``` - -Compile your smart contract. - -This generates both the prover functions, needed to create proofs for running `@method`s, -and the verification key, needed to deploy your zkApp. - -Although provers and verification key are returned by this method, they are also cached internally and used when needed, -so you don't actually have to use the return value of this function. - -Under the hood, "compiling" means calling into the lower-level [Pickles and Kimchi libraries](https://o1-labs.github.io/proof-systems/kimchi/overview.html) to -create multiple prover & verifier indices (one for each smart contract method as part of a "step circuit" and one for the "wrap circuit" which recursively wraps -it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**, -up to several minutes if your circuit is large or your hardware is not optimal for these operations. - -#### Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.cache**: `undefined` \| [`Cache`](../type-aliases/Cache.mdx)= `Cache.FileSystemDefault` - -• **\_\_namedParameters.forceRecompile**: `undefined` \| `boolean`= `false` - -#### Returns - -`Promise`\<\{ - `"provers"`: `Prover`[]; - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](Field.mdx); - \}; - `"verify"`: (`statement`: `Statement`\<`FieldConst`\>, `proof`: `unknown`) => `Promise`\<`boolean`\>; - \}\> - -> ##### provers -> -> ```ts -> provers: Prover[]; -> ``` -> -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> -> ##### verify() -> -> ```ts -> verify: (statement: Statement, proof: unknown) => Promise; -> ``` -> -> ###### Parameters -> -> • **statement**: `Statement`\<`FieldConst`\> -> -> • **proof**: `unknown` -> -> ###### Returns -> -> `Promise`\<`boolean`\> -> - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`compile`](SmartContract.mdx#compile) - -#### Source - -[lib/mina/zkapp.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L642) - -*** - -### digest() - -```ts -static digest(): Promise -``` - -Computes a hash of your smart contract, which will reliably change _whenever one of your method circuits changes_. -This digest is quick to compute. it is designed to help with deciding whether a contract should be re-compiled or -a cached verification key can be used. - -#### Returns - -`Promise`\<`string`\> - -the digest, as a hex string - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`digest`](SmartContract.mdx#digest) - -#### Source - -[lib/mina/zkapp.ts:683](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L683) - -*** - -### runOutsideCircuit() - -```ts -static runOutsideCircuit(run: () => void): void -``` - -#### Parameters - -• **run** - -#### Returns - -`void` - -#### Inherited from - -[`SmartContract`](SmartContract.mdx).[`runOutsideCircuit`](SmartContract.mdx#runoutsidecircuit) - -#### Source - -[lib/mina/zkapp.ts:1153](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1153) - ---- -url: /zkapps/o1js-reference/classes/TokenSymbol ---- - -## Extends - -- \{ - `"field"`: [`Field`](Field.mdx); - `"symbol"`: `string`; - \} - -## Constructors - -### new TokenSymbol() - -```ts -new TokenSymbol(value: { - "field": Field; - "symbol": string; - }): TokenSymbol -``` - -#### Parameters - -• **value** - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -[`TokenSymbol`](TokenSymbol.mdx) - -#### Inherited from - -`Struct(TokenSymbolPure).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### field - -```ts -field: Field; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).field` - -#### Source - -[lib/provable/crypto/poseidon.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L212) - -*** - -### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).symbol` - -#### Source - -[lib/provable/crypto/poseidon.ts:212](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L212) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct(TokenSymbolPure)._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "field": Field; - "symbol": string; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -`void` - -#### Inherited from - -`Struct(TokenSymbolPure).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "field": Field; - "symbol": string; -}; -``` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[], aux: any[]) => { - "field": Field; - "symbol": string; -}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling [toFields](TokenSymbol.mdx#tofields) and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of [Field](Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L59) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: string) => { - "field": Field; - "symbol": string; -}; -``` - -#### Parameters - -• **x**: `string` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: string | { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; - } & (value: string | { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct(TokenSymbolPure).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "field": Field; - "symbol": string; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.field?**: [`Field`](Field.mdx) - -• **value.symbol?**: `string` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct(TokenSymbolPure).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "field": Field; - "symbol": string; - }) => { - "field": Field; - "symbol": string; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -```ts -{ - "field": Field; - "symbol": string; -} -``` - -##### field - -```ts -field: Field; -``` - -##### symbol - -```ts -symbol: string; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "field": Field; - "symbol": string; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.field**: [`Field`](Field.mdx) - -• **value.symbol**: `string` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct(TokenSymbolPure).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "field": Field; - "symbol": string; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct(TokenSymbolPure).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "field": Field; - "symbol": string; - }) => string; -``` - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -`string` - -#### Inherited from - -`Struct(TokenSymbolPure).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "field": Field; - "symbol": string; - }) => string; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.field**: [`Field`](Field.mdx) - -• **x.symbol**: `string` - -#### Returns - -`string` - -#### Inherited from - -`Struct(TokenSymbolPure).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### from() - -```ts -static from(value: string | TokenSymbol): TokenSymbol -``` - -#### Parameters - -• **value**: `string` \| [`TokenSymbol`](TokenSymbol.mdx) - -#### Returns - -[`TokenSymbol`](TokenSymbol.mdx) - -#### Source - -[lib/provable/crypto/poseidon.ts:259](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L259) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct(TokenSymbolPure).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/classes/UInt32 ---- - -A 32 bit unsigned integer with values ranging from 0 to 4,294,967,295. - -## Extends - -- `CircuitValue` - -## Constructors - -### new UInt32() - -```ts -new UInt32(x: - | string - | number - | bigint - | FieldVar - | UInt32): UInt32 -``` - -Create a [UInt32](UInt32.mdx). -The max value of a [UInt32](UInt32.mdx) is `2^32 - 1 = UInt32.MAXINT()`. - -**Warning**: Cannot overflow, an error is thrown if the result is greater than UInt32.MAXINT() - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/int.ts:540](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L540) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:531](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L531) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 32; -``` - -#### Source - -[lib/provable/int.ts:532](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L532) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt32; -}; -``` - -#### fromField() - -Create a [UInt32](UInt32.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 32 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt32.from](UInt32.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:548](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L548) - -## Accessors - -### one - -```ts -get static one(): UInt32 -``` - -Static method to create a [UInt32](UInt32.mdx) with value `0`. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:570](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L570) - -*** - -### zero - -```ts -get static zero(): UInt32 -``` - -Static method to create a [UInt32](UInt32.mdx) with value `0`. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:563](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L563) - -## Methods - -### add() - -```ts -add(y: number | UInt32): UInt32 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:717](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L717) - -*** - -### addMod32() - -```ts -addMod32(y: UInt32): UInt32 -``` - -Addition modulo 2^32. Check Gadgets.addMod32 for a detailed description. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:643](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L643) - -*** - -### and() - -```ts -and(x: UInt32): UInt32 -``` - -Bitwise AND gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values below. - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```typescript -let a = UInt32.from(3); // ... 000011 -let b = UInt32.from(5); // ... 000101 - -let c = a.and(b, 2); // ... 000001 -c.assertEquals(1); -``` - -#### Source - -[lib/provable/int.ts:888](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L888) - -*** - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:975](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L975) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:989](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L989) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:952](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L952) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: UInt32, message?: string): void -``` - -Asserts that a [UInt32](UInt32.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:924](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L924) - -*** - -### div() - -```ts -div(y: number | UInt32): UInt32 -``` - -Integer division. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -`z` such that `x * y <= x`. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:694](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L694) - -*** - -### divMod() - -```ts -divMod(y: string | number | UInt32): { - "quotient": UInt32; - "rest": UInt32; -} -``` - -Integer division with remainder. - -`x.divMod(y)` returns the quotient and the remainder. - -#### Parameters - -• **y**: `string` \| `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -```ts -{ - "quotient": UInt32; - "rest": UInt32; -} -``` - -##### quotient - -```ts -quotient: UInt32; -``` - -##### rest - -```ts -rest: UInt32; -``` - -#### Source - -[lib/provable/int.ts:652](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L652) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### greaterThan() - -```ts -greaterThan(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:968](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L968) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:982](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L982) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### leftShift() - -```ts -leftShift(bits: number): UInt32 -``` - -Performs a left shift operation on the provided [UInt32](UInt32.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -The operation expects the input to be range checked to 32 bit. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt32](UInt32.mdx) element to the left. The amount should be between 0 and 32 (or else the shift will fail). - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); // 12 in binary -const y = x.leftShift(2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:836](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L836) - -*** - -### lessThan() - -```ts -lessThan(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:940](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L940) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: UInt32): Bool -``` - -Checks if a [UInt32](UInt32.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:912](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L912) - -*** - -### mod() - -```ts -mod(y: number | UInt32): UInt32 -``` - -Integer remainder. - -`x.mod(y)` returns the value `z` such that `0 <= z < y` and -`x - z` is divisible by `y`. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:703](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L703) - -*** - -### mul() - -```ts -mul(y: number | UInt32): UInt32 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:709](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L709) - -*** - -### not() - -```ts -not(): UInt32 -``` - -Bitwise NOT gate on [UInt32](UInt32.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate operates over 32 bit for UInt32 types. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -NOT is implemented as a subtraction of the input from the all one bitmask. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -// NOTing 4 bits with the unchecked version -let a = UInt32.from(0b0101); -let b = a.not(); - -console.log(b.toBigInt().toString(2)); -// 11111111111111111111111111111010 -``` - -#### Source - -[lib/provable/int.ts:781](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L781) - -*** - -### or() - -```ts -or(x: UInt32): UInt32 -``` - -Bitwise OR gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```typescript -let a = UInt32.from(3); // ... 000011 -let b = UInt32.from(5); // ... 000101 - -let c = a.or(b); // ... 000111 -c.assertEquals(7); -``` - -#### Source - -[lib/provable/int.ts:905](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L905) - -*** - -### rightShift() - -```ts -rightShift(bits: number): UInt32 -``` - -Performs a left right operation on the provided [UInt32](UInt32.mdx) element. -This operation is similar to the `>>` shift operation in JavaScript, -where bits are shifted to the right, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt32](UInt32.mdx) element to the right. The amount should be between 0 and 32 (or else the shift will fail). - -The operation expects the input to be range checked to 32 bit. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); // 12 in binary -const y = x.rightShift(2); // left shift by 2 bits -y.assertEquals(0b000011); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:859](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L859) - -*** - -### rotate() - -```ts -rotate(bits: number, direction: "left" | "right"): UInt32 -``` - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -To safely use `rotate()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **bits**: `number` - -amount of bits to rotate this [UInt32](UInt32.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -const x = UInt32.from(0b001100); -const y = x.rotate(2, 'left'); -const z = x.rotate(2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); -``` - -#### Source - -[lib/provable/int.ts:813](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L813) - -*** - -### sub() - -```ts -sub(y: number | UInt32): UInt32 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:725](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L725) - -*** - -### toBigint() - -```ts -toBigint(): bigint -``` - -Turns the [UInt32](UInt32.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:582](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L582) - -*** - -### toBytes() - -```ts -toBytes(): [UInt8, UInt8, UInt8, UInt8] -``` - -Split a UInt32 into 4 UInt8s, in little-endian order. - -#### Returns - -[[`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx)] - -#### Source - -[lib/provable/int.ts:1006](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1006) - -*** - -### toBytesBE() - -```ts -toBytesBE(): [UInt8, UInt8, UInt8, UInt8] -``` - -Split a UInt32 into 4 UInt8s, in big-endian order. - -#### Returns - -[[`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx), [`UInt8`](UInt8.mdx)] - -#### Source - -[lib/provable/int.ts:1013](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1013) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [UInt32](UInt32.mdx) into a string. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:576](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L576) - -*** - -### toUInt64() - -```ts -toUInt64(): UInt64 -``` - -Turns the [UInt32](UInt32.mdx) into a [UInt64](UInt64.mdx). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:588](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L588) - -*** - -### xor() - -```ts -xor(x: UInt32): UInt32 -``` - -Bitwise XOR gadget on [UInt32](UInt32.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -[UInt32](UInt32.mdx) element to compare. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Example - -```ts -let a = UInt32.from(0b0101); -let b = UInt32.from(0b0011); - -let c = a.xor(b); -c.assertEquals(0b0110); -``` - -#### Source - -[lib/provable/int.ts:750](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L750) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt32 -``` - -Creates a [UInt32](UInt32.mdx) with a value of 4,294,967,295. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:636](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L636) - -*** - -### check() - -```ts -static check(x: UInt32): void -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:593](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L593) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: string | number | bigint | UInt32): UInt32 -``` - -Creates a new [UInt32](UInt32.mdx). - -#### Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:628](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L628) - -*** - -### fromBytes() - -```ts -static fromBytes(bytes: UInt8[]): UInt32 -``` - -Combine 4 UInt8s into a UInt32, in little-endian order. - -#### Parameters - -• **bytes**: [`UInt8`](UInt8.mdx)[] - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1020](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1020) - -*** - -### fromBytesBE() - -```ts -static fromBytesBE(bytes: UInt8[]): UInt32 -``` - -Combine 4 UInt8s into a UInt32, in big-endian order. - -#### Parameters - -• **bytes**: [`UInt8`](UInt8.mdx)[] - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1028](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1028) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): InstanceType -``` - -Decodes a JSON-like object into this structure. - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:609](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L609) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | UInt32): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`UInt32`](UInt32.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:997](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L997) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: UInt32): HashInput -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:596](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L596) - -*** - -### toJSON() - -```ts -static toJSON(x: UInt32): string -``` - -Encodes this structure into a JSON-like object. - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`string` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:602](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L602) - -*** - -### toValue() - -```ts -static toValue(x: UInt32): bigint -``` - -#### Parameters - -• **x**: [`UInt32`](UInt32.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:993](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L993) - ---- -url: /zkapps/o1js-reference/classes/UInt64 ---- - -A 64 bit unsigned integer with values ranging from 0 to 18,446,744,073,709,551,615. - -## Extends - -- `CircuitValue` - -## Constructors - -### new UInt64() - -```ts -new UInt64(x: - | string - | number - | bigint - | FieldVar - | UInt64 - | UInt32): UInt64 -``` - -Create a [UInt64](UInt64.mdx). -The max value of a [UInt64](UInt64.mdx) is `2^64 - 1 = UInt64.MAXINT()`. - -**Warning**: Cannot overflow, an error is thrown if the result is greater than UInt64.MAXINT() - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| `FieldVar` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Overrides - -`CircuitValue.constructor` - -#### Source - -[lib/provable/int.ts:40](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L40) - -## Properties - -### value - -```ts -value: Field; -``` - -#### Source - -[lib/provable/int.ts:31](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L31) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 64; -``` - -#### Source - -[lib/provable/int.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L32) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt64; -}; -``` - -#### fromField() - -Create a [UInt64](UInt64.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 64 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt64.from](UInt64.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:48](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L48) - -## Accessors - -### one - -```ts -get static one(): UInt64 -``` - -Static method to create a [UInt64](UInt64.mdx) with value `1`. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L69) - -*** - -### zero - -```ts -get static zero(): UInt64 -``` - -Static method to create a [UInt64](UInt64.mdx) with value `0`. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:63](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L63) - -## Methods - -### add() - -```ts -add(y: number | UInt64): UInt64 -``` - -Addition with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:241](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L241) - -*** - -### addMod64() - -```ts -addMod64(y: UInt64): UInt64 -``` - -Addition modulo 2^64. Check Gadgets.addMod64 for a detailed description. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L163) - -*** - -### and() - -```ts -and(x: UInt64): UInt64 -``` - -Bitwise AND gadget on [UInt64](UInt64.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values below. - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```typescript -let a = UInt64.from(3); // ... 000011 -let b = UInt64.from(5); // ... 000101 - -let c = a.and(b); // ... 000001 -c.assertEquals(1); -``` - -#### Source - -[lib/provable/int.ts:411](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L411) - -*** - -### assertEquals() - -```ts -assertEquals(x: this): void -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -`void` - -#### Inherited from - -`CircuitValue.assertEquals` - -#### Source - -[lib/provable/types/circuit-value.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L130) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L499) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:513](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L513) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:476](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L476) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: UInt64, message?: string): void -``` - -Asserts that a [UInt64](UInt64.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:447](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L447) - -*** - -### div() - -```ts -div(y: number | UInt64): UInt64 -``` - -Integer division. - -`x.div(y)` returns the floor of `x / y`, that is, the greatest -`z` such that `z * y <= x`. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:215](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L215) - -*** - -### divMod() - -```ts -divMod(y: string | number | UInt64): { - "quotient": UInt64; - "rest": UInt64; -} -``` - -Integer division with remainder. - -`x.divMod(y)` returns the quotient and the remainder. - -#### Parameters - -• **y**: `string` \| `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -```ts -{ - "quotient": UInt64; - "rest": UInt64; -} -``` - -##### quotient - -```ts -quotient: UInt64; -``` - -##### rest - -```ts -rest: UInt64; -``` - -#### Source - -[lib/provable/int.ts:172](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L172) - -*** - -### equals() - -```ts -equals(x: this): Bool -``` - -#### Parameters - -• **x**: `this` - -#### Returns - -[`Bool`](Bool.mdx) - -#### Inherited from - -`CircuitValue.equals` - -#### Source - -[lib/provable/types/circuit-value.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L126) - -*** - -### greaterThan() - -```ts -greaterThan(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is greater than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:492](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L492) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is greater than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:506](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L506) - -*** - -### isConstant() - -```ts -isConstant(): boolean -``` - -#### Returns - -`boolean` - -#### Inherited from - -`CircuitValue.isConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L134) - -*** - -### leftShift() - -```ts -leftShift(bits: number): UInt64 -``` - -Performs a left shift operation on the provided [UInt64](UInt64.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt64](UInt64.mdx) element to the left. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); // 12 in binary -const y = x.leftShift(2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -#### Source - -[lib/provable/int.ts:361](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L361) - -*** - -### lessThan() - -```ts -lessThan(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is less than another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:464](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L464) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: UInt64): Bool -``` - -Checks if a [UInt64](UInt64.mdx) is less than or equal to another one. - -#### Parameters - -• **y**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Source - -[lib/provable/int.ts:435](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L435) - -*** - -### mod() - -```ts -mod(y: number | UInt64): UInt64 -``` - -Integer remainder. - -`x.mod(y)` returns the value `z` such that `0 <= z < y` and -`x - z` is divisible by `y`. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:225](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L225) - -*** - -### mul() - -```ts -mul(y: number | UInt64): UInt64 -``` - -Multiplication with overflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:232](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L232) - -*** - -### not() - -```ts -not(): UInt64 -``` - -Bitwise NOT gate on [Field](../variables/Field.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate operates over 64 bit for UInt64 types. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -NOT is implemented as a subtraction of the input from the all one bitmask - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -// NOTing 4 bits with the unchecked version -let a = UInt64.from(0b0101); -let b = a.not(false); - -console.log(b.toBigInt().toString(2)); -// 1111111111111111111111111111111111111111111111111111111111111010 - -``` - -#### Source - -[lib/provable/int.ts:308](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L308) - -*** - -### or() - -```ts -or(x: UInt64): UInt64 -``` - -Bitwise OR gadget on [UInt64](UInt64.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```typescript -let a = UInt64.from(3); // ... 000011 -let b = UInt64.from(5); // ... 000101 - -let c = a.or(b); // ... 000111 -c.assertEquals(7); -``` - -#### Source - -[lib/provable/int.ts:428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L428) - -*** - -### rightShift() - -```ts -rightShift(bits: number): UInt64 -``` - -Performs a right shift operation on the provided [UInt64](UInt64.mdx) element. -This operation is similar to the `>>` shift operation in JavaScript, -where bits are shifted to the right, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -#### Parameters - -• **bits**: `number` - -Amount of bits to shift the [UInt64](UInt64.mdx) element to the right. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); // 12 in binary -const y = x.rightShift(2); // right shift by 2 bits -y.assertEquals(0b000011); // 3 in binary -``` - -#### Source - -[lib/provable/int.ts:382](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L382) - -*** - -### rotate() - -```ts -rotate(bits: number, direction: "left" | "right"): UInt64 -``` - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -To safely use `rotate()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **bits**: `number` - -amount of bits to rotate this [UInt64](UInt64.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -const x = UInt64.from(0b001100); -const y = x.rotate(2, 'left'); -const z = x.rotate(2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); -``` - -#### Source - -[lib/provable/int.ts:340](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L340) - -*** - -### sub() - -```ts -sub(y: number | UInt64): UInt64 -``` - -Subtraction with underflow checking. - -#### Parameters - -• **y**: `number` \| [`UInt64`](UInt64.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:250](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L250) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Turns the [UInt64](UInt64.mdx) into a BigInt. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:83](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L83) - -*** - -### toConstant() - -```ts -toConstant(): this -``` - -#### Returns - -`this` - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:122](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L122) - -*** - -### toFields() - -```ts -toFields(): Field[] -``` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L85) - -*** - -### toJSON() - -```ts -toJSON(): any -``` - -#### Returns - -`any` - -#### Inherited from - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/types/circuit-value.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L118) - -*** - -### toString() - -```ts -toString(): string -``` - -Turns the [UInt64](UInt64.mdx) into a string. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L76) - -*** - -### toUInt32() - -```ts -toUInt32(): UInt32 -``` - -Turns the [UInt64](UInt64.mdx) into a [UInt32](UInt32.mdx), asserting that it fits in 32 bits. - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:90](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L90) - -*** - -### toUInt32Clamped() - -```ts -toUInt32Clamped(): UInt32 -``` - -Turns the [UInt64](UInt64.mdx) into a [UInt32](UInt32.mdx), clamping to the 32 bits range if it's too large. -```ts -UInt64.from(4294967296).toUInt32Clamped().toString(); // "4294967295" -``` - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L102) - -*** - -### xor() - -```ts -xor(x: UInt64): UInt64 -``` - -Bitwise XOR gadget on [Field](../variables/Field.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -[UInt64](UInt64.mdx) element to XOR. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Example - -```ts -let a = UInt64.from(0b0101); -let b = UInt64.from(0b0011); - -let c = a.xor(b); -c.assertEquals(0b0110); -``` - -#### Source - -[lib/provable/int.ts:275](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L275) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt64 -``` - -Creates a [UInt64](UInt64.mdx) with a value of 18,446,744,073,709,551,615. - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L156) - -*** - -### check() - -```ts -static check(x: UInt64): void -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`void` - -#### Overrides - -`CircuitValue.check` - -#### Source - -[lib/provable/int.ts:112](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L112) - -*** - -### empty() - -```ts -static empty(): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.empty` - -#### Source - -[lib/provable/types/circuit-value.ts:230](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L230) - -*** - -### from() - -```ts -static from(x: - | string - | number - | bigint - | UInt64 - | UInt32): UInt64 -``` - -Creates a new [UInt64](UInt64.mdx). - -#### Parameters - -• **x**: - \| `string` - \| `number` - \| `bigint` - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L148) - -*** - -### fromFields() - -```ts -static fromFields(this: T, xs: Field[]): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **xs**: [`Field`](Field.mdx)[] - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromFields` - -#### Source - -[lib/provable/types/circuit-value.ts:138](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L138) - -*** - -### fromJSON() - -```ts -static fromJSON(x: string): InstanceType -``` - -Decodes a JSON-like object into this structure. - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `string` - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromJSON` - -#### Source - -[lib/provable/int.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L130) - -*** - -### fromObject() - -```ts -static fromObject(this: T, value: NonMethods>): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `NonMethods`\<`InstanceType`\<`T`\>\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.fromObject` - -#### Source - -[lib/provable/types/circuit-value.ts:30](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L30) - -*** - -### fromValue() - -```ts -static fromValue(x: bigint | UInt64): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **x**: `bigint` \| [`UInt64`](UInt64.mdx) - -#### Returns - -`InstanceType`\<`T`\> - -#### Overrides - -`CircuitValue.fromValue` - -#### Source - -[lib/provable/int.ts:521](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L521) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -#### Returns - -`number` - -#### Inherited from - -`CircuitValue.sizeInFields` - -#### Source - -[lib/provable/types/circuit-value.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L37) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary(): [] -``` - -#### Returns - -[] - -#### Inherited from - -`CircuitValue.toAuxiliary` - -#### Source - -[lib/provable/types/circuit-value.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L59) - -*** - -### toCanonical() - -```ts -static toCanonical(this: T, value: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **value**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toCanonical` - -#### Source - -[lib/provable/types/circuit-value.ts:177](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L177) - -*** - -### toConstant() - -```ts -static toConstant(this: T, t: InstanceType): InstanceType -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **t**: `InstanceType`\<`T`\> - -#### Returns - -`InstanceType`\<`T`\> - -#### Inherited from - -`CircuitValue.toConstant` - -#### Source - -[lib/provable/types/circuit-value.ts:189](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L189) - -*** - -### toFields() - -```ts -static toFields(this: T, v: InstanceType): Field[] -``` - -#### Type parameters - -• **T** *extends* `AnyConstructor` - -#### Parameters - -• **this**: `T` - -• **v**: `InstanceType`\<`T`\> - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`CircuitValue.toFields` - -#### Source - -[lib/provable/types/circuit-value.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/circuit-value.ts#L42) - -*** - -### toInput() - -```ts -static toInput(x: UInt64): HashInput -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`CircuitValue.toInput` - -#### Source - -[lib/provable/int.ts:116](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L116) - -*** - -### toJSON() - -```ts -static toJSON(x: UInt64): string -``` - -Encodes this structure into a JSON-like object. - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`string` - -#### Overrides - -`CircuitValue.toJSON` - -#### Source - -[lib/provable/int.ts:123](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L123) - -*** - -### toValue() - -```ts -static toValue(x: UInt64): bigint -``` - -#### Parameters - -• **x**: [`UInt64`](UInt64.mdx) - -#### Returns - -`bigint` - -#### Overrides - -`CircuitValue.toValue` - -#### Source - -[lib/provable/int.ts:517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L517) - ---- -url: /zkapps/o1js-reference/classes/UInt8 ---- - -A 8 bit unsigned integer with values ranging from 0 to 255. - -## Extends - -- \{ - `"value"`: `Field`; - \} - -## Constructors - -### new UInt8() - -```ts -new UInt8(x: number | bigint | FieldVar | UInt8): UInt8 -``` - -Create a [UInt8](UInt8.mdx) from a bigint or number. -The max value of a [UInt8](UInt8.mdx) is `2^8 - 1 = 255`. - -**Warning**: Cannot overflow past 255, an error is thrown if the result is greater than 255. - -#### Parameters - -• **x**: `number` \| `bigint` \| `FieldVar` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Overrides - -`Struct({ - value: Field, -}).constructor` - -#### Source - -[lib/provable/int.ts:1456](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1456) - -## Properties - -### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).value` - -#### Source - -[lib/provable/int.ts:1446](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1446) - -*** - -### NUM\_BITS - -```ts -static NUM_BITS: number = 8; -``` - -#### Source - -[lib/provable/int.ts:1448](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1448) - -*** - -### Unsafe - -```ts -static Unsafe: { - "fromField": UInt8; -}; -``` - -#### fromField() - -Create a [UInt8](UInt8.mdx) from a [Field](../variables/Field.mdx) without constraining its range. - -**Warning**: This is unsafe, because it does not prove that the input [Field](../variables/Field.mdx) actually fits in 8 bits.\ -Only use this if you know what you are doing, otherwise use the safe [UInt8.from](UInt8.mdx#from). - -##### Parameters - -• **x**: [`Field`](Field.mdx) - -##### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1462](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1462) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - value: Field, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### empty() - -```ts -static empty: () => { - "value": Field; -}; -``` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "value": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: `string`= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "value": Field; - } | { - "value": Field; - }) => { - "value": Field; - } & (value: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - value: Field, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "value": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.value?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - value: Field, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: Field = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "value": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - value: Field, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: string = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "value": Field; - }) => { - "value": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "value": Field; -} -``` - -##### value - -```ts -value: bigint = Field; -``` - -#### Inherited from - -`Struct({ - value: Field, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Accessors - -### one - -```ts -get static one(): UInt8 -``` - -Static method to create a [UInt8](UInt8.mdx) with value `1`. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1483](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1483) - -*** - -### zero - -```ts -get static zero(): UInt8 -``` - -Static method to create a [UInt8](UInt8.mdx) with value `0`. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1477](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1477) - -## Methods - -### add() - -```ts -add(y: number | bigint | UInt8): UInt8 -``` - -Add a [UInt8](UInt8.mdx) to another [UInt8](UInt8.mdx) without allowing overflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(3); -const sum = x.add(5); -sum.assertEquals(8); -``` - -#### Throws - -if the result is greater than 255. - -#### Source - -[lib/provable/int.ts:1499](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1499) - -*** - -### assertEquals() - -```ts -assertEquals(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is equal another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1765](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1765) - -*** - -### assertGreaterThan() - -```ts -assertGreaterThan(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is greater than another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1741](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1741) - -*** - -### assertGreaterThanOrEqual() - -```ts -assertGreaterThanOrEqual(y: UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is greater than or equal to another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1753](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1753) - -*** - -### assertLessThan() - -```ts -assertLessThan(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is less than another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1659](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1659) - -*** - -### assertLessThanOrEqual() - -```ts -assertLessThanOrEqual(y: number | bigint | UInt8, message?: string): void -``` - -Assert that this [UInt8](UInt8.mdx) is less than or equal to another [UInt8](UInt8.mdx) value. - -**Important**: If an assertion fails, the code throws an error. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -the [UInt8](UInt8.mdx) value to compare & assert with this [UInt8](UInt8.mdx). - -• **message?**: `string` - -#### Returns - -`void` - -#### Source - -[lib/provable/int.ts:1684](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1684) - -*** - -### div() - -```ts -div(y: number | bigint | UInt8): UInt8 -``` - -Divide a [UInt8](UInt8.mdx) by another [UInt8](UInt8.mdx). -This is integer division that rounds down. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(7); -const quotient = x.div(2); -quotient.assertEquals(3); -``` - -#### Source - -[lib/provable/int.ts:1552](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1552) - -*** - -### divMod() - -```ts -divMod(y: number | bigint | UInt8): { - "quotient": UInt8; - "remainder": UInt8; -} -``` - -Get the quotient and remainder of a [UInt8](UInt8.mdx) divided by another [UInt8](UInt8.mdx): - -`x == y * q + r`, where `0 <= r < y`. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -a [UInt8](UInt8.mdx) to get the quotient and remainder of another [UInt8](UInt8.mdx). - -#### Returns - -```ts -{ - "quotient": UInt8; - "remainder": UInt8; -} -``` - -The quotient `q` and remainder `r`. - -##### quotient - -```ts -quotient: UInt8; -``` - -##### remainder - -```ts -remainder: UInt8; -``` - -#### Source - -[lib/provable/int.ts:1579](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1579) - -*** - -### greaterThan() - -```ts -greaterThan(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is greater than another [UInt8](UInt8.mdx). -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// 5 > 3 -UInt8.from(5).greaterThan(3); -``` - -#### Source - -[lib/provable/int.ts:1715](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1715) - -*** - -### greaterThanOrEqual() - -```ts -greaterThanOrEqual(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is greater than or equal another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -// 3 >= 3 -UInt8.from(3).greaterThanOrEqual(3); -``` - -#### Source - -[lib/provable/int.ts:1729](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1729) - -*** - -### lessThan() - -```ts -lessThan(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is less than another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -UInt8.from(2).lessThan(UInt8.from(3)); -``` - -#### Source - -[lib/provable/int.ts:1638](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1638) - -*** - -### lessThanOrEqual() - -```ts -lessThanOrEqual(y: number | bigint | UInt8): Bool -``` - -Check if this [UInt8](UInt8.mdx) is less than or equal to another [UInt8](UInt8.mdx) value. -Returns a [Bool](../variables/Bool.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`Bool`](Bool.mdx) - -#### Example - -```ts -UInt8.from(3).lessThanOrEqual(UInt8.from(5)); -``` - -#### Source - -[lib/provable/int.ts:1616](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1616) - -*** - -### mod() - -```ts -mod(y: number | bigint | UInt8): UInt8 -``` - -Get the remainder a [UInt8](UInt8.mdx) of division of another [UInt8](UInt8.mdx). - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(50); -const mod = x.mod(30); -mod.assertEquals(20); -``` - -#### Source - -[lib/provable/int.ts:1566](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1566) - -*** - -### mul() - -```ts -mul(y: number | bigint | UInt8): UInt8 -``` - -Multiply a [UInt8](UInt8.mdx) by another [UInt8](UInt8.mdx) without allowing overflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(3); -const product = x.mul(5); -product.assertEquals(15); -``` - -#### Throws - -if the result is greater than 255. - -#### Source - -[lib/provable/int.ts:1535](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1535) - -*** - -### sub() - -```ts -sub(y: number | bigint | UInt8): UInt8 -``` - -Subtract a [UInt8](UInt8.mdx) from another [UInt8](UInt8.mdx) without allowing underflow. - -#### Parameters - -• **y**: `number` \| `bigint` \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Example - -```ts -const x = UInt8.from(8); -const difference = x.sub(5); -difference.assertEquals(3); -``` - -#### Throws - -if the result is less than 0. - -#### Source - -[lib/provable/int.ts:1517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1517) - -*** - -### toBigInt() - -```ts -toBigInt(): bigint -``` - -Serialize the [UInt8](UInt8.mdx) to a bigint. - -**Warning**: This operation is not provable. - -#### Returns - -`bigint` - -#### Source - -[lib/provable/int.ts:1793](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1793) - -*** - -### toNumber() - -```ts -toNumber(): number -``` - -Serialize the [UInt8](UInt8.mdx) to a number. - -**Warning**: This operation is not provable. - -#### Returns - -`number` - -#### Source - -[lib/provable/int.ts:1784](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1784) - -*** - -### toString() - -```ts -toString(): string -``` - -Serialize the [UInt8](UInt8.mdx) to a string, e.g. for printing. - -**Warning**: This operation is not provable. - -#### Returns - -`string` - -#### Source - -[lib/provable/int.ts:1775](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1775) - -*** - -### toUInt32() - -```ts -toUInt32(): UInt32 -``` - -Turns a [UInt8](UInt8.mdx) into a [UInt32](UInt32.mdx). - -#### Returns - -[`UInt32`](UInt32.mdx) - -#### Source - -[lib/provable/int.ts:1813](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1813) - -*** - -### toUInt64() - -```ts -toUInt64(): UInt64 -``` - -Turns a [UInt8](UInt8.mdx) into a [UInt64](UInt64.mdx). - -#### Returns - -[`UInt64`](UInt64.mdx) - -#### Source - -[lib/provable/int.ts:1820](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1820) - -*** - -### MAXINT() - -```ts -static MAXINT(): UInt8 -``` - -Creates a [UInt8](UInt8.mdx) with a value of 255. - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1827](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1827) - -*** - -### check() - -```ts -static check(x: Field | { - "value": Field; - }): void -``` - -Provable.check for [UInt8](UInt8.mdx). -Proves that the input is in the [0, 255] range. - -#### Parameters - -• **x**: [`Field`](Field.mdx) \| \{ - `"value"`: [`Field`](Field.mdx); - \} - -#### Returns - -`void` - -#### Overrides - -`Struct({ - value: Field, -}).check` - -#### Source - -[lib/provable/int.ts:1801](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1801) - -*** - -### from() - -```ts -static from(x: - | number - | bigint - | Field - | UInt64 - | UInt32 - | UInt8): UInt8 -``` - -Creates a new [UInt8](UInt8.mdx). - -#### Parameters - -• **x**: - \| `number` - \| `bigint` - \| [`Field`](Field.mdx) - \| [`UInt64`](UInt64.mdx) - \| [`UInt32`](UInt32.mdx) - \| [`UInt8`](UInt8.mdx) - -#### Returns - -[`UInt8`](UInt8.mdx) - -#### Source - -[lib/provable/int.ts:1834](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1834) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - value: Field, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - -*** - -### toInput() - -```ts -static toInput(x: { - "value": Field; - }): HashInput -``` - -#### Parameters - -• **x** - -• **x.value**: [`Field`](Field.mdx) - -#### Returns - -`HashInput` - -#### Overrides - -`Struct({ - value: Field, -}).toInput` - -#### Source - -[lib/provable/int.ts:1806](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/int.ts#L1806) - ---- -url: /zkapps/o1js-reference/classes/Unconstrained ---- - -Container which holds an unconstrained value. This can be used to pass values -between the out-of-circuit blocks in provable code. - -Invariants: -- An `Unconstrained`'s value can only be accessed in auxiliary contexts. -- An `Unconstrained` can be empty when compiling, but never empty when running as the prover. - (there is no way to create an empty `Unconstrained` in the prover) - -## Example - -```ts -let x = Unconstrained.from(0n); - -class MyContract extends SmartContract { - `@method` myMethod(x: Unconstrained) { - - Provable.witness(Field, () => { - // we can access and modify `x` here - let newValue = x.get() + otherField.toBigInt(); - x.set(newValue); - - // ... - }); - - // throws an error! - x.get(); - } -``` - -## Type parameters - -• **T** - -## Properties - -### provable - -```ts -static provable: UnconstrainedProvable & { - "empty": () => Unconstrained; - "toInput": (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; - }; -}; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => Unconstrained; -``` - -###### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`any`\> - -##### toInput() - -```ts -toInput: (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -###### Parameters - -• **x**: [`Unconstrained`](Unconstrained.mdx)\<`any`\> - -###### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -###### fields? - -```ts -optional fields: Field[]; -``` - -###### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Source - -[lib/provable/types/unconstrained.ts:111](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L111) - -## Methods - -### get() - -```ts -get(): T -``` - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -#### Returns - -`T` - -#### Source - -[lib/provable/types/unconstrained.ts:53](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L53) - -*** - -### set() - -```ts -set(value: T): void -``` - -Modify the unconstrained value. - -#### Parameters - -• **value**: `T` - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L67) - -*** - -### setTo() - -```ts -setTo(value: Unconstrained): void -``` - -Set the unconstrained value to the same as another `Unconstrained`. - -#### Parameters - -• **value**: [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:74](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L74) - -*** - -### updateAsProver() - -```ts -updateAsProver(compute: (value: T) => T): void -``` - -Update an `Unconstrained` by a witness computation. - -#### Parameters - -• **compute** - -#### Returns - -`void` - -#### Source - -[lib/provable/types/unconstrained.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L104) - -*** - -### from() - -```ts -static from(value: T | Unconstrained): Unconstrained -``` - -Create an `Unconstrained` with the given `value`. - -Note: If `T` contains provable types, `Unconstrained.from` is an anti-pattern, -because it stores witnesses in a space that's intended to be used outside the proof. -Something like the following should be used instead: - -```ts -let xWrapped = Unconstrained.witness(() => Provable.toConstant(type, x)); -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **value**: `T` \| [`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Source - -[lib/provable/types/unconstrained.ts:89](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L89) - -*** - -### withEmpty() - -```ts -static withEmpty(empty: T): Provable, T> & { - "empty": () => Unconstrained; - "toInput": (x: Unconstrained) => { - "fields": Field[]; - "packed": [Field, number][]; - }; -} -``` - -#### Type parameters - -• **T** - -#### Parameters - -• **empty**: `T` - -#### Returns - -`Provable`\<[`Unconstrained`](Unconstrained.mdx)\<`T`\>, `T`\> & \{ - `"empty"`: () => [`Unconstrained`](Unconstrained.mdx)\<`T`\>; - `"toInput"`: (`x`: [`Unconstrained`](Unconstrained.mdx)\<`T`\>) => \{ - `"fields"`: [`Field`](Field.mdx)[]; - `"packed"`: [[`Field`](Field.mdx), `number`][]; - \}; - \} - -#### Source - -[lib/provable/types/unconstrained.ts:131](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L131) - -*** - -### witness() - -```ts -static witness(compute: () => T): Unconstrained -``` - -Create an `Unconstrained` from a witness computation. - -#### Type parameters - -• **T** - -#### Parameters - -• **compute** - -#### Returns - -[`Unconstrained`](Unconstrained.mdx)\<`T`\> - -#### Source - -[lib/provable/types/unconstrained.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/unconstrained.ts#L97) - ---- -url: /zkapps/o1js-reference/classes/VerificationKey ---- - -## Extends - -- \{ - `"data"`: `String`; - `"hash"`: `Field`; - \} - -## Constructors - -### new VerificationKey() - -```ts -new VerificationKey(value: { - "data": String; - "hash": Field; - }): VerificationKey -``` - -#### Parameters - -• **value** - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`VerificationKey`](VerificationKey.mdx) - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### data - -```ts -data: string = String; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).data` - -#### Source - -[lib/proof-system/zkprogram.ts:545](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L545) - -*** - -### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).hash` - -#### Source - -[lib/proof-system/zkprogram.ts:545](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L545) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -})._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "data": String; - "hash": Field; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`void` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "data": String; - "hash": Field; -}; -``` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[], aux: any[]) => { - "data": String; - "hash": Field; -}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling [toFields](VerificationKey.mdx#tofields) and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](Field.mdx)[] - -an array of [Field](Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:59](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L59) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: string) => { - "data": String; - "hash": Field; -}; -``` - -#### Parameters - -• **x**: `string` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "data": String; - "hash": Field; - } | { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; - } & (value: { - "data": String; - "hash": Field; - } | { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "data": String; - "hash": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.data?**: `string`= `String` - -• **value.hash?**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: Field = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "data": String; - "hash": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](Field.mdx) array from. - -• **value.data**: `string`= `String` - -• **value.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -[`Field`](Field.mdx)[] - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "data": String; - "hash": Field; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "data": String; - "hash": Field; - }) => string; -``` - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -`string` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "data": String; - "hash": Field; - }) => { - "data": String; - "hash": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.data**: `string`= `String` - -• **x.hash**: [`Field`](Field.mdx)= `Field` - -#### Returns - -```ts -{ - "data": String; - "hash": Field; -} -``` - -##### data - -```ts -data: string = String; -``` - -##### hash - -```ts -hash: bigint = Field; -``` - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### dummy() - -```ts -static dummy(): Promise -``` - -#### Returns - -`Promise`\<[`VerificationKey`](VerificationKey.mdx)\> - -#### Source - -[lib/proof-system/zkprogram.ts:550](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L550) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](Field.mdx) type, as [Field](Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](Field.mdx) type. - -#### Inherited from - -`Struct({ - ...provable({ data: String, hash: Field }), - toJSON({ data }: { data: string }) { - return data; - }, -}).sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/functions/Bytes ---- - -```ts -function Bytes(size: number): typeof Bytes -``` - -A provable type representing an array of bytes. - -```ts -class Bytes32 extends Bytes(32) {} - -let bytes = Bytes32.fromHex('deadbeef'); -``` - -## Parameters - -• **size**: `number` - -## Returns - -*typeof* `Bytes` - -## Source - -[lib/provable/wrapped-classes.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped-classes.ts#L16) - ---- -url: /zkapps/o1js-reference/functions/ConstantField ---- - -```ts -function ConstantField(x: bigint | ConstantFieldVar): ConstantField -``` - -## Parameters - -• **x**: `bigint` \| `ConstantFieldVar` - -## Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -## Source - -[lib/provable/field.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1246) - ---- -url: /zkapps/o1js-reference/functions/MerkleListBase ---- - -```ts -function MerkleListBase(): ProvableHashable> -``` - -## Type parameters - -• **T** - -## Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`MerkleListBase`](../type-aliases/MerkleListBase.mdx)\<`T`\>\> - -## Source - -[lib/provable/merkle-list.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L46) - ---- -url: /zkapps/o1js-reference/functions/MerkleWitness ---- - -```ts -function MerkleWitness(height: number): typeof BaseMerkleWitness -``` - -Returns a circuit-compatible Witness for a specific Tree height. - -## Parameters - -• **height**: `number` - -Height of the Merkle Tree that this Witness belongs to. - -## Returns - -*typeof* [`BaseMerkleWitness`](../classes/BaseMerkleWitness.mdx) - -A circuit-compatible Merkle Witness. - -## Source - -[lib/provable/merkle-tree.ts:240](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L240) - ---- -url: /zkapps/o1js-reference/functions/Option ---- - -```ts -function Option(type: A): ProvableInferPureFrom, InferValue>, InferValue | undefined> & (option: { - "isSome": Bool; - "value": InferProvable; - }) => Option, InferValue> & { - "from": Option, InferValue>; - "fromValue": Option, InferValue>; - "none": Option, InferValue>; -} -``` - -Define an optional version of a provable type. - -## Type parameters - -• **A** *extends* [`ProvableType`](../type-aliases/ProvableType.mdx) - -## Parameters - -• **type**: `A` - -## Returns - -`ProvableInferPureFrom`\<`A`, [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>, `InferValue`\<`A`\> \| `undefined`\> & (`option`: \{ - `"isSome"`: [`Bool`](../type-aliases/Bool.mdx); - `"value"`: [`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>; - \}) => [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\> & \{ - `"from"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - `"fromValue"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - `"none"`: [`Option`](../type-aliases/Option.mdx)\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>\>; - \} - -## Example - -```ts -class OptionUInt64 extends Option(UInt64) {} - -// create an optional UInt64 -let some = OptionUInt64.from(5n); -let none = OptionUInt64.none(); - -// get back a UInt64 -let five: UInt64 = some.assertSome('must have a value'); -let zero: UInt64 = none.orElse(0n); // specify a default value -``` - -## Source - -[lib/provable/option.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/option.ts#L37) - ---- -url: /zkapps/o1js-reference/functions/Reducer ---- - -```ts -function Reducer(reducer: { - "actionType": T; -}): ReducerReturn -``` - -## Type parameters - -• **T** *extends* [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\> - -• **A** *extends* `any` = [`InferProvable`](../type-aliases/InferProvable.mdx)\<`T`\> - -## Parameters - -• **reducer** - -• **reducer.actionType**: `T` - -## Returns - -`ReducerReturn`\<`A`\> - -## Source - -[lib/mina/actions/reducer.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/reducer.ts#L17) - ---- -url: /zkapps/o1js-reference/functions/State ---- - -```ts -function State(defaultValue?: A): State -``` - -## Type parameters - -• **A** - -## Parameters - -• **defaultValue?**: `A` - -## Returns - -[`State`](../type-aliases/State.mdx)\<`A`\> - -## Source - -[lib/mina/state.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L91) - ---- -url: /zkapps/o1js-reference/functions/Struct ---- - -```ts -function Struct(type: A): (value: T) => T & { - "_isStruct": true; - } & Pure extends true ? ProvablePure : Provable & { - "empty": () => T; - "fromJSON": (x: J) => T; - "fromValue": (value: From) => T; - "toInput": (x: T) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: T) => J; -} -``` - -`Struct` lets you declare composite types for use in o1js circuits. - -These composite types can be passed in as arguments to smart contract methods, used for on-chain state variables -or as event / action types. - -Here's an example of creating a "Voter" struct, which holds a public key and a collection of votes on 3 different proposals: -```ts -let Vote = { hasVoted: Bool, inFavor: Bool }; - -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote] -}) {} - -// use Voter as SmartContract input: -class VoterContract extends SmartContract { - \@method register(voter: Voter) { - // ... - } -} -``` -In this example, there are no instance methods on the class. This makes `Voter` type-compatible with an anonymous object of the form -`{ publicKey: PublicKey, votes: Vote[] }`. -This mean you don't have to create instances by using `new Voter(...)`, you can operate with plain objects: -```ts -voterContract.register({ publicKey, votes }); -``` - -On the other hand, you can also add your own methods: -```ts -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote] -}) { - vote(index: number, inFavor: Bool) { - let vote = this.votes[i]; - vote.hasVoted = Bool(true); - vote.inFavor = inFavor; - } -} -``` - -In this case, you'll need the constructor to create instances of `Voter`. It always takes as input the plain object: -```ts -let emptyVote = { hasVoted: Bool(false), inFavor: Bool(false) }; -let voter = new Voter({ publicKey, votes: Array(3).fill(emptyVote) }); -voter.vote(1, Bool(true)); -``` - -In addition to creating types composed of Field elements, you can also include auxiliary data which does not become part of the proof. -This, for example, allows you to re-use the same type outside o1js methods, where you might want to store additional metadata. - -To declare non-proof values of type `string`, `number`, etc, you can use the built-in objects `String`, `Number`, etc. -Here's how we could add the voter's name (a string) as auxiliary data: -```ts -class Voter extends Struct({ - publicKey: PublicKey, - votes: [Vote, Vote, Vote], - fullName: String -}) {} -``` - -Again, it's important to note that this doesn't enable you to prove anything about the `fullName` string. -From the circuit point of view, it simply doesn't exist! - -## Type parameters - -• **A** - -• **T** *extends* `unknown` = [`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\> - -• **V** *extends* `unknown` = `InferValue`\<`A`\> - -• **J** *extends* `unknown` = `InferJson`\<`A`\> - -• **Pure** *extends* `boolean` = `IsPure`\<`A`\> - -## Parameters - -• **type**: `A` - -Object specifying the layout of the `Struct` - -## Returns - -(`value`: `T`) => `T` & \{ - `"_isStruct"`: `true`; - \} & `Pure` *extends* `true` ? [`ProvablePure`](../type-aliases/ProvablePure.mdx)\<`T`, `V`\> : `Provable`\<`T`, `V`\> & \{ - `"empty"`: () => `T`; - `"fromJSON"`: (`x`: `J`) => `T`; - `"fromValue"`: (`value`: `From`\<`A`\>) => `T`; - `"toInput"`: (`x`: `T`) => \{ - `"fields"`: [`Field`](../type-aliases/Field.mdx)[]; - `"packed"`: [[`Field`](../type-aliases/Field.mdx), `number`][]; - \}; - `"toJSON"`: (`x`: `T`) => `J`; - \} - -Class which you can extend - -## Note - -Ensure you do not use or extend `Struct` as a type directly. Instead, always call it as a function to construct a type. `Struct` is not a valid provable type itself, types created with `Struct(...)` are. - -## Source - -[lib/provable/types/struct.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L140) - ---- -url: /zkapps/o1js-reference/functions/VarField ---- - -```ts -function VarField(x: VarFieldVar): VarField -``` - -## Parameters - -• **x**: `VarFieldVar` - -## Returns - -[`VarField`](../type-aliases/VarField.mdx) - -## Source - -[lib/provable/field.ts:1242](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1242) - ---- -url: /zkapps/o1js-reference/functions/WithHash ---- - -```ts -function WithHash(type: ProvableHashable): ProvableHashable> -``` - -## Type parameters - -• **T** - -## Parameters - -• **type**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -## Returns - -[`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<[`WithHash`](../type-aliases/WithHash.mdx)\<`T`\>\> - -## Source - -[lib/provable/merkle-list.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L28) - ---- -url: /zkapps/o1js-reference/functions/ZkProgram ---- - -```ts -function ZkProgram(config: Config & { - "methods": { [I in string | number | symbol]: Methods[I] }; - "name": string; - "overrideWrapDomain": 0 | 2 | 1; - }): { - "analyzeMethods": () => Promise<{ [I in keyof Config["methods"]]: UnwrapPromise> }>; - "auxiliaryOutputTypes": AuxiliaryOutputs; - "compile": (options?: { - "cache": Cache; - "forceRecompile": boolean; - "proofsEnabled": boolean; - }) => Promise<{ - "verificationKey": { - "data": string; - "hash": Field; - }; - }>; - "digest": () => Promise; - "name": string; - "privateInputTypes": PrivateInputs; - "proofsEnabled": boolean; - "publicInputType": ProvableOrUndefined>; - "publicOutputType": ProvableOrVoid>; - "rawMethods": { [I in keyof Config["methods"]]: Methods[I]["method"] }; - "verify": (proof: Proof>, InferProvableOrVoid>>) => Promise; - "setProofsEnabled": void; - } & { [I in keyof Config["methods"]]: Prover>, InferProvableOrVoid>, PrivateInputs[I], InferProvableOrUndefined> } -``` - -## Type parameters - -• **Config** *extends* \{ - `"methods"`: \{\}; - `"publicInput"`: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx); - `"publicOutput"`: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx); - \} - -• **Methods** *extends* \{ [I in string \| number \| symbol]: Method\\>, InferProvableOrVoid\\>, Config["methods"][I]\> \} - -• **MethodSignatures** *extends* \{\} = `Config`\[`"methods"`\] - -• **PrivateInputs** *extends* \{ [I in string \| number \| symbol]: MethodSignatures[I]["privateInputs"] \} = \{ [I in string \| number \| symbol]: MethodSignatures[I]["privateInputs"] \} - -• **AuxiliaryOutputs** *extends* \{ [I in string \| number \| symbol]: Get\ \} = \{ [I in string \| number \| symbol]: Get\ \} - -## Parameters - -• **config**: `Config` & \{ - `"methods"`: \{ [I in string \| number \| symbol]: Methods[I] \}; - `"name"`: `string`; - `"overrideWrapDomain"`: `0` \| `2` \| `1`; - \} - -## Returns - -\{ - `"analyzeMethods"`: () => `Promise`\<`{ [I in keyof Config["methods"]]: UnwrapPromise> }`\>; - `"auxiliaryOutputTypes"`: `AuxiliaryOutputs`; - `"compile"`: (`options`?: \{ - `"cache"`: [`Cache`](../type-aliases/Cache.mdx); - `"forceRecompile"`: `boolean`; - `"proofsEnabled"`: `boolean`; - \}) => `Promise`\<\{ - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](../type-aliases/Field.mdx); - \}; - \}\>; - `"digest"`: () => `Promise`\<`string`\>; - `"name"`: `string`; - `"privateInputTypes"`: `PrivateInputs`; - `"proofsEnabled"`: `boolean`; - `"publicInputType"`: `ProvableOrUndefined`\<`Get`\<`Config`, `"publicInput"`\>\>; - `"publicOutputType"`: `ProvableOrVoid`\<`Get`\<`Config`, `"publicOutput"`\>\>; - `"rawMethods"`: `{ [I in keyof Config["methods"]]: Methods[I]["method"] }`; - `"verify"`: (`proof`: [`Proof`](../classes/Proof.mdx)\<`InferProvableOrUndefined`\<`Get`\<`Config`, `"publicInput"`\>\>, `InferProvableOrVoid`\<`Get`\<`Config`, `"publicOutput"`\>\>\>) => `Promise`\<`boolean`\>; - `"setProofsEnabled"`: `void`; - \} & `{ [I in keyof Config["methods"]]: Prover>, InferProvableOrVoid>, PrivateInputs[I], InferProvableOrUndefined> }` - -## Source - -[lib/proof-system/zkprogram.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L174) - ---- -url: /zkapps/o1js-reference/functions/addCachedAccount ---- - -```ts -function addCachedAccount(partialAccount: PartialAccount, graphqlEndpoint: string): void -``` - -Adds an account to the local cache, indexed by a GraphQL endpoint. - -## Parameters - -• **partialAccount**: `PartialAccount` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:418](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L418) - ---- -url: /zkapps/o1js-reference/functions/assert ---- - -```ts -function assert(stmt: boolean | Bool, message?: string): asserts stmt -``` - -Assert that a statement is true. If the statement is false, throws an error with the given message. -Can be used in provable code. - -## Parameters - -• **stmt**: `boolean` \| [`Bool`](../classes/Bool.mdx) - -• **message?**: `string` - -## Returns - -`asserts stmt` - -## Source - -[lib/provable/gadgets/common.ts:57](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/common.ts#L57) - ---- -url: /zkapps/o1js-reference/functions/checkBitLength ---- - -```ts -function checkBitLength( - name: string, - length: number, - maxLength: number): void -``` - -## Parameters - -• **name**: `string` - -• **length**: `number` - -• **maxLength**: `number`= `Fp.sizeInBits` - -## Returns - -`void` - -## Source - -[lib/provable/field.ts:1180](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1180) - ---- -url: /zkapps/o1js-reference/functions/checkZkappTransaction ---- - -```ts -function checkZkappTransaction(transactionHash: string, blockLength: number): Promise<{ - "failureReason": string[][][]; - "success": false; - } | { - "failureReason": null; - "success": true; -}> -``` - -## Parameters - -• **transactionHash**: `string` - -• **blockLength**: `number`= `20` - -## Returns - -`Promise`\<\{ - `"failureReason"`: `string`[][][]; - `"success"`: `false`; - \} \| \{ - `"failureReason"`: `null`; - `"success"`: `true`; - \}\> - -## Source - -[lib/mina/fetch.ts:517](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L517) - ---- -url: /zkapps/o1js-reference/functions/circuitMain ---- - -```ts -function circuitMain( - target: typeof Circuit, - propertyName: string, - _descriptor?: PropertyDescriptor): any -``` - -## Parameters - -• **target**: *typeof* [`Circuit`](../classes/Circuit.mdx) - -• **propertyName**: `string` - -• **\_descriptor?**: `PropertyDescriptor` - -## Returns - -`any` - -## Source - -[lib/proof-system/circuit.ts:192](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L192) - ---- -url: /zkapps/o1js-reference/functions/conditionalSwap ---- - -```ts -function conditionalSwap( - b: Bool, - x: Field, - y: Field): [Field, Field] -``` - -## Parameters - -• **b**: [`Bool`](../classes/Bool.mdx) - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -## Returns - -[[`Field`](../type-aliases/Field.mdx), [`Field`](../type-aliases/Field.mdx)] - -## Source - -[lib/provable/merkle-tree.ts:251](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L251) - ---- -url: /zkapps/o1js-reference/functions/createEcdsa ---- - -```ts -function createEcdsa(curve: CurveParams | typeof ForeignCurve): typeof EcdsaSignature -``` - -Create a class [EcdsaSignature](../classes/EcdsaSignature.mdx) for verifying ECDSA signatures on the given curve. - -## Parameters - -• **curve**: `CurveParams` \| *typeof* [`ForeignCurve`](../classes/ForeignCurve.mdx) - -## Returns - -*typeof* [`EcdsaSignature`](../classes/EcdsaSignature.mdx) - -## Source - -[lib/provable/crypto/foreign-ecdsa.ts:246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-ecdsa.ts#L246) - ---- -url: /zkapps/o1js-reference/functions/createForeignCurve ---- - -```ts -function createForeignCurve(params: CurveParams): typeof ForeignCurve -``` - -Create a class representing an elliptic curve group, which is different from the native [Group](../classes/Group.mdx). - -```ts -const Curve = createForeignCurve(Crypto.CurveParams.Secp256k1); -``` - -`createForeignCurve(params)` takes curve parameters CurveParams as input. -We support `modulus` and `order` to be prime numbers up to 259 bits. - -The returned ForeignCurveNotNeeded class represents a _non-zero curve point_ and supports standard -elliptic curve operations like point addition and scalar multiplication. - -ForeignCurveNotNeeded also includes to associated foreign fields: `ForeignCurve.Field` and `ForeignCurve.Scalar`, see [createForeignField](createForeignField.mdx). - -## Parameters - -• **params**: `CurveParams` - -## Returns - -*typeof* [`ForeignCurve`](../classes/ForeignCurve.mdx) - -## Source - -[lib/provable/crypto/foreign-curve.ts:432](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/foreign-curve.ts#L432) - ---- -url: /zkapps/o1js-reference/functions/createForeignField ---- - -```ts -function createForeignField(modulus: bigint): typeof UnreducedForeignField -``` - -Create a class representing a prime order finite field, which is different from the native [Field](../classes/Field.mdx). - -```ts -const SmallField = createForeignField(17n); // the finite field F_17 -``` - -`createForeignField(p)` takes the prime modulus `p` of the finite field as input, as a bigint. -We support prime moduli up to a size of 259 bits. - -The returned [ForeignField](../classes/ForeignField.mdx) class supports arithmetic modulo `p` (addition and multiplication), -as well as helper methods like `assertEquals()` and `equals()`. - -_Advanced details:_ - -Internally, a foreign field element is represented as three native field elements, each of which -represents a limb of 88 bits. Therefore, being a valid foreign field element means that all 3 limbs -fit in 88 bits, and the foreign field element altogether is smaller than the modulus p. - -Since the full `x < p` check is expensive, by default we only prove a weaker assertion, `x < 2^ceil(log2(p))`, -see [ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) for more details. - -This weaker assumption is what we call "almost reduced", and it is represented by the [AlmostForeignField](../classes/AlmostForeignField.mdx) class. -Note that only [AlmostForeignField](../classes/AlmostForeignField.mdx) supports multiplication and inversion, while UnreducedForeignField -only supports addition and subtraction. - -This function returns the `Unreduced` class, which will cause the minimum amount of range checks to be created by default. -If you want to do multiplication, you have two options: -- create your field elements using the [ForeignField.AlmostReduced](../classes/ForeignField.mdx#almostreduced) constructor. -```ts -let x = Provable.witness(ForeignField.AlmostReduced, () => 5n); -``` -- create your field elements normally and convert them using `x.assertAlmostReduced()`. -```ts -let xChecked = x.assertAlmostReduced(); // asserts x < 2^ceil(log2(p)); returns `AlmostForeignField` -``` - -Similarly, there is a separate class [CanonicalForeignField](../classes/CanonicalForeignField.mdx) which represents fully reduced, "canonical" field elements. -To convert to a canonical field element, use `ForeignField.assertCanonical()`: - -```ts -x.assertCanonical(); // asserts x < p; returns `CanonicalForeignField` -``` -You will likely not need canonical fields most of the time. - -Base types for all of these classes are separately exported as UnreducedForeignField, [AlmostForeignField](../classes/AlmostForeignField.mdx) and [CanonicalForeignField](../classes/CanonicalForeignField.mdx)., - -## Parameters - -• **modulus**: `bigint` - -the modulus of the finite field you are instantiating - -## Returns - -*typeof* `UnreducedForeignField` - -## Source - -[lib/provable/foreign-field.ts:642](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/foreign-field.ts#L642) - ---- -url: /zkapps/o1js-reference/functions/declareMethods ---- - -```ts -function declareMethods(SmartContract: T, methodArguments: Record[]>): void -``` - -`declareMethods` can be used in place of the `@method` decorator -to declare SmartContract methods along with their list of arguments. -It should be placed _after_ the class declaration. -Here is an example of declaring a method `update`, which takes a single argument of type `Field`: -```ts -class MyContract extends SmartContract { - // ... - update(x: Field) { - // ... - } -} -declareMethods(MyContract, { update: [Field] }); // `[Field]` is the list of arguments! -``` -Note that a method of the same name must still be defined on the class, just without the decorator. - -## Type parameters - -• **T** *extends* *typeof* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **SmartContract**: `T` - -• **methodArguments**: `Record`\<`string`, `Provable`\<`unknown`\>[]\> - -## Returns - -`void` - -## Source - -[lib/mina/zkapp.ts:1270](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1270) - ---- -url: /zkapps/o1js-reference/functions/declareState ---- - -```ts -function declareState(SmartContract: T, states: Record>): void -``` - -`declareState` can be used in place of the `@state` decorator to declare on-chain state on a SmartContract. -It should be placed _after_ the class declaration. -Here is an example of declaring a state property `x` of type `Field`. -```ts -class MyContract extends SmartContract { - x = State(); - // ... -} -declareState(MyContract, { x: Field }); -``` - -If you're using pure JS, it's _not_ possible to use the built-in class field syntax, -i.e. the following will _not_ work: - -```js -// THIS IS WRONG IN JS! -class MyContract extends SmartContract { - x = State(); -} -declareState(MyContract, { x: Field }); -``` - -Instead, add a constructor where you assign the property: -```js -class MyContract extends SmartContract { - constructor(x) { - super(); - this.x = State(); - } -} -declareState(MyContract, { x: Field }); -``` - -## Type parameters - -• **T** *extends* *typeof* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **SmartContract**: `T` - -• **states**: `Record`\<`string`, [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`any`\>\> - -## Returns - -`void` - -## Source - -[lib/mina/state.ts:183](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L183) - ---- -url: /zkapps/o1js-reference/functions/fetchAccount ---- - -```ts -function fetchAccount( - accountInfo: { - "publicKey": string | PublicKey; - "tokenId": string | Field; - }, - graphqlEndpoint: string, - __namedParameters: { - "timeout": defaultTimeout; - }): Promise<{ - "account": Types.Account; - "error": undefined; - } | { - "account": undefined; - "error": FetchError; -}> -``` - -Gets account information on the specified publicKey by performing a GraphQL query -to the specified endpoint. This will call the 'GetAccountInfo' query which fetches -zkapp related account information. - -If an error is returned by the specified endpoint, an error is thrown. Otherwise, -the data is returned. - -## Parameters - -• **accountInfo** - -• **accountInfo.publicKey**: `string` \| [`PublicKey`](../classes/PublicKey.mdx) - -• **accountInfo.tokenId?**: `string` \| [`Field`](../classes/Field.mdx) - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -The graphql endpoint to fetch from - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.timeout**: `undefined` \| `number`= `defaultTimeout` - -## Returns - -`Promise`\<\{ - `"account"`: `Types.Account`; - `"error"`: `undefined`; - \} \| \{ - `"account"`: `undefined`; - `"error"`: `FetchError`; - \}\> - -zkapp information on the specified account or an error is thrown - -## Source - -[lib/mina/fetch.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L179) - ---- -url: /zkapps/o1js-reference/functions/fetchEvents ---- - -```ts -function fetchEvents( - accountInfo: { - "publicKey": string; - "tokenId": string; - }, - graphqlEndpoint?: string, - filterOptions?: EventActionFilterOptions): Promise<{ - "blockHash": event.blockInfo.stateHash; - "blockHeight": UInt32; - "chainStatus": event.blockInfo.chainStatus; - "events": { - "data": string[]; - "transactionInfo": { - "hash": string; - "memo": string; - "status": string; - }; - }[]; - "globalSlot": UInt32; - "parentBlockHash": event.blockInfo.parentHash; -}[]> -``` - -Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API. - -## Parameters - -• **accountInfo** - -The account information object. - -• **accountInfo.publicKey**: `string` - -The account public key. - -• **accountInfo.tokenId?**: `string` - -The optional token ID for the account. - -• **graphqlEndpoint?**: `string`= `networkConfig.archiveEndpoint` - -The GraphQL endpoint to query. Defaults to the Archive Node GraphQL API. - -• **filterOptions?**: `EventActionFilterOptions`= `{}` - -The optional filter options object. - -## Returns - -`Promise`\<\{ - `"blockHash"`: `event.blockInfo.stateHash`; - `"blockHeight"`: [`UInt32`](../classes/UInt32.mdx); - `"chainStatus"`: `event.blockInfo.chainStatus`; - `"events"`: \{ - `"data"`: `string`[]; - `"transactionInfo"`: \{ - `"hash"`: `string`; - `"memo"`: `string`; - `"status"`: `string`; - \}; - \}[]; - `"globalSlot"`: [`UInt32`](../classes/UInt32.mdx); - `"parentBlockHash"`: `event.blockInfo.parentHash`; - \}[]\> - -A promise that resolves to an array of objects containing event data, block information and transaction information for the account. - -## Async - -## Throws - -If the GraphQL request fails or the response is invalid. - -## Example - -```ts -const accountInfo = { publicKey: 'B62qiwmXrWn7Cok5VhhB3KvCwyZ7NHHstFGbiU5n7m8s2RqqNW1p1wF' }; -const events = await fetchEvents(accountInfo); -console.log(events); -``` - -## Source - -[lib/mina/fetch.ts:648](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L648) - ---- -url: /zkapps/o1js-reference/functions/fetchLastBlock ---- - -```ts -function fetchLastBlock(graphqlEndpoint: string): Promise> -``` - -Fetches the last block on the Mina network. - -## Parameters - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`Promise`\<`PreconditionBaseTypes`\<\{\}\>\> - -## Source - -[lib/mina/fetch.ts:461](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L461) - ---- -url: /zkapps/o1js-reference/functions/fetchTransactionStatus ---- - -```ts -function fetchTransactionStatus(txId: string, graphqlEndpoint: string): Promise -``` - -Fetches the status of a transaction. - -## Parameters - -• **txId**: `string` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -## Returns - -`Promise`\<[`TransactionStatus`](../type-aliases/TransactionStatus.mdx)\> - -## Source - -[lib/mina/fetch.ts:598](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L598) - ---- -url: /zkapps/o1js-reference/functions/genericHash ---- - -```ts -function genericHash( - provable: ProvableHashable, - prefix: string, - value: T): Field -``` - -## Type parameters - -• **T** - -## Parameters - -• **provable**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -• **prefix**: `string` - -• **value**: `T` - -## Returns - -[`Field`](../classes/Field.mdx) - -## Source - -[lib/provable/merkle-list.ts:755](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L755) - ---- -url: /zkapps/o1js-reference/functions/initializeBindings ---- - -```ts -function initializeBindings(): Promise -``` - -A function that has to finish before any bindings exports can be used. - -## Returns - -`Promise`\<`void`\> - -## Source - -[snarky.d.ts:763](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/snarky.d.ts#L763) - ---- -url: /zkapps/o1js-reference/functions/merkleListHash ---- - -```ts -function merkleListHash(provable: ProvableHashable, prefix: string): (hash: Field, value: T) => Field -``` - -## Type parameters - -• **T** - -## Parameters - -• **provable**: [`ProvableHashable`](../type-aliases/ProvableHashable.mdx)\<`T`\> - -• **prefix**: `string`= `''` - -## Returns - -`Function` - -> ### Parameters -> -> • **hash**: [`Field`](../classes/Field.mdx) -> -> • **value**: `T` -> -> ### Returns -> -> [`Field`](../classes/Field.mdx) -> - -## Source - -[lib/provable/merkle-list.ts:765](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L765) - ---- -url: /zkapps/o1js-reference/functions/method ---- - -```ts -function method( - target: T & { [k in string]: Function }, - methodName: K & string & keyof T, - descriptor: PropertyDescriptor, - returnType?: Provable): void -``` - -A decorator to use in a zkApp to mark a method as provable. -You can use inside your zkApp class as: - -``` -\@method async myMethod(someArg: Field) { - // your code here -} -``` - -To return a value from the method, you have to explicitly declare the return type using the [method.returns](method.mdx#returns) decorator: -``` -\@method.returns(Field) -async myMethod(someArg: Field): Promise { - // your code here -} -``` - -## Type parameters - -• **K** *extends* `string` - -• **T** *extends* [`SmartContract`](../classes/SmartContract.mdx) - -## Parameters - -• **target**: `T` & `{ [k in string]: Function }` - -• **methodName**: `K` & `string` & keyof `T` - -• **descriptor**: `PropertyDescriptor` - -• **returnType?**: `Provable`\<`any`\> - -## Returns - -`void` - -## Source - -[lib/mina/zkapp.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L105) - ---- -url: /zkapps/o1js-reference/functions/provable ---- - -```ts -function provable(typeObj: A, options?: {}): InferredProvable -``` - -## Type parameters - -• **A** - -## Parameters - -• **typeObj**: `A` - -• **options?** - -**Deprecated** - -## Returns - -`InferredProvable`\<`A`, [`Field`](../classes/Field.mdx)\> - -## Source - -[lib/provable/types/provable-derivers.ts:78](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L78) - ---- -url: /zkapps/o1js-reference/functions/provablePure ---- - -```ts -function provablePure(typeObj: A): ProvablePureExtended, InferValue, InferJson> -``` - -## Type parameters - -• **A** - -## Parameters - -• **typeObj**: `A` - -## Returns - -`ProvablePureExtended`\<[`InferProvable`](../type-aliases/InferProvable.mdx)\<`A`\>, `InferValue`\<`A`\>, `InferJson`\<`A`\>\> - -## Source - -[lib/provable/types/provable-derivers.ts:80](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L80) - ---- -url: /zkapps/o1js-reference/functions/public ---- - -```ts -function public_( - target: any, - _key: string | symbol, - index: number): void -``` - -## Parameters - -• **target**: `any` - -• **\_key**: `string` \| `symbol` - -• **index**: `number` - -## Returns - -`void` - -## Source - -[lib/proof-system/circuit.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/circuit.ts#L156) - ---- -url: /zkapps/o1js-reference/functions/readVarMessage ---- - -```ts -function readVarMessage( - methodName: string, - varName: string, - varDescription: string): string -``` - -## Parameters - -• **methodName**: `string` - -• **varName**: `string` - -• **varDescription**: `string` - -## Returns - -`string` - -## Source - -[lib/provable/field.ts:1222](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1222) - ---- -url: /zkapps/o1js-reference/functions/sendZkapp ---- - -```ts -function sendZkapp( - json: string, - graphqlEndpoint: string, - __namedParameters: { - "timeout": defaultTimeout; -}): Promise<[undefined, FetchError] | [FetchResponse, undefined]> -``` - -Sends a zkApp command (transaction) to the specified GraphQL endpoint. - -## Parameters - -• **json**: `string` - -• **graphqlEndpoint**: `string`= `networkConfig.minaEndpoint` - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.timeout**: `undefined` \| `number`= `defaultTimeout` - -## Returns - -`Promise`\<[`undefined`, `FetchError`] \| [`FetchResponse`\<`SendZkAppResponse`\>, `undefined`]\> - -## Source - -[lib/mina/fetch.ts:618](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L618) - ---- -url: /zkapps/o1js-reference/functions/setArchiveGraphqlEndpoint ---- - -```ts -function setArchiveGraphqlEndpoint(graphqlEndpoint: string): void -``` - -Sets up a GraphQL endpoint to be used for fetching information from an Archive Node. - -## Parameters - -• **graphqlEndpoint**: `string` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:134](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L134) - ---- -url: /zkapps/o1js-reference/functions/setGraphqlEndpoint ---- - -```ts -function setGraphqlEndpoint(graphqlEndpoint: string): void -``` - -## Parameters - -• **graphqlEndpoint**: `string` - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:112](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L112) - ---- -url: /zkapps/o1js-reference/functions/setGraphqlEndpoints ---- - -```ts -function setGraphqlEndpoints(__namedParameters: string[]): void -``` - -## Parameters - -• **\_\_namedParameters**: `string`[] - -## Returns - -`void` - -## Source - -[lib/mina/fetch.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L105) - ---- -url: /zkapps/o1js-reference/functions/setNumberOfWorkers ---- - -```ts -function setNumberOfWorkers(numWorkers: number): void -``` - -Set the number of workers to use for parallelizing the proof generation. By default the number of workers is set to the number of physical CPU cores on your machine, but there may be some instances where you want to set the number of workers manually. Some machines may have a large number of cores, but not enough memory to support that many workers. In that case, you can set the number of workers to a lower number to avoid running out of memory. On the other hand, some machines with heterogeneous cores may benefit from setting the number of workers to a lower number to avoid contention between core types if load-link/store-conditional multithreading is used. Feel free to experiment and see what works best for your use case. Maybe you can squeeze slightly more performance out by tweaking this value :) - -## Parameters - -• **numWorkers**: `number` - -## Returns - -`void` - -## Example - -```typescript -setNumberOfWorkers(2); // set the number of workers to 2 -``` - -## Source - -[lib/proof-system/workers.ts:15](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/workers.ts#L15) - ---- -url: /zkapps/o1js-reference/functions/state-1 ---- - -```ts -function state(type: ProvableTypePure | FlexibleProvablePure): (target: SmartContract & { - "constructor": any; - }, key: string, _descriptor?: PropertyDescriptor) => void -``` - -A decorator to use within a zkapp to indicate what will be stored on-chain. -For example, if you want to store a field element `some_state` in a zkapp, -you can use the following in the declaration of your zkapp: - -``` -@state(Field) some_state = State(); -``` - -## Type parameters - -• **A** - -## Parameters - -• **type**: [`ProvableTypePure`](../type-aliases/ProvableTypePure.mdx)\<`A`\> \| [`FlexibleProvablePure`](../type-aliases/FlexibleProvablePure.mdx)\<`A`\> - -## Returns - -`Function` - -> ### Parameters -> -> • **target**: [`SmartContract`](../classes/SmartContract.mdx) & \{ -> `"constructor"`: `any`; -> \} -> -> • **key**: `string` -> -> • **\_descriptor?**: `PropertyDescriptor` -> -> ### Returns -> -> `void` -> - -## Source - -[lib/mina/state.ts:105](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L105) - ---- -url: /zkapps/o1js-reference/functions/toConstantField ---- - -```ts -function toConstantField( - x: Field, - methodName: string, - varName: string, - varDescription: string): ConstantField -``` - -## Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **methodName**: `string` - -• **varName**: `string`= `'x'` - -• **varDescription**: `string`= `'field element'` - -## Returns - -[`ConstantField`](../type-aliases/ConstantField.mdx) - -## Source - -[lib/provable/field.ts:1197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1197) - ---- -url: /zkapps/o1js-reference/functions/toFp ---- - -```ts -function toFp(x: string | number | bigint | Field): bigint -``` - -## Parameters - -• **x**: `string` \| `number` \| `bigint` \| [`Field`](../classes/Field.mdx) - -## Returns - -`bigint` - -## Source - -[lib/provable/field.ts:1156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1156) - ---- -url: /zkapps/o1js-reference/functions/verify ---- - -```ts -function verify(proof: ProofBase | JsonProof, verificationKey: string | VerificationKey): Promise -``` - -## Parameters - -• **proof**: [`ProofBase`](../classes/ProofBase.mdx)\<`any`, `any`\> \| [`JsonProof`](../type-aliases/JsonProof.mdx) - -• **verificationKey**: `string` \| [`VerificationKey`](../classes/VerificationKey.mdx) - -## Returns - -`Promise`\<`boolean`\> - -## Source - -[lib/proof-system/zkprogram.ts:109](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L109) - ---- -url: /zkapps/o1js-reference/functions/withHashes ---- - -```ts -function withHashes( - data: T[], - nextHash: (hash: Field, value: T) => Field, - emptyHash: Field): { - "data": WithHash[]; - "hash": Field; -} -``` - -## Type parameters - -• **T** - -## Parameters - -• **data**: `T`[] - -• **nextHash** - -• **emptyHash**: [`Field`](../classes/Field.mdx) - -## Returns - -```ts -{ - "data": WithHash[]; - "hash": Field; -} -``` - -### data - -```ts -data: WithHash[]; -``` - -### hash - -```ts -hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:773](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L773) - ---- -url: /zkapps/o1js-reference/functions/withMessage ---- - -```ts -function withMessage(error: unknown, message?: string): unknown -``` - -## Parameters - -• **error**: `unknown` - -• **message?**: `string` - -## Returns - -`unknown` - -## Source - -[lib/provable/field.ts:1174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1174) - ---- -url: /zkapps/o1js-reference/interfaces/Permissions ---- - -Permissions specify how specific aspects of the zkapp account are allowed -to be modified. All fields are denominated by a Permission. - -## Extends - -- `Permissions_` - -## Properties - -### access - -```ts -access: AuthRequired; -``` - -Permission to control the ability to include _any_ account update for this -account in a transaction. Note that this is more restrictive than all other -permissions combined. For normal accounts it can safely be set to `none`, -but for token contracts this has to be more restrictive, to prevent -unauthorized token interactions -- for example, it could be -`proofOrSignature`. - -#### Overrides - -`Permissions_.access` - -#### Source - -[lib/mina/account-update.ts:397](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L397) - -*** - -### editActionState - -```ts -editActionState: AuthRequired; -``` - -The Permission corresponding to the ability to emit actions to the account. - -#### Overrides - -`Permissions_.editActionState` - -#### Source - -[lib/mina/account-update.ts:376](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L376) - -*** - -### editState - -```ts -editState: AuthRequired; -``` - -The Permission corresponding to the 8 state fields associated with -an account. - -#### Overrides - -`Permissions_.editState` - -#### Source - -[lib/mina/account-update.ts:332](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L332) - -*** - -### incrementNonce - -```ts -incrementNonce: AuthRequired; -``` - -#### Overrides - -`Permissions_.incrementNonce` - -#### Source - -[lib/mina/account-update.ts:385](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L385) - -*** - -### receive - -```ts -receive: AuthRequired; -``` - -The Permission corresponding to the ability to receive transactions -to this account. - -#### Overrides - -`Permissions_.receive` - -#### Source - -[lib/mina/account-update.ts:344](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L344) - -*** - -### send - -```ts -send: AuthRequired; -``` - -The Permission corresponding to the ability to send transactions -from this account. - -#### Overrides - -`Permissions_.send` - -#### Source - -[lib/mina/account-update.ts:338](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L338) - -*** - -### setDelegate - -```ts -setDelegate: AuthRequired; -``` - -The Permission corresponding to the ability to set the delegate -field of the account. - -#### Overrides - -`Permissions_.setDelegate` - -#### Source - -[lib/mina/account-update.ts:350](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L350) - -*** - -### setPermissions - -```ts -setPermissions: AuthRequired; -``` - -The Permission corresponding to the ability to set the permissions -field of the account. - -#### Overrides - -`Permissions_.setPermissions` - -#### Source - -[lib/mina/account-update.ts:356](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L356) - -*** - -### setTiming - -```ts -setTiming: AuthRequired; -``` - -#### Overrides - -`Permissions_.setTiming` - -#### Source - -[lib/mina/account-update.ts:387](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L387) - -*** - -### setTokenSymbol - -```ts -setTokenSymbol: AuthRequired; -``` - -The Permission corresponding to the ability to set the token symbol -for this account. - -#### Overrides - -`Permissions_.setTokenSymbol` - -#### Source - -[lib/mina/account-update.ts:382](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L382) - -*** - -### setVerificationKey - -```ts -setVerificationKey: VerificationKeyPermission; -``` - -The Permission corresponding to the ability to set the verification -key associated with the circuit tied to this account. Effectively -"upgradeability" of the smart contract. - -#### Overrides - -`Permissions_.setVerificationKey` - -#### Source - -[lib/mina/account-update.ts:363](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L363) - -*** - -### setVotingFor - -```ts -setVotingFor: AuthRequired; -``` - -#### Overrides - -`Permissions_.setVotingFor` - -#### Source - -[lib/mina/account-update.ts:386](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L386) - -*** - -### setZkappUri - -```ts -setZkappUri: AuthRequired; -``` - -The Permission corresponding to the ability to set the zkapp uri -typically pointing to the source code of the smart contract. Usually this -should be changed whenever the [Permissions.setVerificationKey](Permissions.mdx#setverificationkey) is -changed. Effectively "upgradeability" of the smart contract. - -#### Overrides - -`Permissions_.setZkappUri` - -#### Source - -[lib/mina/account-update.ts:371](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L371) - ---- -url: /zkapps/o1js-reference/namespaces/Crypto/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [Curve](type-aliases/Curve.mdx) | - | -| [CurveParams](type-aliases/CurveParams.mdx) | Parameters defining an elliptic curve in short Weierstraß form | - ---- -url: /zkapps/o1js-reference/namespaces/Crypto/type-aliases/Curve ---- - -```ts -type Curve: CurveAffine; -``` - -## Source - -[lib/provable/crypto/crypto.ts:29](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L29) - ---- -url: /zkapps/o1js-reference/namespaces/Crypto/type-aliases/CurveParams ---- - -```ts -type CurveParams: CurveParams_; -``` - -Parameters defining an elliptic curve in short Weierstraß form -y^2 = x^3 + ax + b - -## Source - -[lib/provable/crypto/crypto.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L27) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [CipherText](type-aliases/CipherText.mdx) | - | -| [CipherTextBytes](type-aliases/CipherTextBytes.mdx) | - | -| [decrypt](functions/decrypt.mdx) | Decrypts a [CipherText](type-aliases/CipherText.mdx) using a [PrivateKey](../../classes/PrivateKey.mdx). | -| [decryptBytes](functions/decryptBytes.mdx) | Decrypts a [CipherText](type-aliases/CipherText.mdx) using a [PrivateKey](../../classes/PrivateKey.mdx). | -| [encrypt](functions/encrypt.mdx) | Public Key Encryption, encrypts Field elements using a [PublicKey](../../classes/PublicKey.mdx). | -| [encryptBytes](functions/encryptBytes.mdx) | Public Key Encryption, encrypts Bytes using a [PublicKey](../../classes/PublicKey.mdx). | - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/functions/decrypt ---- - -```ts -function decrypt(__namedParameters: CipherText, privateKey: PrivateKey): Field[] -``` - -Decrypts a [CipherText](../type-aliases/CipherText.mdx) using a [PrivateKey](../../../classes/PrivateKey.mdx). - -## Parameters - -• **\_\_namedParameters**: [`CipherText`](../type-aliases/CipherText.mdx) - -• **privateKey**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -[`Field`](../../../classes/Field.mdx)[] - -## Source - -[lib/provable/crypto/encryption.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L28) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/functions/decryptBytes ---- - -```ts -function decryptBytes(cipherText: CipherTextBytes, privateKey: PrivateKey): Bytes -``` - -Decrypts a [CipherText](../type-aliases/CipherText.mdx) using a [PrivateKey](../../../classes/PrivateKey.mdx). - -## Parameters - -• **cipherText**: [`CipherTextBytes`](../type-aliases/CipherTextBytes.mdx) - -• **privateKey**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -`Bytes` - -## Source - -[lib/provable/crypto/encryption.ts:129](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L129) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/functions/encrypt ---- - -```ts -function encrypt(message: Field[], otherPublicKey: PublicKey): CipherText -``` - -Public Key Encryption, encrypts Field elements using a [PublicKey](../../../classes/PublicKey.mdx). - -## Parameters - -• **message**: [`Field`](../../../classes/Field.mdx)[] - -• **otherPublicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -## Returns - -[`CipherText`](../type-aliases/CipherText.mdx) - -## Source - -[lib/provable/crypto/encryption.ts:64](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L64) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/functions/encryptBytes ---- - -```ts -function encryptBytes(message: Bytes, otherPublicKey: PublicKey): CipherTextBytes -``` - -Public Key Encryption, encrypts Bytes using a [PublicKey](../../../classes/PublicKey.mdx). - -## Parameters - -• **message**: `Bytes` - -• **otherPublicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -## Returns - -[`CipherTextBytes`](../type-aliases/CipherTextBytes.mdx) - -## Source - -[lib/provable/crypto/encryption.ts:97](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L97) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherText ---- - -```ts -type CipherText: { - "cipherText": Field[]; - "publicKey": Group; -}; -``` - -## Type declaration - -### cipherText - -```ts -cipherText: Field[]; -``` - -### publicKey - -```ts -publicKey: Group; -``` - -## Source - -[lib/provable/crypto/encryption.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L19) - ---- -url: /zkapps/o1js-reference/namespaces/Encryption/type-aliases/CipherTextBytes ---- - -```ts -type CipherTextBytes: CipherText & { - "messageLength": number; -}; -``` - -## Type declaration - -### messageLength - -```ts -messageLength: number; -``` - -## Source - -[lib/provable/crypto/encryption.ts:23](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/encryption.ts#L23) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/README ---- - -This module exposes APIs that are unstable, in the sense that the API surface is expected to change. -(Not unstable in the sense that they are less functional or tested than other parts.) - -## Index - -| Member | Description | -| :------ | :------ | -| [BatchReducer](classes/BatchReducer.mdx) | A reducer to process actions in fixed-size batches. | -| [OffchainStateCommitments](classes/OffchainStateCommitments.mdx) | Commitments that keep track of the current state of an offchain Merkle tree constructed from actions. | -| [ActionBatch](type-aliases/ActionBatch.mdx) | - | -| [IndexedMerkleMap](type-aliases/IndexedMerkleMap.mdx) | - | -| [ActionBatch](functions/ActionBatch.mdx) | Provable type that represents a batch of actions. | -| [IndexedMerkleMap](functions/IndexedMerkleMap.mdx) | Class factory for an Indexed Merkle Map with a given height. | -| [OffchainState](functions/OffchainState.mdx) | Offchain state for a `SmartContract`. | -| [memoizeWitness](functions/memoizeWitness.mdx) | Like Provable.witness, but memoizes the witness during transaction construction | - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/classes/BatchReducer ---- - -A reducer to process actions in fixed-size batches. - -```ts -let batchReducer = new BatchReducer({ actionType: Action, batchSize: 5 }); - -// in contract: concurrent dispatching of actions -batchReducer.dispatch(action); - -// reducer logic -// outside contract: prepare a list of { batch, proof } objects which cover all pending actions -let batches = await batchReducer.prepareBatches(); - -// in contract: process a single batch -// create one transaction that does this for each batch! -batchReducer.processBatch({ batch, proof }, (action, isDummy) => { - // ... -}); -``` - -## Extends - -- `BatchReducer`\<`ActionType`, `BatchSize`, `Action`\> - -## Type parameters - -• **ActionType** *extends* `Actionable`\<`any`\> - -• **BatchSize** *extends* `number` = `number` - -• **Action** = [`InferProvable`](../../../type-aliases/InferProvable.mdx)\<`ActionType`\> - -## Constructors - -### new BatchReducer() - -```ts -new BatchReducer(__namedParameters: { - "actionType": ActionType; - "batchSize": BatchSize; - "maxActionsPerUpdate": number; - "maxUpdatesFinalProof": 100; - "maxUpdatesPerProof": 300; -}): BatchReducer -``` - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.actionType**: `ActionType` - -The provable type of actions submitted by this reducer. - -• **\_\_namedParameters.batchSize**: `BatchSize` - -The number of actions in a batch. The idea is to process one batch per transaction, by calling `processBatch()`. - -The motivation for processing actions in small batches is to work around the protocol limit on the number of account updates. -If every action should result in an account update, then you have to set the batch size low enough to not exceed the limit. - -If transaction limits are no concern, the `batchSize` could be set based on amount of logic you do per action. -A smaller batch size will make proofs faster, but you might need more individual transactions as more batches are needed to process all pending actions. - -• **\_\_namedParameters.maxActionsPerUpdate?**: `number`= `undefined` - -The maximum number of actions dispatched in any of the zkApp methods on the contract. - -Note: This number just has to be an upper bound of the actual maximum, but if it's the precise number, -fewer constraints will be used. (The overhead of a higher number is fairly small though.) - -A restriction is that the number has to be less or equal than the `batchSize`. -The reason is that actions in one account update are always processed together, so if you'd have more actions in one than the batch size, we couldn't process them at all. - -By default, this is set to `Math.min(batchSize, 5)` which should be sensible for most applications. - -• **\_\_namedParameters.maxUpdatesFinalProof?**: `number`= `100` - -The maximum number of action lists (= all actions on an account update) to process inside `processBatch()`, -i.e. in your zkApp method. - -Default: 100, which will take up about 3000 constraints. - -The current default should be sensible for most applications, but here are some trade-offs to consider when changing it: - -- Using a smaller number means a smaller circuit, so proofs of your method will be faster. -- Using a bigger number means it's more likely that you can prove _all_ actions in the method call and won't need a recursive proof. - -So, go lower if you expect very few actions, and higher if you expect a lot of actions. - -• **\_\_namedParameters.maxUpdatesPerProof?**: `number`= `300` - -The maximum number of action lists (= all actions on an account update) to process in a single recursive proof, in `prepareBatches()`. - -Default: 300, which will take up about 9000 constraints. - -The current default should be sensible for most applications, but here are some trade-offs to consider when changing it: - -- Using a smaller number means a smaller circuit, so recursive proofs will be faster. -- Using a bigger number means you'll need fewer recursive proofs in the case a lot of actions are pending. - -So, go lower if you expect very few actions, and higher if you expect a lot of actions. -(Note: A larger circuit causes longer compilation and proof times for your zkApp even if you _never_ need a recursive proof) - -#### Returns - -[`BatchReducer`](BatchReducer.mdx)\<`ActionType`, `BatchSize`, `Action`\> - -#### Inherited from - -`BatchReducer_.BatchReducer.constructor` - -#### Source - -[lib/mina/actions/batch-reducer.ts:75](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L75) - -## Properties - -### Batch - -```ts -Batch: (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - } & { - "_isStruct": true; - } & Provable<{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }, { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses; - }> & { - "empty": () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromValue": (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "toInput": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }; -}; -``` - -#### Type declaration - -##### \_isStruct - -```ts -_isStruct: true; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### fromJSON() - -```ts -fromJSON: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: `boolean`= `Bool` - -• **x.onchainActionState**: `string`= `Field` - -• **x.onchainStack**: `string`= `Field` - -• **x.processedActionState**: `string`= `Field` - -• **x.stack**= `undefined` - -• **x.stack.\_emptyHash**: `null` \| `string` - -• **x.stack.\_innerProvable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.\_nextHash**: `null` \| \{\} - -• **x.stack.\_provable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.empty** - -• **x.stack.emptyHash**: `string` - -• **x.stack.from** - -• **x.stack.fromReverse** - -• **x.stack.prototype** - -• **x.stack.prototype.Constructor** - -• **x.stack.prototype.Constructor.\_emptyHash**: `null` \| `string` - -• **x.stack.prototype.Constructor.\_innerProvable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.prototype.Constructor.\_nextHash**: `null` \| \{\} - -• **x.stack.prototype.Constructor.\_provable**: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \} - -• **x.stack.prototype.Constructor.emptyHash**: `string` - -• **x.stack.prototype.Constructor.prototype**: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \} - -• **x.stack.prototype.Constructor.create** - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -**Example** -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -• **x.stack.prototype.data** - -• **x.stack.prototype.data.get** - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -• **x.stack.prototype.data.set** - -Modify the unconstrained value. - -• **x.stack.prototype.data.setTo** - -Set the unconstrained value to the same as another `Unconstrained`. - -• **x.stack.prototype.data.updateAsProver** - -Update an `Unconstrained` by a witness computation. - -• **x.stack.prototype.hash**: `string` - -• **x.stack.prototype.innerProvable** - -• **x.stack.prototype.innerProvable.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.stack.prototype.innerProvable.empty** - -• **x.stack.prototype.innerProvable.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.stack.prototype.innerProvable.fromValue** - -Convert provable type from a normal JS type. - -• **x.stack.prototype.innerProvable.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.stack.prototype.innerProvable.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.stack.prototype.innerProvable.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.stack.prototype.innerProvable.toInput** - -• **x.stack.prototype.innerProvable.toValue** - -Convert provable type to a normal JS type. - -• **x.stack.prototype.innerProvable.sizeInFields** - -• **x.stack.prototype.clone** - -• **x.stack.prototype.forEach** - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -• **x.stack.prototype.isEmpty** - -• **x.stack.prototype.lengthUnconstrained** - -• **x.stack.prototype.nextHash** - -• **x.stack.prototype.pop** - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -• **x.stack.prototype.popExn** - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -• **x.stack.prototype.popIf** - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -• **x.stack.prototype.popIfUnsafe** - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -• **x.stack.prototype.push** - -Push a new element to the list. - -• **x.stack.prototype.pushIf** - -Push a new element to the list, if the `condition` is true. - -• **x.stack.prototype.startIterating** - -• **x.stack.prototype.startIteratingFromLast** - -• **x.stack.prototype.toArrayUnconstrained** - -• **x.stack.provable** - -• **x.stack.provable.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.stack.provable.empty** - -• **x.stack.provable.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.stack.provable.fromValue** - -Convert provable type from a normal JS type. - -• **x.stack.provable.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.stack.provable.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.stack.provable.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.stack.provable.toInput** - -• **x.stack.provable.toValue** - -Convert provable type to a normal JS type. - -• **x.stack.provable.sizeInFields** - -• **x.stack.create** - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -**Example** -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -• **x.useOnchainStack**: `boolean`= `Bool` - -• **x.witnesses**= `undefined` - -• **x.witnesses.check** - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -**Param** -the element of type `T` to put assertions on. - -• **x.witnesses.empty** - -• **x.witnesses.fromFields** - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -**Param** -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -**Param** -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -• **x.witnesses.fromValue** - -Convert provable type from a normal JS type. - -• **x.witnesses.toAuxiliary** - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -**Param** -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **x.witnesses.toCanonical?**: `null` \| \{\} - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -• **x.witnesses.toFields** - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -**Param** -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **x.witnesses.toInput** - -• **x.witnesses.toValue** - -Convert provable type to a normal JS type. - -• **x.witnesses.sizeInFields** - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### fromValue() - -```ts -fromValue: (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -}; -``` - -###### Parameters - -• **value** - -• **value.isRecursive**: `boolean` \| [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **value.onchainActionState**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.onchainStack**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.processedActionState**: `string` \| `number` \| `bigint` \| [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.stack**: `any`= `undefined` - -• **value.useOnchainStack**: `boolean` \| [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **value.witnesses**: `ActionWitnesses` \| [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; -} -``` - -###### isRecursive - -```ts -isRecursive: Bool = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: Field = Field; -``` - -###### onchainStack - -```ts -onchainStack: Field = Field; -``` - -###### processedActionState - -```ts -processedActionState: Field = Field; -``` - -###### stack - -```ts -stack: MerkleList>>; -``` - -###### useOnchainStack - -```ts -useOnchainStack: Bool = Bool; -``` - -###### witnesses - -```ts -witnesses: Unconstrained; -``` - -##### toInput() - -```ts -toInput: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.onchainActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.onchainStack**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.processedActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.stack**: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`any`\>\>\>= `undefined` - -• **x.useOnchainStack**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.witnesses**: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -###### fields? - -```ts -optional fields: Field[]; -``` - -###### packed? - -```ts -optional packed: [Field, number][]; -``` - -##### toJSON() - -```ts -toJSON: (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; -}; -``` - -###### Parameters - -• **x** - -• **x.isRecursive**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.onchainActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.onchainStack**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.processedActionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.stack**: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`any`\>\>\>= `undefined` - -• **x.useOnchainStack**: [`Bool`](../../../classes/Bool.mdx)= `Bool` - -• **x.witnesses**: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>= `undefined` - -###### Returns - -```ts -{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; -} -``` - -###### isRecursive - -```ts -isRecursive: boolean = Bool; -``` - -###### onchainActionState - -```ts -onchainActionState: string = Field; -``` - -###### onchainStack - -```ts -onchainStack: string = Field; -``` - -###### processedActionState - -```ts -processedActionState: string = Field; -``` - -###### stack - -```ts -stack: { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; -}; -``` - -###### stack.\_emptyHash - -```ts -_emptyHash: null | string; -``` - -###### stack.\_innerProvable - -```ts -_innerProvable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.\_nextHash - -```ts -_nextHash: null | {}; -``` - -###### stack.\_provable - -```ts -_provable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.empty - -```ts -empty: {}; -``` - -###### stack.emptyHash - -```ts -emptyHash: string; -``` - -###### stack.from - -```ts -from: {}; -``` - -###### stack.fromReverse - -```ts -fromReverse: {}; -``` - -###### stack.prototype - -```ts -prototype: { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; -}; -``` - -###### stack.prototype.Constructor - -```ts -Constructor: { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; -}; -``` - -###### stack.prototype.Constructor.\_emptyHash - -```ts -_emptyHash: null | string; -``` - -###### stack.prototype.Constructor.\_innerProvable - -```ts -_innerProvable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.Constructor.\_nextHash - -```ts -_nextHash: null | {}; -``` - -###### stack.prototype.Constructor.\_provable - -```ts -_provable: null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.Constructor.emptyHash - -```ts -emptyHash: string; -``` - -###### stack.prototype.Constructor.prototype - -```ts -prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; -``` - -###### stack.prototype.Constructor.create - -```ts -create; -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -###### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -###### stack.prototype.data - -```ts -data: { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; -}; -``` - -###### stack.prototype.data.get - -```ts -get; -``` - -Read an unconstrained value. - -Note: Can only be called outside provable code. - -###### stack.prototype.data.set - -```ts -set; -``` - -Modify the unconstrained value. - -###### stack.prototype.data.setTo - -```ts -setTo; -``` - -Set the unconstrained value to the same as another `Unconstrained`. - -###### stack.prototype.data.updateAsProver - -```ts -updateAsProver; -``` - -Update an `Unconstrained` by a witness computation. - -###### stack.prototype.hash - -```ts -hash: string; -``` - -###### stack.prototype.innerProvable - -```ts -innerProvable: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.prototype.innerProvable.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### stack.prototype.innerProvable.empty - -```ts -empty: {}; -``` - -###### stack.prototype.innerProvable.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### stack.prototype.innerProvable.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### stack.prototype.innerProvable.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### stack.prototype.innerProvable.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### stack.prototype.innerProvable.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### stack.prototype.innerProvable.toInput - -```ts -toInput: {}; -``` - -###### stack.prototype.innerProvable.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### stack.prototype.innerProvable.sizeInFields - -```ts -sizeInFields; -``` - -###### stack.prototype.clone - -```ts -clone; -``` - -###### stack.prototype.forEach - -```ts -forEach; -``` - -Iterate through the list in a fixed number of steps any apply a given callback on each element. - -Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback. - -Note: There are no guarantees about the contents of dummy elements, so the callback is expected -to handle the `isDummy` flag separately. - -###### stack.prototype.isEmpty - -```ts -isEmpty; -``` - -###### stack.prototype.lengthUnconstrained - -```ts -lengthUnconstrained; -``` - -###### stack.prototype.nextHash - -```ts -nextHash; -``` - -###### stack.prototype.pop - -```ts -pop; -``` - -Remove the last element from the list and return it. - -If the list is empty, returns a dummy element. - -###### stack.prototype.popExn - -```ts -popExn; -``` - -Remove the last element from the list and return it. - -This proves that the list is non-empty, and fails otherwise. - -###### stack.prototype.popIf - -```ts -popIf; -``` - -Return the last element, but only remove it if `condition` is true. - -If the list is empty, returns a dummy element. - -###### stack.prototype.popIfUnsafe - -```ts -popIfUnsafe; -``` - -Low-level, minimal version of `pop()` which lets the _caller_ decide whether there is an element to pop. - -I.e. this proves: -- If the input condition is true, this returns the last element and removes it from the list. -- If the input condition is false, the list is unchanged and the return value is garbage. - -Note that if the caller passes `true` but the list is empty, this will fail. -If the caller passes `false` but the list is non-empty, this succeeds and just doesn't pop off an element. - -###### stack.prototype.push - -```ts -push; -``` - -Push a new element to the list. - -###### stack.prototype.pushIf - -```ts -pushIf; -``` - -Push a new element to the list, if the `condition` is true. - -###### stack.prototype.startIterating - -```ts -startIterating; -``` - -###### stack.prototype.startIteratingFromLast - -```ts -startIteratingFromLast; -``` - -###### stack.prototype.toArrayUnconstrained - -```ts -toArrayUnconstrained; -``` - -###### stack.provable - -```ts -provable: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### stack.provable.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### stack.provable.empty - -```ts -empty: {}; -``` - -###### stack.provable.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### stack.provable.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### stack.provable.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### stack.provable.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### stack.provable.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### stack.provable.toInput - -```ts -toInput: {}; -``` - -###### stack.provable.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### stack.provable.sizeInFields - -```ts -sizeInFields; -``` - -###### stack.create - -```ts -create; -``` - -Create a Merkle list type - -Optionally, you can tell `create()` how to do the hash that pushes a new list element, by passing a `nextHash` function. - -###### Example - -```ts -class MyList extends MerkleList.create(Field, (hash, x) => - Poseidon.hashWithPrefix('custom', [hash, x]) -) {} -``` - -###### useOnchainStack - -```ts -useOnchainStack: boolean = Bool; -``` - -###### witnesses - -```ts -witnesses: { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; -}; -``` - -###### witnesses.check - -```ts -check: {}; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -###### Param - -the element of type `T` to put assertions on. - -###### witnesses.empty - -```ts -empty: {}; -``` - -###### witnesses.fromFields - -```ts -fromFields: {}; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -###### Param - -an array of [Field](../../../classes/Field.mdx) elements describing the provable data of the new `T` element. - -###### Param - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -###### witnesses.fromValue - -```ts -fromValue: {}; -``` - -Convert provable type from a normal JS type. - -###### witnesses.toAuxiliary - -```ts -toAuxiliary: {}; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -###### Param - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -###### witnesses.toCanonical? - -```ts -optional toCanonical: null | {}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -###### witnesses.toFields - -```ts -toFields: {}; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -###### Param - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -###### witnesses.toInput - -```ts -toInput: {}; -``` - -###### witnesses.toValue - -```ts -toValue: {}; -``` - -Convert provable type to a normal JS type. - -###### witnesses.sizeInFields - -```ts -sizeInFields; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.Batch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L67) - -*** - -### BatchProof - -```ts -BatchProof: typeof Proof; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.BatchProof` - -#### Source - -[lib/mina/actions/batch-reducer.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L70) - -*** - -### \_contract? - -```ts -optional _contract: BatchReducerContract; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer._contract` - -#### Source - -[lib/mina/actions/batch-reducer.ts:164](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L164) - -*** - -### \_contractClass? - -```ts -optional _contractClass: BatchReducerContractClass; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer._contractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L165) - -*** - -### actionType - -```ts -actionType: Provable & { - "empty": () => Action; - } & { - "toInput": (x: Action) => HashInput; - } & Omit, "fromFields"> & { - "fromFields": (fields: Field[]) => Action; -}; -``` - -#### Type declaration - -##### empty() - -```ts -empty: () => Action; -``` - -###### Returns - -`Action` - -#### Type declaration - -##### toInput() - -```ts -toInput: (x: Action) => HashInput; -``` - -###### Parameters - -• **x**: `Action` - -###### Returns - -`HashInput` - -#### Type declaration - -##### fromFields() - -```ts -fromFields: (fields: Field[]) => Action; -``` - -###### Parameters - -• **fields**: [`Field`](../../../classes/Field.mdx)[] - -###### Returns - -`Action` - -#### Inherited from - -`BatchReducer_.BatchReducer.actionType` - -#### Source - -[lib/mina/actions/batch-reducer.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L66) - -*** - -### batchSize - -```ts -batchSize: BatchSize; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.batchSize` - -#### Source - -[lib/mina/actions/batch-reducer.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L65) - -*** - -### maxActionsPerUpdate - -```ts -maxActionsPerUpdate: number; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.maxActionsPerUpdate` - -#### Source - -[lib/mina/actions/batch-reducer.ts:73](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L73) - -*** - -### maxUpdatesFinalProof - -```ts -maxUpdatesFinalProof: number; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.maxUpdatesFinalProof` - -#### Source - -[lib/mina/actions/batch-reducer.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L72) - -*** - -### program - -```ts -program: ActionStackProgram; -``` - -#### Inherited from - -`BatchReducer_.BatchReducer.program` - -#### Source - -[lib/mina/actions/batch-reducer.ts:69](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L69) - -## Accessors - -### initialActionStack - -```ts -get static initialActionStack(): Field -``` - -#### Returns - -[`Field`](../../../classes/Field.mdx) - -#### Source - -[lib/mina/actions/batch-reducer.ts:160](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L160) - -*** - -### initialActionState - -```ts -get static initialActionState(): Field -``` - -#### Returns - -[`Field`](../../../classes/Field.mdx) - -#### Source - -[lib/mina/actions/batch-reducer.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L157) - -## Methods - -### compile() - -```ts -compile(): Promise<{ - "verificationKey": { - "data": string; - "hash": Field; - }; -}> -``` - -Compile the recursive action stack prover. - -#### Returns - -`Promise`\<\{ - `"verificationKey"`: \{ - `"data"`: `string`; - `"hash"`: [`Field`](../../../classes/Field.mdx); - \}; - \}\> - -> ##### verificationKey -> -> ```ts -> verificationKey: { -> "data": string; -> "hash": Field; -> }; -> ``` -> -> ##### verificationKey.data -> -> ```ts -> data: string; -> ``` -> -> ##### verificationKey.hash -> -> ```ts -> hash: Field; -> ``` -> - -#### Inherited from - -`BatchReducer_.BatchReducer.compile` - -#### Source - -[lib/mina/actions/batch-reducer.ts:421](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L421) - -*** - -### contract() - -```ts -contract(): BatchReducerContract -``` - -#### Returns - -`BatchReducerContract` - -#### Inherited from - -`BatchReducer_.BatchReducer.contract` - -#### Source - -[lib/mina/actions/batch-reducer.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L174) - -*** - -### contractClass() - -```ts -contractClass(): BatchReducerContractClass -``` - -#### Returns - -`BatchReducerContractClass` - -#### Inherited from - -`BatchReducer_.BatchReducer.contractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:167](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L167) - -*** - -### dispatch() - -```ts -dispatch(action: From): void -``` - -Submit an action. - -#### Parameters - -• **action**: `From`\<`ActionType`\> - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.dispatch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:202](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L202) - -*** - -### dispatchIf() - -```ts -dispatchIf(condition: Bool, action: From): void -``` - -Conditionally submit an action. - -#### Parameters - -• **condition**: [`Bool`](../../../classes/Bool.mdx) - -• **action**: `From`\<`ActionType`\> - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.dispatchIf` - -#### Source - -[lib/mina/actions/batch-reducer.ts:215](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L215) - -*** - -### prepareBatches() - -```ts -prepareBatches(): Promise<{ - "batch": ActionBatch; - "proof": ActionStackProof; -}[]> -``` - -Create a proof which returns the next actions batch(es) to process and helps guarantee their correctness. - -#### Returns - -`Promise`\<\{ - `"batch"`: `ActionBatch`\<`Action`\>; - `"proof"`: `ActionStackProof`; - \}[]\> - -#### Inherited from - -`BatchReducer_.BatchReducer.prepareBatches` - -#### Source - -[lib/mina/actions/batch-reducer.ts:428](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L428) - -*** - -### processBatch() - -```ts -processBatch(__namedParameters: { - "batch": ActionBatch; - "proof": Proof; - }, callback: (action: Action, isDummy: Bool, i: number) => void): void -``` - -Process a batch of actions which was created by `prepareBatches()`. - -**Important**: The callback exposes the action's value along with an `isDummy` flag. -This is necessary because we process a dynamically-sized list in a fixed number of steps. -Dummies will be passed to your callback once the actual actions are exhausted. - -Make sure to write your code to account for dummies. For example, when sending MINA from your contract for every action, -you probably want to zero out the balance decrease in the `isDummy` case: -```ts -processBatch({ batch, proof }, (action, isDummy) => { - // ... other logic ... - - let amountToSend = Provable.if(isDummy, UInt64.zero, action.amount); - this.balance.subInPlace(amountToSend); -}); -``` - -**Warning**: Don't call `processBatch()` on two _different_ batches within the same method. The second call -would override the preconditions set by the first call, which would leave the method insecure. -To process more actions per method call, increase the `batchSize`. - -#### Parameters - -• **\_\_namedParameters** - -• **\_\_namedParameters.batch**: `ActionBatch`\<`Action`\> - -• **\_\_namedParameters.proof**: [`Proof`](../../../classes/Proof.mdx)\<[`Field`](../../../classes/Field.mdx), `ActionStackState`\> - -• **callback** - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.processBatch` - -#### Source - -[lib/mina/actions/batch-reducer.ts:253](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L253) - -*** - -### setContractClass() - -```ts -setContractClass(contractClass: BatchReducerContractClass): void -``` - -Set the smart contract class this reducer is connected with. - -Note: You can use either this method or `setContractInstance()` before calling `compile()`. -However, `setContractInstance()` is required for `proveNextBatch()`. - -#### Parameters - -• **contractClass**: `BatchReducerContractClass` - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.setContractClass` - -#### Source - -[lib/mina/actions/batch-reducer.ts:195](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L195) - -*** - -### setContractInstance() - -```ts -setContractInstance(contract: BatchReducerContract): void -``` - -Set the smart contract instance this reducer is connected with. - -Note: This is a required step before using `dispatch()`, `proveNextBatch()` or `processNextBatch()`. - -#### Parameters - -• **contract**: `BatchReducerContract` - -#### Returns - -`void` - -#### Inherited from - -`BatchReducer_.BatchReducer.setContractInstance` - -#### Source - -[lib/mina/actions/batch-reducer.ts:184](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/batch-reducer.ts#L184) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/classes/OffchainStateCommitments ---- - -Commitments that keep track of the current state of an offchain Merkle tree constructed from actions. -Intended to be stored on-chain. - -Fields: -- `root`: The root of the current Merkle tree -- `actionState`: The hash pointing to the list of actions that have been applied to form the current Merkle tree - -## Extends - -- `OffchainStateCommitments` - -## Constructors - -### new OffchainStateCommitments() - -```ts -new OffchainStateCommitments(value: { - "actionState": Field; - "length": Field; - "root": Field; - }): OffchainStateCommitments -``` - -#### Parameters - -• **value** - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -[`OffchainStateCommitments`](OffchainStateCommitments.mdx) - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.constructor` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -## Properties - -### actionState - -```ts -actionState: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.actionState` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L49) - -*** - -### length - -```ts -length: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.length` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L46) - -*** - -### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.root` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:45](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L45) - -*** - -### \_isStruct - -```ts -static _isStruct: true; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments._isStruct` - -#### Source - -[lib/provable/types/struct.ts:148](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L148) - -*** - -### check() - -```ts -static check: (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../../../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value** - -the element of type `T` to put assertions on. - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -`void` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.check` - -#### Source - -[lib/provable/types/provable-intf.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L76) - -*** - -### empty() - -```ts -static empty: () => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.empty` - -#### Source - -[lib/provable/types/struct.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L158) - -*** - -### fromFields() - -```ts -static fromFields: (fields: Field[]) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **fields**: [`Field`](../../../classes/Field.mdx)[] - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromFields` - -#### Source - -[lib/provable/types/provable-intf.ts:115](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L115) - -*** - -### fromJSON() - -```ts -static fromJSON: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: `string`= `Field` - -• **x.length**: `string`= `Field` - -• **x.root**: `string`= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromJSON` - -#### Source - -[lib/provable/types/struct.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L157) - -*** - -### fromValue - -```ts -static fromValue: (x: { - "actionState": Field; - "length": Field; - "root": Field; - } | { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; - } & (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Convert provable type from a normal JS type. - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.fromValue` - -#### Source - -[lib/provable/types/provable-intf.ts:86](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L86) - -*** - -### toAuxiliary() - -```ts -static toAuxiliary: (value?: { - "actionState": Field; - "length": Field; - "root": Field; - }) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?** - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -• **value.actionState?**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length?**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root?**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -`any`[] - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toAuxiliary` - -#### Source - -[lib/provable/types/provable-intf.ts:47](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L47) - -*** - -### toCanonical()? - -```ts -static optional toCanonical: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: Field = Field; -``` - -##### length - -```ts -length: Field = Field; -``` - -##### root - -```ts -root: Field = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toCanonical` - -#### Source - -[lib/provable/types/provable-intf.ts:104](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L104) - -*** - -### toFields() - -```ts -static toFields: (value: { - "actionState": Field; - "length": Field; - "root": Field; - }) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../../../classes/Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value** - -the element of type `T` to generate the [Field](../../../classes/Field.mdx) array from. - -• **value.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **value.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -[`Field`](../../../classes/Field.mdx)[] - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toFields` - -#### Source - -[lib/provable/types/provable-intf.ts:36](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L36) - -*** - -### toInput() - -```ts -static toInput: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "fields": Field[]; - "packed": [Field, number][]; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "fields": Field[]; - "packed": [Field, number][]; -} -``` - -##### fields? - -```ts -optional fields: Field[]; -``` - -##### packed? - -```ts -optional packed: [Field, number][]; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toInput` - -#### Source - -[lib/provable/types/struct.ts:152](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L152) - -*** - -### toJSON() - -```ts -static toJSON: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: string = Field; -``` - -##### length - -```ts -length: string = Field; -``` - -##### root - -```ts -root: string = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toJSON` - -#### Source - -[lib/provable/types/struct.ts:156](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L156) - -*** - -### toValue() - -```ts -static toValue: (x: { - "actionState": Field; - "length": Field; - "root": Field; - }) => { - "actionState": Field; - "length": Field; - "root": Field; -}; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x** - -• **x.actionState**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.length**: [`Field`](../../../classes/Field.mdx)= `Field` - -• **x.root**: [`Field`](../../../classes/Field.mdx)= `Field` - -#### Returns - -```ts -{ - "actionState": Field; - "length": Field; - "root": Field; -} -``` - -##### actionState - -```ts -actionState: bigint = Field; -``` - -##### length - -```ts -length: bigint = Field; -``` - -##### root - -```ts -root: bigint = Field; -``` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.toValue` - -#### Source - -[lib/provable/types/provable-intf.ts:81](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L81) - -## Methods - -### emptyFromHeight() - -```ts -static emptyFromHeight(height: number): OffchainStateCommitments -``` - -#### Parameters - -• **height**: `number` - -#### Returns - -`OffchainStateCommitments` - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.emptyFromHeight` - -#### Source - -[lib/mina/actions/offchain-state-rollup.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/offchain-state-rollup.ts#L51) - -*** - -### sizeInFields() - -```ts -static sizeInFields(): number -``` - -Return the size of the `T` type in terms of [Field](../../../classes/Field.mdx) type, as [Field](../../../classes/Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](../../../classes/Field.mdx) type. - -#### Inherited from - -`OffchainState_.OffchainStateCommitments.sizeInFields` - -#### Source - -[lib/provable/types/provable-intf.ts:66](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L66) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/functions/ActionBatch ---- - -```ts -function ActionBatch(actionType: A): (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - } & { - "_isStruct": true; - } & Provable<{ - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }, { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses; - }> & { - "empty": () => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "fromValue": (value: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": any; - "useOnchainStack": Bool; - "witnesses": ActionWitnesses | Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }; - "toInput": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "fields": Field[]; - "packed": [Field, number][]; - }; - "toJSON": (x: { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": MerkleList>>>; - "useOnchainStack": Bool; - "witnesses": Unconstrained; - }) => { - "isRecursive": Bool; - "onchainActionState": Field; - "onchainStack": Field; - "processedActionState": Field; - "stack": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "empty": {}; - "emptyHash": string; - "from": {}; - "fromReverse": {}; - "prototype": { - "Constructor": { - "_emptyHash": null | string; - "_innerProvable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "_nextHash": null | {}; - "_provable": null | { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "emptyHash": string; - "prototype": { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; startIteratingFromLast: {}; ... 4 more ...; readonly innerProvable: { ...; }; }; - "create": ; - }; - "data": { - "get": ; - "set": ; - "setTo": ; - "updateAsProver": ; - }; - "hash": string; - "innerProvable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "clone": ; - "forEach": ; - "isEmpty": ; - "lengthUnconstrained": ; - "nextHash": ; - "pop": ; - "popExn": ; - "popIf": ; - "popIfUnsafe": ; - "push": ; - "pushIf": ; - "startIterating": ; - "startIteratingFromLast": ; - "toArrayUnconstrained": ; - }; - "provable": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - "create": ; - }; - "useOnchainStack": Bool; - "witnesses": { - "check": {}; - "empty": {}; - "fromFields": {}; - "fromValue": {}; - "toAuxiliary": {}; - "toCanonical": null | {}; - "toFields": {}; - "toInput": {}; - "toValue": {}; - "sizeInFields": ; - }; - }; -} -``` - -Provable type that represents a batch of actions. - -## Type parameters - -• **A** *extends* `Actionable`\<`any`\> - -## Parameters - -• **actionType**: `A` - -## Returns - -(`value`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \} & \{ - `"_isStruct"`: `true`; - \} & `Provable`\<\{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}, \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: `any`; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: `ActionWitnesses`; - \}\> & \{ - `"empty"`: () => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"fromJSON"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"empty"`: \{\}; - `"emptyHash"`: `string`; - `"from"`: \{\}; - `"fromReverse"`: \{\}; - `"prototype"`: \{ - `"Constructor"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"emptyHash"`: `string`; - `"prototype"`: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \}; - `"create"`: ; - \}; - `"data"`: \{ - `"get"`: ; - `"set"`: ; - `"setTo"`: ; - `"updateAsProver"`: ; - \}; - `"hash"`: `string`; - `"innerProvable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"clone"`: ; - `"forEach"`: ; - `"isEmpty"`: ; - `"lengthUnconstrained"`: ; - `"nextHash"`: ; - `"pop"`: ; - `"popExn"`: ; - `"popIf"`: ; - `"popIfUnsafe"`: ; - `"push"`: ; - `"pushIf"`: ; - `"startIterating"`: ; - `"startIteratingFromLast"`: ; - `"toArrayUnconstrained"`: ; - \}; - `"provable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"create"`: ; - \}; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"fromValue"`: (`value`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: `any`; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: `ActionWitnesses` \| [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}; - `"toInput"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"fields"`: [`Field`](../../../classes/Field.mdx)[]; - `"packed"`: [[`Field`](../../../classes/Field.mdx), `number`][]; - \}; - `"toJSON"`: (`x`: \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: [`MerkleList`](../../../classes/MerkleList.mdx)\<[`MerkleList`](../../../classes/MerkleList.mdx)\<[`Hashed`](../../../classes/Hashed.mdx)\<`InferProvable`\<`A`, [`Field`](../../../classes/Field.mdx)\>\>\>\>; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: [`Unconstrained`](../../../classes/Unconstrained.mdx)\<`ActionWitnesses`\>; - \}) => \{ - `"isRecursive"`: `Bool`; - `"onchainActionState"`: `Field`; - `"onchainStack"`: `Field`; - `"processedActionState"`: `Field`; - `"stack"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"empty"`: \{\}; - `"emptyHash"`: `string`; - `"from"`: \{\}; - `"fromReverse"`: \{\}; - `"prototype"`: \{ - `"Constructor"`: \{ - `"_emptyHash"`: `null` \| `string`; - `"_innerProvable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"_nextHash"`: `null` \| \{\}; - `"_provable"`: `null` \| \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"emptyHash"`: `string`; - `"prototype"`: \{ hash: string; data: \{ get: \{\}; set: \{\}; setTo: \{\}; updateAsProver: \{\}; \}; isEmpty: \{\}; push: \{\}; pushIf: \{\}; popExn: \{\}; pop: \{\}; popIf: \{\}; popIfUnsafe: \{\}; clone: \{\}; forEach: \{\}; startIterating: \{\}; startIteratingFromLast: \{\}; ... 4 more ...; readonly innerProvable: \{ ...; \}; \}; - `"create"`: ; - \}; - `"data"`: \{ - `"get"`: ; - `"set"`: ; - `"setTo"`: ; - `"updateAsProver"`: ; - \}; - `"hash"`: `string`; - `"innerProvable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"clone"`: ; - `"forEach"`: ; - `"isEmpty"`: ; - `"lengthUnconstrained"`: ; - `"nextHash"`: ; - `"pop"`: ; - `"popExn"`: ; - `"popIf"`: ; - `"popIfUnsafe"`: ; - `"push"`: ; - `"pushIf"`: ; - `"startIterating"`: ; - `"startIteratingFromLast"`: ; - `"toArrayUnconstrained"`: ; - \}; - `"provable"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - `"create"`: ; - \}; - `"useOnchainStack"`: `Bool`; - `"witnesses"`: \{ - `"check"`: \{\}; - `"empty"`: \{\}; - `"fromFields"`: \{\}; - `"fromValue"`: \{\}; - `"toAuxiliary"`: \{\}; - `"toCanonical"`: `null` \| \{\}; - `"toFields"`: \{\}; - `"toInput"`: \{\}; - `"toValue"`: \{\}; - `"sizeInFields"`: ; - \}; - \}; - \} - -## Source - -[index.ts:213](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L213) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap ---- - -```ts -function IndexedMerkleMap(height: number): typeof IndexedMerkleMapBase -``` - -Class factory for an Indexed Merkle Map with a given height. - -```ts -class MerkleMap extends IndexedMerkleMap(33) {} - -let map = new MerkleMap(); - -map.insert(2n, 14n); -map.insert(1n, 13n); - -let x = map.get(2n); // 14 -``` - -Indexed Merkle maps can be used directly in provable code: - -```ts -ZkProgram({ - methods: { - test: { - privateInputs: [MerkleMap, Field], - - method(map: MerkleMap, key: Field) { - // get the value associated with `key` - let value = map.getOption(key).orElse(0n); - - // increment the value by 1 - map.set(key, value.add(1)); - } - } - } -}) -``` - -Initially, every `IndexedMerkleMap` is populated by a single key-value pair: `(0, 0)`. The value for key `0` can be updated like any other. -When keys and values are hash outputs, `(0, 0)` can serve as a convenient way to represent a dummy update to the tree, since 0 is not -effciently computable as a hash image, and this update doesn't affect the Merkle root. - -## Parameters - -• **height**: `number` - -## Returns - -*typeof* `IndexedMerkleMapBase` - -## Source - -[index.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L166) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/functions/OffchainState ---- - -```ts -function OffchainState(config: Config, options?: { - "logTotalCapacity": number; - "maxActionsPerProof": number; - "maxActionsPerUpdate": number; -}): OffchainState -``` - -Offchain state for a `SmartContract`. - -```ts -// declare your offchain state - -const offchainState = OffchainState({ - accounts: OffchainState.Map(PublicKey, UInt64), - totalSupply: OffchainState.Field(UInt64), -}); - -// use it in a contract, by adding an onchain state field of type `OffchainStateCommitments` - -class MyContract extends SmartContract { - \@state(OffchainStateCommitments) offchainState = State( - OffchainStateCommitments.empty() - ); - - // ... -} - -// set the contract instance - -let contract = new MyContract(address); -offchainState.setContractInstance(contract); -``` - -See the individual methods on `offchainState` for more information on usage. - -## Type parameters - -• **Config** *extends* \{\} - -## Parameters - -• **config**: `Config` - -• **options?** - -• **options.logTotalCapacity?**: `number` - -The base-2 logarithm of the total capacity of the offchain state. - -Example: if you want to have 1 million individual state fields and map entries available, -set this to 20, because 2^20 ~= 1M. - -The default is 30, which allows for ~1 billion entries. - -Passing in lower numbers will reduce the number of constraints required to prove offchain state updates, -which we will make proof creation slightly faster. -Instead, you could also use a smaller total capacity to increase the `maxActionsPerProof`, so that fewer proofs are required, -which will reduce the proof time even more, but only in the case of many actions. - -• **options.maxActionsPerProof?**: `number` - -• **options.maxActionsPerUpdate?**: `number` - -The maximum number of offchain state actions that can be included in a single account update. - -In other words, you must not call `.update()` or `.overwrite()` more than this number of times in any of your smart contract methods. - -The default is 4. - -Note: When increasing this, consider decreasing `maxActionsPerProof` or `logTotalCapacity` in order to not exceed the circuit size limit. - -## Returns - -`OffchainState`\<`Config`\> - -## Source - -[index.ts:170](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L170) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/functions/memoizeWitness ---- - -```ts -function memoizeWitness(type: FlexibleProvable, compute: () => T): T -``` - -Like Provable.witness, but memoizes the witness during transaction construction -for reuse by the prover. This is needed to witness non-deterministic values. - -## Type parameters - -• **T** - -## Parameters - -• **type**: [`FlexibleProvable`](../../../type-aliases/FlexibleProvable.mdx)\<`T`\> - -• **compute** - -## Returns - -`T` - -## Source - -[index.ts:163](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L163) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/type-aliases/ActionBatch ---- - -```ts -type ActionBatch: BatchReducer_.ActionBatch; -``` - -## Type parameters - -• **Action** - -## Source - -[index.ts:213](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L213) - ---- -url: /zkapps/o1js-reference/namespaces/Experimental/type-aliases/IndexedMerkleMap ---- - -```ts -type IndexedMerkleMap: IndexedMerkleMapBase; -``` - -## Source - -[index.ts:166](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/index.ts#L166) - ---- -url: /zkapps/o1js-reference/namespaces/Lightnet/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [acquireKeyPair](functions/acquireKeyPair.mdx) | Gets random key pair (public and private keys) from account manager | -| [listAcquiredKeyPairs](functions/listAcquiredKeyPairs.mdx) | Gets previously acquired key pairs list. | -| [releaseKeyPair](functions/releaseKeyPair.mdx) | Releases previously acquired key pair by public key. | - ---- -url: /zkapps/o1js-reference/namespaces/Lightnet/functions/acquireKeyPair ---- - -```ts -function acquireKeyPair(options: { - "isRegularAccount": boolean; - "lightnetAccountManagerEndpoint": string; - }): Promise<{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -}> -``` - -Gets random key pair (public and private keys) from account manager -that operates with accounts configured in target network Genesis Ledger. - -If an error is returned by the specified endpoint, an error is thrown. Otherwise, -the data is returned. - -## Parameters - -• **options**= `{}` - -• **options.isRegularAccount?**: `boolean` - -Whether to acquire key pair of regular or zkApp account (one with already configured verification key) - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -## Returns - -`Promise`\<\{ - `"privateKey"`: [`PrivateKey`](../../../classes/PrivateKey.mdx); - `"publicKey"`: [`PublicKey`](../../../classes/PublicKey.mdx); - \}\> - -Key pair - -> ### privateKey -> -> ```ts -> privateKey: PrivateKey; -> ``` -> -> ### publicKey -> -> ```ts -> publicKey: PublicKey; -> ``` -> - -## Source - -[lib/mina/fetch.ts:843](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L843) - ---- -url: /zkapps/o1js-reference/namespaces/Lightnet/functions/listAcquiredKeyPairs ---- - -```ts -function listAcquiredKeyPairs(options: { - "lightnetAccountManagerEndpoint": string; - }): Promise<{ - "privateKey": PrivateKey; - "publicKey": PublicKey; -}[] | null> -``` - -Gets previously acquired key pairs list. - -## Parameters - -• **options** - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -## Returns - -`Promise`\<\{ - `"privateKey"`: [`PrivateKey`](../../../classes/PrivateKey.mdx); - `"publicKey"`: [`PublicKey`](../../../classes/PublicKey.mdx); - \}[] \| `null`\> - -Key pairs list or null if the request failed - -## Source - -[lib/mina/fetch.ts:923](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L923) - ---- -url: /zkapps/o1js-reference/namespaces/Lightnet/functions/releaseKeyPair ---- - -```ts -function releaseKeyPair(options: { - "lightnetAccountManagerEndpoint": string; - "publicKey": string; -}): Promise -``` - -Releases previously acquired key pair by public key. - -## Parameters - -• **options** - -• **options.lightnetAccountManagerEndpoint?**: `string` - -Account manager endpoint to fetch from - -• **options.publicKey**: `string` - -Public key of previously acquired key pair to release - -## Returns - -`Promise`\<`string` \| `null`\> - -Response message from the account manager as string or null if the request failed - -## Source - -[lib/mina/fetch.ts:886](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/fetch.ts#L886) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [TestPublicKey](namespaces/TestPublicKey/README.mdx) | - | -| [Transaction](namespaces/Transaction/README.mdx) | - | -| [ActionStates](type-aliases/ActionStates.mdx) | - | -| [FeePayerSpec](type-aliases/FeePayerSpec.mdx) | Allows you to specify information about the fee payer account and the transaction. | -| [IncludedTransaction](type-aliases/IncludedTransaction.mdx) | Represents a transaction that has been successfully included in a block. | -| [NetworkConstants](type-aliases/NetworkConstants.mdx) | - | -| [PendingTransaction](type-aliases/PendingTransaction.mdx) | Represents a transaction that has been submitted to the blockchain but has not yet reached a final state. | -| [PendingTransactionPromise](type-aliases/PendingTransactionPromise.mdx) | A `Promise` with an additional `wait` method, which calls | -| [PendingTransactionStatus](type-aliases/PendingTransactionStatus.mdx) | - | -| [RejectedTransaction](type-aliases/RejectedTransaction.mdx) | Represents a transaction that has been rejected and not included in a blockchain block. | -| [TestPublicKey](type-aliases/TestPublicKey.mdx) | - | -| [Transaction](type-aliases/Transaction.mdx) | Defines the structure and operations associated with a transaction. | -| [activeInstance](variables/activeInstance.mdx) | - | -| [LocalBlockchain](functions/LocalBlockchain.mdx) | A mock Mina blockchain running locally and useful for testing. | -| [Network](functions/Network.mdx) | Represents the Mina blockchain running on a real network | -| [TestPublicKey](functions/TestPublicKey.mdx) | - | -| [currentSlot](functions/currentSlot.mdx) | - | -| [currentTransaction](functions/currentTransaction.mdx) | - | -| [faucet](functions/faucet.mdx) | Requests the [testnet faucet](https://faucet.minaprotocol.com/api/v1/faucet) to fund a public key. | -| [fetchActions](functions/fetchActions.mdx) | - | -| [fetchEvents](functions/fetchEvents.mdx) | - | -| [filterGroups](functions/filterGroups.mdx) | - | -| [getAccount](functions/getAccount.mdx) | - | -| [getActions](functions/getActions.mdx) | - | -| [getBalance](functions/getBalance.mdx) | - | -| [getNetworkConstants](functions/getNetworkConstants.mdx) | - | -| [getNetworkId](functions/getNetworkId.mdx) | - | -| [getNetworkState](functions/getNetworkState.mdx) | - | -| [getProofsEnabled](functions/getProofsEnabled.mdx) | - | -| [hasAccount](functions/hasAccount.mdx) | Checks if an account exists within the ledger. | -| [sender](functions/sender.mdx) | Returns the public key of the current transaction's sender account. | -| [setActiveInstance](functions/setActiveInstance.mdx) | Set the currently used Mina instance. | -| [transaction](functions/transaction.mdx) | Construct a smart contract transaction. Within the callback passed to this function, | -| [waitForFunding](functions/waitForFunding.mdx) | - | - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/LocalBlockchain ---- - -```ts -function LocalBlockchain(__namedParameters: { - "enforceTransactionLimits": true; - "proofsEnabled": true; - }): Promise<{ - "addAccount": (publicKey: PublicKey, balance: string) => void; - "getNetworkId": () => NetworkId; - "proofsEnabled": boolean; - "testAccounts": [TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey]; - "applyJsonTransaction": void; - "currentSlot": UInt32; - "fetchActions": Promise<{ - "actions": string[][]; - "hash": string; - }[]>; - "fetchEvents": Promise; - "getAccount": Account; - "getActions": { - "actions": string[][]; - "hash": string; - }[]; - "getNetworkConstants": { - "accountCreationFee": UInt64; - "genesisTimestamp": UInt64; - "slotTime": UInt64; - }; - "getNetworkState": PreconditionBaseTypes<{}>; - "hasAccount": boolean; - "incrementGlobalSlot": void; - "resetProofsEnabled": void; - "sendTransaction": PendingTransactionPromise; - "setBlockchainLength": void; - "setGlobalSlot": void; - "setProofsEnabled": void; - "setTotalCurrency": void; - "transaction": TransactionPromise; -}> -``` - -A mock Mina blockchain running locally and useful for testing. - -## Parameters - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.enforceTransactionLimits**: `undefined` \| `boolean`= `true` - -• **\_\_namedParameters.proofsEnabled**: `undefined` \| `boolean`= `true` - -## Returns - -`Promise`\<\{ - `"addAccount"`: (`publicKey`: [`PublicKey`](../../../classes/PublicKey.mdx), `balance`: `string`) => `void`; - `"getNetworkId"`: () => `NetworkId`; - `"proofsEnabled"`: `boolean`; - `"testAccounts"`: [[`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx), [`TestPublicKey`](../type-aliases/TestPublicKey.mdx)]; - `"applyJsonTransaction"`: `void`; - `"currentSlot"`: [`UInt32`](../../../classes/UInt32.mdx); - `"fetchActions"`: `Promise`\<\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[]\>; - `"fetchEvents"`: `Promise`\<`any`\>; - `"getAccount"`: `Account`; - `"getActions"`: \{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[]; - `"getNetworkConstants"`: \{ - `"accountCreationFee"`: [`UInt64`](../../../classes/UInt64.mdx); - `"genesisTimestamp"`: [`UInt64`](../../../classes/UInt64.mdx); - `"slotTime"`: [`UInt64`](../../../classes/UInt64.mdx); - \}; - `"getNetworkState"`: `PreconditionBaseTypes`\<\{\}\>; - `"hasAccount"`: `boolean`; - `"incrementGlobalSlot"`: `void`; - `"resetProofsEnabled"`: `void`; - `"sendTransaction"`: [`PendingTransactionPromise`](../type-aliases/PendingTransactionPromise.mdx); - `"setBlockchainLength"`: `void`; - `"setGlobalSlot"`: `void`; - `"setProofsEnabled"`: `void`; - `"setTotalCurrency"`: `void`; - `"transaction"`: [`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\>; - \}\> - -> ### addAccount() -> -> ```ts -> addAccount: (publicKey: PublicKey, balance: string) => void; -> ``` -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **balance**: `string` -> -> #### Returns -> -> `void` -> -> ### getNetworkId() -> -> ```ts -> getNetworkId: () => NetworkId; -> ``` -> -> #### Returns -> -> `NetworkId` -> -> ### proofsEnabled -> -> ```ts -> proofsEnabled: boolean; -> ``` -> -> ### testAccounts -> -> ```ts -> testAccounts: [TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey, TestPublicKey]; -> ``` -> -> ### applyJsonTransaction() -> -> #### Parameters -> -> • **json**: `string` -> -> #### Returns -> -> `void` -> -> ### currentSlot() -> -> #### Returns -> -> [`UInt32`](../../../classes/UInt32.mdx) -> -> ### fetchActions() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) -> -> • **tokenId?**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Promise`\<\{ -> `"actions"`: `string`[][]; -> `"hash"`: `string`; -> \}[]\> -> -> ### fetchEvents() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Promise`\<`any`\> -> -> ### getAccount() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `Account` -> -> ### getActions() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) -> -> • **tokenId?**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> \{ -> `"actions"`: `string`[][]; -> `"hash"`: `string`; -> \}[] -> -> ### getNetworkConstants() -> -> #### Returns -> -> ```ts -> { -> "accountCreationFee": UInt64; -> "genesisTimestamp": UInt64; -> "slotTime": UInt64; -> } -> ``` -> -> ##### accountCreationFee -> -> ```ts -> accountCreationFee: UInt64; -> ``` -> -> ##### genesisTimestamp -> -> ```ts -> genesisTimestamp: UInt64; -> ``` -> -> ##### slotTime -> -> ```ts -> slotTime: UInt64; -> ``` -> -> Duration of 1 slot in millisecondw -> -> ### getNetworkState() -> -> #### Returns -> -> `PreconditionBaseTypes`\<\{\}\> -> -> ### hasAccount() -> -> #### Parameters -> -> • **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) -> -> • **tokenId**: [`Field`](../../../classes/Field.mdx)= `TokenId.default` -> -> #### Returns -> -> `boolean` -> -> ### incrementGlobalSlot() -> -> #### Parameters -> -> • **increment**: `number` \| [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### resetProofsEnabled() -> -> #### Returns -> -> `void` -> -> ### sendTransaction() -> -> #### Parameters -> -> • **txn**: [`Transaction`](../type-aliases/Transaction.mdx)\<`boolean`, `boolean`\> -> -> #### Returns -> -> [`PendingTransactionPromise`](../type-aliases/PendingTransactionPromise.mdx) -> -> ### setBlockchainLength() -> -> #### Parameters -> -> • **height**: [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### setGlobalSlot() -> -> #### Parameters -> -> • **slot**: `number` \| [`UInt32`](../../../classes/UInt32.mdx) -> -> #### Returns -> -> `void` -> -> ### setProofsEnabled() -> -> #### Parameters -> -> • **newProofsEnabled**: `boolean` -> -> #### Returns -> -> `void` -> -> ### setTotalCurrency() -> -> #### Parameters -> -> • **currency**: [`UInt64`](../../../classes/UInt64.mdx) -> -> #### Returns -> -> `void` -> -> ### transaction() -> -> #### Parameters -> -> • **sender**: [`FeePayerSpec`](../type-aliases/FeePayerSpec.mdx) -> -> • **f** -> -> #### Returns -> -> [`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> -> - -## Source - -[lib/mina/local-blockchain.ts:72](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L72) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/Network ---- - -## Network(graphqlEndpoint) - -```ts -function Network(graphqlEndpoint: string): Mina -``` - -Represents the Mina blockchain running on a real network - -### Parameters - -• **graphqlEndpoint**: `string` - -### Returns - -`Mina` - -### Source - -[lib/mina/mina.ts:101](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L101) - -## Network(options) - -```ts -function Network(options: { - "archive": string | string[]; - "lightnetAccountManager": string; - "mina": string | string[]; - "networkId": NetworkId; - }): Mina -``` - -### Parameters - -• **options** - -• **options.archive?**: `string` \| `string`[] - -• **options.lightnetAccountManager?**: `string` - -• **options.mina**: `string` \| `string`[] - -• **options.networkId?**: `NetworkId` - -### Returns - -`Mina` - -### Source - -[lib/mina/mina.ts:102](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L102) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/TestPublicKey ---- - -```ts -function TestPublicKey(key: PrivateKey): TestPublicKey -``` - -## Parameters - -• **key**: [`PrivateKey`](../../../classes/PrivateKey.mdx) - -## Returns - -[`TestPublicKey`](../type-aliases/TestPublicKey.mdx) - -## Source - -[lib/mina/local-blockchain.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L51) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/currentSlot ---- - -```ts -function currentSlot(): UInt32 -``` - -## Returns - -[`UInt32`](../../../classes/UInt32.mdx) - -The current slot number, according to the active Mina instance. - -## Source - -[lib/mina/mina-instance.ts:137](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L137) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/currentTransaction ---- - -```ts -function currentTransaction(): undefined | CurrentTransaction -``` - -## Returns - -`undefined` \| `CurrentTransaction` - -## Source - -[lib/mina/transaction-context.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction-context.ts#L16) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/faucet ---- - -```ts -function faucet(pub: PublicKey, network: string): Promise -``` - -Requests the [testnet faucet](https://faucet.minaprotocol.com/api/v1/faucet) to fund a public key. - -## Parameters - -• **pub**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **network**: `string`= `'berkeley-qanet'` - -## Returns - -`Promise`\<`void`\> - -## Source - -[lib/mina/mina.ts:514](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L514) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/fetchActions ---- - -```ts -function fetchActions( - publicKey: PublicKey, - actionStates?: ActionStates, - tokenId?: Field): Promise<{ - "actions": string[][]; - "hash": string; - }[] | { - "error": { - "statusCode": 404; - "statusText": string; - }; -}> -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -`Promise`\<\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[] \| \{ - `"error"`: \{ - `"statusCode"`: `404`; - `"statusText"`: `string`; - \}; - \}\> - -A list of emitted sequencing actions associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:197](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L197) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/fetchEvents ---- - -```ts -function fetchEvents( - publicKey: PublicKey, - tokenId: Field, - filterOptions: EventActionFilterOptions): Promise<{ - "blockHash": event.blockInfo.stateHash; - "blockHeight": UInt32; - "chainStatus": event.blockInfo.chainStatus; - "events": { - "data": string[]; - "transactionInfo": { - "hash": string; - "memo": string; - "status": string; - }; - }[]; - "globalSlot": UInt32; - "parentBlockHash": event.blockInfo.parentHash; -}[]> -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId**: [`Field`](../../../classes/Field.mdx) - -• **filterOptions**: `EventActionFilterOptions`= `{}` - -## Returns - -`Promise`\<\{ - `"blockHash"`: `event.blockInfo.stateHash`; - `"blockHeight"`: [`UInt32`](../../../classes/UInt32.mdx); - `"chainStatus"`: `event.blockInfo.chainStatus`; - `"events"`: \{ - `"data"`: `string`[]; - `"transactionInfo"`: \{ - `"hash"`: `string`; - `"memo"`: `string`; - `"status"`: `string`; - \}; - \}[]; - `"globalSlot"`: [`UInt32`](../../../classes/UInt32.mdx); - `"parentBlockHash"`: `event.blockInfo.parentHash`; - \}[]\> - -A list of emitted events associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:186](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L186) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/filterGroups ---- - -```ts -function filterGroups(xs: AuthorizationKind[]): { - "proof": proofCount; - "signedPair": pairs.pairs; - "signedSingle": singleCount; -} -``` - -## Parameters - -• **xs**: `AuthorizationKind`[] - -## Returns - -```ts -{ - "proof": proofCount; - "signedPair": pairs.pairs; - "signedSingle": singleCount; -} -``` - -### proof - -```ts -proof: number = proofCount; -``` - -### signedPair - -```ts -signedPair: number = pairs.pairs; -``` - -### signedSingle - -```ts -signedSingle: number = singleCount; -``` - -## Source - -[lib/mina/transaction-validation.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction-validation.ts#L130) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getAccount ---- - -```ts -function getAccount(publicKey: PublicKey, tokenId?: Field): Account -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -[`Account`](../../../type-aliases/Account.mdx) - -The account data associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:144](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L144) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getActions ---- - -```ts -function getActions( - publicKey: PublicKey, - actionStates?: ActionStates, - tokenId?: Field): { - "actions": string[][]; - "hash": string; - }[] -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **actionStates?**: [`ActionStates`](../type-aliases/ActionStates.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -\{ - `"actions"`: `string`[][]; - `"hash"`: `string`; - \}[] - -A list of emitted sequencing actions associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:208](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L208) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getBalance ---- - -```ts -function getBalance(publicKey: PublicKey, tokenId?: Field): UInt64 -``` - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -[`UInt64`](../../../classes/UInt64.mdx) - -The balance associated to the given public key. - -## Source - -[lib/mina/mina-instance.ts:179](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L179) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getNetworkConstants ---- - -```ts -function getNetworkConstants(): NetworkConstants -``` - -## Returns - -[`NetworkConstants`](../type-aliases/NetworkConstants.mdx) - -Data associated with the current Mina network constants. - -## Source - -[lib/mina/mina-instance.ts:165](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L165) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getNetworkId ---- - -```ts -function getNetworkId(): NetworkId -``` - -## Returns - -`NetworkId` - -The current Mina network ID. - -## Source - -[lib/mina/mina-instance.ts:158](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L158) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getNetworkState ---- - -```ts -function getNetworkState(): PreconditionBaseTypes<{}> -``` - -## Returns - -`PreconditionBaseTypes`\<\{\}\> - -Data associated with the current state of the Mina network. - -## Source - -[lib/mina/mina-instance.ts:172](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L172) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/getProofsEnabled ---- - -```ts -function getProofsEnabled(): boolean -``` - -## Returns - -`boolean` - -## Source - -[lib/mina/mina-instance.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L216) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/hasAccount ---- - -```ts -function hasAccount(publicKey: PublicKey, tokenId?: Field): boolean -``` - -Checks if an account exists within the ledger. - -## Parameters - -• **publicKey**: [`PublicKey`](../../../classes/PublicKey.mdx) - -• **tokenId?**: [`Field`](../../../classes/Field.mdx) - -## Returns - -`boolean` - -## Source - -[lib/mina/mina-instance.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L151) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/sender ---- - -```ts -function sender(): PublicKey -``` - -Returns the public key of the current transaction's sender account. - -Throws an error if not inside a transaction, or the sender wasn't passed in. - -## Returns - -[`PublicKey`](../../../classes/PublicKey.mdx) - -## Source - -[lib/mina/mina.ts:463](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L463) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/setActiveInstance ---- - -```ts -function setActiveInstance(m: Mina): void -``` - -Set the currently used Mina instance. - -## Parameters - -• **m**: `Mina` - -## Returns - -`void` - -## Source - -[lib/mina/mina-instance.ts:126](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L126) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/transaction ---- - -## transaction(sender, f) - -```ts -function transaction(sender: FeePayerSpec, f: () => Promise): TransactionPromise -``` - -Construct a smart contract transaction. Within the callback passed to this function, -you can call into the methods of smart contracts. - -``` -let tx = await Mina.transaction(sender, async () => { - await myZkapp.update(); - await someOtherZkapp.someOtherMethod(); -}); -``` - -### Parameters - -• **sender**: [`FeePayerSpec`](../type-aliases/FeePayerSpec.mdx) - -• **f** - -### Returns - -[`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> - -A transaction that can subsequently be submitted to the chain. - -### Source - -[lib/mina/transaction.ts:564](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L564) - -## transaction(f) - -```ts -function transaction(f: () => Promise): TransactionPromise -``` - -### Parameters - -• **f** - -### Returns - -[`TransactionPromise`](../../../type-aliases/TransactionPromise.mdx)\<`false`, `false`\> - -### Source - -[lib/mina/transaction.ts:568](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L568) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/functions/waitForFunding ---- - -```ts -function waitForFunding(address: string): Promise -``` - -## Parameters - -• **address**: `string` - -## Returns - -`Promise`\<`void`\> - -## Source - -[lib/mina/mina.ts:490](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina.ts#L490) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [fromBase58](functions/fromBase58.mdx) | - | -| [random](functions/random.mdx) | - | - ---- -url: /zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/fromBase58 ---- - -```ts -function fromBase58(base58: string): TestPublicKey -``` - -## Parameters - -• **base58**: `string` - -## Returns - -[`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx) - -## Source - -[lib/mina/local-blockchain.ts:64](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L64) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/namespaces/TestPublicKey/functions/random ---- - -```ts -function random(count: N): N extends 1 ? TestPublicKey : TupleN -``` - -## Type parameters - -• **N** *extends* `number` = `1` - -## Parameters - -• **count**: `N`= `undefined` - -## Returns - -`N` *extends* `1` ? [`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx) : [`TupleN`](../../../../../type-aliases/TupleN.mdx)\<[`TestPublicKey`](../../../type-aliases/TestPublicKey.mdx), `N`\> - -## Source - -[lib/mina/local-blockchain.ts:55](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L55) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/README ---- - -## Index - -| Member | Description | -| :------ | :------ | -| [fromJSON](functions/fromJSON.mdx) | - | - ---- -url: /zkapps/o1js-reference/namespaces/Mina/namespaces/Transaction/functions/fromJSON ---- - -```ts -function fromJSON(json: ZkappCommand): Transaction -``` - -## Parameters - -• **json**: `ZkappCommand` - -## Returns - -[`Transaction`](../../../type-aliases/Transaction.mdx)\<`false`, `false`\> - -## Source - -[lib/mina/transaction.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L85) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/ActionStates ---- - -```ts -type ActionStates: { - "endActionState": Field; - "fromActionState": Field; -}; -``` - -## Type declaration - -### endActionState? - -```ts -optional endActionState: Field; -``` - -### fromActionState? - -```ts -optional fromActionState: Field; -``` - -## Source - -[lib/mina/mina-instance.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L62) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/FeePayerSpec ---- - -```ts -type FeePayerSpec: PublicKey | { - "fee": number | string | UInt64; - "memo": string; - "nonce": number; - "sender": PublicKey; - } | undefined; -``` - -Allows you to specify information about the fee payer account and the transaction. - -## Source - -[lib/mina/mina-instance.ts:52](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L52) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/IncludedTransaction ---- - -```ts -type IncludedTransaction: Pick & { - "status": "included"; -}; -``` - -Represents a transaction that has been successfully included in a block. - -## Type declaration - -### status - -```ts -status: "included"; -``` - -#### Example - -```ts -try { - const includedTx: IncludedTransaction = await pendingTransaction.wait(); - // If wait() resolves, it means the transaction was successfully included. - console.log(`Transaction ${includedTx.hash} included in a block.`); -} catch (error) { - // If wait() throws, the transaction was not included in a block. - console.error('Transaction failed to be included in a block:', error); -} -``` - -## Source - -[lib/mina/transaction.ts:258](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L258) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/NetworkConstants ---- - -```ts -type NetworkConstants: { - "accountCreationFee": UInt64; - "genesisTimestamp": UInt64; - "slotTime": UInt64; -}; -``` - -## Type declaration - -### accountCreationFee - -```ts -accountCreationFee: UInt64; -``` - -### genesisTimestamp - -```ts -genesisTimestamp: UInt64; -``` - -### slotTime - -```ts -slotTime: UInt64; -``` - -Duration of 1 slot in millisecondw - -## Source - -[lib/mina/mina-instance.ts:67](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L67) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransaction ---- - -```ts -type PendingTransaction: Pick & { - "data": SendZkAppResponse; - "errors": string[]; - "hash": string; - "status": PendingTransactionStatus; - "safeWait": Promise; - "wait": Promise; -}; -``` - -Represents a transaction that has been submitted to the blockchain but has not yet reached a final state. -The [PendingTransaction](PendingTransaction.mdx) type extends certain functionalities from the base [Transaction](Transaction.mdx) type, -adding methods to monitor the transaction's progress towards being finalized (either included in a block or rejected). - -## Type declaration - -### data? - -```ts -optional data: SendZkAppResponse; -``` - -Optional. Contains response data from a ZkApp transaction submission. - -### errors - -```ts -errors: string[]; -``` - -An array of error messages related to the transaction processing. - -#### Example - -```ts -if (!pendingTransaction.status === 'rejected') { - console.error(`Transaction errors: ${pendingTransaction.errors.join(', ')}`); -} -``` - -### hash - -```ts -hash: string; -``` - -Returns the transaction hash as a string identifier. - -#### Example - -```ts -const txHash = pendingTransaction.hash; -console.log(`Transaction hash: ${txHash}`); -``` - -### status - -```ts -status: PendingTransactionStatus; -``` - -#### Example - -```ts -if (pendingTransaction.status === 'pending') { - console.log('Transaction accepted for processing by the Mina daemon.'); - try { - await pendingTransaction.wait(); - console.log('Transaction successfully included in a block.'); - } catch (error) { - console.error('Transaction was rejected or failed to be included in a block:', error); - } -} else { - console.error('Transaction was not accepted for processing by the Mina daemon.'); -} -``` - -### safeWait() - -Waits for the transaction to be included in a block. This method polls the Mina daemon to check the transaction's status - -#### Parameters - -• **options?** - -Configuration options for polling behavior. - -• **options.interval?**: `number` - -The time interval, in milliseconds, between each polling attempt. - -• **options.maxAttempts?**: `number` - -The maximum number of polling attempts. - -#### Returns - -`Promise`\<[`RejectedTransaction`](RejectedTransaction.mdx) \| [`IncludedTransaction`](IncludedTransaction.mdx)\> - -A promise that resolves to the transaction's final state. - -#### Example - -```ts -const transaction = await pendingTransaction.wait({ maxAttempts: 5, interval: 1000 }); -console.log(transaction.status); // 'included' or 'rejected' -``` - -### wait() - -Waits for the transaction to be included in a block. This method polls the Mina daemon to check the transaction's status, and throws an error if the transaction is rejected. - -#### Parameters - -• **options?** - -Configuration options for polling behavior. - -• **options.interval?**: `number` - -The interval, in milliseconds, between status checks. - -• **options.maxAttempts?**: `number` - -The maximum number of attempts to check the transaction status. - -#### Returns - -`Promise`\<[`IncludedTransaction`](IncludedTransaction.mdx)\> - -A promise that resolves to the transaction's final state or throws an error. - -#### Throws - -If the transaction is rejected or fails to finalize within the given attempts. - -#### Example - -```ts -try { - const transaction = await pendingTransaction.wait({ maxAttempts: 10, interval: 2000 }); - console.log('Transaction included in a block.'); -} catch (error) { - console.error('Transaction rejected or failed to finalize:', error); -} -``` - -## Source - -[lib/mina/transaction.ts:157](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L157) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionPromise ---- - -```ts -type PendingTransactionPromise: Promise & { - "wait": PendingTransaction["wait"]; -}; -``` - -A `Promise` with an additional `wait` method, which calls -into the inner `TransactionStatus`'s `wait` method upon its resolution. - -## Type declaration - -### wait - -```ts -wait: PendingTransaction["wait"]; -``` - -Equivalent to calling the resolved `PendingTransaction`'s `wait` method. - -## Source - -[lib/mina/transaction.ts:376](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L376) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/PendingTransactionStatus ---- - -```ts -type PendingTransactionStatus: "pending" | "rejected"; -``` - -## Source - -[lib/mina/transaction.ts:151](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L151) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/RejectedTransaction ---- - -```ts -type RejectedTransaction: Pick & { - "errors": string[]; - "status": "rejected"; -}; -``` - -Represents a transaction that has been rejected and not included in a blockchain block. - -## Type declaration - -### errors - -```ts -errors: string[]; -``` - -### status - -```ts -status: "rejected"; -``` - -#### Example - -```ts -try { - const txResult = await pendingTransaction.wait(); - // This line will not execute if the transaction is rejected, as `.wait()` will throw an error instead. - console.log(`Transaction ${txResult.hash} was successfully included in a block.`); -} catch (error) { - console.error(`Transaction ${error.transaction.hash} was rejected.`); - error.errors.forEach((error, i) => { - console.error(`Error ${i + 1}: ${error}`); - }); -} -``` - -## Source - -[lib/mina/transaction.ts:282](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L282) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/TestPublicKey ---- - -```ts -type TestPublicKey: PublicKey & { - "key": PrivateKey; -}; -``` - -## Type declaration - -### key - -```ts -key: PrivateKey; -``` - -## Source - -[lib/mina/local-blockchain.ts:51](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/local-blockchain.ts#L51) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/type-aliases/Transaction ---- - -```ts -type Transaction: TransactionCommon & { - "safeSend": Promise; - "send": PendingTransactionPromise; - } & Proven extends false ? { - "prove": Promise>; - } : { - "proofs": (Proof | undefined)[]; - } & Signed extends false ? { - "sign": Transaction; -} : {}; -``` - -Defines the structure and operations associated with a transaction. -This type encompasses methods for serializing the transaction, signing it, generating proofs, -and submitting it to the network. - -## Type declaration - -### safeSend() - -Sends the [Transaction](Transaction.mdx) to the network. Unlike the standard Transaction.send, this function does not throw an error if internal errors are detected. Instead, it returns a [PendingTransaction](PendingTransaction.mdx) if the transaction is successfully sent for processing or a [RejectedTransaction](RejectedTransaction.mdx) if it encounters errors during processing or is outright rejected by the Mina daemon. - -#### Returns - -`Promise`\<[`PendingTransaction`](PendingTransaction.mdx) \| [`RejectedTransaction`](RejectedTransaction.mdx)\> - -A promise that resolves to a [PendingTransaction](PendingTransaction.mdx) if the transaction is accepted for processing, or a [RejectedTransaction](RejectedTransaction.mdx) if the transaction fails or is rejected. - -#### Example - -```ts -const result = await transaction.safeSend(); -if (result.status === 'pending') { - console.log('Transaction sent successfully to the Mina daemon.'); -} else if (result.status === 'rejected') { - console.error('Transaction failed with errors:', result.errors); -} -``` - -### send() - -#### Returns - -[`PendingTransactionPromise`](PendingTransactionPromise.mdx) - -## Type parameters - -• **Proven** *extends* `boolean` - -• **Signed** *extends* `boolean` - -## Source - -[lib/mina/transaction.ts:84](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L84) - ---- -url: /zkapps/o1js-reference/namespaces/Mina/variables/activeInstance ---- - -```ts -activeInstance: Mina; -``` - -## Source - -[lib/mina/mina-instance.ts:108](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/mina-instance.ts#L108) - ---- -url: /zkapps/o1js-reference/type-aliases/Account ---- - -```ts -type Account: Types.Account; -``` - -## Source - -[lib/mina/account.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account.ts#L19) - ---- -url: /zkapps/o1js-reference/type-aliases/Bool ---- - -```ts -type Bool: Bool; -``` - -## Source - -[lib/provable/wrapped.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L70) - ---- -url: /zkapps/o1js-reference/type-aliases/BoolVar ---- - -```ts -type BoolVar: FieldVar; -``` - -## Source - -[lib/provable/bool.ts:14](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/bool.ts#L14) - ---- -url: /zkapps/o1js-reference/type-aliases/Bytes ---- - -```ts -type Bytes: InternalBytes; -``` - -## Source - -[lib/provable/wrapped-classes.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped-classes.ts#L16) - ---- -url: /zkapps/o1js-reference/type-aliases/Cache ---- - -```ts -type Cache: { - "canWrite": boolean; - "debug": boolean; - "read": undefined | Uint8Array; - "write": void; -}; -``` - -Interface for storing and retrieving values, for caching. -`read()` and `write()` can just throw errors on failure. - -The data that will be passed to the cache for writing is exhaustively described by the [CacheHeader](CacheHeader.mdx) type. -It represents one of the following: -- The SRS. This is a deterministic lists of curve points (one per curve) that needs to be generated just once, - to be used for polynomial commitments. -- Lagrange basis commitments. Similar to the SRS, this will be created once for every power-of-2 circuit size. -- Prover and verifier keys for every compiled circuit. - -Per smart contract or ZkProgram, several different keys are created: -- a step prover key (`step-pk`) and verification key (`step-vk`) _for every method_. -- a wrap prover key (`wrap-pk`) and verification key (`wrap-vk`) for the entire contract. - -## Type declaration - -### canWrite - -```ts -canWrite: boolean; -``` - -Indicates whether the cache is writable. - -### debug? - -```ts -optional debug: boolean; -``` - -If `debug` is toggled, `read()` and `write()` errors are logged to the console. - -By default, cache errors are silent, because they don't necessarily represent an error condition, -but could just be a cache miss, or file system permissions incompatible with writing data. - -### read() - -Read a value from the cache. - -#### Parameters - -• **header**: [`CacheHeader`](CacheHeader.mdx) - -A small header to identify what is read from the cache. - -#### Returns - -`undefined` \| `Uint8Array` - -### write() - -Write a value to the cache. - -#### Parameters - -• **header**: [`CacheHeader`](CacheHeader.mdx) - -A small header to identify what is written to the cache. This will be used by `read()` to retrieve the data. - -• **value**: `Uint8Array` - -The value to write to the cache, as a byte array. - -#### Returns - -`void` - -## Source - -[lib/proof-system/cache.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L37) - ---- -url: /zkapps/o1js-reference/type-aliases/CacheHeader ---- - -```ts -type CacheHeader: - | StepKeyHeader<"step-pk"> - | StepKeyHeader<"step-vk"> - | WrapKeyHeader<"wrap-pk"> - | WrapKeyHeader<"wrap-vk"> - | PlainHeader<"srs"> - | PlainHeader & CommonHeader; -``` - -A header that is passed to the caching layer, to support rich caching strategies. - -Both `uniqueId` and `programId` can safely be used as a file path. - -## Source - -[lib/proof-system/cache.ts:106](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L106) - ---- -url: /zkapps/o1js-reference/type-aliases/ConstantField ---- - -```ts -type ConstantField: Field & { - "value": ConstantFieldVar; -}; -``` - -## Type declaration - -### value - -```ts -value: ConstantFieldVar; -``` - -## Source - -[lib/provable/field.ts:1246](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1246) - ---- -url: /zkapps/o1js-reference/type-aliases/DeployArgs ---- - -```ts -type DeployArgs: { - "verificationKey": { - "data": string; - "hash": string | Field; - }; - } | undefined; -``` - -## Source - -[lib/mina/zkapp.ts:1248](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/zkapp.ts#L1248) - ---- -url: /zkapps/o1js-reference/type-aliases/Empty ---- - -```ts -type Empty: Undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L85) - ---- -url: /zkapps/o1js-reference/type-aliases/FeatureFlags ---- - -```ts -type FeatureFlags: { - "foreignFieldAdd": boolean | undefined; - "foreignFieldMul": boolean | undefined; - "lookup": boolean | undefined; - "rangeCheck0": boolean | undefined; - "rangeCheck1": boolean | undefined; - "rot": boolean | undefined; - "runtimeTables": boolean | undefined; - "xor": boolean | undefined; -}; -``` - -## Type declaration - -### foreignFieldAdd - -```ts -foreignFieldAdd: boolean | undefined; -``` - -### foreignFieldMul - -```ts -foreignFieldMul: boolean | undefined; -``` - -### lookup - -```ts -lookup: boolean | undefined; -``` - -### rangeCheck0 - -```ts -rangeCheck0: boolean | undefined; -``` - -### rangeCheck1 - -```ts -rangeCheck1: boolean | undefined; -``` - -### rot - -```ts -rot: boolean | undefined; -``` - -### runtimeTables - -```ts -runtimeTables: boolean | undefined; -``` - -### xor - -```ts -xor: boolean | undefined; -``` - -## Source - -[lib/proof-system/feature-flags.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/feature-flags.ts#L17) - ---- -url: /zkapps/o1js-reference/type-aliases/Field ---- - -```ts -type Field: Field; -``` - -## Source - -[lib/provable/wrapped.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L42) - ---- -url: /zkapps/o1js-reference/type-aliases/FlexibleProvable ---- - -```ts -type FlexibleProvable: Provable | Struct; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:61](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L61) - ---- -url: /zkapps/o1js-reference/type-aliases/FlexibleProvablePure ---- - -```ts -type FlexibleProvablePure: ProvablePure | StructPure; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:62](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L62) - ---- -url: /zkapps/o1js-reference/type-aliases/Group ---- - -```ts -type Group: Group; -``` - -## Source - -[lib/provable/wrapped.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L76) - ---- -url: /zkapps/o1js-reference/type-aliases/InferProvable ---- - -```ts -type InferProvable: GenericInferProvable; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/provable-derivers.ts:65](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-derivers.ts#L65) - ---- -url: /zkapps/o1js-reference/type-aliases/JsonProof ---- - -```ts -type JsonProof: { - "maxProofsVerified": 0 | 1 | 2; - "proof": string; - "publicInput": string[]; - "publicOutput": string[]; -}; -``` - -## Type declaration - -### maxProofsVerified - -```ts -maxProofsVerified: 0 | 1 | 2; -``` - -### proof - -```ts -proof: string; -``` - -### publicInput - -```ts -publicInput: string[]; -``` - -### publicOutput - -```ts -publicOutput: string[]; -``` - -## Source - -[lib/proof-system/zkprogram.ts:146](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L146) - ---- -url: /zkapps/o1js-reference/type-aliases/MerkleListBase ---- - -```ts -type MerkleListBase: { - "data": Unconstrained[]>; - "hash": Field; -}; -``` - -Common base type for [MerkleList](../classes/MerkleList.mdx) and [MerkleListIterator](../classes/MerkleListIterator.mdx) - -## Type parameters - -• **T** - -## Type declaration - -### data - -```ts -data: Unconstrained[]>; -``` - -### hash - -```ts -hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:46](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L46) - ---- -url: /zkapps/o1js-reference/type-aliases/MerkleListIteratorBase ---- - -```ts -type MerkleListIteratorBase: { - "currentHash": Field; - "currentIndex": Unconstrained; - "data": Unconstrained[]>; - "hash": Field; -}; -``` - -## Type parameters - -• **T** - -## Type declaration - -### currentHash - -```ts -currentHash: Field; -``` - -The merkle list hash of `[data[currentIndex], ..., data[length-1]]` (when hashing from right to left). - -For example: -- If `currentIndex === 0`, then `currentHash === this.hash` is the hash of the entire array. -- If `currentIndex === length`, then `currentHash === emptyHash` is the hash of an empty array. - -### currentIndex - -```ts -currentIndex: Unconstrained; -``` - -The index of the element that will be returned by the next call to `next()`. - -### data - -```ts -readonly data: Unconstrained[]>; -``` - -### hash - -```ts -readonly hash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:383](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L383) - ---- -url: /zkapps/o1js-reference/type-aliases/Option ---- - -```ts -type Option: { - "isSome": Bool; - "value": T; - } & { - "assertSome": T; - "orElse": T; -}; -``` - -## Type declaration - -### isSome - -```ts -isSome: Bool; -``` - -### value - -```ts -value: T; -``` - -## Type declaration - -### assertSome() - -#### Parameters - -• **message?**: `string` - -#### Returns - -`T` - -### orElse() - -#### Parameters - -• **defaultValue**: `T` \| `V` - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **V** = `any` - -## Source - -[lib/provable/option.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/option.ts#L37) - ---- -url: /zkapps/o1js-reference/type-aliases/Provable ---- - -```ts -type Provable: { - "check": (value: T) => void; - "fromFields": (fields: Field[], aux: any[]) => T; - "fromValue": (x: TValue | T) => T; - "toAuxiliary": (value?: T) => any[]; - "toCanonical": (x: T) => T; - "toFields": (value: T) => Field[]; - "toValue": (x: T) => TValue; - "sizeInFields": number; -}; -``` - -`Provable` is the general interface for provable types in o1js. - -`Provable` describes how a type `T` is made up of [Field](../classes/Field.mdx) elements and "auxiliary" (non-provable) data. - -`Provable` is the required input type in several methods in o1js. -One convenient way to create a `Provable` is using `Struct`. - -All built-in provable types in o1js ([Field](../classes/Field.mdx), [Bool](../classes/Bool.mdx), etc.) are instances of `Provable` as well. - -Note: These methods are meant to be used by the library internally and are not directly when writing provable code. - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Type declaration - -### check() - -```ts -check: (value: T) => void; -``` - -Add assertions to the proof to check if `value` is a valid member of type `T`. -This function does not return anything, instead it creates any number of assertions to prove that `value` is a valid member of the type `T`. - -For instance, calling check function on the type [Bool](../classes/Bool.mdx) asserts that the value of the element is either 1 or 0. - -#### Parameters - -• **value**: `T` - -the element of type `T` to put assertions on. - -#### Returns - -`void` - -### fromFields() - -```ts -fromFields: (fields: Field[], aux: any[]) => T; -``` - -A function that returns an element of type `T` from the given provable and "auxiliary" data. - -This function is the reverse operation of calling toFields and toAuxilary methods on an element of type `T`. - -#### Parameters - -• **fields**: [`Field`](../classes/Field.mdx)[] - -an array of [Field](../classes/Field.mdx) elements describing the provable data of the new `T` element. - -• **aux**: `any`[] - -an array of any type describing the "auxiliary" data of the new `T` element, optional. - -#### Returns - -`T` - -### fromValue() - -```ts -fromValue: (x: TValue | T) => T; -``` - -Convert provable type from a normal JS type. - -#### Parameters - -• **x**: `TValue` \| `T` - -#### Returns - -`T` - -### toAuxiliary() - -```ts -toAuxiliary: (value?: T) => any[]; -``` - -A function that takes `value` (optional), an element of type `T`, as argument and -returns an array of any type that make up the "auxiliary" (non-provable) data of `value`. - -#### Parameters - -• **value?**: `T` - -the element of type `T` to generate the auxiliary data array from, optional. -If not provided, a default value for auxiliary data is returned. - -#### Returns - -`any`[] - -### toCanonical()? - -```ts -optional toCanonical: (x: T) => T; -``` - -Optional method which transforms a provable type into its canonical representation. - -This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations. - -An example is the `ForeignField` class, which allows non-native field elements to exist in unreduced form. -The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error. - -Specific protocols need to be able to protect themselves against incomplete operations at all costs. -For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. -`toCanonical()` converts any input into a safe form and enables us to handle cases like this generically. - -Note: For most types, this method is the identity function. -The identity function will also be used when the `toCanonical()` is not present on a type. - -#### Parameters - -• **x**: `T` - -#### Returns - -`T` - -### toFields() - -```ts -toFields: (value: T) => Field[]; -``` - -A function that takes `value`, an element of type `T`, as argument and returns -an array of [Field](../classes/Field.mdx) elements that make up the provable data of `value`. - -#### Parameters - -• **value**: `T` - -the element of type `T` to generate the [Field](../classes/Field.mdx) array from. - -#### Returns - -[`Field`](../classes/Field.mdx)[] - -### toValue() - -```ts -toValue: (x: T) => TValue; -``` - -Convert provable type to a normal JS type. - -#### Parameters - -• **x**: `T` - -#### Returns - -`TValue` - -### sizeInFields() - -Return the size of the `T` type in terms of [Field](../classes/Field.mdx) type, as [Field](../classes/Field.mdx) is the primitive type. - -#### Returns - -`number` - -A `number` representing the size of the `T` type in terms of [Field](../classes/Field.mdx) type. - -## Source - -[lib/provable/types/provable-intf.ts:27](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L27) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableExtended ---- - -```ts -type ProvableExtended: Provable & ProvableExtension; -``` - -## Type parameters - -• **T** - -• **TValue** = `any` - -• **TJson** = `any` - -## Source - -[lib/provable/types/struct.ts:49](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L49) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableHashable-1 ---- - -```ts -type ProvableHashable: ProvableWithEmpty & { - "toInput": (x: T) => HashInput; -}; -``` - -## Type declaration - -### toInput() - -```ts -toInput: (x: T) => HashInput; -``` - -#### Parameters - -• **x**: `T` - -#### Returns - -`HashInput` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:124](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L124) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableHashable ---- - -```ts -type ProvableHashable: Provable & Hashable; -``` - -## Type parameters - -• **T** - -• **V** = `any` - -## Source - -[lib/provable/crypto/poseidon.ts:32](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L32) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvablePure ---- - -```ts -type ProvablePure: Omit, "fromFields"> & { - "fromFields": (fields: Field[]) => T; -}; -``` - -`ProvablePure` is a special kind of [Provable](Provable.mdx) interface, where the "auxiliary" (non-provable) data is empty. -This means the type consists only of field elements, in that sense it is "pure". -Any instance of `ProvablePure` is also an instance of `Provable` where the "auxiliary" data is empty. - -Examples where `ProvablePure` is required are types of on-chain state, events and actions. - -## Type declaration - -### fromFields() - -```ts -fromFields: (fields: Field[]) => T; -``` - -#### Parameters - -• **fields**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:114](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L114) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableType ---- - -```ts -type ProvableType: WithProvable>; -``` - -## Type parameters - -• **T** = `any` - -• **V** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L132) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableTypePure ---- - -```ts -type ProvableTypePure: WithProvable>; -``` - -## Type parameters - -• **T** = `any` - -• **V** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:133](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L133) - ---- -url: /zkapps/o1js-reference/type-aliases/ProvableWithEmpty ---- - -```ts -type ProvableWithEmpty: Provable & { - "empty": () => T; -}; -``` - -## Type declaration - -### empty() - -```ts -empty: () => T; -``` - -#### Returns - -`T` - -## Type parameters - -• **T** - -• **TValue** = `any` - -## Source - -[lib/provable/types/provable-intf.ts:118](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L118) - ---- -url: /zkapps/o1js-reference/type-aliases/Reducer ---- - -```ts -type Reducer: { - "actionType": FlexibleProvablePure; -}; -``` - -## Type parameters - -• **Action** - -## Type declaration - -### actionType - -```ts -actionType: FlexibleProvablePure; -``` - -## Source - -[lib/mina/actions/reducer.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/actions/reducer.ts#L17) - ---- -url: /zkapps/o1js-reference/type-aliases/ScalarConst ---- - -```ts -type ScalarConst: [0, bigint]; -``` - -## Source - -[lib/provable/scalar.ts:20](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/scalar.ts#L20) - ---- -url: /zkapps/o1js-reference/type-aliases/State ---- - -```ts -type State: { - "fetch": Promise; - "fromAppState": A; - "get": A; - "getAndRequireEquals": A; - "requireEquals": void; - "requireEqualsIf": void; - "requireNothing": void; - "set": void; -}; -``` - -Gettable and settable state that can be checked for equality. - -## Type parameters - -• **A** - -## Type declaration - -### fetch() - -Asynchronously fetch the on-chain state. This is intended for getting the state outside a smart contract. - -#### Returns - -`Promise`\<`undefined` \| `A`\> - -### fromAppState() - -Get the state from the raw list of field elements on a zkApp account, for example: - -```ts -let myContract = new MyContract(address); -let account = Mina.getAccount(address); - -let x = myContract.x.fromAppState(account.zkapp!.appState); -``` - -#### Parameters - -• **appState**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -`A` - -### get() - -Get the current on-chain state. - -Caution: If you use this method alone inside a smart contract, it does not prove that your contract uses the current on-chain state. -To successfully prove that your contract uses the current on-chain state, you must add an additional `.requireEquals()` statement or use `.getAndRequireEquals()`: - -```ts -let x = this.x.get(); -this.x.requireEquals(x); -``` - -OR - -```ts -let x = this.x.getAndRequireEquals(); -``` - -#### Returns - -`A` - -### getAndRequireEquals() - -Get the current on-chain state and prove it really has to equal the on-chain state, -by adding a precondition which the verifying Mina node will check before accepting this transaction. - -#### Returns - -`A` - -### requireEquals() - -Prove that the on-chain state has to equal the given state, -by adding a precondition which the verifying Mina node will check before accepting this transaction. - -#### Parameters - -• **a**: `A` - -#### Returns - -`void` - -### requireEqualsIf() - -Require that the on-chain state has to equal the given state if the provided condition is true. - -If the condition is false, this is a no-op. -If the condition is true, this adds a precondition that the verifying Mina node will check before accepting this transaction. - -#### Parameters - -• **condition**: [`Bool`](../classes/Bool.mdx) - -• **a**: `A` - -#### Returns - -`void` - -### requireNothing() - -**DANGER ZONE**: Override the error message that warns you when you use `.get()` without adding a precondition. - -#### Returns - -`void` - -### set() - -Set the on-chain state to a new value. - -#### Parameters - -• **a**: `A` - -#### Returns - -`void` - -## Source - -[lib/mina/state.ts:91](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/state.ts#L91) - ---- -url: /zkapps/o1js-reference/type-aliases/Struct ---- - -```ts -type Struct: ProvableExtended> & Constructor & { - "_isStruct": true; -}; -``` - -## Type declaration - -### \_isStruct - -```ts -_isStruct: true; -``` - -## Type parameters - -• **T** - -## Source - -[lib/provable/types/struct.ts:140](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/struct.ts#L140) - ---- -url: /zkapps/o1js-reference/type-aliases/ToProvable ---- - -```ts -type ToProvable: A extends { - "provable": infer P; - } ? P : A; -``` - -## Type parameters - -• **A** *extends* [`WithProvable`](WithProvable.mdx)\<`any`\> - -## Source - -[lib/provable/types/provable-intf.ts:135](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L135) - ---- -url: /zkapps/o1js-reference/type-aliases/TransactionPromise ---- - -```ts -type TransactionPromise: Promise> & { - "send": PendingTransactionPromise; - } & Proven extends false ? { - "prove": TransactionPromise; - } : { - "proofs": Promise["proofs"]>; - } & Signed extends false ? { - "sign": TransactionPromise; -} : {}; -``` - -A `Promise` with some additional methods for making chained method calls -into the pending value upon its resolution. - -## Type declaration - -### send() - -Equivalent to calling the resolved `Transaction`'s `send` method. - -#### Returns - -[`PendingTransactionPromise`](../namespaces/Mina/type-aliases/PendingTransactionPromise.mdx) - -## Type parameters - -• **Proven** *extends* `boolean` - -• **Signed** *extends* `boolean` - -## Source - -[lib/mina/transaction.ts:314](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/transaction.ts#L314) - ---- -url: /zkapps/o1js-reference/type-aliases/TransactionStatus ---- - -```ts -type TransactionStatus: "INCLUDED" | "PENDING" | "UNKNOWN"; -``` - -INCLUDED: A transaction that is on the longest chain - -PENDING: A transaction either in the transition frontier or in transaction pool but is not on the longest chain - -UNKNOWN: The transaction has either been snarked, reached finality through consensus or has been dropped - -## Source - -[lib/mina/graphql.ts:216](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/graphql.ts#L216) - ---- -url: /zkapps/o1js-reference/type-aliases/TupleN ---- - -```ts -type TupleN: N extends N ? number extends N ? [...T[]] : [...TupleRec] : never; -``` - -tuple type that has the length as generic parameter - -## Type parameters - -• **T** - -• **N** *extends* `number` - -## Source - -[lib/util/types.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/util/types.ts#L28) - ---- -url: /zkapps/o1js-reference/type-aliases/Undefined ---- - -```ts -type Undefined: undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L82) - ---- -url: /zkapps/o1js-reference/type-aliases/VarField ---- - -```ts -type VarField: Field & { - "value": VarFieldVar; -}; -``` - -## Type declaration - -### value - -```ts -value: VarFieldVar; -``` - -## Source - -[lib/provable/field.ts:1242](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/field.ts#L1242) - ---- -url: /zkapps/o1js-reference/type-aliases/Void ---- - -```ts -type Void: undefined; -``` - -## Source - -[lib/proof-system/zkprogram.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L87) - ---- -url: /zkapps/o1js-reference/type-aliases/WithHash ---- - -```ts -type WithHash: { - "element": T; - "previousHash": Field; -}; -``` - -## Type parameters - -• **T** - -## Type declaration - -### element - -```ts -element: T; -``` - -### previousHash - -```ts -previousHash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L28) - ---- -url: /zkapps/o1js-reference/type-aliases/WithProvable ---- - -```ts -type WithProvable: { - "provable": A; - } | A; -``` - -## Type parameters - -• **A** - -## Source - -[lib/provable/types/provable-intf.ts:130](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L130) - ---- -url: /zkapps/o1js-reference/type-aliases/Witness ---- - -```ts -type Witness: { - "isLeft": boolean; - "sibling": Field; - }[]; -``` - -## Source - -[lib/provable/merkle-tree.ts:16](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-tree.ts#L16) - ---- -url: /zkapps/o1js-reference/type-aliases/ZkProgram ---- - -```ts -type ZkProgram: ReturnType; -``` - -## Type parameters - -• **Config** *extends* \{ - `"methods"`: `{ [I in string]: Object }`; - `"publicInput"`: [`ProvableTypePure`](ProvableTypePure.mdx); - `"publicOutput"`: [`ProvableTypePure`](ProvableTypePure.mdx); - \} - -• **Methods** *extends* `{ [I in keyof Config["methods"]]: Method>, InferProvableOrVoid>, Config["methods"][I]> }` - -## Source - -[lib/proof-system/zkprogram.ts:174](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L174) - ---- -url: /zkapps/o1js-reference/type-aliases/ZkappPublicInput ---- - -```ts -type ZkappPublicInput: { - "accountUpdate": Field; - "calls": Field; -}; -``` - -The public input for zkApps consists of certain hashes of the proving -account update (and its child updates) which is constructed during method execution. - -For SmartContract proving, a method is run twice: First outside the proof, to -obtain the public input, and once in the prover, which takes the public input -as input. The current transaction is hashed again inside the prover, which -asserts that the result equals the input public input, as part of the snark -circuit. The block producer will also hash the transaction they receive and -pass it as a public input to the verifier. Thus, the transaction is fully -constrained by the proof - the proof couldn't be used to attest to a different -transaction. - -## Type declaration - -### accountUpdate - -```ts -accountUpdate: Field; -``` - -### calls - -```ts -calls: Field; -``` - -## Source - -[lib/mina/account-update.ts:2050](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L2050) - ---- -url: /zkapps/o1js-reference/variables/Account ---- - -```ts -Account: GenericProvableExtended; -``` - -## Source - -[lib/mina/account.ts:19](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account.ts#L19) - ---- -url: /zkapps/o1js-reference/variables/Bool ---- - -```ts -const Bool: typeof Bool & (...args: [boolean | FieldVar | Bool]) => Bool; -``` - -A boolean value. You can create it like this: - -## Example - -``` -const b = Bool(true); -``` - -You can also combine multiple Bools with boolean operations: - -## Example - -```ts -const c = Bool(false); - -const d = b.or(c).and(false).not(); - -d.assertTrue(); -``` - -Bools are often created by methods on other types such as `Field.equals()`: - -```ts -const b: Bool = Field(5).equals(6); -``` - -## Source - -[lib/provable/wrapped.ts:70](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L70) - ---- -url: /zkapps/o1js-reference/variables/Cache ---- - -```ts -Cache: { - "FileSystem": (cacheDirectory: string, debug?: boolean) => Cache; - "FileSystemDefault": Cache; - "None": Cache; -}; -``` - -## Type declaration - -### FileSystem() - -```ts -FileSystem: (cacheDirectory: string, debug?: boolean) => Cache; -``` - -#### Parameters - -• **cacheDirectory**: `string` - -• **debug?**: `boolean` - -#### Returns - -[`Cache`](../type-aliases/Cache.mdx) - -### FileSystemDefault - -```ts -FileSystemDefault: Cache; -``` - -### None - -```ts -None: Cache; -``` - -## Source - -[lib/proof-system/cache.ts:37](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/cache.ts#L37) - ---- -url: /zkapps/o1js-reference/variables/Crypto ---- - -```ts -const Crypto: { - "CurveParams": CurveParams_; - "createCurve": {}; -}; -``` - -## Type declaration - -### CurveParams - -```ts -CurveParams: {} = CurveParams_; -``` - -Parameters defining an elliptic curve in short Weierstraß form -y^2 = x^3 + ax + b - -### createCurve() - -Create elliptic curve arithmetic methods. - -#### Parameters - -• **params**: `CurveParams` - -#### Returns - -```ts -{} -``` - -## Source - -[lib/provable/crypto/crypto.ts:8](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/crypto.ts#L8) - ---- -url: /zkapps/o1js-reference/variables/Empty ---- - -```ts -Empty: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:85](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L85) - ---- -url: /zkapps/o1js-reference/variables/FeatureFlags ---- - -```ts -FeatureFlags: { - "allMaybe": { - "foreignFieldAdd": undefined; - "foreignFieldMul": undefined; - "lookup": undefined; - "rangeCheck0": undefined; - "rangeCheck1": undefined; - "rot": undefined; - "runtimeTables": undefined; - "xor": undefined; - }; - "allNone": { - "foreignFieldAdd": false; - "foreignFieldMul": false; - "lookup": false; - "rangeCheck0": false; - "rangeCheck1": false; - "rot": false; - "runtimeTables": false; - "xor": false; - }; - "fromGates": featureFlagsFromGates; - "fromZkProgram": (program: AnalysableProgram) => Promise; - "fromZkProgramList": (programs: AnalysableProgram[]) => Promise; -}; -``` - -Feature flags indicate what custom gates are used in a proof of circuit. -Side loading, for example, requires a set of feature flags in advance (at compile time) in order to verify and side load proofs. -If the side loaded proofs and verification keys do not match the specified feature flag configurations, the verification will fail. -Flags specified as `undefined` are considered as `maybe` by Pickles. This means, proofs can be sided loaded that can, but don't have to, use a specific custom gate. -_Note:_ `Maybe` feature flags incur a proving overhead. - -## Type declaration - -### allMaybe - -```ts -allMaybe: { - "foreignFieldAdd": undefined; - "foreignFieldMul": undefined; - "lookup": undefined; - "rangeCheck0": undefined; - "rangeCheck1": undefined; - "rot": undefined; - "runtimeTables": undefined; - "xor": undefined; -}; -``` - -Returns a feature flag configuration where all flags are optional. - -### allMaybe.foreignFieldAdd - -```ts -foreignFieldAdd: undefined = undefined; -``` - -### allMaybe.foreignFieldMul - -```ts -foreignFieldMul: undefined = undefined; -``` - -### allMaybe.lookup - -```ts -lookup: undefined = undefined; -``` - -### allMaybe.rangeCheck0 - -```ts -rangeCheck0: undefined = undefined; -``` - -### allMaybe.rangeCheck1 - -```ts -rangeCheck1: undefined = undefined; -``` - -### allMaybe.rot - -```ts -rot: undefined = undefined; -``` - -### allMaybe.runtimeTables - -```ts -runtimeTables: undefined = undefined; -``` - -### allMaybe.xor - -```ts -xor: undefined = undefined; -``` - -### allNone - -```ts -allNone: { - "foreignFieldAdd": false; - "foreignFieldMul": false; - "lookup": false; - "rangeCheck0": false; - "rangeCheck1": false; - "rot": false; - "runtimeTables": false; - "xor": false; -}; -``` - -Returns a feature flag configuration where all flags are set to false. - -### allNone.foreignFieldAdd - -```ts -foreignFieldAdd: boolean = false; -``` - -### allNone.foreignFieldMul - -```ts -foreignFieldMul: boolean = false; -``` - -### allNone.lookup - -```ts -lookup: boolean = false; -``` - -### allNone.rangeCheck0 - -```ts -rangeCheck0: boolean = false; -``` - -### allNone.rangeCheck1 - -```ts -rangeCheck1: boolean = false; -``` - -### allNone.rot - -```ts -rot: boolean = false; -``` - -### allNone.runtimeTables - -```ts -runtimeTables: boolean = false; -``` - -### allNone.xor - -```ts -xor: boolean = false; -``` - -### fromGates() - -```ts -fromGates: (gates: Gate[]) => FeatureFlags = featureFlagsFromGates; -``` - -Given a list of gates, returns the feature flag configuration that the gates use. - -#### Parameters - -• **gates**: `Gate`[] - -#### Returns - -[`FeatureFlags`](../type-aliases/FeatureFlags.mdx) - -### fromZkProgram() - -```ts -fromZkProgram: (program: AnalysableProgram) => Promise; -``` - -Given a ZkProgram, return the feature flag configuration that fits the given program. -This function considers all methods of the specified ZkProgram and finds a configuration that fits all. - -#### Parameters - -• **program**: `AnalysableProgram` - -#### Returns - -`Promise`\<[`FeatureFlags`](../type-aliases/FeatureFlags.mdx)\> - -### fromZkProgramList() - -```ts -fromZkProgramList: (programs: AnalysableProgram[]) => Promise; -``` - -#### Parameters - -• **programs**: `AnalysableProgram`[] - -#### Returns - -`Promise`\<[`FeatureFlags`](../type-aliases/FeatureFlags.mdx)\> - -## Source - -[lib/proof-system/feature-flags.ts:17](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/feature-flags.ts#L17) - ---- -url: /zkapps/o1js-reference/variables/Field ---- - -```ts -const Field: typeof Field & (...args: [ - | string - | number - | bigint - | FieldConst - | FieldVar - | Field]) => Field; -``` - -A [Field](Field.mdx) is an element of a prime order [finite field](https://en.wikipedia.org/wiki/Finite_field). -Every other provable type is built using the [Field](Field.mdx) type. - -The field is the [pasta base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) of order 2^254 + 0x224698fc094cf91b992d30ed00000001 ([Field.ORDER](../classes/Field.mdx#order)). - -You can create a new Field from everything "field-like" (`bigint`, integer `number`, decimal `string`, `Field`). - -## Example - -``` -Field(10n); // Field construction from a bigint -Field(100); // Field construction from a number -Field("1"); // Field construction from a decimal string -``` - -**Beware**: Fields _cannot_ be constructed from fractional numbers or alphanumeric strings: -```ts -Field(3.141); // ERROR: Cannot convert a float to a field element -Field("abc"); // ERROR: Invalid argument "abc" -``` - -Creating a Field from a negative number can result in unexpected behavior if you are not familiar with [modular arithmetic](https://en.wikipedia.org/wiki/Modular_arithmetic). - -## Example - -``` -const x = Field(-1); // valid Field construction from negative number -const y = Field(Field.ORDER - 1n); // same as `x` -``` - -**Important**: All the functions defined on a Field (arithmetic, logic, etc.) take their arguments as "field-like". -A Field itself is also defined as a "field-like" element. - -## Param - -the value to convert to a [Field](Field.mdx) - -## Source - -[lib/provable/wrapped.ts:42](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L42) - ---- -url: /zkapps/o1js-reference/variables/Gadgets ---- - -```ts -const Gadgets: { - "BLAKE2B": BLAKE2B; - "Field3": { - "provable": { - "fromValue": Field3; - "toValue": bigint; - }; - "from": Field3; - "isConstant": boolean; - "toBigint": bigint; - "toBigints": [...{ [i in string | number | symbol]: bigint }[]]; - }; - "ForeignField": { - "Sum": Sum; - "add": Field3; - "assertAlmostReduced": void; - "assertLessThan": void; - "assertLessThanOrEqual": void; - "assertMul": void; - "div": Field3; - "inv": Field3; - "mul": Field3; - "neg": Field3; - "sub": Field3; - "sum": Field3; - "toCanonical": Field3; - }; - "SHA256": SHA256; - "addMod32": (x: Field, y: Field) => Field; - "addMod64": (x: Field, y: Field) => Field; - "arrayGet": (array: Field[], index: Field) => Field; - "divMod32": (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; - }; - "divMod64": (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; - }; - "and": Field; - "compactMultiRangeCheck": [Field, Field, Field]; - "isDefinitelyInRangeN": Bool; - "leftShift32": Field; - "leftShift64": Field; - "multiRangeCheck": void; - "not": Field; - "or": Field; - "rangeCheck16": void; - "rangeCheck32": void; - "rangeCheck3x12": void; - "rangeCheck64": [Field, Field, Field, Field]; - "rangeCheck8": void; - "rangeCheckN": void; - "rightShift64": Field; - "rotate32": Field; - "rotate64": Field; - "xor": Field; -}; -``` - -## Type declaration - -### BLAKE2B - -```ts -BLAKE2B: { - get "IV": UInt64[]; - "hash": Bytes; -}; -``` - -Implementation of the [BLAKE2b hash function.](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2) Hash function with arbitrary length output. - -Applies the BLAKE2b hash function to a list of byte-sized elements. - -The function accepts [Bytes](../type-aliases/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]`, `bigint[]` or `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../type-aliases/Bytes.mdx) that conforms to the chosen digest length. - -#### Param - -[Bytes](../type-aliases/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Gadgets.BLAKE2b.hash(preimage); -``` - -### BLAKE2B.IV - -```ts -get IV(): UInt64[] -``` - -#### Returns - -[`UInt64`](../classes/UInt64.mdx)[] - -#### Source - -[lib/provable/gadgets/blake2b.ts:77](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/blake2b.ts#L77) - -### BLAKE2B.hash() - -#### Parameters - -• **data**: `FlexibleBytes` - -• **digestLength**: `number`= `64` - -#### Returns - -`Bytes` - -### Field3 - -```ts -Field3: { - "provable": { - "fromValue": Field3; - "toValue": bigint; - }; - "from": Field3; - "isConstant": boolean; - "toBigint": bigint; - "toBigints": [...{ [i in string | number | symbol]: bigint }[]]; -}; -``` - -### Field3.provable - -```ts -provable: { - "fromValue": Field3; - "toValue": bigint; -}; -``` - -`Provable` interface for `Field3 = [Field, Field, Field]`. - -Note: Witnessing this creates a plain tuple of field elements without any implicit -range checks. - -### Field3.provable.fromValue() - -#### Parameters - -• **x**: `bigint` \| `Field3` - -#### Returns - -`Field3` - -### Field3.provable.toValue() - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`bigint` - -### Field3.from() - -Turn a bigint into a 3-tuple of Fields - -#### Parameters - -• **x**: `bigint` \| `Field3` - -#### Returns - -`Field3` - -### Field3.isConstant() - -Check whether a 3-tuple of Fields is constant - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`boolean` - -### Field3.toBigint() - -Turn a 3-tuple of Fields into a bigint - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`bigint` - -### Field3.toBigints() - -Turn several 3-tuples of Fields into bigints - -#### Type parameters - -• **T** *extends* `Tuple`\<`Field3`\> - -#### Parameters - -• ...**xs**: `T` - -#### Returns - -[...\{ [i in string \| number \| symbol]: bigint \}[]] - -### ForeignField - -```ts -ForeignField: { - "Sum": Sum; - "add": Field3; - "assertAlmostReduced": void; - "assertLessThan": void; - "assertLessThanOrEqual": void; - "assertMul": void; - "div": Field3; - "inv": Field3; - "mul": Field3; - "neg": Field3; - "sub": Field3; - "sum": Field3; - "toCanonical": Field3; -}; -``` - -Gadgets for foreign field operations. - -A _foreign field_ is a finite field different from the native field of the proof system. - -The `ForeignField` namespace exposes operations like modular addition and multiplication, -which work for any finite field of size less than 2^259. - -Foreign field elements are represented as 3 limbs of native field elements. -Each limb holds 88 bits of the total, in little-endian order. - -All `ForeignField` gadgets expect that their input limbs are constrained to the range [0, 2^88). -Range checks on outputs are added by the gadget itself. - -### ForeignField.Sum() - -Lazy sum of Field3 elements, which can be used as input to Gadgets.ForeignField.assertMul. - -#### Parameters - -• **x**: `Field3` - -#### Returns - -`Sum` - -### ForeignField.add() - -Foreign field addition: `x + y mod f` - -The modulus `f` does not need to be prime. - -Inputs and outputs are 3-tuples of native Fields. -Each input limb is assumed to be in the range [0, 2^88), and the gadget is invalid if this is not the case. -The result limbs are guaranteed to be in the same range. - -#### Parameters - -• **x**: `Field3` - -left summand - -• **y**: `Field3` - -right summand - -• **f**: `bigint` - -modulus - -#### Returns - -`Field3` - -x + y mod f - -#### Example - -```ts -let x = Provable.witness(Field3, () => 9n); -let y = Provable.witness(Field3, () => 10n); - -// range check x and y -Gadgets.multiRangeCheck(x); -Gadgets.multiRangeCheck(y); - -// compute x + y mod 17 -let z = ForeignField.add(x, y, 17n); - -Provable.log(z); // ['2', '0', '0'] = limb representation of 2 = 9 + 10 mod 17 -``` - -**Warning**: The gadget does not assume that inputs are reduced modulo f, -and does not prove that the result is reduced modulo f. -It only guarantees that the result is in the correct residue class. - -### ForeignField.assertAlmostReduced() - -Prove that each of the given Field3 elements is "almost" reduced modulo f, -i.e., satisfies the assumptions required by Gadgets.ForeignField.mul and other gadgets: -- each limb is in the range [0, 2^88) -- the most significant limb is less or equal than the modulus, x[2] ≤ f[2] - -**Note**: This method is most efficient when the number of input elements is a multiple of 3. - -#### Parameters - -• **xs**: `Field3`[] - -• **f**: `bigint` - -• **\_\_namedParameters**= `{}` - -• **\_\_namedParameters.skipMrc**: `undefined` \| `boolean`= `false` - -#### Returns - -`void` - -#### Throws - -if any of the assumptions is violated. - -#### Example - -```ts -let x = Provable.witness(Field3, () => 4n); -let y = Provable.witness(Field3, () => 5n); -let z = Provable.witness(Field3, () => 10n); - -ForeignField.assertAlmostReduced([x, y, z], f); - -// now we can use x, y, z as inputs to foreign field multiplication -let xy = ForeignField.mul(x, y, f); -let xyz = ForeignField.mul(xy, z, f); - -// since xy is an input to another multiplication, we need to prove that it is almost reduced again! -ForeignField.assertAlmostReduced([xy], f); // TODO: would be more efficient to batch this with 2 other elements -``` - -### ForeignField.assertLessThan() - -Prove that x < f for any constant f < 2^264, or for another `Field3` f. - -If f is a finite field modulus, this means that the given field element is fully reduced modulo f. -This is a stronger statement than [ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) -and also uses more constraints; it should not be needed in most use cases. - -**Note**: This assumes that the limbs of x are in the range [0, 2^88), in contrast to -[ForeignField.assertAlmostReduced](../classes/ForeignField.mdx#assertalmostreduced-1) which adds that check itself. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` \| `Field3` - -#### Returns - -`void` - -#### Throws - -if x is greater or equal to f. - -#### Example - -```ts -let x = Provable.witness(Field3, () => 0x1235n); - - // range check limbs of x -Gadgets.multiRangeCheck(x); - -// prove that x is fully reduced mod f -Gadgets.ForeignField.assertLessThan(x, f); -``` - -### ForeignField.assertLessThanOrEqual() - -Prove that x ≤ f for any constant f < 2^264, or for another `Field3` f. - -See [ForeignField.assertLessThan](../classes/ForeignField.mdx#assertlessthan) for details and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` \| `Field3` - -#### Returns - -`void` - -### ForeignField.assertMul() - -Optimized multiplication of sums in a foreign field, for example: `(x - y)*z = a + b + c mod f` - -Note: This is much more efficient than using Gadgets.ForeignField.add and Gadgets.ForeignField.sub separately to -compute the multiplication inputs and outputs, and then using Gadgets.ForeignField.mul to constrain the result. - -The sums passed into this method are "lazy sums" created with Gadgets.ForeignField.Sum. -You can also pass in plain Field3 elements. - -**Assumptions**: The assumptions on the _summands_ are analogous to the assumptions described in Gadgets.ForeignField.mul: -- each summand's limbs are in the range [0, 2^88) -- summands that are part of a multiplication input satisfy `x[2] <= f[2]` - -#### Parameters - -• **x**: `Field3` \| `Sum` - -• **y**: `Field3` \| `Sum` - -• **z**: `Field3` \| `Sum` - -• **f**: `bigint` - -#### Returns - -`void` - -#### Throws - -if the modulus is so large that the second assumption no longer suffices for validity of the multiplication. -For small sums and moduli < 2^256, this will not fail. - -#### Throws - -if the provided multiplication result is not correct modulo f. - -#### Example - -```ts -// range-check x, y, z, a, b, c -ForeignField.assertAlmostReduced([x, y, z], f); -Gadgets.multiRangeCheck(a); -Gadgets.multiRangeCheck(b); -Gadgets.multiRangeCheck(c); - -// create lazy input sums -let xMinusY = ForeignField.Sum(x).sub(y); -let aPlusBPlusC = ForeignField.Sum(a).add(b).add(c); - -// assert that (x - y)*z = a + b + c mod f -ForeignField.assertMul(xMinusY, z, aPlusBPlusC, f); -``` - -### ForeignField.div() - -Foreign field division: `x * y^(-1) mod f` - -See Gadgets.ForeignField.mul for assumptions on inputs and usage examples. - -This gadget adds an extra bound check on the result, so it can be used directly in another foreign field multiplication. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -Different than Gadgets.ForeignField.mul, this fails on unreduced input `x`, because it checks that `x === (x/y)*y` and the right side will be reduced. - -### ForeignField.inv() - -Foreign field inverse: `x^(-1) mod f` - -See Gadgets.ForeignField.mul for assumptions on inputs and usage examples. - -This gadget adds an extra bound check on the result, so it can be used directly in another foreign field multiplication. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -### ForeignField.mul() - -Foreign field multiplication: `x * y mod f` - -The modulus `f` does not need to be prime, but has to be smaller than 2^259. - -**Assumptions**: In addition to the assumption that input limbs are in the range [0, 2^88), as in all foreign field gadgets, -this assumes an additional bound on the inputs: `x * y < 2^264 * p`, where p is the native modulus. -We usually assert this bound by proving that `x[2] < f[2] + 1`, where `x[2]` is the most significant limb of x. -To do this, we use an 88-bit range check on `2^88 - x[2] - (f[2] + 1)`, and same for y. -The implication is that x and y are _almost_ reduced modulo f. - -All of the above assumptions are checked by Gadgets.ForeignField.assertAlmostReduced. - -**Warning**: This gadget does not add the extra bound check on the result. -So, to use the result in another foreign field multiplication, you have to add the bound check on it yourself, again. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Example - -```ts -// example modulus: secp256k1 prime -let f = (1n << 256n) - (1n << 32n) - 0b1111010001n; - -let x = Provable.witness(Field3, () => f - 1n); -let y = Provable.witness(Field3, () => f - 2n); - -// range check x, y and prove additional bounds x[2] <= f[2] -ForeignField.assertAlmostReduced([x, y], f); - -// compute x * y mod f -let z = ForeignField.mul(x, y, f); - -Provable.log(z); // ['2', '0', '0'] = limb representation of 2 = (-1)*(-2) mod f -``` - -### ForeignField.neg() - -Foreign field negation: `-x mod f = f - x` - -See [ForeignField.add](../classes/ForeignField.mdx#add) for assumptions and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -fails if `x > f`, where `f - x < 0`. - -### ForeignField.sub() - -Foreign field subtraction: `x - y mod f` - -See Gadgets.ForeignField.add for assumptions and usage examples. - -#### Parameters - -• **x**: `Field3` - -• **y**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Throws - -fails if `x - y < -f`, where the result cannot be brought back to a positive number by adding `f` once. - -### ForeignField.sum() - -Foreign field sum: `xs[0] + signs[0] * xs[1] + ... + signs[n-1] * xs[n] mod f` - -This gadget takes a list of inputs and a list of signs (of size one less than the inputs), -and computes a chain of additions or subtractions, depending on the sign. -A sign is of type `1n | -1n`, where `1n` represents addition and `-1n` represents subtraction. - -**Note**: For 3 or more inputs, `sum()` uses fewer constraints than a sequence of `add()` and `sub()` calls, -because we can avoid range checks on intermediate results. - -See Gadgets.ForeignField.add for assumptions on inputs. - -#### Parameters - -• **xs**: `Field3`[] - -• **signs**: (`1n` \| `-1n`)[] - -• **f**: `bigint` - -#### Returns - -`Field3` - -#### Example - -```ts -let x = Provable.witness(Field3, () => 4n); -let y = Provable.witness(Field3, () => 5n); -let z = Provable.witness(Field3, () => 10n); - -// range check x, y, z -Gadgets.multiRangeCheck(x); -Gadgets.multiRangeCheck(y); -Gadgets.multiRangeCheck(z); - -// compute x + y - z mod 17 -let sum = ForeignField.sum([x, y, z], [1n, -1n], 17n); - -Provable.log(sum); // ['16', '0', '0'] = limb representation of 16 = 4 + 5 - 10 mod 17 -``` - -### ForeignField.toCanonical() - -Convert x, which may be unreduced, to a canonical representative xR < f -such that x = xR mod f - -Note: This method is complete, it works for all unreduced field elements. -It can therefore be used to protect against incompleteness of field operations in other places. - -#### Parameters - -• **x**: `Field3` - -• **f**: `bigint` - -#### Returns - -`Field3` - -### SHA256 - -```ts -SHA256: { - "compression": sha256Compression; - "createMessageSchedule": (M: UInt32[]) => UInt32[]; - "padding": (data: FlexibleBytes) => UInt32[][]; - get "initialState": UInt32[]; - "hash": Bytes; -}; -``` - -Implementation of the [SHA256 hash function.](https://en.wikipedia.org/wiki/SHA-2) Hash function with 256bit output. - -Applies the SHA2-256 hash function to a list of byte-sized elements. - -The function accepts [Bytes](../type-aliases/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]`, `bigint[]` or `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../type-aliases/Bytes.mdx) that conforms to the chosen bit length. - -#### Param - -[Bytes](../type-aliases/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Gadgets.SHA256.hash(preimage); -``` - -### SHA256.compression() - -```ts -compression: (H: UInt32[], W: UInt32[]) => UInt32[] = sha256Compression; -``` - -Performs the SHA-256 compression function on the given hash values and message schedule. - -#### Parameters - -• **H**: [`UInt32`](../classes/UInt32.mdx)[] - -The initial or intermediate hash values (8-element array of UInt32). - -• **W**: [`UInt32`](../classes/UInt32.mdx)[] - -The message schedule (64-element array of UInt32). - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -The updated intermediate hash values after compression. - -### SHA256.createMessageSchedule() - -```ts -createMessageSchedule: (M: UInt32[]) => UInt32[]; -``` - -Prepares the message schedule for the SHA-256 compression function from the given message block. - -#### Parameters - -• **M**: [`UInt32`](../classes/UInt32.mdx)[] - -The 512-bit message block (16-element array of UInt32). - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -The message schedule (64-element array of UInt32). - -### SHA256.padding() - -```ts -padding: (data: FlexibleBytes) => UInt32[][]; -``` - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[][] - -### SHA256.initialState - -```ts -get initialState(): UInt32[] -``` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx)[] - -#### Source - -[lib/provable/gadgets/sha256.ts:100](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/sha256.ts#L100) - -### SHA256.hash() - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -`Bytes` - -### addMod32() - -```ts -addMod32: (x: Field, y: Field) => Field; -``` - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### addMod64() - -```ts -addMod64: (x: Field, y: Field) => Field; -``` - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -• **y**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### arrayGet() - -```ts -arrayGet: (array: Field[], index: Field) => Field; -``` - -Get value from array in O(n) rows. - -Assumes that index is in [0, n), returns an unconstrained result otherwise. - -Note: This saves 0.5*n constraints compared to equals() + switch() even if equals() were implemented optimally. - -#### Parameters - -• **array**: [`Field`](../classes/Field.mdx)[] - -• **index**: [`Field`](../classes/Field.mdx) - -#### Returns - -[`Field`](../classes/Field.mdx) - -### divMod32() - -```ts -divMod32: (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; -}; -``` - -#### Parameters - -• **n**: [`Field`](../classes/Field.mdx) - -• **nBits**: `number`= `64` - -#### Returns - -```ts -{ - "quotient": Field; - "remainder": Field; -} -``` - -##### quotient - -```ts -quotient: Field; -``` - -##### remainder - -```ts -remainder: Field; -``` - -### divMod64() - -```ts -divMod64: (n: Field, nBits: number) => { - "quotient": Field; - "remainder": Field; -}; -``` - -#### Parameters - -• **n**: [`Field`](../classes/Field.mdx) - -• **nBits**: `number`= `128` - -#### Returns - -```ts -{ - "quotient": Field; - "remainder": Field; -} -``` - -##### quotient - -```ts -quotient: Field; -``` - -##### remainder - -```ts -remainder: Field; -``` - -### and() - -Bitwise AND gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND). -The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise. - -It can be checked by a double generic gate that verifies the following relationship between the values -below (in the process it also invokes the Gadgets.xor gadget which will create additional constraints depending on `length`). - -The generic gate verifies:\ -`a + b = sum` and the conjunction equation `2 * and = sum - xor`\ -Where:\ -`a + b = sum`\ -`a ^ b = xor`\ -`a & b = and` - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and) - -The `length` parameter lets you define how many bits should be compared. `length` is rounded -to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values -are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -**Note:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. -For example, with `length = 2` (`paddedLength = 16`), `and()` will fail for any input that is larger than `2**16`. - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -• **b**: [`Field`](../classes/Field.mdx) - -• **length**: `number` - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```typescript -let a = Field(3); // ... 000011 -let b = Field(5); // ... 000101 - -let c = Gadgets.and(a, b, 2); // ... 000001 -c.assertEquals(1); -``` - -### compactMultiRangeCheck() - -Compact multi-range check - -This is a variant of multiRangeCheck where the first two variables are passed in -combined form xy = x + 2^88*y. - -The gadget -- splits up xy into x and y -- proves that xy = x + 2^88*y -- proves that x, y, z are all in the range [0, 2^88). - -The split form [x, y, z] is returned. - -#### Parameters - -• **xy**: [`Field`](../classes/Field.mdx) - -• **z**: [`Field`](../classes/Field.mdx) - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -#### Example - -```ts -let [x, y] = Gadgets.compactMultiRangeCheck([xy, z]); -``` - -#### Throws - -Throws an error if `xy` exceeds 2*88 = 176 bits, or if z exceeds 88 bits. - -### isDefinitelyInRangeN() - -Returns a boolean which being true proves that x is in the range [0, 2^n). - -**Beware**: The output being false does **not** prove that x is not in the range [0, 2^n). -This should not be viewed as a standalone provable method but as an advanced helper function -for gadgets which need a weakened form of range check. - -#### Parameters - -• **n**: `number` - -The number of bits to be considered for the range check. - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be weakly range-checked. - -#### Returns - -[`Bool`](../classes/Bool.mdx) - -a Bool that is definitely only true if the input is in the range [0, 2^n), -but could also be false _even if_ the input is in the range [0, 2^n). - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -let definitelyInRange = Gadgets.isDefinitelyInRangeN(32, x); // could be true or false -``` - -### leftShift32() - -Performs a left shift operation on the provided [Field](Field.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 32 bits in size. - -The output is range checked to 32 bits. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the left. The amount should be between 0 and 32 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.leftShift32(x, 2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary -``` - -### leftShift64() - -Performs a left shift operation on the provided [Field](Field.mdx) element. -This operation is similar to the `<<` shift operation in JavaScript, -where bits are shifted to the left, and the overflowing bits are discarded. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the shift. -Therefore, to safely use `leftShift()`, you need to make sure that the values passed in are range checked to 64 bits. -For example, this can be done with Gadgets.rangeCheck64. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the left. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.leftShift64(x, 2); // left shift by 2 bits -y.assertEquals(0b110000); // 48 in binary - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -leftShift64(xLarge, 32); // throws an error since input exceeds 64 bits -``` - -### multiRangeCheck() - -Multi-range check. - -Proves that x, y, z are all in the range [0, 2^88). - -This takes 4 rows, so it checks 88*3/4 = 66 bits per row. This is slightly more efficient -than 64-bit range checks, which can do 64 bits in 1 row. - -In particular, the 3x88-bit range check supports bigints up to 264 bits, which in turn is enough -to support foreign field multiplication with moduli up to 2^259. - -#### Parameters - -• **limbs**: `Field3` - -#### Returns - -`void` - -#### Example - -```ts -Gadgets.multiRangeCheck([x, y, z]); -``` - -#### Throws - -Throws an error if one of the input values exceeds 88 bits. - -### not() - -Bitwise NOT gate on [Field](Field.mdx) elements. Similar to the [bitwise -NOT `~` operator in JavaScript](https://developer.mozilla.org/en-US/docs/ -Web/JavaScript/Reference/Operators/Bitwise_NOT). - -**Note:** The NOT gate only operates over the amount -of bits specified by the `length` parameter. - -A NOT gate works by returning `1` in each bit position if the -corresponding bit of the operand is `0`, and returning `0` if the -corresponding bit of the operand is `1`. - -The `length` parameter lets you define how many bits to NOT. - -**Note:** Specifying a larger `length` parameter adds additional constraints. The operation will fail if the length or the input value is larger than 254. - -NOT is implemented in two different ways. If the `checked` parameter is set to `true` -the Gadgets.xor gadget is reused with a second argument to be an -all one bitmask the same length. This approach needs as many rows as an XOR would need -for a single negation. If the `checked` parameter is set to `false`, NOT is -implemented as a subtraction of the input from the all one bitmask. This -implementation is returned by default if no `checked` parameter is provided. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#not) - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -The value to apply NOT to. The operation will fail if the value is larger than 254. - -• **length**: `number` - -The number of bits to be considered for the NOT operation. - -• **checked**: `boolean`= `false` - -Optional boolean to determine if the checked or unchecked not implementation is used. If it -is set to `true` the Gadgets.xor gadget is reused. If it is set to `false`, NOT is implemented - as a subtraction of the input from the all one bitmask. It is set to `false` by default if no parameter is provided. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```ts -// not-ing 4 bits with the unchecked version -let a = Field(0b0101); -let b = Gadgets.not(a,4,false); - -b.assertEquals(0b1010); - -// not-ing 4 bits with the checked version utilizing the xor gadget -let a = Field(0b0101); -let b = Gadgets.not(a,4,true); - -b.assertEquals(0b1010); -``` - -#### Throws - -Throws an error if the input value exceeds 254 bits. - -### or() - -Bitwise OR gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR). -The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise. - -The `length` parameter lets you define how many bits should be compared. `length` is rounded -to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values -are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -**Note:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. -For example, with `length = 2` (`paddedLength = 16`), `and()` will fail for any input that is larger than `2**16`. - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -• **b**: [`Field`](../classes/Field.mdx) - -• **length**: `number` - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Example - -```typescript -let a = Field.from(3); // ... 000011 -let b = Field.from(5); // ... 000101 - -let c = Gadgets.or(a, b, 16); // ... 000111 -c.assertEquals(7); -``` - -### rangeCheck16() - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -#### Returns - -`void` - -### rangeCheck32() - -Asserts that the input value is in the range [0, 2^32). - -This function proves that the provided field element can be represented with 32 bits. -If the field element exceeds 32 bits, an error is thrown. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -#### Returns - -`void` - -#### Throws - -Throws an error if the input value exceeds 32 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheck32(x); // successfully proves 32-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheck32(xLarge); // throws an error since input exceeds 32 bits -``` - -**Note**: Small "negative" field element inputs are interpreted as large integers close to the field size, -and don't pass the 32-bit check. If you want to prove that a value lies in the int32 range [-2^31, 2^31), -you could use `rangeCheck32(x.add(1n << 31n))`. - -### rangeCheck3x12() - -Checks that three [Field](Field.mdx) elements are in the range [0, 2^12) (using only one row). - -Internally, this gadget relies on the 12-bit [range check table](https://github.com/o1-labs/proof-systems/blob/master/kimchi/src/circuits/lookup/tables/mod.rs). -All three inputs are checked to be included in that table. - -It's possible to use this as a range check for bit lengths n < 12, by passing in _two values_. -- the value to be checked, `x`, to prove that x in [0, 2^12) -- x scaled by 2^(12 - n), to prove that either x in [0, 2^n) or `x * 2^(12 - n)` overflows the field size (which is excluded by the first check) - -Note that both of these checks are necessary to prove x in [0, 2^n). - -You can find more details about lookups in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=lookup%20gate#lookup) - -#### Parameters - -• **v0**: [`Field`](../classes/Field.mdx) - -The first [Field](Field.mdx) element to be checked. - -• **v1**: [`Field`](../classes/Field.mdx) - -The second [Field](Field.mdx) element to be checked. - -• **v2**: [`Field`](../classes/Field.mdx) - -The third [Field](Field.mdx) element to be checked. - -#### Returns - -`void` - -#### Throws - -Throws an error if one of the input values exceeds 2^12. - -#### Example - -```typescript -let a = Field(4000); -rangeCheck3x12(a, Field(0), Field(0)); // works, since `a` is less than 12 bits - -let aScaled = a.mul(1 << 4); // scale `a`, to assert that it's less than 8 bits -rangeCheck3x12(a, aScaled, Field(0)); // throws an error, since `a` is greater than 8 bits (and so `aScaled` is greater than 12 bits) -``` - -### rangeCheck64() - -Asserts that the input value is in the range [0, 2^64). - -This function proves that the provided field element can be represented with 64 bits. -If the field element exceeds 64 bits, an error is thrown. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheck64(x); // successfully proves 64-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheck64(xLarge); // throws an error since input exceeds 64 bits -``` - -**Note**: Small "negative" field element inputs are interpreted as large integers close to the field size, -and don't pass the 64-bit check. If you want to prove that a value lies in the int64 range [-2^63, 2^63), -you could use `rangeCheck64(x.add(1n << 63n))`. - -_Advanced usage_: This returns the 4 highest limbs of x, in reverse order, i.e. [x52, x40, x28, x16]. -This is useful if you want to do a range check for 52, 40, 28, or 16 bits instead of 64, -by constraining some of the returned limbs to be 0. - -### rangeCheck8() - -Asserts that the input value is in the range [0, 2^8). - -See Gadgets.rangeCheck64 for analogous details and usage examples. - -#### Parameters - -• **x**: [`Field`](../classes/Field.mdx) - -#### Returns - -`void` - -### rangeCheckN() - -Asserts that the input value is in the range [0, 2^n). `n` must be a multiple of 16. - -This function proves that the provided field element can be represented with `n` bits. -If the field element exceeds `n` bits, an error is thrown. - -#### Parameters - -• **n**: `number` - -The number of bits to be considered for the range check. - -• **x**: [`Field`](../classes/Field.mdx) - -The value to be range-checked. - -• **message?**: `string` - -Optional message to be displayed when the range check fails. - -#### Returns - -`void` - -#### Throws - -Throws an error if the input value exceeds `n` bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(12345678n)); -Gadgets.rangeCheckN(32, x); // successfully proves 32-bit range - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rangeCheckN(32, xLarge); // throws an error since input exceeds 32 bits -``` - -### rightShift64() - -Performs a right shift operation on the provided [Field](Field.mdx) element. -This is similar to the `>>` shift operation in JavaScript, where bits are moved to the right. -The `rightShift64` function utilizes the rotation method internally to implement this operation. - -* It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. - -**Important:** The gadgets assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the shift. -To safely use `rightShift64()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to shift. - -• **bits**: `number` - -Amount of bits to shift the [Field](Field.mdx) element to the right. The amount should be between 0 and 64 (or else the shift will fail). - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); // 12 in binary -const y = Gadgets.rightShift64(x, 2); // right shift by 2 bits -y.assertEquals(0b000011); // 3 in binary - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -rightShift64(xLarge, 32); // throws an error since input exceeds 64 bits -``` - -### rotate32() - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 32-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 32-bit representation of the number, -where the most significant (32th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -**Important:** The gadget assumes that its input is at most 32 bits in size. - -If the input exceeds 32 bits, the gadget is invalid and fails to prove correct execution of the rotation. -To safely use `rotate32()`, you need to make sure that the value passed in is range-checked to 32 bits; -for example, using Gadgets.rangeCheck32. - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to rotate. - -• **bits**: `number` - -amount of bits to rotate this [Field](Field.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 32 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); -const y = Gadgets.rotate32(x, 2, 'left'); // left rotation by 2 bits -const z = Gadgets.rotate32(x, 2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rotate32(xLarge, 32, "left"); // throws an error since input exceeds 32 bits -``` - -### rotate64() - -A (left and right) rotation operates similarly to the shift operation (`<<` for left and `>>` for right) in JavaScript, -with the distinction that the bits are circulated to the opposite end of a 64-bit representation rather than being discarded. -For a left rotation, this means that bits shifted off the left end reappear at the right end. -Conversely, for a right rotation, bits shifted off the right end reappear at the left end. - -It’s important to note that these operations are performed considering the big-endian 64-bit representation of the number, -where the most significant (64th) bit is on the left end and the least significant bit is on the right end. -The `direction` parameter is a string that accepts either `'left'` or `'right'`, determining the direction of the rotation. - -**Important:** The gadget assumes that its input is at most 64 bits in size. - -If the input exceeds 64 bits, the gadget is invalid and fails to prove correct execution of the rotation. -To safely use `rotate64()`, you need to make sure that the value passed in is range-checked to 64 bits; -for example, using Gadgets.rangeCheck64. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#rotation) - -#### Parameters - -• **field**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to rotate. - -• **bits**: `number` - -amount of bits to rotate this [Field](Field.mdx) element with. - -• **direction**: `"left"` \| `"right"`= `'left'` - -left or right rotation direction. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input value exceeds 64 bits. - -#### Example - -```ts -const x = Provable.witness(Field, () => Field(0b001100)); -const y = Gadgets.rotate64(x, 2, 'left'); // left rotation by 2 bits -const z = Gadgets.rotate64(x, 2, 'right'); // right rotation by 2 bits -y.assertEquals(0b110000); -z.assertEquals(0b000011); - -const xLarge = Provable.witness(Field, () => Field(12345678901234567890123456789012345678n)); -Gadgets.rotate64(xLarge, 32, "left"); // throws an error since input exceeds 64 bits -``` - -### xor() - -Bitwise XOR gadget on [Field](Field.mdx) elements. Equivalent to the [bitwise XOR `^` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR). -A XOR gate works by comparing two bits and returning `1` if two bits differ, and `0` if two bits are equal. - -This gadget builds a chain of XOR gates recursively. Each XOR gate can verify 16 bit at most. If your input elements exceed 16 bit, another XOR gate will be added to the chain. - -The `length` parameter lets you define how many bits should be compared. `length` is rounded to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well. - -**Note:** Specifying a larger `length` parameter adds additional constraints. - -It is also important to mention that specifying a smaller `length` allows the verifier to infer the length of the original input data (e.g. smaller than 16 bit if only one XOR gate has been used). -A zkApp developer should consider these implications when choosing the `length` parameter and carefully weigh the trade-off between increased amount of constraints and security. - -**Important:** Both [Field](Field.mdx) elements need to fit into `2^paddedLength - 1`. Otherwise, an error is thrown and no proof can be generated. - -For example, with `length = 2` (`paddedLength = 16`), `xor()` will fail for any input that is larger than `2**16`. - -You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#xor-1) - -#### Parameters - -• **a**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to compare. - -• **b**: [`Field`](../classes/Field.mdx) - -[Field](Field.mdx) element to compare. - -• **length**: `number` - -amount of bits to compare. - -#### Returns - -[`Field`](../classes/Field.mdx) - -#### Throws - -Throws an error if the input values exceed `2^paddedLength - 1`. - -#### Example - -```ts -let a = Field(0b0101); -let b = Field(0b0011); - -let c = Gadgets.xor(a, b, 4); // xor-ing 4 bits -c.assertEquals(0b0110); -``` - -## Source - -[lib/provable/gadgets/gadgets.ts:39](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/gadgets/gadgets.ts#L39) - ---- -url: /zkapps/o1js-reference/variables/Group ---- - -```ts -const Group: typeof Group & (...args: [{ - "x": | string - | number - | bigint - | FieldVar - | Field; - "y": | string - | number - | bigint - | FieldVar - | Field; - }]) => Group; -``` - -An element of a Group. - -## Source - -[lib/provable/wrapped.ts:76](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/wrapped.ts#L76) - ---- -url: /zkapps/o1js-reference/variables/Hash ---- - -```ts -const Hash: { - "BLAKE2B": { - "hash": Bytes; - }; - "Keccak256": { - "hash": Bytes; - }; - "Keccak384": { - "hash": Bytes; - }; - "Keccak512": { - "hash": Bytes; - }; - "Poseidon": { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; - }; - "SHA2_256": { - "hash": Gadgets.SHA256.hash; - }; - "SHA3_256": { - "hash": Bytes; - }; - "SHA3_384": { - "hash": Bytes; - }; - "SHA3_512": { - "hash": Bytes; - }; - "hash": Poseidon.hash; -}; -``` - -A collection of hash functions which can be used in provable code. - -## Type declaration - -### BLAKE2B - -```ts -BLAKE2B: { - "hash": Bytes; -}; -``` - -### BLAKE2B.hash() - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak256 - -```ts -Keccak256: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 256 bits. - -### Keccak256.hash() - -Hashes the given bytes using Keccak-256. - -This is an alias for `Keccak.preNist(256, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak384 - -```ts -Keccak384: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 384 bits. - -### Keccak384.hash() - -Hashes the given bytes using Keccak-384. - -This is an alias for `Keccak.preNist(384, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Keccak512 - -```ts -Keccak512: { - "hash": Bytes; -}; -``` - -The pre-NIST Keccak hash function with an output length of 512 bits. - -### Keccak512.hash() - -Hashes the given bytes using Keccak-512. - -This is an alias for `Keccak.preNist(512, bytes)`.\ -See Keccak.preNist for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### Poseidon - -```ts -Poseidon: { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; -}; -``` - -### Poseidon.Sponge - -```ts -Sponge: typeof Sponge; -``` - -### Poseidon.Unsafe - -```ts -Unsafe: { - "hashToGroup": Group; -}; -``` - -### Poseidon.Unsafe.hashToGroup() - -Low-level version of `Poseidon.hashToGroup()`. - -**Warning**: This function is marked unsafe because its output is not deterministic. -It returns the square root of a value without constraining which of the two possible -square roots is chosen. This allows the prover to choose between two different hashes, -which can be a vulnerability if consuming code treats the output as unique. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### Poseidon.hash() - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.hashPacked() - -Hashes a provable type efficiently. - -```ts -let skHash = Poseidon.hashPacked(PrivateKey, secretKey); -``` - -Note: Instead of just doing `Poseidon.hash(value.toFields())`, this -uses the `toInput()` method on the provable type to pack the input into as few -field elements as possible. This saves constraints because packing has a much -lower per-field element cost than hashing. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<`Hashable`\<`T`\>\> - -• **value**: `T` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.hashToGroup() - -Hashes a list of field elements to a point on the Pallas curve. - -The output point is deterministic and its discrete log is not efficiently computable. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### Poseidon.hashWithPrefix() - -#### Parameters - -• **prefix**: `string` - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### Poseidon.initialState() - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### Poseidon.update() - -#### Parameters - -• **state**: [[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### SHA2\_256 - -```ts -SHA2_256: { - "hash": Gadgets.SHA256.hash; -}; -``` - -The SHA2 hash function with an output length of 256 bits. - -### SHA2\_256.hash() - -```ts -hash: (data: FlexibleBytes) => Bytes = Gadgets.SHA256.hash; -``` - -Hashes the given bytes using SHA2-256. - -This is an alias for `Gadgets.SHA256.hash(bytes)`.\ -See Gadgets.SHA256.hash for details and usage examples. - -#### Parameters - -• **data**: `FlexibleBytes` - -#### Returns - -`Bytes` - -### SHA3\_256 - -```ts -SHA3_256: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 256 bits. - -### SHA3\_256.hash() - -Hashes the given bytes using SHA3-256. - -This is an alias for `Keccak.nistSha3(256, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### SHA3\_384 - -```ts -SHA3_384: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 384 bits. - -### SHA3\_384.hash() - -Hashes the given bytes using SHA3-384. - -This is an alias for `Keccak.nistSha3(384, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### SHA3\_512 - -```ts -SHA3_512: { - "hash": Bytes; -}; -``` - -The SHA3 hash function with an output length of 512 bits. - -### SHA3\_512.hash() - -Hashes the given bytes using SHA3-512. - -This is an alias for `Keccak.nistSha3(512, bytes)`.\ -See Keccak.nistSha3 for details and usage examples. - -#### Parameters - -• **bytes**: `Bytes` - -#### Returns - -`Bytes` - -### hash() - -```ts -hash: (input: Field[]) => Field = Poseidon.hash; -``` - -Hashes the given field elements using [Poseidon](https://eprint.iacr.org/2019/458.pdf). Alias for `Poseidon.hash()`. - -```ts -let hash = Hash.hash([a, b, c]); -``` - -**Important:** This is by far the most efficient hash function o1js has available in provable code. -Use it by default, if no compatibility concerns require you to use a different hash function. - -The Poseidon implementation operates over the native [Pallas base field](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) -and uses parameters generated specifically for the [Mina](https://minaprotocol.com) blockchain. - -We use a `rate` of 2, which means that 2 field elements are hashed per permutation. -A permutation causes 11 rows in the constraint system. - -You can find the full set of Poseidon parameters [here](https://github.com/o1-labs/o1js-bindings/blob/main/crypto/constants.ts). - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -## Source - -[lib/provable/crypto/hash.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/hash.ts#L11) - ---- -url: /zkapps/o1js-reference/variables/Keccak ---- - -```ts -const Keccak: { - "ethereum": Bytes; - "nistSha3": Bytes; - "preNist": Bytes; -}; -``` - -## Type declaration - -### ethereum() - -Ethereum-Compatible Keccak-256 Hash Function. -This is a specialized variant of Keccak.preNist configured for a 256-bit output length. - -Primarily used in Ethereum for hashing transactions, messages, and other types of payloads. - -The function accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) of length 32. Both input and output bytes are big-endian. - -#### Parameters - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest = Keccak.ethereum(preimage); -``` - -#### Returns - -`Bytes` - -### nistSha3() - -Implementation of [NIST SHA-3](https://csrc.nist.gov/pubs/fips/202/final) Hash Function. -Supports output lengths of 256, 384, or 512 bits. - -Applies the SHA-3 hash function to a list of big-endian byte-sized [Field](../classes/Field.mdx) elements, flexible to handle varying output lengths (256, 384, 512 bits) as specified. - -The function accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) that conforms to the chosen bit length. -Both input and output bytes are big-endian. - -#### Parameters - -• **len**: `256` \| `384` \| `512` - -Desired output length in bits. Valid options: 256, 384, 512. - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest256 = Keccak.nistSha3(256, preimage); -let digest384 = Keccak.nistSha3(384, preimage); -let digest512 = Keccak.nistSha3(512, preimage); -``` - -#### Returns - -`Bytes` - -### preNist() - -Implementation of [pre-NIST Keccak](https://keccak.team/keccak.html) hash function. -Supports output lengths of 256, 384, or 512 bits. - -Keccak won the SHA-3 competition and was slightly altered before being standardized as SHA-3 by NIST in 2015. -This variant was used in Ethereum before the NIST standardization, by specifying `len` as 256 bits you can obtain the same hash function as used by Ethereum Keccak.ethereum. - -The function applies the pre-NIST Keccak hash function to a list of byte-sized [Field](../classes/Field.mdx) elements and is flexible to handle varying output lengths (256, 384, 512 bits) as specified. - -Keccak.preNist accepts [Bytes](../functions/Bytes.mdx) as the input message, which is a type that represents a static-length list of byte-sized field elements (range-checked using Gadgets.rangeCheck8). -Alternatively, you can pass plain `number[]` of `Uint8Array` to perform a hash outside provable code. - -Produces an output of [Bytes](../functions/Bytes.mdx) that conforms to the chosen bit length. -Both input and output bytes are big-endian. - -#### Parameters - -• **len**: `256` \| `384` \| `512` - -Desired output length in bits. Valid options: 256, 384, 512. - -• **message**: `FlexibleBytes` - -Big-endian [Bytes](../functions/Bytes.mdx) representing the message to hash. - -```ts -let preimage = Bytes.fromString("hello world"); -let digest256 = Keccak.preNist(256, preimage); -let digest384 = Keccak.preNist(384, preimage); -let digest512= Keccak.preNist(512, preimage); -``` - -#### Returns - -`Bytes` - -## Source - -[lib/provable/crypto/keccak.ts:11](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/keccak.ts#L11) - ---- -url: /zkapps/o1js-reference/variables/Permissions ---- - -```ts -Permissions: { - "VerificationKey": { - "impossibleDuringCurrentVersion": () => VerificationKeyPermission; - "none": () => VerificationKeyPermission; - "proofDuringCurrentVersion": () => VerificationKeyPermission; - "proofOrSignature": () => VerificationKeyPermission; - "signature": () => VerificationKeyPermission; - }; - "allImpossible": () => Permissions; - "default": () => Permissions; - "dummy": () => Permissions; - "fromJSON": (permissions: {}) => Permissions; - "fromString": (permission: AuthRequired) => AuthRequired; - "impossible": () => AuthRequired; - "initial": () => Permissions; - "none": () => AuthRequired; - "proof": () => AuthRequired; - "proofOrSignature": () => AuthRequired; - "signature": () => AuthRequired; -}; -``` - -## Type declaration - -### VerificationKey - -```ts -VerificationKey: { - "impossibleDuringCurrentVersion": () => VerificationKeyPermission; - "none": () => VerificationKeyPermission; - "proofDuringCurrentVersion": () => VerificationKeyPermission; - "proofOrSignature": () => VerificationKeyPermission; - "signature": () => VerificationKeyPermission; -}; -``` - -Special Verification key permissions. - -The difference to normal permissions is that `Permission.proof` and `Permission.impossible` are replaced by less restrictive permissions: -- `impossible` is replaced by `impossibleDuringCurrentVersion` -- `proof` is replaced by `proofDuringCurrentVersion` - -The issue is that a future hardfork which changes the proof system could mean that old verification keys can no longer -be used to verify proofs in the new proof system, and the zkApp would have to be redeployed to adapt the verification key. - -Having either `impossible` or `proof` would mean that these zkApps can't be upgraded after this hypothetical hardfork, and would become unusable. - -Such a future hardfork would manifest as an increment in the "transaction version" of zkApps, which you can check with (). - -The `impossibleDuringCurrentVersion` and `proofDuringCurrentVersion` have an additional `txnVersion` field. -These permissions follow the same semantics of not upgradable, or only upgradable with proofs, -_as long as_ the current transaction version is the same as the one on the permission. - -Once the current transaction version is higher than the one on the permission, the permission is treated as `signature`, -and the zkApp can be redeployed with a signature of the original account owner. - -### VerificationKey.impossibleDuringCurrentVersion() - -```ts -impossibleDuringCurrentVersion: () => VerificationKeyPermission; -``` - -Modification is impossible, as long as the network accepts the current [TransactionVersion](TransactionVersion.mdx). - -After a hardfork that increments the transaction version, the permission is treated as `signature`. - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.none() - -```ts -none: () => VerificationKeyPermission; -``` - -Modification is always permitted - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.proofDuringCurrentVersion() - -```ts -proofDuringCurrentVersion: () => VerificationKeyPermission; -``` - -Modification is permitted by zkapp proofs only; as long as the network accepts the current [TransactionVersion](TransactionVersion.mdx). - -After a hardfork that increments the transaction version, the permission is treated as `signature`. - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.proofOrSignature() - -```ts -proofOrSignature: () => VerificationKeyPermission; -``` - -Modification is permitted by zkapp proofs or signatures - -#### Returns - -`VerificationKeyPermission` - -### VerificationKey.signature() - -```ts -signature: () => VerificationKeyPermission; -``` - -Modification is permitted by signatures only, using the private key of the zkapp account - -#### Returns - -`VerificationKeyPermission` - -### allImpossible() - -```ts -allImpossible: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### default() - -```ts -default: () => Permissions; -``` - -Default permissions are: - - [Permissions.editState](../interfaces/Permissions.mdx#editstate) = Permission.proof - - [Permissions.send](../interfaces/Permissions.mdx#send) = Permission.signature - - [Permissions.receive](../interfaces/Permissions.mdx#receive) = Permission.none - - [Permissions.setDelegate](../interfaces/Permissions.mdx#setdelegate) = Permission.signature - - [Permissions.setPermissions](../interfaces/Permissions.mdx#setpermissions) = Permission.signature - - [Permissions.setVerificationKey](../interfaces/Permissions.mdx#setverificationkey) = Permission.signature - - [Permissions.setZkappUri](../interfaces/Permissions.mdx#setzkappuri) = Permission.signature - - [Permissions.editActionState](../interfaces/Permissions.mdx#editactionstate) = Permission.proof - - [Permissions.setTokenSymbol](../interfaces/Permissions.mdx#settokensymbol) = Permission.signature - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### dummy() - -```ts -dummy: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### fromJSON() - -```ts -fromJSON: (permissions: {}) => Permissions; -``` - -#### Parameters - -• **permissions** - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### fromString() - -```ts -fromString: (permission: AuthRequired) => AuthRequired; -``` - -#### Parameters - -• **permission**: `AuthRequired` - -#### Returns - -`AuthRequired` - -### impossible() - -```ts -impossible: () => AuthRequired; -``` - -Modification is impossible. - -#### Returns - -`AuthRequired` - -### initial() - -```ts -initial: () => Permissions; -``` - -#### Returns - -[`Permissions`](../interfaces/Permissions.mdx) - -### none() - -```ts -none: () => AuthRequired; -``` - -Modification is always permitted - -#### Returns - -`AuthRequired` - -### proof() - -```ts -proof: () => AuthRequired; -``` - -Modification is permitted by zkapp proofs only - -#### Returns - -`AuthRequired` - -### proofOrSignature() - -```ts -proofOrSignature: () => AuthRequired; -``` - -Modification is permitted by zkapp proofs or signatures - -#### Returns - -`AuthRequired` - -### signature() - -```ts -signature: () => AuthRequired; -``` - -Modification is permitted by signatures only, using the private key of the zkapp account - -#### Returns - -`AuthRequired` - -## Source - -[lib/mina/account-update.ts:327](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L327) - ---- -url: /zkapps/o1js-reference/variables/Poseidon ---- - -```ts -const Poseidon: { - "Sponge": typeof Sponge; - "Unsafe": { - "hashToGroup": Group; - }; - "hash": Field; - "hashPacked": Field; - "hashToGroup": Group; - "hashWithPrefix": Field; - "initialState": [Field, Field, Field]; - "update": [Field, Field, Field]; -}; -``` - -## Type declaration - -### Sponge - -```ts -Sponge: typeof Sponge; -``` - -### Unsafe - -```ts -Unsafe: { - "hashToGroup": Group; -}; -``` - -### Unsafe.hashToGroup() - -Low-level version of `Poseidon.hashToGroup()`. - -**Warning**: This function is marked unsafe because its output is not deterministic. -It returns the square root of a value without constraining which of the two possible -square roots is chosen. This allows the prover to choose between two different hashes, -which can be a vulnerability if consuming code treats the output as unique. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### hash() - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### hashPacked() - -Hashes a provable type efficiently. - -```ts -let skHash = Poseidon.hashPacked(PrivateKey, secretKey); -``` - -Note: Instead of just doing `Poseidon.hash(value.toFields())`, this -uses the `toInput()` method on the provable type to pack the input into as few -field elements as possible. This saves constraints because packing has a much -lower per-field element cost than hashing. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`WithProvable`](../type-aliases/WithProvable.mdx)\<`Hashable`\<`T`\>\> - -• **value**: `T` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### hashToGroup() - -Hashes a list of field elements to a point on the Pallas curve. - -The output point is deterministic and its discrete log is not efficiently computable. - -#### Parameters - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Group`](../classes/Group.mdx) - -### hashWithPrefix() - -#### Parameters - -• **prefix**: `string` - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[`Field`](../classes/Field.mdx) - -### initialState() - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -### update() - -#### Parameters - -• **state**: [[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -• **input**: [`Field`](../classes/Field.mdx)[] - -#### Returns - -[[`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx), [`Field`](../classes/Field.mdx)] - -## Source - -[lib/provable/crypto/poseidon.ts:56](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/crypto/poseidon.ts#L56) - ---- -url: /zkapps/o1js-reference/variables/ProvableType ---- - -```ts -ProvableType: { - "get": ToProvable; - "synthesize": T; -}; -``` - -## Type declaration - -### get() - -#### Type parameters - -• **A** *extends* `unknown` - -#### Parameters - -• **type**: `A` - -#### Returns - -[`ToProvable`](../type-aliases/ToProvable.mdx)\<`A`\> - -### synthesize() - -Create some value of type `T` from its provable type description. - -#### Type parameters - -• **T** - -#### Parameters - -• **type**: [`ProvableType`](../type-aliases/ProvableType.mdx)\<`T`, `any`\> - -#### Returns - -`T` - -## Source - -[lib/provable/types/provable-intf.ts:132](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/types/provable-intf.ts#L132) - ---- -url: /zkapps/o1js-reference/variables/TokenId ---- - -```ts -const TokenId: { - "default": Field; - "derive": Field; - "fromBase58": Field; - "toBase58": string; -}; -``` - -## Type declaration - -### default - -```ts -default: Field; -``` - -### derive() - -#### Parameters - -• **tokenOwner**: [`PublicKey`](../classes/PublicKey.mdx) - -• **parentTokenId**: [`Field`](../classes/Field.mdx)= `undefined` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### fromBase58() - -#### Parameters - -• **base58**: `string` - -#### Returns - -[`Field`](../classes/Field.mdx) - -### toBase58() - -#### Parameters - -• **t**: [`Field`](../classes/Field.mdx) - -#### Returns - -`string` - -## Source - -[lib/mina/account-update.ts:666](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L666) - ---- -url: /zkapps/o1js-reference/variables/TransactionVersion ---- - -```ts -const TransactionVersion: { - "current": () => UInt32; -}; -``` - -## Type declaration - -### current() - -```ts -current: () => UInt32; -``` - -#### Returns - -[`UInt32`](../classes/UInt32.mdx) - -## Source - -[lib/mina/account-update.ts:119](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L119) - ---- -url: /zkapps/o1js-reference/variables/TupleN ---- - -```ts -TupleN: { - "fromArray": TupleN; - "hasLength": tuple is TupleN; - "map": [...{ [i in string | number | symbol]: B }[]]; -}; -``` - -## Type declaration - -### fromArray() - -#### Type parameters - -• **T** - -• **N** *extends* `number` - -#### Parameters - -• **n**: `N` - -• **arr**: `T`[] - -#### Returns - -[`TupleN`](../type-aliases/TupleN.mdx)\<`T`, `N`\> - -### hasLength() - -#### Type parameters - -• **T** - -• **N** *extends* `number` - -#### Parameters - -• **n**: `N` - -• **tuple**: `T`[] - -#### Returns - -`tuple is TupleN` - -### map() - -#### Type parameters - -• **T** *extends* `Tuple`\<`any`\> - -• **B** - -#### Parameters - -• **tuple**: `T` - -• **f** - -#### Returns - -[...\{ [i in string \| number \| symbol]: B \}[]] - -## Source - -[lib/util/types.ts:28](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/util/types.ts#L28) - ---- -url: /zkapps/o1js-reference/variables/Undefined ---- - -```ts -Undefined: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:82](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L82) - ---- -url: /zkapps/o1js-reference/variables/Void ---- - -```ts -Void: ProvablePureExtended; -``` - -## Source - -[lib/proof-system/zkprogram.ts:87](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/proof-system/zkprogram.ts#L87) - ---- -url: /zkapps/o1js-reference/variables/ZkappPublicInput ---- - -```ts -ZkappPublicInput: ProvablePureExtended<{ - "accountUpdate": Field; - "calls": Field; - }, { - "accountUpdate": Field; - "calls": Field; - }, { - "accountUpdate": Field; - "calls": Field; -}>; -``` - -## Type declaration - -### accountUpdate - -```ts -accountUpdate: Field = Field; -``` - -### calls - -```ts -calls: Field = Field; -``` - -## Source - -[lib/mina/account-update.ts:2050](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/mina/account-update.ts#L2050) - ---- -url: /zkapps/o1js-reference/variables/emptyHash ---- - -```ts -const emptyHash: Field; -``` - -## Source - -[lib/provable/merkle-list.ts:24](https://github.com/o1-labs/o1js/blob/6ebbc23710f6de023fea6d83dc93c5a914c571f2/src/lib/provable/merkle-list.ts#L24) - --- url: /zkapps/o1js/basic-concepts --- @@ -62273,7 +16227,7 @@ let sig = Signature.create(privKey, msg); // sign a message sig.verify(pubKey, msg); // Bool(true) ``` -For a full list, see the [o1js reference](../o1js-reference). +For a full list, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). --- url: /zkapps/o1js/bitwise-operations @@ -63195,7 +17149,7 @@ Foreign fields are useful for implementing cryptographic algorithms in provable ## Why foreign fields? -The core data type in o1js is `Field` that represents the field that is _native to the proof system_. In other words, addition and multiplication of Fields are the fundamental operations upon which all provable code is built. Because a lot of cryptography uses finite fields, o1js natively supports several cryptographic algorithms with high efficiency. See classes and modules like [Poseidon](../o1js-reference/variables/Poseidon), [PublicKey](../o1js-reference/classes/PublicKey), [PrivateKey](../o1js-reference/classes/PrivateKey), [Signature](../o1js-reference/classes/Signature), and [Encryption](../o1js-reference/namespaces/Encryption). +The core data type in o1js is `Field` that represents the field that is _native to the proof system_. In other words, addition and multiplication of Fields are the fundamental operations upon which all provable code is built. Because a lot of cryptography uses finite fields, o1js natively supports several cryptographic algorithms with high efficiency. See classes and modules like [Poseidon](https://docs.o1labs.org/o1js/api-reference/variables/Poseidon), [PublicKey](https://docs.o1labs.org/o1js/api-reference/classes/PublicKey), [PrivateKey](https://docs.o1labs.org/o1js/api-reference/classes/PrivateKey), [Signature](https://docs.o1labs.org/o1js/api-reference/classes/Signature), and [Encryption](https://docs.o1labs.org/o1js/api-reference/namespaces/Encryption). However, these classes and modules are not compatible with the cryptography used in the wider world: `Signature.verify()` doesn't let you verify a signed JWT or email, and `Encryption.decrypt()` won't help you with your WhatsApp messages. That's because these methods use different finite fields than the native Field that was chosen primarily to enable efficient zk proofs. @@ -63203,7 +17157,7 @@ Here is where foreign fields come in: They let you perform algorithms that conne ## Basic usage -This section provides a brief overview of how to use foreign fields. For more details, refer to the [API reference](../o1js-reference/classes/ForeignField) or the doc comments on each method. +This section provides a brief overview of how to use foreign fields. For more details, refer to the [API reference](https://docs.o1labs.org/o1js/api-reference/classes/ForeignField) or the doc comments on each method. The entry point for using foreign fields is the `createForeignField()` function: @@ -63275,7 +17229,7 @@ let y = SmallField.from(5n); // convert from bigint or number y.toBigInt() === 5n; // convert to bigint ``` -As usual, you can find more information about each method in the [API reference](../o1js-reference/classes/ForeignField). +As usual, you can find more information about each method in the [API reference](https://docs.o1labs.org/o1js/api-reference/classes/ForeignField). ## Three kinds of foreign fields @@ -63502,7 +17456,7 @@ In o1js, you can import these provable and helper methods from the `Gadgets` nam - [Bitwise Operations](/zkapps/o1js/bitwise-operations) - [Foreign Field Arithmetic](/zkapps/o1js/ecdsa) -See the type declaration for [Gadgets](/zkapps/o1js-reference/variables/Gadgets) in the o1js Reference documentation. +See the type declaration for [Gadgets](https://docs.o1labs.org/o1js/api-reference/variables/Gadgets) in the o1js Reference documentation. --- url: /zkapps/o1js @@ -63611,7 +17565,7 @@ In this example, `IndexedMerkleMap31` is a Merkle map capable of holding up to 2 ### Indexed Merkle Map - API reference -For an example, see the `IndexedMerkleMap` [API reference](/zkapps/o1js-reference/namespaces/Experimental/functions/IndexedMerkleMap) in o1js. +For an example, see the `IndexedMerkleMap` [API reference](https://docs.o1labs.org/o1js/api-reference/namespaces/Experimental/functions/IndexedMerkleMap) in o1js. ## Additional Resources @@ -64472,7 +18426,7 @@ Since this code extends `SmartContract` that has its own initialization to perfo Then, `this.num.set(Field(3))` initializes the on-chain state `num` to a value of `3`. -You can optionally specify permissions. See [setPermissions](/zkapps/o1js-reference/classes/SmartContract) in the o1js Reference documentation. +You can optionally specify permissions. See [setPermissions](https://docs.o1labs.org/o1js/api-reference/classes/SmartContract) in the o1js Reference documentation. Finally, this code adds the `update()` function: @@ -64508,7 +18462,7 @@ Notice that `get()` and `set()` methods are used for retrieving and setting on-c - Similarly, using `set()` changes the transaction to indicate that changes to this particular on-chain state are updated only when the transaction is received by the Mina network if it contains a valid authorization (usually, a valid authorization is a proof). -The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available [methods](/zkapps/o1js-reference/classes/Field#methods) in the o1js Reference documentation. +The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available [methods](https://docs.o1labs.org/o1js/api-reference/classes/Field#methods) in the o1js Reference documentation. You remember that functions in your smart contract must operate on o1js compatible data types: `Field` types and other types built on top of `Field` types. Because a smart contract is really a zero knowledge circuit, functions from random npm packages work inside a smart contract only if the functions the contract provides operate on o1js-compatible data types. @@ -66043,11 +19997,11 @@ Ensure your environment meets the [Prerequisites](/zkapps/tutorials#prerequisite Five basic types are derived from Fields: -- [Bool](../o1js-reference/classes/Bool) -- [UInt32](../o1js-reference/classes/UInt32) -- [UInt64](../o1js-reference/classes/UInt64) -- [Int64](../o1js-reference/classes/Int64) -- [Character](../o1js-reference/classes/Character) +- [Bool](https://docs.o1labs.org/o1js/api-reference/classes/Bool) +- [UInt32](https://docs.o1labs.org/o1js/api-reference/classes/UInt32) +- [UInt64](https://docs.o1labs.org/o1js/api-reference/classes/UInt64) +- [Int64](https://docs.o1labs.org/o1js/api-reference/classes/Int64) +- [Character](https://docs.o1labs.org/o1js/api-reference/classes/Character) Each type has the usual programming language semantics. @@ -66099,10 +20053,10 @@ Fields in char1: 1 Four advanced types are: -- [CircuitString](../o1js-reference/classes/CircuitString) -- [PrivateKey](../o1js-reference/classes/PrivateKey) -- [PublicKey](../o1js-reference/classes/PublicKey) -- [Signature](../o1js-reference/classes/Signature) +- [CircuitString](https://docs.o1labs.org/o1js/api-reference/classes/CircuitString) +- [PrivateKey](https://docs.o1labs.org/o1js/api-reference/classes/PrivateKey) +- [PublicKey](https://docs.o1labs.org/o1js/api-reference/classes/PublicKey) +- [Signature](https://docs.o1labs.org/o1js/api-reference/classes/Signature) All arguments passed into smart contracts must be arguments o1js can consume. You cannot pass normal strings. Instead, you must pass in strings that are wrapped to be compatible with circuits. This is accomplished with `Struct`. @@ -66161,7 +20115,7 @@ There are 255 Fields in a private key and 256 Fields in a signature. If you are ## Struct -You can create your own compound data types with the special [Struct](../o1js-reference/functions/Struct) type. +You can create your own compound data types with the special [Struct](https://docs.o1labs.org/o1js/api-reference/functions/Struct) type. Define a Struct as one or more data types that o1js understands. For example, Field, higher-order types built into o1js based on Field, or other Struct types defined by you. You can also define methods on your Struct to act upon this data type. @@ -66286,7 +20240,7 @@ If a program is too large to fit into these constraints, it can be broken up int ## Merkle Trees -You can use [Merkle trees](../o1js-reference/classes/MerkleTree) to manage large amounts of data within a circuit. The power of Merkle trees is demonstrated in the [05-common-types-and-functions/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/05-common-types-and-functions/src) reference project for this tutorial. See the [BasicMerkleTreeContract.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/BasicMerkleTreeContract.ts) contract and [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/main.ts) that demonstrates how contracts interact with Merkle trees and how to construct them. +You can use [Merkle trees](https://docs.o1labs.org/o1js/api-reference/classes/MerkleTree) to manage large amounts of data within a circuit. The power of Merkle trees is demonstrated in the [05-common-types-and-functions/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/05-common-types-and-functions/src) reference project for this tutorial. See the [BasicMerkleTreeContract.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/BasicMerkleTreeContract.ts) contract and [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/05-common-types-and-functions/src/main.ts) that demonstrates how contracts interact with Merkle trees and how to construct them. The first step is to import `MerkleTree`: @@ -66307,7 +20261,7 @@ const tree = new MerkleTree(height); The height variable determines how many leaves are available to the application. For example, a height of 20 leads to a tree with `2^(20-1)`, or 524,288 leaves. -Merkle trees in smart contracts are stored as the hash of the Merkle tree's root. Smart contract methods that update the Merkle root can take a _witness_ of the change as an argument. The [MerkleMapWitness](/zkapps/o1js-reference/classes/MerkleMapWitness) represents the Merkle path to the data for which inclusion is being proved. +Merkle trees in smart contracts are stored as the hash of the Merkle tree's root. Smart contract methods that update the Merkle root can take a _witness_ of the change as an argument. The [MerkleMapWitness](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMapWitness) represents the Merkle path to the data for which inclusion is being proved. A contract stores the root of a Merkle tree, where each leaf stores a number, and the smart contract has an `update` function that adds a number to the leaf. @@ -66413,7 +20367,7 @@ A more advanced example `LedgerContract` implements a basic ledger of tokens, in ## Merkle Map -See the API reference documentation for the [MerkleMap](../o1js-reference/classes/MerkleMap) class you can use to implement key-value stores. +See the API reference documentation for the [MerkleMap](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMap) class you can use to implement key-value stores. The API for Merkle Maps is similar to Merkle Trees, just instead of using an index to set a leaf, one uses a key: @@ -66493,7 +20447,7 @@ const txn1 = await Mina.transaction(deployerAccount, async () => { ... ``` -You use [MerkleMaps](/zkapps/o1js-reference/classes/MerkleMap) to implement many useful patterns. For example: +You use [MerkleMaps](https://docs.o1labs.org/o1js/api-reference/classes/MerkleMap) to implement many useful patterns. For example: - A key value store from public keys to booleans, of token accounts to whether they've participated in a voted yet. - A nullifier that privately tracks if an input was used, without revealing it. @@ -67732,7 +21686,7 @@ Recursive ZKPs also make it easy to allow multiple parties to construct transact ## ZkProgram Example -You build recursive zkApps with [ZkProgram](/zkapps/o1js-reference/functions/ZkProgram), the o1js general purpose API for creating zero knowledge proofs. A ZkProgram is similar to zkApp smart contracts but isn't tied to an on-chain account. +You build recursive zkApps with [ZkProgram](https://docs.o1labs.org/o1js/api-reference/functions/ZkProgram), the o1js general purpose API for creating zero knowledge proofs. A ZkProgram is similar to zkApp smart contracts but isn't tied to an on-chain account. Proofs generated using a ZkProgram can be passed into zkApp smart contracts for them to verify recursively. They can even be passed recursively into their own functions for off-chain recursive composition. @@ -68102,7 +22056,7 @@ url: /zkapps/tutorials/10-account-updates The fundamental data structure that Mina transactions are built from is called an _account update_. Account updates are a flexible and powerful data structure that can express all kinds of updates, events, and preconditions you use to develop smart contracts. -Each zkApp transaction constructed by o1js is composed of one or more [AccountUpdate](../o1js-reference/classes/AccountUpdate) classes, which are a set of instructions for the Mina network to perform, such as altering on-chain state, emitting an event, and so on. +Each zkApp transaction constructed by o1js is composed of one or more [AccountUpdate](https://docs.o1labs.org/o1js/api-reference/classes/AccountUpdate) classes, which are a set of instructions for the Mina network to perform, such as altering on-chain state, emitting an event, and so on. Each `AccountUpdate` can make assertions about its account, apply updates to its account, and make assertions about its child `AccountUpdates`. @@ -68123,7 +22077,7 @@ In this tutorial, you learn the essential account update features. The `AccountUpdate` class is a set of instructions for the Mina network. It includes preconditions (conditions that must be true for the account update to be applied) and a list of state updates that need to be authorized by a signature or proof. -Each [AccountUpdate](/zkapps/o1js-reference/classes/AccountUpdate) class has these components: +Each [AccountUpdate](https://docs.o1labs.org/o1js/api-reference/classes/AccountUpdate) class has these components: - `PublicKey`: The account address for the account update - `TokenId`: A unique hash representing the custom token. Defaults to the MINA TokenId (`1`). @@ -68871,7 +22825,7 @@ Line numbers are provided for convenience. To prevent copying line numbers and c ## Useful Resources -The API Reference docs are a detailed resource that is useful after you have familiarized yourself with the basics. See the [o1js Reference](/zkapps/o1js-reference) docs for an in-depth explanation of all the methods, properties, and interfaces available in o1js. +The API Reference docs are a detailed resource that is useful after you have familiarized yourself with the basics. See the [o1js Reference](https://docs.o1labs.org/o1js/api-reference/Introduction) docs for an in-depth explanation of all the methods, properties, and interfaces available in o1js. See the o1Labs blog at https://www.o1labs.org/blog/. For updates about o1js, see https://www.o1labs.org/blog?topics=o1js. @@ -71727,7 +25681,7 @@ A basic smart contract example is generated when you created a zk project. The h For guided steps to create your first zkApp, start with [Tutorial 1: Hello World](/zkapps/tutorials/hello-world). -For comprehensive details about the o1js API, see the [o1js reference](/zkapps/o1js-reference). +For comprehensive details about the o1js API, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). ## Next Steps @@ -72939,7 +26893,7 @@ x.assertGt(y); // x > y x.assertGte(y); // x >= y ``` -For a full list, see the [o1js reference](/zkapps/o1js-reference). +For a full list, see the [o1js reference](https://docs.o1labs.org/o1js/api-reference/Introduction). To modify the `increment()` method to accept a parameter: diff --git a/static/llms.txt b/static/llms.txt index 29e03cea4..5989b36b7 100644 --- a/static/llms.txt +++ b/static/llms.txt @@ -6,7 +6,8 @@ This file is auto-generated from `sidebars.js` and the frontmatter of each docum ## Network Upgrades -- [Network Upgrades](https://docs.minaprotocol.com/network-upgrades): History of Mina protocol network upgrades on mainnet. +- [Network Upgrades](https://docs.minaprotocol.com/network-upgrades): History of Mina Protocol mainnet network upgrades (hard forks), including Berkeley and Mesa. +- [Berkeley Upgrade](https://docs.minaprotocol.com/network-upgrades/berkeley): Overview of the Berkeley network upgrade for Mina Protocol — the transition to the Berkeley proof system with zkApp support. - [Requirements](https://docs.minaprotocol.com/network-upgrades/berkeley/requirements): Berkeley upgrade is a major upgrade that requires all nodes in a network to upgrade to a newer version. It is not backward compatible. - [Archive Migration](https://docs.minaprotocol.com/network-upgrades/berkeley/archive-migration): Berkeley upgrade is a major upgrade that requires all nodes in a network to upgrade to a newer version. It is not backward compatible. - [Understanding archive migration](https://docs.minaprotocol.com/network-upgrades/berkeley/archive-migration/understanding-archive-migration): Overview of the migration tools and requirements to successfully migrate Devnet/Mainnet archive database. @@ -20,8 +21,22 @@ This file is auto-generated from `sidebars.js` and the frontmatter of each docum - [Upgrade Steps](https://docs.minaprotocol.com/network-upgrades/berkeley/upgrade-steps): Detailed upgrade steps and operators' tasks - [Post-Upgrade Flags and Configurations for Mainnet](https://docs.minaprotocol.com/network-upgrades/berkeley/flags-configs): Post-Upgrade Flags and Configurations for Mainnet - [Appendix](https://docs.minaprotocol.com/network-upgrades/berkeley/appendix): Berkeley Upgrade Appendix -- [Connect to Mesa Preflight Network](https://docs.minaprotocol.com/network-upgrades/mesa/preflight-network): Instructions for connecting to the Mesa upgrade preflight network for testing and validation. +- [Mesa Upgrade](https://docs.minaprotocol.com/network-upgrades/mesa): Overview of the Mesa mainnet upgrade for Mina Protocol — expanded zkApp state, automode upgrades, and protocol improvements. +- [Requirements](https://docs.minaprotocol.com/network-upgrades/mesa/requirements): Hardware and connectivity requirements for daemon node operators upgrading to Mesa — block producers, SNARK coordinators, archive nodes, Rosetta API nodes, and seed nodes. +- [Upgrade Modes](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-modes): Automode and Manual upgrade paths for the Mesa hard fork. Automode handles the transition automatically for daemon nodes; Manual gives operators full control. +- [Mesa Fork Schedule](https://docs.minaprotocol.com/network-upgrades/mesa/fork-schedule): Concrete fork-schedule values for the Mesa upgrade — Mesa genesis timestamp, stop-transaction-slot (slot_tx_end), stop-network-slot (slot_chain_end), and pre-fork / Mesa release versions per network. +- [Upgrade Steps](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-steps): Step-by-step Mesa upgrade instructions with per-role timelines and examples for block producers, SNARK workers, archive nodes, and exchanges. +- [State Finalization](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-steps/state-finalization): State finalization phase of the Mesa upgrade — stabilization period between stop-transaction-slot and stop-network-slot. +- [Upgrade](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-steps/upgrade): Upgrade phase of the Mesa hard fork — network halt, state export, and Mesa build publication. +- [Post-Upgrade](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-steps/post-upgrade): Post-upgrade verification, health checks, and monitoring for the Mesa mainnet network. +- [Examples](https://docs.minaprotocol.com/network-upgrades/mesa/upgrade-steps/examples): End-to-end Mesa upgrade walkthroughs by role and deployment style — block producer (automode/manual), archive node, zkApp developer, and exchange. - [Archive Upgrade](https://docs.minaprotocol.com/network-upgrades/mesa/archive-upgrade): General guide for upgrading a Mina archive database to the Mesa schema — applies to preflight, devnet, and mainnet. +- [Connect to Mesa Preflight Network](https://docs.minaprotocol.com/network-upgrades/mesa/preflight-network): Instructions for connecting to the Mesa upgrade preflight network for testing and validation. +- [Troubleshooting](https://docs.minaprotocol.com/network-upgrades/mesa/troubleshooting): Troubleshooting the Mesa upgrade — checking which binary your node is running, dispatcher behavior, and debug mode for automode operators. +- [Archive Node Schema Changes](https://docs.minaprotocol.com/network-upgrades/mesa/appendix/archive-node-schema-changes): Reference of database schema changes applied to the Mina archive node during the Mesa hard fork — new columns, modified tables, and the SQL applied by the upgrade script. +- [Upgrade Modes - Details](https://docs.minaprotocol.com/network-upgrades/mesa/appendix/upgrade-modes-details): In-depth technical details of the Mesa upgrade mechanism, including automode internals, the dispatcher, stop-slot system, and manual upgrade flow. +- [Automode Docker Compose Quickstart](https://docs.minaprotocol.com/network-upgrades/mesa/appendix/automode-docker-compose-quickstart): Run a Mina node with automode enabled for the Mesa upgrade using Docker Compose. +- [Glossary](https://docs.minaprotocol.com/network-upgrades/mesa/glossary): Definitions of key terms used throughout the Mesa upgrade documentation — stop-slots, automode, dispatcher, trustless/trustful upgrades, and more. ## zkApp Developers @@ -111,6 +126,7 @@ This file is auto-generated from `sidebars.js` and the frontmatter of each docum - [Archive Redundancy](https://docs.minaprotocol.com/node-operators/archive-node/archive-redundancy): Strategies for archive node redundancy, backup, and data recovery. - [Backfilling Missing Blocks](https://docs.minaprotocol.com/node-operators/archive-node/backfilling-missing-blocks): How to detect and repair gaps in a Mina archive database using archive dumps, precomputed blocks, mina-archive-blocks, and the mina-missing-blocks-auditor. - [Docker Compose Archive](https://docs.minaprotocol.com/node-operators/archive-node/docker-compose): Example of how to run a Mina archive node using Docker Compose. +- [Archive Replayer](https://docs.minaprotocol.com/node-operators/archive-node/replayer): Use the mina-replayer tool to verify a Mina archive database by replaying its transactions and reconstructing the ledger state. - [Seed Peers](https://docs.minaprotocol.com/node-operators/seed-peers): What are seed peers - [Seed Peers Getting Started](https://docs.minaprotocol.com/node-operators/seed-peers/getting-started): How to run a seed peer. Seed Peers help connect to the network. - [Generating a libp2p Key Pair](https://docs.minaprotocol.com/node-operators/seed-peers/generating-a-libp2p-keypair): Generate a libp2p key pair for seed node identity on the Mina gossip network. diff --git a/vercel.json b/vercel.json index 0a122fd90..f1cdbda37 100644 --- a/vercel.json +++ b/vercel.json @@ -13,7 +13,19 @@ }, { "source": "/zkapps/snarkyjs-reference/:path(.*)", - "destination": "/zkapps/o1js-reference/:path(.*)" + "destination": "https://docs.o1labs.org/o1js/api-reference/:path(.*)" + }, + { + "source": "/zkapps/o1js-reference", + "destination": "https://docs.o1labs.org/o1js/api-reference/Introduction" + }, + { + "source": "/zkapps/o1js-reference/README", + "destination": "https://docs.o1labs.org/o1js/api-reference/Introduction" + }, + { + "source": "/zkapps/o1js-reference/:path(.*)", + "destination": "https://docs.o1labs.org/o1js/api-reference/:path(.*)" }, { "source": "/zkapps/o1js/smart-contracts",