From 76fed2cb29c585cbc2356ddfdd1cef710cb29e82 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 11:58:41 +0100 Subject: [PATCH 1/7] move mina and utils stuff into their folders --- src/bindings | 2 +- src/index.ts | 12 ++--- src/lib/circuit.ts | 5 +- src/lib/field.ts | 2 +- src/lib/gadgets/arithmetic.ts | 2 +- src/lib/hash.ts | 2 +- src/lib/keccak.ts | 2 +- .../mina/account-update-layout.unit-test.ts | 4 +- src/lib/{ => mina}/account-update.ts | 52 +++++++++---------- .../{ => mina}/account-update.unit-test.ts | 6 +-- src/lib/mina/account.ts | 4 +- src/lib/{ => mina}/base58-encodings.ts | 4 +- src/lib/mina/errors.ts | 2 +- src/lib/{ => mina}/events.ts | 6 +-- src/lib/{ => mina}/fetch.ts | 12 ++--- src/lib/{ => mina}/fetch.unit-test.ts | 2 +- src/lib/mina/graphql.ts | 4 +- src/lib/mina/local-blockchain.ts | 2 +- src/lib/mina/mina-instance.ts | 6 +-- src/lib/{ => mina}/mina.ts | 28 +++++----- src/lib/{ => mina}/mina.unit-test.ts | 0 src/lib/{ => mina}/precondition.test.ts | 0 src/lib/{ => mina}/precondition.ts | 24 ++++----- src/lib/mina/smart-contract-base.ts | 2 +- src/lib/mina/smart-contract-context.ts | 6 +-- src/lib/{ => mina}/state.ts | 12 ++--- src/lib/{ => mina}/token.test.ts | 0 src/lib/mina/token/forest-iterator.ts | 2 +- .../mina/token/forest-iterator.unit-test.ts | 2 +- src/lib/mina/token/token-contract.ts | 4 +- src/lib/mina/token/token-methods.ts | 4 +- src/lib/mina/transaction-context.ts | 4 +- src/lib/mina/transaction-logic/apply.ts | 2 +- src/lib/mina/transaction-logic/ledger.ts | 2 +- src/lib/mina/transaction-validation.ts | 4 +- src/lib/mina/transaction.ts | 6 +-- src/lib/{ => mina}/zkapp.ts | 34 ++++++------ src/lib/ml/consistency.unit-test.ts | 2 +- src/lib/proof-system.ts | 2 +- src/lib/provable-context.ts | 4 +- src/lib/provable-types/struct.unit-test.ts | 12 +++-- src/lib/provable-types/unconstrained.ts | 2 +- src/lib/provable.ts | 2 +- src/lib/testing/random.ts | 2 +- src/lib/{ => util}/base58.ts | 6 +-- src/lib/{ => util}/base58.unit-test.ts | 4 +- src/lib/{ => util}/errors.ts | 0 src/lib/{ => util}/global-context.ts | 0 src/lib/util/types.ts | 2 +- src/mina-signer/src/curve-bigint.ts | 2 +- src/mina-signer/src/memo.ts | 2 +- .../src/sign-zkapp-command.unit-test.ts | 4 +- src/mina-signer/src/signature.ts | 2 +- src/mina-signer/src/transaction-hash.ts | 2 +- src/mina-signer/tests/zkapp.unit-test.ts | 2 +- 55 files changed, 163 insertions(+), 156 deletions(-) rename src/lib/{ => mina}/account-update.ts (97%) rename src/lib/{ => mina}/account-update.unit-test.ts (96%) rename src/lib/{ => mina}/base58-encodings.ts (66%) rename src/lib/{ => mina}/events.ts (96%) rename src/lib/{ => mina}/fetch.ts (99%) rename src/lib/{ => mina}/fetch.unit-test.ts (97%) rename src/lib/{ => mina}/mina.ts (95%) rename src/lib/{ => mina}/mina.unit-test.ts (100%) rename src/lib/{ => mina}/precondition.test.ts (100%) rename src/lib/{ => mina}/precondition.ts (96%) rename src/lib/{ => mina}/state.ts (97%) rename src/lib/{ => mina}/token.test.ts (100%) rename src/lib/{ => mina}/zkapp.ts (98%) rename src/lib/{ => util}/base58.ts (95%) rename src/lib/{ => util}/base58.unit-test.ts (91%) rename src/lib/{ => util}/errors.ts (100%) rename src/lib/{ => util}/global-context.ts (100%) diff --git a/src/bindings b/src/bindings index b5422da399..a49252882e 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit b5422da399520e7acd529648eeeadf30e1be2c79 +Subproject commit a49252882e66d078b4d77cba679c2e22932def96 diff --git a/src/index.ts b/src/index.ts index b9fb2cb520..e12f591730 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,22 +37,22 @@ export { MerkleListIterator, } from './lib/provable-types/merkle-list.js'; -export * as Mina from './lib/mina.js'; +export * as Mina from './lib/mina/mina.js'; export { type Transaction, type PendingTransaction, type IncludedTransaction, type RejectedTransaction, } from './lib/mina/transaction.js'; -export type { DeployArgs } from './lib/zkapp.js'; +export type { DeployArgs } from './lib/mina/zkapp.js'; export { SmartContract, method, declareMethods, Account, Reducer, -} from './lib/zkapp.js'; -export { state, State, declareState } from './lib/state.js'; +} from './lib/mina/zkapp.js'; +export { state, State, declareState } from './lib/mina/state.js'; export type { JsonProof } from './lib/proof-system.js'; export { @@ -74,7 +74,7 @@ export { TransactionVersion, AccountUpdateForest, AccountUpdateTree, -} from './lib/account-update.js'; +} from './lib/mina/account-update.js'; export { TokenAccountUpdateIterator } from './lib/mina/token/forest-iterator.js'; export { TokenContract } from './lib/mina/token/token-contract.js'; @@ -92,7 +92,7 @@ export { setArchiveGraphqlEndpoint, sendZkapp, Lightnet, -} from './lib/fetch.js'; +} from './lib/mina/fetch.js'; export * as Encryption from './lib/encryption.js'; export * as Encoding from './bindings/lib/encoding.js'; export { Character, CircuitString } from './lib/provable-types/string.js'; diff --git a/src/lib/circuit.ts b/src/lib/circuit.ts index c47d2baf51..399ed17864 100644 --- a/src/lib/circuit.ts +++ b/src/lib/circuit.ts @@ -4,7 +4,10 @@ import { MlFieldArray, MlFieldConstArray } from './ml/fields.js'; import { withThreadPool } from '../snarky.js'; import { Provable } from './provable.js'; import { snarkContext, gatesFromJson } from './provable-context.js'; -import { prettifyStacktrace, prettifyStacktracePromise } from './errors.js'; +import { + prettifyStacktrace, + prettifyStacktracePromise, +} from './util/errors.js'; import { ProvablePure } from './provable-types/provable-intf.js'; // external API diff --git a/src/lib/field.ts b/src/lib/field.ts index 5f832e269f..87ed88d4b0 100644 --- a/src/lib/field.ts +++ b/src/lib/field.ts @@ -5,7 +5,7 @@ import { defineBinable } from '../bindings/lib/binable.js'; import type { NonNegativeInteger } from '../bindings/crypto/non-negative.js'; import { asProver, inCheckedComputation } from './provable-context.js'; import { Bool } from './bool.js'; -import { assert } from './errors.js'; +import { assert } from './util/errors.js'; import { Provable } from './provable.js'; import { assertEqual, diff --git a/src/lib/gadgets/arithmetic.ts b/src/lib/gadgets/arithmetic.ts index 09b7278815..56b8efb39c 100644 --- a/src/lib/gadgets/arithmetic.ts +++ b/src/lib/gadgets/arithmetic.ts @@ -1,6 +1,6 @@ import { provableTuple } from '../provable-types/struct.js'; import { Field } from '../core.js'; -import { assert } from '../errors.js'; +import { assert } from '../util/errors.js'; import { Provable } from '../provable.js'; import { rangeCheck32, rangeCheckN } from './range-check.js'; diff --git a/src/lib/hash.ts b/src/lib/hash.ts index cf2c068a5f..d1b15b1570 100644 --- a/src/lib/hash.ts +++ b/src/lib/hash.ts @@ -9,7 +9,7 @@ import { createHashHelpers } from './hash-generic.js'; import { Provable } from './provable.js'; import { MlFieldArray } from './ml/fields.js'; import { Poseidon as PoseidonBigint } from '../bindings/crypto/poseidon.js'; -import { assert } from './errors.js'; +import { assert } from './util/errors.js'; import { rangeCheckN } from './gadgets/range-check.js'; import { TupleN } from './util/types.js'; diff --git a/src/lib/keccak.ts b/src/lib/keccak.ts index 1d1f0e40a9..e4b7c9e746 100644 --- a/src/lib/keccak.ts +++ b/src/lib/keccak.ts @@ -1,6 +1,6 @@ import { Field } from './field.js'; import { Gadgets } from './gadgets/gadgets.js'; -import { assert } from './errors.js'; +import { assert } from './util/errors.js'; import { FlexibleBytes } from './provable-types/bytes.js'; import { UInt8 } from './int.js'; import { Bytes } from './provable-types/provable-types.js'; diff --git a/src/lib/mina/account-update-layout.unit-test.ts b/src/lib/mina/account-update-layout.unit-test.ts index 8ff2d6853c..82d183c63e 100644 --- a/src/lib/mina/account-update-layout.unit-test.ts +++ b/src/lib/mina/account-update-layout.unit-test.ts @@ -1,7 +1,7 @@ import { Mina } from '../../index.js'; -import { AccountUpdate, AccountUpdateTree } from '../account-update.js'; +import { AccountUpdate, AccountUpdateTree } from './account-update.js'; import { UInt64 } from '../int.js'; -import { SmartContract, method } from '../zkapp.js'; +import { SmartContract, method } from './zkapp.js'; // smart contract which creates an account update that has a child of its own diff --git a/src/lib/account-update.ts b/src/lib/mina/account-update.ts similarity index 97% rename from src/lib/account-update.ts rename to src/lib/mina/account-update.ts index 7dd256d9ef..1c95bb5553 100644 --- a/src/lib/account-update.ts +++ b/src/lib/mina/account-update.ts @@ -4,18 +4,18 @@ import { provable, provablePure, StructNoJson, -} from './provable-types/struct.js'; -import { memoizationContext, memoizeWitness, Provable } from './provable.js'; -import { Field, Bool } from './core.js'; -import { Pickles, Test } from '../snarky.js'; -import { jsLayout } from '../bindings/mina-transaction/gen/js-layout.js'; +} from '../provable-types/struct.js'; +import { memoizationContext, memoizeWitness, Provable } from '../provable.js'; +import { Field, Bool } from '../core.js'; +import { Pickles, Test } from '../../snarky.js'; +import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; import { Types, TypesBigint, toJSONEssential, -} from '../bindings/mina-transaction/types.js'; -import { PrivateKey, PublicKey } from './signature.js'; -import { UInt64, UInt32, Int64, Sign } from './int.js'; +} from '../../bindings/mina-transaction/types.js'; +import { PrivateKey, PublicKey } from '../signature.js'; +import { UInt64, UInt32, Int64, Sign } from '../int.js'; import type { SmartContract } from './zkapp.js'; import { Preconditions, @@ -27,49 +27,49 @@ import { ClosedInterval, getAccountPreconditions, } from './precondition.js'; -import { dummyBase64Proof, Empty, Proof, Prover } from './proof-system.js'; -import { Memo } from '../mina-signer/src/memo.js'; +import { dummyBase64Proof, Empty, Proof, Prover } from '../proof-system.js'; +import { Memo } from '../../mina-signer/src/memo.js'; import { Events, Actions, -} from '../bindings/mina-transaction/transaction-leaves.js'; +} from '../../bindings/mina-transaction/transaction-leaves.js'; import { TokenId as Base58TokenId } from './base58-encodings.js'; -import { hashWithPrefix, packToFields, Poseidon } from './hash.js'; +import { hashWithPrefix, packToFields, Poseidon } from '../hash.js'; import { mocks, prefixes, protocolVersions, -} from '../bindings/crypto/constants.js'; -import { MlArray } from './ml/base.js'; +} from '../../bindings/crypto/constants.js'; +import { MlArray } from '../ml/base.js'; import { Signature, signFieldElement, zkAppBodyPrefix, -} from '../mina-signer/src/signature.js'; -import { MlFieldConstArray } from './ml/fields.js'; +} from '../../mina-signer/src/signature.js'; +import { MlFieldConstArray } from '../ml/fields.js'; import { accountUpdatesToCallForest, CallForest, callForestHashGeneric, transactionCommitments, -} from '../mina-signer/src/sign-zkapp-command.js'; -import { currentTransaction } from './mina/transaction-context.js'; -import { isSmartContract } from './mina/smart-contract-base.js'; -import { activeInstance } from './mina/mina-instance.js'; +} from '../../mina-signer/src/sign-zkapp-command.js'; +import { currentTransaction } from './transaction-context.js'; +import { isSmartContract } from './smart-contract-base.js'; +import { activeInstance } from './mina-instance.js'; import { emptyHash, genericHash, MerkleList, MerkleListBase, -} from './provable-types/merkle-list.js'; -import { Hashed } from './provable-types/packed.js'; +} from '../provable-types/merkle-list.js'; +import { Hashed } from '../provable-types/packed.js'; import { accountUpdateLayout, smartContractContext, -} from './mina/smart-contract-context.js'; -import { assert } from './util/assert.js'; -import { RandomId } from './provable-types/auxiliary.js'; -import { NetworkId } from '../mina-signer/src/types.js'; +} from './smart-contract-context.js'; +import { assert } from '../util/assert.js'; +import { RandomId } from '../provable-types/auxiliary.js'; +import { NetworkId } from '../../mina-signer/src/types.js'; // external API export { diff --git a/src/lib/account-update.unit-test.ts b/src/lib/mina/account-update.unit-test.ts similarity index 96% rename from src/lib/account-update.unit-test.ts rename to src/lib/mina/account-update.unit-test.ts index 5f1e61a1b0..7f44a5dace 100644 --- a/src/lib/account-update.unit-test.ts +++ b/src/lib/mina/account-update.unit-test.ts @@ -1,4 +1,4 @@ -import { mocks } from '../bindings/crypto/constants.js'; +import { mocks } from '../../bindings/crypto/constants.js'; import { AccountUpdate, PrivateKey, @@ -6,8 +6,8 @@ import { Mina, Int64, Types, -} from '../index.js'; -import { Test } from '../snarky.js'; +} from '../../index.js'; +import { Test } from '../../snarky.js'; import { expect } from 'expect'; let address = PrivateKey.random().toPublicKey(); diff --git a/src/lib/mina/account.ts b/src/lib/mina/account.ts index 525bff7e5d..03aca7a9f1 100644 --- a/src/lib/mina/account.ts +++ b/src/lib/mina/account.ts @@ -1,9 +1,9 @@ import { Types } from '../../bindings/mina-transaction/types.js'; import { Bool, Field } from '../core.js'; -import { Permissions } from '../account-update.js'; +import { Permissions } from './account-update.js'; import { UInt32, UInt64 } from '../int.js'; import { PublicKey } from '../signature.js'; -import { TokenId, ReceiptChainHash } from '../base58-encodings.js'; +import { TokenId, ReceiptChainHash } from './base58-encodings.js'; import { genericLayoutFold } from '../../bindings/lib/from-layout.js'; import { customTypes, diff --git a/src/lib/base58-encodings.ts b/src/lib/mina/base58-encodings.ts similarity index 66% rename from src/lib/base58-encodings.ts rename to src/lib/mina/base58-encodings.ts index 52b3842330..c2f4335b06 100644 --- a/src/lib/base58-encodings.ts +++ b/src/lib/mina/base58-encodings.ts @@ -1,5 +1,5 @@ -import { fieldEncodings } from './base58.js'; -import { Field } from './core.js'; +import { fieldEncodings } from '../util/base58.js'; +import { Field } from '../core.js'; export { TokenId, ReceiptChainHash, LedgerHash, EpochSeed, StateHash }; diff --git a/src/lib/mina/errors.ts b/src/lib/mina/errors.ts index bdbfd16c04..0a2c51c97f 100644 --- a/src/lib/mina/errors.ts +++ b/src/lib/mina/errors.ts @@ -1,5 +1,5 @@ import { Types } from '../../bindings/mina-transaction/types.js'; -import { TokenId } from '../account-update.js'; +import { TokenId } from './account-update.js'; import { Int64 } from '../int.js'; export { invalidTransactionError }; diff --git a/src/lib/events.ts b/src/lib/mina/events.ts similarity index 96% rename from src/lib/events.ts rename to src/lib/mina/events.ts index 70fce76400..5362c73e7c 100644 --- a/src/lib/events.ts +++ b/src/lib/mina/events.ts @@ -1,9 +1,9 @@ -import { prefixes } from '../bindings/crypto/constants.js'; -import { prefixToField } from '../bindings/lib/binable.js'; +import { prefixes } from '../../bindings/crypto/constants.js'; +import { prefixToField } from '../../bindings/lib/binable.js'; import { GenericProvableExtended, GenericSignableField, -} from '../bindings/lib/generic.js'; +} from '../../bindings/lib/generic.js'; export { createEvents, dataAsHash }; diff --git a/src/lib/fetch.ts b/src/lib/mina/fetch.ts similarity index 99% rename from src/lib/fetch.ts rename to src/lib/mina/fetch.ts index e357579501..2c82608db8 100644 --- a/src/lib/fetch.ts +++ b/src/lib/mina/fetch.ts @@ -1,10 +1,10 @@ import 'isomorphic-fetch'; -import { Field } from './core.js'; -import { UInt32, UInt64 } from './int.js'; +import { Field } from '../core.js'; +import { UInt32, UInt64 } from '../int.js'; import { Actions, TokenId } from './account-update.js'; -import { PublicKey, PrivateKey } from './signature.js'; +import { PublicKey, PrivateKey } from '../signature.js'; import { NetworkValue } from './precondition.js'; -import { Types } from '../bindings/mina-transaction/types.js'; +import { Types } from '../../bindings/mina-transaction/types.js'; import { ActionStates } from './mina.js'; import { LedgerHash, EpochSeed, StateHash } from './base58-encodings.js'; import { @@ -12,7 +12,7 @@ import { fillPartialAccount, parseFetchedAccount, PartialAccount, -} from './mina/account.js'; +} from './account.js'; import { type LastBlockQueryResponse, type GenesisConstantsResponse, @@ -35,7 +35,7 @@ import { genesisConstantsQuery, accountQuery, currentSlotQuery, -} from './mina/graphql.js'; +} from './graphql.js'; export { fetchAccount, diff --git a/src/lib/fetch.unit-test.ts b/src/lib/mina/fetch.unit-test.ts similarity index 97% rename from src/lib/fetch.unit-test.ts rename to src/lib/mina/fetch.unit-test.ts index c1a4eb422d..e61a7155a6 100644 --- a/src/lib/fetch.unit-test.ts +++ b/src/lib/mina/fetch.unit-test.ts @@ -1,4 +1,4 @@ -import { removeJsonQuotes } from './mina/graphql.js'; +import { removeJsonQuotes } from './graphql.js'; import { expect } from 'expect'; console.log('testing regex helpers'); diff --git a/src/lib/mina/graphql.ts b/src/lib/mina/graphql.ts index 9cff4b2217..4e8c14b3e6 100644 --- a/src/lib/mina/graphql.ts +++ b/src/lib/mina/graphql.ts @@ -1,6 +1,6 @@ import { UInt32 } from '../int.js'; -import type { ZkappCommand } from '../account-update.js'; -import type { ActionStatesStringified } from '../fetch.js'; +import type { ZkappCommand } from './account-update.js'; +import type { ActionStatesStringified } from './fetch.js'; import { Types } from '../../bindings/mina-transaction/types.js'; export { diff --git a/src/lib/mina/local-blockchain.ts b/src/lib/mina/local-blockchain.ts index 689991d983..17a200fa08 100644 --- a/src/lib/mina/local-blockchain.ts +++ b/src/lib/mina/local-blockchain.ts @@ -11,7 +11,7 @@ import { TokenId, Authorization, Actions, -} from '../account-update.js'; +} from './account-update.js'; import { NetworkId } from '../../mina-signer/src/types.js'; import { Types, TypesBigint } from '../../bindings/mina-transaction/types.js'; import { invalidTransactionError } from './errors.js'; diff --git a/src/lib/mina/mina-instance.ts b/src/lib/mina/mina-instance.ts index 5b73af5947..0cd271846b 100644 --- a/src/lib/mina/mina-instance.ts +++ b/src/lib/mina/mina-instance.ts @@ -6,10 +6,10 @@ import { UInt64, UInt32 } from '../int.js'; import { PublicKey, PrivateKey } from '../signature.js'; import type { EventActionFilterOptions } from '././../mina/graphql.js'; import type { NetworkId } from '../../mina-signer/src/types.js'; -import type { Transaction, PendingTransaction } from '../mina.js'; +import type { Transaction, PendingTransaction } from './mina.js'; import type { Account } from './account.js'; -import type { NetworkValue } from '../precondition.js'; -import type * as Fetch from '../fetch.js'; +import type { NetworkValue } from './precondition.js'; +import type * as Fetch from './fetch.js'; export { Mina, diff --git a/src/lib/mina.ts b/src/lib/mina/mina.ts similarity index 95% rename from src/lib/mina.ts rename to src/lib/mina/mina.ts index 430cb63e10..7e8aac1b33 100644 --- a/src/lib/mina.ts +++ b/src/lib/mina/mina.ts @@ -1,14 +1,14 @@ -import { Test } from '../snarky.js'; -import { Field } from './core.js'; -import { UInt64 } from './int.js'; -import { PublicKey } from './signature.js'; +import { Test } from '../../snarky.js'; +import { Field } from '../core.js'; +import { UInt64 } from '../int.js'; +import { PublicKey } from '../signature.js'; import { ZkappCommand, TokenId, Authorization } from './account-update.js'; import * as Fetch from './fetch.js'; -import { invalidTransactionError } from './mina/errors.js'; -import { Types } from '../bindings/mina-transaction/types.js'; -import { Account } from './mina/account.js'; -import { NetworkId } from '../mina-signer/src/types.js'; -import { currentTransaction } from './mina/transaction-context.js'; +import { invalidTransactionError } from './errors.js'; +import { Types } from '../../bindings/mina-transaction/types.js'; +import { Account } from './account.js'; +import { NetworkId } from '../../mina-signer/src/types.js'; +import { currentTransaction } from './transaction-context.js'; import { type FeePayerSpec, type ActionStates, @@ -28,8 +28,8 @@ import { fetchActions, getActions, getProofsEnabled, -} from './mina/mina-instance.js'; -import { type EventActionFilterOptions } from './mina/graphql.js'; +} from './mina-instance.js'; +import { type EventActionFilterOptions } from './graphql.js'; import { type Transaction, type PendingTransaction, @@ -41,14 +41,14 @@ import { transaction, createRejectedTransaction, createIncludedTransaction, -} from './mina/transaction.js'; +} from './transaction.js'; import { reportGetAccountError, verifyTransactionLimits, defaultNetworkState, filterGroups, -} from './mina/transaction-validation.js'; -import { LocalBlockchain } from './mina/local-blockchain.js'; +} from './transaction-validation.js'; +import { LocalBlockchain } from './local-blockchain.js'; export { LocalBlockchain, diff --git a/src/lib/mina.unit-test.ts b/src/lib/mina/mina.unit-test.ts similarity index 100% rename from src/lib/mina.unit-test.ts rename to src/lib/mina/mina.unit-test.ts diff --git a/src/lib/precondition.test.ts b/src/lib/mina/precondition.test.ts similarity index 100% rename from src/lib/precondition.test.ts rename to src/lib/mina/precondition.test.ts diff --git a/src/lib/precondition.ts b/src/lib/mina/precondition.ts similarity index 96% rename from src/lib/precondition.ts rename to src/lib/mina/precondition.ts index 0f57b426aa..f0307d9597 100644 --- a/src/lib/precondition.ts +++ b/src/lib/mina/precondition.ts @@ -1,22 +1,22 @@ -import { Bool, Field } from './core.js'; +import { Bool, Field } from '../core.js'; import { circuitValueEquals, cloneCircuitValue, -} from './provable-types/struct.js'; -import { Provable } from './provable.js'; -import { activeInstance as Mina } from './mina/mina-instance.js'; +} from '../provable-types/struct.js'; +import { Provable } from '../provable.js'; +import { activeInstance as Mina } from './mina-instance.js'; import type { AccountUpdate } from './account-update.js'; -import { Int64, UInt32, UInt64 } from './int.js'; -import { Layout } from '../bindings/mina-transaction/gen/transaction.js'; -import { jsLayout } from '../bindings/mina-transaction/gen/js-layout.js'; -import { emptyReceiptChainHash, TokenSymbol } from './hash.js'; -import { PublicKey } from './signature.js'; +import { Int64, UInt32, UInt64 } from '../int.js'; +import { Layout } from '../../bindings/mina-transaction/gen/transaction.js'; +import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; +import { emptyReceiptChainHash, TokenSymbol } from '../hash.js'; +import { PublicKey } from '../signature.js'; import { Actions, ZkappUri, -} from '../bindings/mina-transaction/transaction-leaves.js'; -import type { Types } from '../bindings/mina-transaction/types.js'; -import { ZkappStateLength } from './mina/mina-instance.js'; +} from '../../bindings/mina-transaction/transaction-leaves.js'; +import type { Types } from '../../bindings/mina-transaction/types.js'; +import { ZkappStateLength } from './mina-instance.js'; export { preconditions, diff --git a/src/lib/mina/smart-contract-base.ts b/src/lib/mina/smart-contract-base.ts index 37d54379e0..0c0db7c805 100644 --- a/src/lib/mina/smart-contract-base.ts +++ b/src/lib/mina/smart-contract-base.ts @@ -2,7 +2,7 @@ * This file exists to avoid an import cycle between code that just needs access * to a smart contract base class, and the code that implements `SmartContract`. */ -import type { SmartContract } from '../zkapp.js'; +import type { SmartContract } from './zkapp.js'; export { isSmartContract, SmartContractBase }; diff --git a/src/lib/mina/smart-contract-context.ts b/src/lib/mina/smart-contract-context.ts index 916908dd10..2920c26d42 100644 --- a/src/lib/mina/smart-contract-context.ts +++ b/src/lib/mina/smart-contract-context.ts @@ -1,6 +1,6 @@ -import type { SmartContract } from '../zkapp.js'; -import type { AccountUpdate, AccountUpdateLayout } from '../account-update.js'; -import { Context } from '../global-context.js'; +import type { SmartContract } from './zkapp.js'; +import type { AccountUpdate, AccountUpdateLayout } from './account-update.js'; +import { Context } from '../util/global-context.js'; import { currentTransaction } from './transaction-context.js'; export { smartContractContext, SmartContractContext, accountUpdateLayout }; diff --git a/src/lib/state.ts b/src/lib/mina/state.ts similarity index 97% rename from src/lib/state.ts rename to src/lib/mina/state.ts index b57cfc31d0..9b234d7ec2 100644 --- a/src/lib/state.ts +++ b/src/lib/mina/state.ts @@ -1,13 +1,13 @@ -import { FlexibleProvablePure } from './provable-types/struct.js'; +import { FlexibleProvablePure } from '../provable-types/struct.js'; import { AccountUpdate, TokenId } from './account-update.js'; -import { PublicKey } from './signature.js'; +import { PublicKey } from '../signature.js'; import * as Mina from './mina.js'; import { fetchAccount, networkConfig } from './fetch.js'; import { SmartContract } from './zkapp.js'; -import { Account } from './mina/account.js'; -import { Provable } from './provable.js'; -import { Field } from '../lib/core.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +import { Account } from './account.js'; +import { Provable } from '../provable.js'; +import { Field } from '../core.js'; +import { ProvablePure } from '../provable-types/provable-intf.js'; // external API export { State, state, declareState }; diff --git a/src/lib/token.test.ts b/src/lib/mina/token.test.ts similarity index 100% rename from src/lib/token.test.ts rename to src/lib/mina/token.test.ts diff --git a/src/lib/mina/token/forest-iterator.ts b/src/lib/mina/token/forest-iterator.ts index 25529472c6..662f6add40 100644 --- a/src/lib/mina/token/forest-iterator.ts +++ b/src/lib/mina/token/forest-iterator.ts @@ -3,7 +3,7 @@ import { AccountUpdateForest, AccountUpdateTreeBase, TokenId, -} from '../../account-update.js'; +} from '../account-update.js'; import { Field } from '../../core.js'; import { Provable } from '../../provable.js'; import { Struct } from '../../provable-types/struct.js'; diff --git a/src/lib/mina/token/forest-iterator.unit-test.ts b/src/lib/mina/token/forest-iterator.unit-test.ts index 4d03d158de..bd5ffd1320 100644 --- a/src/lib/mina/token/forest-iterator.unit-test.ts +++ b/src/lib/mina/token/forest-iterator.unit-test.ts @@ -6,7 +6,7 @@ import { AccountUpdateForest, TokenId, hashAccountUpdate, -} from '../../account-update.js'; +} from '../account-update.js'; import { TypesBigint } from '../../../bindings/mina-transaction/types.js'; import { Pickles } from '../../../snarky.js'; import { diff --git a/src/lib/mina/token/token-contract.ts b/src/lib/mina/token/token-contract.ts index ad400259c4..836fec4758 100644 --- a/src/lib/mina/token/token-contract.ts +++ b/src/lib/mina/token/token-contract.ts @@ -8,8 +8,8 @@ import { AccountUpdateTree, Permissions, TokenId, -} from '../../account-update.js'; -import { DeployArgs, SmartContract } from '../../zkapp.js'; +} from '../account-update.js'; +import { DeployArgs, SmartContract } from '../zkapp.js'; import { TokenAccountUpdateIterator } from './forest-iterator.js'; import { tokenMethods } from './token-methods.js'; diff --git a/src/lib/mina/token/token-methods.ts b/src/lib/mina/token/token-methods.ts index 58d96ca1f4..53136d1e21 100644 --- a/src/lib/mina/token/token-methods.ts +++ b/src/lib/mina/token/token-methods.ts @@ -1,7 +1,7 @@ -import { AccountUpdate, Authorization, TokenId } from '../../account-update.js'; +import { AccountUpdate, Authorization, TokenId } from '../account-update.js'; import { isSmartContract } from '../smart-contract-base.js'; import { PublicKey } from '../../signature.js'; -import type { SmartContract } from '../../zkapp.js'; +import type { SmartContract } from '../zkapp.js'; import { UInt64 } from '../../int.js'; import { Bool, Field } from '../../core.js'; diff --git a/src/lib/mina/transaction-context.ts b/src/lib/mina/transaction-context.ts index e152d4eca9..412ecbf516 100644 --- a/src/lib/mina/transaction-context.ts +++ b/src/lib/mina/transaction-context.ts @@ -1,6 +1,6 @@ -import type { AccountUpdateLayout } from '../account-update.js'; +import type { AccountUpdateLayout } from './account-update.js'; import type { PublicKey } from '../signature.js'; -import { Context } from '../global-context.js'; +import { Context } from '../util/global-context.js'; export { currentTransaction, CurrentTransaction, FetchMode }; diff --git a/src/lib/mina/transaction-logic/apply.ts b/src/lib/mina/transaction-logic/apply.ts index 7a185b95bd..9448444974 100644 --- a/src/lib/mina/transaction-logic/apply.ts +++ b/src/lib/mina/transaction-logic/apply.ts @@ -1,7 +1,7 @@ /** * Apply transactions to a ledger of accounts. */ -import { type AccountUpdate } from '../../account-update.js'; +import { type AccountUpdate } from '../account-update.js'; import { Account } from '../account.js'; export { applyAccountUpdate }; diff --git a/src/lib/mina/transaction-logic/ledger.ts b/src/lib/mina/transaction-logic/ledger.ts index 3951ff2f5f..b79f535d02 100644 --- a/src/lib/mina/transaction-logic/ledger.ts +++ b/src/lib/mina/transaction-logic/ledger.ts @@ -2,7 +2,7 @@ * A ledger of accounts - simple model of a local blockchain. */ import { PublicKey } from '../../signature.js'; -import type { AccountUpdate } from '../../account-update.js'; +import type { AccountUpdate } from '../account-update.js'; import { Account, newAccount } from '../account.js'; import { Field } from '../../field.js'; import { applyAccountUpdate } from './apply.js'; diff --git a/src/lib/mina/transaction-validation.ts b/src/lib/mina/transaction-validation.ts index 10d39c7f82..be14ff4298 100644 --- a/src/lib/mina/transaction-validation.ts +++ b/src/lib/mina/transaction-validation.ts @@ -8,7 +8,7 @@ import { ZkappPublicInput, AccountUpdate, dummySignature, -} from '../account-update.js'; +} from './account-update.js'; import { Field } from '../core.js'; import { UInt64, UInt32 } from '../int.js'; import { PublicKey } from '../signature.js'; @@ -20,7 +20,7 @@ import { assert } from '../gadgets/common.js'; import { Types, TypesBigint } from '../../bindings/mina-transaction/types.js'; import type { NetworkId } from '../../mina-signer/src/types.js'; import type { Account } from './account.js'; -import type { NetworkValue } from '../precondition.js'; +import type { NetworkValue } from './precondition.js'; export { reportGetAccountError, diff --git a/src/lib/mina/transaction.ts b/src/lib/mina/transaction.ts index 030e15fe99..5feaabe56f 100644 --- a/src/lib/mina/transaction.ts +++ b/src/lib/mina/transaction.ts @@ -7,17 +7,17 @@ import { addMissingSignatures, TokenId, addMissingProofs, -} from '../account-update.js'; +} from './account-update.js'; import { Field } from '../core.js'; import { PrivateKey, PublicKey } from '../signature.js'; import { UInt32, UInt64 } from '../int.js'; import { Empty, Proof } from '../proof-system.js'; import { currentTransaction } from './transaction-context.js'; import { Provable } from '../provable.js'; -import { assertPreconditionInvariants } from '../precondition.js'; +import { assertPreconditionInvariants } from './precondition.js'; import { Account } from './account.js'; import { type FeePayerSpec, activeInstance } from './mina-instance.js'; -import * as Fetch from '../fetch.js'; +import * as Fetch from './fetch.js'; import { type SendZkAppResponse, sendZkappQuery } from './graphql.js'; import { type FetchMode } from './transaction-context.js'; import { assertPromise } from '../util/assert.js'; diff --git a/src/lib/zkapp.ts b/src/lib/mina/zkapp.ts similarity index 98% rename from src/lib/zkapp.ts rename to src/lib/mina/zkapp.ts index bfa7907b68..c4369a65de 100644 --- a/src/lib/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -1,6 +1,6 @@ import 'reflect-metadata'; -import { Gate, Pickles } from '../snarky.js'; -import { Field, Bool } from './core.js'; +import { Gate, Pickles } from '../../snarky.js'; +import { Field, Bool } from '../core.js'; import { AccountUpdate, Authorization, @@ -23,17 +23,17 @@ import { FlexibleProvablePure, InferProvable, provable, -} from './provable-types/struct.js'; -import { Provable, getBlindingValue, memoizationContext } from './provable.js'; -import * as Encoding from '../bindings/lib/encoding.js'; +} from '../provable-types/struct.js'; +import { Provable, getBlindingValue, memoizationContext } from '../provable.js'; +import * as Encoding from '../../bindings/lib/encoding.js'; import { HashInput, Poseidon, hashConstant, isHashable, packToFields, -} from './hash.js'; -import { UInt32, UInt64 } from './int.js'; +} from '../hash.js'; +import { UInt32, UInt64 } from '../int.js'; import * as Mina from './mina.js'; import { assertPreconditionInvariants, @@ -50,26 +50,26 @@ import { MethodInterface, Proof, sortMethodArguments, -} from './proof-system.js'; -import { PrivateKey, PublicKey } from './signature.js'; +} from '../proof-system.js'; +import { PrivateKey, PublicKey } from '../signature.js'; import { assertStatePrecondition, cleanStatePrecondition } from './state.js'; import { inAnalyze, inCheckedComputation, inCompile, inProver, -} from './provable-context.js'; -import { Cache } from './proof-system/cache.js'; -import { assert } from './gadgets/common.js'; -import { SmartContractBase } from './mina/smart-contract-base.js'; -import { ZkappStateLength } from './mina/mina-instance.js'; +} from '../provable-context.js'; +import { Cache } from '../proof-system/cache.js'; +import { assert } from '../gadgets/common.js'; +import { SmartContractBase } from './smart-contract-base.js'; +import { ZkappStateLength } from './mina-instance.js'; import { SmartContractContext, accountUpdateLayout, smartContractContext, -} from './mina/smart-contract-context.js'; -import { assertPromise } from './util/assert.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +} from './smart-contract-context.js'; +import { assertPromise } from '../util/assert.js'; +import { ProvablePure } from '../provable-types/provable-intf.js'; // external API export { SmartContract, method, DeployArgs, declareMethods, Account, Reducer }; diff --git a/src/lib/ml/consistency.unit-test.ts b/src/lib/ml/consistency.unit-test.ts index 738884b05f..a5cca0ea4e 100644 --- a/src/lib/ml/consistency.unit-test.ts +++ b/src/lib/ml/consistency.unit-test.ts @@ -2,7 +2,7 @@ import { Test } from '../../snarky.js'; import { Random, test } from '../testing/property.js'; import { Field, Bool } from '../core.js'; import { PrivateKey, PublicKey } from '../signature.js'; -import { TokenId, dummySignature } from '../account-update.js'; +import { TokenId, dummySignature } from '../mina/account-update.js'; import { Ml } from './conversion.js'; import { expect } from 'expect'; import { FieldConst } from '../provable-core/fieldvar.js'; diff --git a/src/lib/proof-system.ts b/src/lib/proof-system.ts index 2df2431edf..bf2e0d3899 100644 --- a/src/lib/proof-system.ts +++ b/src/lib/proof-system.ts @@ -22,7 +22,7 @@ import { provablePure, } from './provable-types/struct.js'; import { Provable } from './provable.js'; -import { assert, prettifyStacktracePromise } from './errors.js'; +import { assert, prettifyStacktracePromise } from './util/errors.js'; import { snarkContext } from './provable-context.js'; import { hashConstant } from './hash.js'; import { MlArray, MlBool, MlResult, MlPair } from './ml/base.js'; diff --git a/src/lib/provable-context.ts b/src/lib/provable-context.ts index fa0286b24a..a84dd471f9 100644 --- a/src/lib/provable-context.ts +++ b/src/lib/provable-context.ts @@ -1,7 +1,7 @@ -import { Context } from './global-context.js'; +import { Context } from './util/global-context.js'; import { Gate, GateType, JsonGate, Snarky } from '../snarky.js'; import { parseHexString32 } from '../bindings/crypto/bigint-helpers.js'; -import { prettifyStacktrace } from './errors.js'; +import { prettifyStacktrace } from './util/errors.js'; import { Fp } from '../bindings/crypto/finite-field.js'; import { MlBool } from './ml/base.js'; diff --git a/src/lib/provable-types/struct.unit-test.ts b/src/lib/provable-types/struct.unit-test.ts index 98cbacf0fe..5a67b0b2f4 100644 --- a/src/lib/provable-types/struct.unit-test.ts +++ b/src/lib/provable-types/struct.unit-test.ts @@ -3,10 +3,14 @@ import { Unconstrained } from './unconstrained.js'; import { UInt32 } from '../int.js'; import { PrivateKey, PublicKey } from '../signature.js'; import { expect } from 'expect'; -import { method, SmartContract } from '../zkapp.js'; -import { LocalBlockchain, setActiveInstance, transaction } from '../mina.js'; -import { State, state } from '../state.js'; -import { AccountUpdate } from '../account-update.js'; +import { method, SmartContract } from '../mina/zkapp.js'; +import { + LocalBlockchain, + setActiveInstance, + transaction, +} from '../mina/mina.js'; +import { State, state } from '../mina/state.js'; +import { AccountUpdate } from '../mina/account-update.js'; import { Provable } from '../provable.js'; import { Field } from '../core.js'; diff --git a/src/lib/provable-types/unconstrained.ts b/src/lib/provable-types/unconstrained.ts index 70d9fd7fbb..f4241e7888 100644 --- a/src/lib/provable-types/unconstrained.ts +++ b/src/lib/provable-types/unconstrained.ts @@ -1,7 +1,7 @@ import { Snarky } from '../../snarky.js'; import { Field } from '../field.js'; import { Provable } from '../provable.js'; -import { assert } from '../errors.js'; +import { assert } from '../util/errors.js'; import { inCheckedComputation } from '../provable-context.js'; export { Unconstrained }; diff --git a/src/lib/provable.ts b/src/lib/provable.ts index 27753fff97..36ef679fca 100644 --- a/src/lib/provable.ts +++ b/src/lib/provable.ts @@ -10,7 +10,7 @@ import type { FlexibleProvable, ProvableExtended, } from './provable-types/struct.js'; -import { Context } from './global-context.js'; +import { Context } from './util/global-context.js'; import { HashInput, InferJson, diff --git a/src/lib/testing/random.ts b/src/lib/testing/random.ts index 1c3df8e506..e4fa1818c5 100644 --- a/src/lib/testing/random.ts +++ b/src/lib/testing/random.ts @@ -36,7 +36,7 @@ import { } from '../../mina-signer/src/curve-bigint.js'; import { Signature } from '../../mina-signer/src/signature.js'; import { randomBytes } from '../../bindings/crypto/random.js'; -import { alphabet } from '../base58.js'; +import { alphabet } from '../util/base58.js'; import { bytesToBigInt } from '../../bindings/crypto/bigint-helpers.js'; import { Memo } from '../../mina-signer/src/memo.js'; import { Signable } from '../../mina-signer/src/derivers-bigint.js'; diff --git a/src/lib/base58.ts b/src/lib/util/base58.ts similarity index 95% rename from src/lib/base58.ts rename to src/lib/util/base58.ts index 778540a263..5862cc2862 100644 --- a/src/lib/base58.ts +++ b/src/lib/util/base58.ts @@ -1,7 +1,7 @@ -import { versionBytes } from '../bindings/crypto/constants.js'; -import { Binable, withVersionNumber } from '../bindings/lib/binable.js'; +import { versionBytes } from '../../bindings/crypto/constants.js'; +import { Binable, withVersionNumber } from '../../bindings/lib/binable.js'; import { sha256 } from 'js-sha256'; -import { changeBase } from '../bindings/crypto/bigint-helpers.js'; +import { changeBase } from '../../bindings/crypto/bigint-helpers.js'; export { toBase58Check, diff --git a/src/lib/base58.unit-test.ts b/src/lib/util/base58.unit-test.ts similarity index 91% rename from src/lib/base58.unit-test.ts rename to src/lib/util/base58.unit-test.ts index 2d09307da6..dca4f6c1ac 100644 --- a/src/lib/base58.unit-test.ts +++ b/src/lib/util/base58.unit-test.ts @@ -1,7 +1,7 @@ import { fromBase58Check, toBase58Check } from './base58.js'; -import { Test } from '../snarky.js'; +import { Test } from '../../snarky.js'; import { expect } from 'expect'; -import { test, Random, withHardCoded } from './testing/property.js'; +import { test, Random, withHardCoded } from '../testing/property.js'; let bytes = withHardCoded( Random.bytes(Random.nat(100)), diff --git a/src/lib/errors.ts b/src/lib/util/errors.ts similarity index 100% rename from src/lib/errors.ts rename to src/lib/util/errors.ts diff --git a/src/lib/global-context.ts b/src/lib/util/global-context.ts similarity index 100% rename from src/lib/global-context.ts rename to src/lib/util/global-context.ts diff --git a/src/lib/util/types.ts b/src/lib/util/types.ts index 3256e60476..2bc40500d1 100644 --- a/src/lib/util/types.ts +++ b/src/lib/util/types.ts @@ -1,4 +1,4 @@ -import { assert } from '../errors.js'; +import { assert } from './errors.js'; export { AnyFunction, Tuple, TupleN, AnyTuple, TupleMap }; diff --git a/src/mina-signer/src/curve-bigint.ts b/src/mina-signer/src/curve-bigint.ts index c848eb468e..79e6708594 100644 --- a/src/mina-signer/src/curve-bigint.ts +++ b/src/mina-signer/src/curve-bigint.ts @@ -9,7 +9,7 @@ import { withCheck, withVersionNumber, } from '../../bindings/lib/binable.js'; -import { base58, withBase58 } from '../../lib/base58.js'; +import { base58, withBase58 } from '../../lib/util/base58.js'; import { Bool, checkRange, Field, pseudoClass } from './field-bigint.js'; import { BinableBigint, SignableBigint, signable } from './derivers-bigint.js'; import { HashInputLegacy } from './poseidon-bigint.js'; diff --git a/src/mina-signer/src/memo.ts b/src/mina-signer/src/memo.ts index 087d5834f0..ad58c4353e 100644 --- a/src/mina-signer/src/memo.ts +++ b/src/mina-signer/src/memo.ts @@ -6,7 +6,7 @@ import { stringToBytes, withBits, } from '../../bindings/lib/binable.js'; -import { base58 } from '../../lib/base58.js'; +import { base58 } from '../../lib/util/base58.js'; import { HashInputLegacy, hashWithPrefix, diff --git a/src/mina-signer/src/sign-zkapp-command.unit-test.ts b/src/mina-signer/src/sign-zkapp-command.unit-test.ts index 9d4750242a..cf0739f5a4 100644 --- a/src/mina-signer/src/sign-zkapp-command.unit-test.ts +++ b/src/mina-signer/src/sign-zkapp-command.unit-test.ts @@ -10,10 +10,10 @@ import * as TypesSnarky from '../../bindings/mina-transaction/gen/transaction.js import { AccountUpdate as AccountUpdateSnarky, ZkappCommand as ZkappCommandSnarky, -} from '../../lib/account-update.js'; +} from '../../lib/mina/account-update.js'; import { FieldConst } from '../../lib/provable-core/fieldvar.js'; import { packToFields as packToFieldsSnarky } from '../../lib/hash.js'; -import { Network, setActiveInstance } from '../../lib/mina.js'; +import { Network, setActiveInstance } from '../../lib/mina/mina.js'; import { Ml, MlHashInput } from '../../lib/ml/conversion.js'; import { PrivateKey as PrivateKeySnarky, diff --git a/src/mina-signer/src/signature.ts b/src/mina-signer/src/signature.ts index c8e42bd22d..bd3d384978 100644 --- a/src/mina-signer/src/signature.ts +++ b/src/mina-signer/src/signature.ts @@ -24,7 +24,7 @@ import { record, withVersionNumber, } from '../../bindings/lib/binable.js'; -import { base58 } from '../../lib/base58.js'; +import { base58 } from '../../lib/util/base58.js'; import { versionBytes } from '../../bindings/crypto/constants.js'; import { Pallas } from '../../bindings/crypto/elliptic-curve.js'; import { NetworkId } from './types.js'; diff --git a/src/mina-signer/src/transaction-hash.ts b/src/mina-signer/src/transaction-hash.ts index 495b36b7bd..1bc923082a 100644 --- a/src/mina-signer/src/transaction-hash.ts +++ b/src/mina-signer/src/transaction-hash.ts @@ -24,7 +24,7 @@ import { import { PublicKey, Scalar } from './curve-bigint.js'; import { Signature, SignatureJson } from './signature.js'; import { blake2b } from 'blakejs'; -import { base58, withBase58 } from '../../lib/base58.js'; +import { base58, withBase58 } from '../../lib/util/base58.js'; import { versionBytes } from '../../bindings/crypto/constants.js'; export { diff --git a/src/mina-signer/tests/zkapp.unit-test.ts b/src/mina-signer/tests/zkapp.unit-test.ts index 0cd8a636c3..165ab7fb0f 100644 --- a/src/mina-signer/tests/zkapp.unit-test.ts +++ b/src/mina-signer/tests/zkapp.unit-test.ts @@ -3,7 +3,7 @@ import * as TransactionJson from '../../bindings/mina-transaction/gen/transactio import Client from '../mina-signer.js'; import { accountUpdateExample } from '../src/test-vectors/accountUpdate.js'; import { expect } from 'expect'; -import { Transaction } from '../../lib/mina.js'; +import { Transaction } from '../../lib/mina/mina.js'; import { PrivateKey } from '../../lib/signature.js'; import { Signature } from '../src/signature.js'; import { mocks } from '../../bindings/crypto/constants.js'; From f25c6e72c178268d670ac61cdc53119afb954d39 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 12:07:46 +0100 Subject: [PATCH 2/7] mina stuff i forgot --- src/lib/{ => mina}/hash-input.unit-test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename src/lib/{ => mina}/hash-input.unit-test.ts (89%) diff --git a/src/lib/hash-input.unit-test.ts b/src/lib/mina/hash-input.unit-test.ts similarity index 89% rename from src/lib/hash-input.unit-test.ts rename to src/lib/mina/hash-input.unit-test.ts index 123fd2f436..4879b2475d 100644 --- a/src/lib/hash-input.unit-test.ts +++ b/src/lib/mina/hash-input.unit-test.ts @@ -3,18 +3,18 @@ import { Types, Permissions, ProvableExtended, -} from '../index.js'; +} from '../../index.js'; import { expect } from 'expect'; -import { jsLayout } from '../bindings/mina-transaction/gen/js-layout.js'; +import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; import { Json, provableFromLayout, -} from '../bindings/mina-transaction/gen/transaction.js'; -import { packToFields } from './hash.js'; -import { Random, test } from './testing/property.js'; -import { MlHashInput } from './ml/conversion.js'; -import { MlFieldConstArray } from './ml/fields.js'; -import { Test } from '../snarky.js'; +} from '../../bindings/mina-transaction/gen/transaction.js'; +import { packToFields } from '../hash.js'; +import { Random, test } from '../testing/property.js'; +import { MlHashInput } from '../ml/conversion.js'; +import { MlFieldConstArray } from '../ml/fields.js'; +import { Test } from '../../snarky.js'; let { hashInputFromJson } = Test; From 5d5cce887a0afe6172bc17d88f8767da745a5489 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 12:26:33 +0100 Subject: [PATCH 3/7] proof system stuff into its folder --- src/index.ts | 13 ++++--- src/lib/foreign-field.unit-test.ts | 2 +- src/lib/gadgets/arithmetic.unit-test.ts | 2 +- src/lib/gadgets/bitwise.unit-test.ts | 2 +- src/lib/gadgets/ecdsa.unit-test.ts | 2 +- src/lib/gadgets/foreign-field.unit-test.ts | 2 +- src/lib/gadgets/range-check.unit-test.ts | 2 +- src/lib/gadgets/sha256.unit-test.ts | 2 +- src/lib/keccak.unit-test.ts | 2 +- src/lib/mina/account-update.ts | 7 +++- src/lib/mina/transaction-validation.ts | 2 +- src/lib/mina/transaction.ts | 2 +- src/lib/mina/zkapp.ts | 2 +- src/lib/primitives.unit-test.ts | 2 +- src/lib/{ => proof-system}/circuit.ts | 14 ++++---- .../proof-system.unit-test.ts | 22 ++++++------ src/lib/proof-system/prover-keys.ts | 2 +- .../zkprogram.ts} | 35 ++++++++++--------- src/lib/provable-types/struct.ts | 2 +- src/lib/testing/constraint-system.ts | 2 +- .../tests/verify-in-snark.unit-test.ts | 2 +- 21 files changed, 68 insertions(+), 55 deletions(-) rename src/lib/{ => proof-system}/circuit.ts (94%) rename src/lib/{ => proof-system}/proof-system.unit-test.ts (86%) rename src/lib/{proof-system.ts => proof-system/zkprogram.ts} (97%) diff --git a/src/index.ts b/src/index.ts index e12f591730..41a83ea63e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,12 @@ export type { export { provable, provablePure, Struct } from './lib/provable-types/struct.js'; export { Unconstrained } from './lib/provable-types/unconstrained.js'; export { Provable } from './lib/provable.js'; -export { Circuit, Keypair, public_, circuitMain } from './lib/circuit.js'; +export { + Circuit, + Keypair, + public_, + circuitMain, +} from './lib/proof-system/circuit.js'; export { UInt32, UInt64, Int64, Sign, UInt8 } from './lib/int.js'; export { Bytes } from './lib/provable-types/provable-types.js'; export { Packed, Hashed } from './lib/provable-types/packed.js'; @@ -54,7 +59,7 @@ export { } from './lib/mina/zkapp.js'; export { state, State, declareState } from './lib/mina/state.js'; -export type { JsonProof } from './lib/proof-system.js'; +export type { JsonProof } from './lib/proof-system/zkprogram.js'; export { Proof, SelfProof, @@ -63,7 +68,7 @@ export { Undefined, Void, VerificationKey, -} from './lib/proof-system.js'; +} from './lib/proof-system/zkprogram.js'; export { Cache, CacheHeader } from './lib/proof-system/cache.js'; export { @@ -104,7 +109,7 @@ export { export { Nullifier } from './lib/nullifier.js'; -export { ZkProgram } from './lib/proof-system.js'; +export { ZkProgram } from './lib/proof-system/zkprogram.js'; export { Crypto } from './lib/crypto.js'; diff --git a/src/lib/foreign-field.unit-test.ts b/src/lib/foreign-field.unit-test.ts index 3d8da573ca..24e171ecd1 100644 --- a/src/lib/foreign-field.unit-test.ts +++ b/src/lib/foreign-field.unit-test.ts @@ -14,7 +14,7 @@ import { } from './testing/equivalent.js'; import { test, Random } from './testing/property.js'; import { Provable } from './provable.js'; -import { Circuit, circuitMain } from './circuit.js'; +import { Circuit, circuitMain } from './proof-system/circuit.js'; import { Scalar } from './scalar.js'; import { l } from './gadgets/range-check.js'; import { assert } from './gadgets/common.js'; diff --git a/src/lib/gadgets/arithmetic.unit-test.ts b/src/lib/gadgets/arithmetic.unit-test.ts index 9c6c7a4322..121a09e9a7 100644 --- a/src/lib/gadgets/arithmetic.unit-test.ts +++ b/src/lib/gadgets/arithmetic.unit-test.ts @@ -1,4 +1,4 @@ -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { equivalentProvable as equivalent, equivalentAsync, diff --git a/src/lib/gadgets/bitwise.unit-test.ts b/src/lib/gadgets/bitwise.unit-test.ts index 7b0ef73b42..f3c7270673 100644 --- a/src/lib/gadgets/bitwise.unit-test.ts +++ b/src/lib/gadgets/bitwise.unit-test.ts @@ -1,4 +1,4 @@ -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { equivalentProvable as equivalent, equivalentAsync, diff --git a/src/lib/gadgets/ecdsa.unit-test.ts b/src/lib/gadgets/ecdsa.unit-test.ts index 138d6c8d3d..2d89ec8458 100644 --- a/src/lib/gadgets/ecdsa.unit-test.ts +++ b/src/lib/gadgets/ecdsa.unit-test.ts @@ -9,7 +9,7 @@ import { import { Field3 } from './foreign-field.js'; import { CurveParams } from '../../bindings/crypto/elliptic-curve-examples.js'; import { Provable } from '../provable.js'; -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { assert } from './common.js'; import { foreignField, uniformForeignField } from './test-utils.js'; import { diff --git a/src/lib/gadgets/foreign-field.unit-test.ts b/src/lib/gadgets/foreign-field.unit-test.ts index 7147a9a478..da57ab05d9 100644 --- a/src/lib/gadgets/foreign-field.unit-test.ts +++ b/src/lib/gadgets/foreign-field.unit-test.ts @@ -11,7 +11,7 @@ import { } from '../testing/equivalent.js'; import { Random } from '../testing/random.js'; import { Field3, Gadgets } from './gadgets.js'; -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { Provable } from '../provable.js'; import { assert } from './common.js'; import { diff --git a/src/lib/gadgets/range-check.unit-test.ts b/src/lib/gadgets/range-check.unit-test.ts index b9665caed7..fec7973b86 100644 --- a/src/lib/gadgets/range-check.unit-test.ts +++ b/src/lib/gadgets/range-check.unit-test.ts @@ -1,6 +1,6 @@ import { mod } from '../../bindings/crypto/finite-field.js'; import { Field } from '../../lib/core.js'; -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { Spec, boolean, diff --git a/src/lib/gadgets/sha256.unit-test.ts b/src/lib/gadgets/sha256.unit-test.ts index dbb5954a45..1ccbf2ef91 100644 --- a/src/lib/gadgets/sha256.unit-test.ts +++ b/src/lib/gadgets/sha256.unit-test.ts @@ -1,4 +1,4 @@ -import { ZkProgram } from '../proof-system.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { Bytes } from '../provable-types/provable-types.js'; import { Gadgets } from './gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; diff --git a/src/lib/keccak.unit-test.ts b/src/lib/keccak.unit-test.ts index 60c2aa45e8..066698313e 100644 --- a/src/lib/keccak.unit-test.ts +++ b/src/lib/keccak.unit-test.ts @@ -1,5 +1,5 @@ import { Keccak } from './keccak.js'; -import { ZkProgram } from './proof-system.js'; +import { ZkProgram } from './proof-system/zkprogram.js'; import { equivalentProvable, equivalent, diff --git a/src/lib/mina/account-update.ts b/src/lib/mina/account-update.ts index 1c95bb5553..a48f1d625d 100644 --- a/src/lib/mina/account-update.ts +++ b/src/lib/mina/account-update.ts @@ -27,7 +27,12 @@ import { ClosedInterval, getAccountPreconditions, } from './precondition.js'; -import { dummyBase64Proof, Empty, Proof, Prover } from '../proof-system.js'; +import { + dummyBase64Proof, + Empty, + Proof, + Prover, +} from '../proof-system/zkprogram.js'; import { Memo } from '../../mina-signer/src/memo.js'; import { Events, diff --git a/src/lib/mina/transaction-validation.ts b/src/lib/mina/transaction-validation.ts index be14ff4298..a162c72c5c 100644 --- a/src/lib/mina/transaction-validation.ts +++ b/src/lib/mina/transaction-validation.ts @@ -12,7 +12,7 @@ import { import { Field } from '../core.js'; import { UInt64, UInt32 } from '../int.js'; import { PublicKey } from '../signature.js'; -import { JsonProof, verify } from '../proof-system.js'; +import { JsonProof, verify } from '../proof-system/zkprogram.js'; import { verifyAccountUpdateSignature } from '../../mina-signer/src/sign-zkapp-command.js'; import { TransactionCost, TransactionLimits } from './constants.js'; import { cloneCircuitValue } from '../provable-types/struct.js'; diff --git a/src/lib/mina/transaction.ts b/src/lib/mina/transaction.ts index 5feaabe56f..f79ead286b 100644 --- a/src/lib/mina/transaction.ts +++ b/src/lib/mina/transaction.ts @@ -11,7 +11,7 @@ import { import { Field } from '../core.js'; import { PrivateKey, PublicKey } from '../signature.js'; import { UInt32, UInt64 } from '../int.js'; -import { Empty, Proof } from '../proof-system.js'; +import { Empty, Proof } from '../proof-system/zkprogram.js'; import { currentTransaction } from './transaction-context.js'; import { Provable } from '../provable.js'; import { assertPreconditionInvariants } from './precondition.js'; diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index c4369a65de..515a5d132a 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -50,7 +50,7 @@ import { MethodInterface, Proof, sortMethodArguments, -} from '../proof-system.js'; +} from '../proof-system/zkprogram.js'; import { PrivateKey, PublicKey } from '../signature.js'; import { assertStatePrecondition, cleanStatePrecondition } from './state.js'; import { diff --git a/src/lib/primitives.unit-test.ts b/src/lib/primitives.unit-test.ts index 6344ddb9f9..fa206b2699 100644 --- a/src/lib/primitives.unit-test.ts +++ b/src/lib/primitives.unit-test.ts @@ -1,4 +1,4 @@ -import { Circuit, circuitMain } from './circuit.js'; +import { Circuit, circuitMain } from './proof-system/circuit.js'; import { UInt64, UInt32 } from './int.js'; import { expect } from 'expect'; import { Provable } from './provable.js'; diff --git a/src/lib/circuit.ts b/src/lib/proof-system/circuit.ts similarity index 94% rename from src/lib/circuit.ts rename to src/lib/proof-system/circuit.ts index 399ed17864..b118e44658 100644 --- a/src/lib/circuit.ts +++ b/src/lib/proof-system/circuit.ts @@ -1,14 +1,14 @@ import 'reflect-metadata'; -import { Snarky } from '../snarky.js'; -import { MlFieldArray, MlFieldConstArray } from './ml/fields.js'; -import { withThreadPool } from '../snarky.js'; -import { Provable } from './provable.js'; -import { snarkContext, gatesFromJson } from './provable-context.js'; +import { Snarky } from '../../snarky.js'; +import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; +import { withThreadPool } from '../../snarky.js'; +import { Provable } from '../provable.js'; +import { snarkContext, gatesFromJson } from '../provable-context.js'; import { prettifyStacktrace, prettifyStacktracePromise, -} from './util/errors.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +} from '../util/errors.js'; +import { ProvablePure } from '../provable-types/provable-intf.js'; // external API export { public_, circuitMain, Circuit, Keypair, Proof, VerificationKey }; diff --git a/src/lib/proof-system.unit-test.ts b/src/lib/proof-system/proof-system.unit-test.ts similarity index 86% rename from src/lib/proof-system.unit-test.ts rename to src/lib/proof-system/proof-system.unit-test.ts index d8882adc00..892bf751ed 100644 --- a/src/lib/proof-system.unit-test.ts +++ b/src/lib/proof-system/proof-system.unit-test.ts @@ -1,6 +1,6 @@ -import { Field, Bool } from './core.js'; -import { Struct } from './provable-types/struct.js'; -import { UInt64 } from './int.js'; +import { Field, Bool } from '../core.js'; +import { Struct } from '../provable-types/struct.js'; +import { UInt64 } from '../int.js'; import { CompiledTag, Empty, @@ -8,16 +8,16 @@ import { ZkProgram, picklesRuleFromFunction, sortMethodArguments, -} from './proof-system.js'; +} from './zkprogram.js'; import { expect } from 'expect'; -import { Pickles, Snarky } from '../snarky.js'; -import { AnyFunction } from './util/types.js'; -import { snarkContext } from './provable-context.js'; +import { Pickles, Snarky } from '../../snarky.js'; +import { AnyFunction } from '../util/types.js'; +import { snarkContext } from '../provable-context.js'; import { it } from 'node:test'; -import { Provable } from './provable.js'; -import { bool, equivalentAsync, field, record } from './testing/equivalent.js'; -import { FieldVar, FieldConst } from './provable-core/fieldvar.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +import { Provable } from '../provable.js'; +import { bool, equivalentAsync, field, record } from '../testing/equivalent.js'; +import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; +import { ProvablePure } from '../provable-types/provable-intf.js'; const EmptyProgram = ZkProgram({ name: 'empty', diff --git a/src/lib/proof-system/prover-keys.ts b/src/lib/proof-system/prover-keys.ts index 484a84aac2..7793532eb1 100644 --- a/src/lib/proof-system/prover-keys.ts +++ b/src/lib/proof-system/prover-keys.ts @@ -14,7 +14,7 @@ import { VerifierIndex } from '../../bindings/crypto/bindings/kimchi-types.js'; import { getRustConversion } from '../../bindings/crypto/bindings.js'; import { MlString } from '../ml/base.js'; import { CacheHeader, cacheHeaderVersion } from './cache.js'; -import type { MethodInterface } from '../proof-system.js'; +import type { MethodInterface } from './zkprogram.js'; export { parseHeader, diff --git a/src/lib/proof-system.ts b/src/lib/proof-system/zkprogram.ts similarity index 97% rename from src/lib/proof-system.ts rename to src/lib/proof-system/zkprogram.ts index bf2e0d3899..85674f751c 100644 --- a/src/lib/proof-system.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -2,16 +2,16 @@ import { EmptyNull, EmptyUndefined, EmptyVoid, -} from '../bindings/lib/generic.js'; -import { withThreadPool } from '../snarky.js'; +} from '../../bindings/lib/generic.js'; +import { withThreadPool } from '../../snarky.js'; import { Pickles, FeatureFlags, MlFeatureFlags, Gate, GateType, -} from '../snarky.js'; -import { Field, Bool } from './core.js'; +} from '../../snarky.js'; +import { Field, Bool } from '../core.js'; import { FlexibleProvable, FlexibleProvablePure, @@ -20,22 +20,25 @@ import { Struct, provable, provablePure, -} from './provable-types/struct.js'; -import { Provable } from './provable.js'; -import { assert, prettifyStacktracePromise } from './util/errors.js'; -import { snarkContext } from './provable-context.js'; -import { hashConstant } from './hash.js'; -import { MlArray, MlBool, MlResult, MlPair } from './ml/base.js'; -import { MlFieldArray, MlFieldConstArray } from './ml/fields.js'; -import { FieldVar, FieldConst } from './provable-core/fieldvar.js'; -import { Cache, readCache, writeCache } from './proof-system/cache.js'; +} from '../provable-types/struct.js'; +import { Provable } from '../provable.js'; +import { assert, prettifyStacktracePromise } from '../util/errors.js'; +import { snarkContext } from '../provable-context.js'; +import { hashConstant } from '../hash.js'; +import { MlArray, MlBool, MlResult, MlPair } from '../ml/base.js'; +import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; +import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; +import { Cache, readCache, writeCache } from './cache.js'; import { decodeProverKey, encodeProverKey, parseHeader, -} from './proof-system/prover-keys.js'; -import { setSrsCache, unsetSrsCache } from '../bindings/crypto/bindings/srs.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +} from './prover-keys.js'; +import { + setSrsCache, + unsetSrsCache, +} from '../../bindings/crypto/bindings/srs.js'; +import { ProvablePure } from '../provable-types/provable-intf.js'; // public API export { diff --git a/src/lib/provable-types/struct.ts b/src/lib/provable-types/struct.ts index 7d41286db3..e4bf6e7893 100644 --- a/src/lib/provable-types/struct.ts +++ b/src/lib/provable-types/struct.ts @@ -13,7 +13,7 @@ import type { IsPure, } from './provable-derivers.js'; import { Provable } from '../provable.js'; -import { Proof } from '../proof-system.js'; +import { Proof } from '../proof-system/zkprogram.js'; import { ProvablePure } from './provable-intf.js'; // external API diff --git a/src/lib/testing/constraint-system.ts b/src/lib/testing/constraint-system.ts index 8f6e406a3d..dc174ac2fd 100644 --- a/src/lib/testing/constraint-system.ts +++ b/src/lib/testing/constraint-system.ts @@ -12,7 +12,7 @@ import { Provable } from '../provable.js'; import { Tuple } from '../util/types.js'; import { Random } from './random.js'; import { test } from './property.js'; -import { Undefined, ZkProgram } from '../proof-system.js'; +import { Undefined, ZkProgram } from '../proof-system/zkprogram.js'; import { constraintSystemSync, printGates } from '../provable-context.js'; export { diff --git a/src/mina-signer/tests/verify-in-snark.unit-test.ts b/src/mina-signer/tests/verify-in-snark.unit-test.ts index 02e692fc88..bd4d401882 100644 --- a/src/mina-signer/tests/verify-in-snark.unit-test.ts +++ b/src/mina-signer/tests/verify-in-snark.unit-test.ts @@ -1,5 +1,5 @@ import { Field } from '../../lib/core.js'; -import { ZkProgram } from '../../lib/proof-system.js'; +import { ZkProgram } from '../../lib/proof-system/zkprogram.js'; import Client from '../mina-signer.js'; import { PrivateKey, Signature } from '../../lib/signature.js'; import { expect } from 'expect'; From ae05d5b03106e539be4d6be8b6d5b623f69dc941 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 13:57:35 +0100 Subject: [PATCH 4/7] all provable code in lib subfolder --- src/bindings | 2 +- src/index.ts | 59 +++++++++++-------- .../mina/account-update-layout.unit-test.ts | 2 +- src/lib/mina/account-update.ts | 22 ++++--- src/lib/mina/account.ts | 8 +-- src/lib/mina/base58-encodings.ts | 2 +- src/lib/mina/errors.ts | 2 +- src/lib/mina/fetch.ts | 6 +- src/lib/mina/graphql.ts | 2 +- src/lib/mina/hash-input.unit-test.ts | 2 +- src/lib/mina/local-blockchain.ts | 6 +- src/lib/mina/mina-instance.ts | 6 +- src/lib/mina/mina.ts | 6 +- src/lib/mina/precondition.ts | 12 ++-- src/lib/mina/state.ts | 10 ++-- src/lib/mina/token/forest-iterator.ts | 10 ++-- .../mina/token/forest-iterator.unit-test.ts | 4 +- src/lib/mina/token/token-contract.ts | 8 +-- src/lib/mina/token/token-methods.ts | 6 +- src/lib/mina/transaction-context.ts | 2 +- src/lib/mina/transaction-logic/ledger.ts | 4 +- src/lib/mina/transaction-validation.ts | 10 ++-- src/lib/mina/transaction.ts | 8 +-- src/lib/mina/zkapp.ts | 23 ++++---- src/lib/ml/consistency.unit-test.ts | 10 ++-- src/lib/ml/conversion.ts | 10 ++-- src/lib/ml/fields.ts | 4 +- src/lib/proof-system/circuit.ts | 6 +- .../proof-system/proof-system.unit-test.ts | 14 ++--- src/lib/proof-system/zkprogram.ts | 14 ++--- src/lib/{ => provable}/bool.ts | 12 ++-- src/lib/{ => provable}/core.ts | 0 .../core}/exists.ts | 8 +-- .../core}/field-constructor.ts | 0 .../core}/fieldvar.ts | 2 +- src/lib/{ => provable}/crypto.ts | 4 +- src/lib/{ => provable}/encryption.ts | 0 src/lib/{ => provable}/field.ts | 18 +++--- src/lib/{ => provable}/field.unit-test.ts | 16 ++--- src/lib/{ => provable}/foreign-curve.ts | 6 +- .../{ => provable}/foreign-curve.unit-test.ts | 4 +- src/lib/{ => provable}/foreign-ecdsa.ts | 8 +-- src/lib/{ => provable}/foreign-field.ts | 6 +- .../{ => provable}/foreign-field.unit-test.ts | 12 ++-- src/lib/{ => provable}/gadgets/arithmetic.ts | 4 +- .../gadgets/arithmetic.unit-test.ts | 6 +- src/lib/{ => provable}/gadgets/basic.ts | 8 +-- src/lib/{ => provable}/gadgets/bit-slices.ts | 6 +- src/lib/{ => provable}/gadgets/bitwise.ts | 4 +- .../gadgets/bitwise.unit-test.ts | 12 ++-- src/lib/{ => provable}/gadgets/common.ts | 6 +- src/lib/{ => provable}/gadgets/compatible.ts | 6 +- .../{ => provable}/gadgets/ecdsa.unit-test.ts | 12 ++-- .../{ => provable}/gadgets/elliptic-curve.ts | 14 ++--- .../gadgets/elliptic-curve.unit-test.ts | 8 +-- .../{ => provable}/gadgets/foreign-field.ts | 12 ++-- .../gadgets/foreign-field.unit-test.ts | 16 ++--- src/lib/{ => provable}/gadgets/gadgets.ts | 0 src/lib/{ => provable}/gadgets/range-check.ts | 8 +-- .../gadgets/range-check.unit-test.ts | 12 ++-- src/lib/{ => provable}/gadgets/sha256.ts | 12 ++-- .../gadgets/sha256.unit-test.ts | 11 ++-- src/lib/{ => provable}/gadgets/test-utils.ts | 8 +-- src/lib/{ => provable}/gates.ts | 10 ++-- src/lib/{ => provable}/group.test.ts | 0 src/lib/{ => provable}/group.ts | 8 +-- src/lib/{ => provable}/group.unit-test.ts | 4 +- src/lib/{ => provable}/hash-generic.ts | 4 +- src/lib/{ => provable}/hash.ts | 16 ++--- src/lib/{ => provable}/hashes-combined.ts | 2 +- src/lib/{ => provable}/int.test.ts | 0 src/lib/{ => provable}/int.ts | 8 +-- src/lib/{ => provable}/keccak.ts | 6 +- src/lib/{ => provable}/keccak.unit-test.ts | 8 +-- src/lib/{ => provable}/nullifier.ts | 6 +- src/lib/{ => provable}/nullifier.unit-test.ts | 2 +- src/lib/{ => provable}/primitives.test.ts | 0 .../{ => provable}/primitives.unit-test.ts | 2 +- src/lib/{ => provable}/provable-context.ts | 12 ++-- src/lib/{ => provable}/provable.test.ts | 0 src/lib/{ => provable}/provable.ts | 13 ++-- src/lib/{ => provable}/provable.unit-test.ts | 2 +- src/lib/{ => provable}/scalar.test.ts | 0 src/lib/{ => provable}/scalar.ts | 10 ++-- src/lib/{ => provable}/signature.ts | 10 ++-- .../types}/auxiliary.ts | 0 .../types}/bytes.ts | 4 +- .../types}/circuit-value.ts | 0 .../types}/fields.ts | 0 .../types}/merkle-list.ts | 0 .../types}/merkle-map.test.ts | 0 .../types}/merkle-map.ts | 0 .../types}/merkle-tree.test.ts | 0 .../types}/merkle-tree.ts | 0 .../types}/merkle-tree.unit-test.ts | 2 +- .../types}/packed.ts | 0 .../types}/provable-derivers.ts | 6 +- .../types}/provable-intf.ts | 0 .../types}/provable-types.ts | 0 .../types}/string.test.ts | 0 .../types}/string.ts | 0 .../types}/struct.ts | 2 +- .../types}/struct.unit-test.ts | 8 +-- .../types}/unconstrained.ts | 4 +- src/lib/testing/constraint-system.ts | 11 ++-- src/lib/testing/equivalent.ts | 10 ++-- src/lib/util/arrays.ts | 2 +- src/mina-signer/src/poseidon-bigint.ts | 2 +- .../src/sign-zkapp-command.unit-test.ts | 6 +- src/mina-signer/src/signature.unit-test.ts | 4 +- .../tests/verify-in-snark.unit-test.ts | 6 +- src/mina-signer/tests/zkapp.unit-test.ts | 2 +- src/snarky.d.ts | 12 ++-- 113 files changed, 379 insertions(+), 366 deletions(-) rename src/lib/{ => provable}/bool.ts (96%) rename src/lib/{ => provable}/core.ts (100%) rename src/lib/{provable-core => provable/core}/exists.ts (93%) rename src/lib/{provable-core => provable/core}/field-constructor.ts (100%) rename src/lib/{provable-core => provable/core}/fieldvar.ts (98%) rename src/lib/{ => provable}/crypto.ts (80%) rename src/lib/{ => provable}/encryption.ts (100%) rename src/lib/{ => provable}/field.ts (98%) rename src/lib/{ => provable}/field.unit-test.ts (93%) rename src/lib/{ => provable}/foreign-curve.ts (97%) rename src/lib/{ => provable}/foreign-curve.unit-test.ts (91%) rename src/lib/{ => provable}/foreign-ecdsa.ts (97%) rename src/lib/{ => provable}/foreign-field.ts (99%) rename src/lib/{ => provable}/foreign-field.unit-test.ts (94%) rename src/lib/{ => provable}/gadgets/arithmetic.ts (91%) rename src/lib/{ => provable}/gadgets/arithmetic.unit-test.ts (89%) rename src/lib/{ => provable}/gadgets/basic.ts (97%) rename src/lib/{ => provable}/gadgets/bit-slices.ts (96%) rename src/lib/{ => provable}/gadgets/bitwise.ts (98%) rename src/lib/{ => provable}/gadgets/bitwise.unit-test.ts (95%) rename src/lib/{ => provable}/gadgets/common.ts (91%) rename src/lib/{ => provable}/gadgets/compatible.ts (97%) rename src/lib/{ => provable}/gadgets/ecdsa.unit-test.ts (93%) rename src/lib/{ => provable}/gadgets/elliptic-curve.ts (98%) rename src/lib/{ => provable}/gadgets/elliptic-curve.unit-test.ts (89%) rename src/lib/{ => provable}/gadgets/foreign-field.ts (98%) rename src/lib/{ => provable}/gadgets/foreign-field.unit-test.ts (95%) rename src/lib/{ => provable}/gadgets/gadgets.ts (100%) rename src/lib/{ => provable}/gadgets/range-check.ts (97%) rename src/lib/{ => provable}/gadgets/range-check.unit-test.ts (92%) rename src/lib/{ => provable}/gadgets/sha256.ts (96%) rename src/lib/{ => provable}/gadgets/sha256.unit-test.ts (87%) rename src/lib/{ => provable}/gadgets/test-utils.ts (86%) rename src/lib/{ => provable}/gates.ts (95%) rename src/lib/{ => provable}/group.test.ts (100%) rename src/lib/{ => provable}/group.ts (97%) rename src/lib/{ => provable}/group.unit-test.ts (94%) rename src/lib/{ => provable}/hash-generic.ts (84%) rename src/lib/{ => provable}/hash.ts (94%) rename src/lib/{ => provable}/hashes-combined.ts (98%) rename src/lib/{ => provable}/int.test.ts (100%) rename src/lib/{ => provable}/int.ts (99%) rename src/lib/{ => provable}/keccak.ts (99%) rename src/lib/{ => provable}/keccak.unit-test.ts (97%) rename src/lib/{ => provable}/nullifier.ts (97%) rename src/lib/{ => provable}/nullifier.unit-test.ts (95%) rename src/lib/{ => provable}/primitives.test.ts (100%) rename src/lib/{ => provable}/primitives.unit-test.ts (91%) rename src/lib/{ => provable}/provable-context.ts (94%) rename src/lib/{ => provable}/provable.test.ts (100%) rename src/lib/{ => provable}/provable.ts (98%) rename src/lib/{ => provable}/provable.unit-test.ts (91%) rename src/lib/{ => provable}/scalar.test.ts (100%) rename src/lib/{ => provable}/scalar.ts (97%) rename src/lib/{ => provable}/signature.ts (97%) rename src/lib/{provable-types => provable/types}/auxiliary.ts (100%) rename src/lib/{provable-types => provable/types}/bytes.ts (96%) rename src/lib/{provable-types => provable/types}/circuit-value.ts (100%) rename src/lib/{provable-types => provable/types}/fields.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-list.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-map.test.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-map.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-tree.test.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-tree.ts (100%) rename src/lib/{provable-types => provable/types}/merkle-tree.unit-test.ts (89%) rename src/lib/{provable-types => provable/types}/packed.ts (100%) rename src/lib/{provable-types => provable/types}/provable-derivers.ts (93%) rename src/lib/{provable-types => provable/types}/provable-intf.ts (100%) rename src/lib/{provable-types => provable/types}/provable-types.ts (100%) rename src/lib/{provable-types => provable/types}/string.test.ts (100%) rename src/lib/{provable-types => provable/types}/string.ts (100%) rename src/lib/{provable-types => provable/types}/struct.ts (99%) rename src/lib/{provable-types => provable/types}/struct.unit-test.ts (95%) rename src/lib/{provable-types => provable/types}/unconstrained.ts (97%) diff --git a/src/bindings b/src/bindings index a49252882e..4c2d2e01ee 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit a49252882e66d078b4d77cba679c2e22932def96 +Subproject commit 4c2d2e01ee6dd3215d29cd39440ca1b13cf4b16a diff --git a/src/index.ts b/src/index.ts index 41a83ea63e..6722a4ea7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,46 +1,53 @@ -export type { ProvablePure } from './lib/provable-types/provable-intf.js'; +export type { ProvablePure } from './lib/provable/types/provable-intf.js'; export { Ledger } from './snarky.js'; -export { Field, Bool, Group, Scalar } from './lib/core.js'; +export { Field, Bool, Group, Scalar } from './lib/provable/core.js'; export { createForeignField, ForeignField, AlmostForeignField, CanonicalForeignField, -} from './lib/foreign-field.js'; -export { createForeignCurve, ForeignCurve } from './lib/foreign-curve.js'; -export { createEcdsa, EcdsaSignature } from './lib/foreign-ecdsa.js'; -export { Poseidon, TokenSymbol, ProvableHashable } from './lib/hash.js'; -export { Keccak } from './lib/keccak.js'; -export { Hash } from './lib/hashes-combined.js'; +} from './lib/provable/foreign-field.js'; +export { + createForeignCurve, + ForeignCurve, +} from './lib/provable/foreign-curve.js'; +export { createEcdsa, EcdsaSignature } from './lib/provable/foreign-ecdsa.js'; +export { + Poseidon, + TokenSymbol, + ProvableHashable, +} from './lib/provable/hash.js'; +export { Keccak } from './lib/provable/keccak.js'; +export { Hash } from './lib/provable/hashes-combined.js'; -export { assert } from './lib/gadgets/common.js'; +export { assert } from './lib/provable/gadgets/common.js'; -export * from './lib/signature.js'; +export * from './lib/provable/signature.js'; export type { ProvableExtended, FlexibleProvable, FlexibleProvablePure, InferProvable, -} from './lib/provable-types/struct.js'; -export { provable, provablePure, Struct } from './lib/provable-types/struct.js'; -export { Unconstrained } from './lib/provable-types/unconstrained.js'; -export { Provable } from './lib/provable.js'; +} from './lib/provable/types/struct.js'; +export { provable, provablePure, Struct } from './lib/provable/types/struct.js'; +export { Unconstrained } from './lib/provable/types/unconstrained.js'; +export { Provable } from './lib/provable/provable.js'; export { Circuit, Keypair, public_, circuitMain, } from './lib/proof-system/circuit.js'; -export { UInt32, UInt64, Int64, Sign, UInt8 } from './lib/int.js'; -export { Bytes } from './lib/provable-types/provable-types.js'; -export { Packed, Hashed } from './lib/provable-types/packed.js'; -export { Gadgets } from './lib/gadgets/gadgets.js'; +export { UInt32, UInt64, Int64, Sign, UInt8 } from './lib/provable/int.js'; +export { Bytes } from './lib/provable/types/provable-types.js'; +export { Packed, Hashed } from './lib/provable/types/packed.js'; +export { Gadgets } from './lib/provable/gadgets/gadgets.js'; export { Types } from './bindings/mina-transaction/types.js'; export { MerkleList, MerkleListIterator, -} from './lib/provable-types/merkle-list.js'; +} from './lib/provable/types/merkle-list.js'; export * as Mina from './lib/mina/mina.js'; export { @@ -98,27 +105,27 @@ export { sendZkapp, Lightnet, } from './lib/mina/fetch.js'; -export * as Encryption from './lib/encryption.js'; +export * as Encryption from './lib/provable/encryption.js'; export * as Encoding from './bindings/lib/encoding.js'; -export { Character, CircuitString } from './lib/provable-types/string.js'; -export { MerkleTree, MerkleWitness } from './lib/provable-types/merkle-tree.js'; +export { Character, CircuitString } from './lib/provable/types/string.js'; +export { MerkleTree, MerkleWitness } from './lib/provable/types/merkle-tree.js'; export { MerkleMap, MerkleMapWitness, -} from './lib/provable-types/merkle-map.js'; +} from './lib/provable/types/merkle-map.js'; -export { Nullifier } from './lib/nullifier.js'; +export { Nullifier } from './lib/provable/nullifier.js'; export { ZkProgram } from './lib/proof-system/zkprogram.js'; -export { Crypto } from './lib/crypto.js'; +export { Crypto } from './lib/provable/crypto.js'; export type { NetworkId } from './mina-signer/mina-signer.js'; export { setNumberOfWorkers } from './lib/proof-system/workers.js'; // experimental APIs -import { memoizeWitness } from './lib/provable.js'; +import { memoizeWitness } from './lib/provable/provable.js'; export { Experimental }; const Experimental_ = { diff --git a/src/lib/mina/account-update-layout.unit-test.ts b/src/lib/mina/account-update-layout.unit-test.ts index 82d183c63e..2cce42f4b7 100644 --- a/src/lib/mina/account-update-layout.unit-test.ts +++ b/src/lib/mina/account-update-layout.unit-test.ts @@ -1,6 +1,6 @@ import { Mina } from '../../index.js'; import { AccountUpdate, AccountUpdateTree } from './account-update.js'; -import { UInt64 } from '../int.js'; +import { UInt64 } from '../provable/int.js'; import { SmartContract, method } from './zkapp.js'; // smart contract which creates an account update that has a child of its own diff --git a/src/lib/mina/account-update.ts b/src/lib/mina/account-update.ts index a48f1d625d..a6f3ac412c 100644 --- a/src/lib/mina/account-update.ts +++ b/src/lib/mina/account-update.ts @@ -4,9 +4,13 @@ import { provable, provablePure, StructNoJson, -} from '../provable-types/struct.js'; -import { memoizationContext, memoizeWitness, Provable } from '../provable.js'; -import { Field, Bool } from '../core.js'; +} from '../provable/types/struct.js'; +import { + memoizationContext, + memoizeWitness, + Provable, +} from '../provable/provable.js'; +import { Field, Bool } from '../provable/core.js'; import { Pickles, Test } from '../../snarky.js'; import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; import { @@ -14,8 +18,8 @@ import { TypesBigint, toJSONEssential, } from '../../bindings/mina-transaction/types.js'; -import { PrivateKey, PublicKey } from '../signature.js'; -import { UInt64, UInt32, Int64, Sign } from '../int.js'; +import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { UInt64, UInt32, Int64, Sign } from '../provable/int.js'; import type { SmartContract } from './zkapp.js'; import { Preconditions, @@ -39,7 +43,7 @@ import { Actions, } from '../../bindings/mina-transaction/transaction-leaves.js'; import { TokenId as Base58TokenId } from './base58-encodings.js'; -import { hashWithPrefix, packToFields, Poseidon } from '../hash.js'; +import { hashWithPrefix, packToFields, Poseidon } from '../provable/hash.js'; import { mocks, prefixes, @@ -66,14 +70,14 @@ import { genericHash, MerkleList, MerkleListBase, -} from '../provable-types/merkle-list.js'; -import { Hashed } from '../provable-types/packed.js'; +} from '../provable/types/merkle-list.js'; +import { Hashed } from '../provable/types/packed.js'; import { accountUpdateLayout, smartContractContext, } from './smart-contract-context.js'; import { assert } from '../util/assert.js'; -import { RandomId } from '../provable-types/auxiliary.js'; +import { RandomId } from '../provable/types/auxiliary.js'; import { NetworkId } from '../../mina-signer/src/types.js'; // external API diff --git a/src/lib/mina/account.ts b/src/lib/mina/account.ts index 03aca7a9f1..4877f2e2ba 100644 --- a/src/lib/mina/account.ts +++ b/src/lib/mina/account.ts @@ -1,8 +1,8 @@ import { Types } from '../../bindings/mina-transaction/types.js'; -import { Bool, Field } from '../core.js'; +import { Bool, Field } from '../provable/core.js'; import { Permissions } from './account-update.js'; -import { UInt32, UInt64 } from '../int.js'; -import { PublicKey } from '../signature.js'; +import { UInt32, UInt64 } from '../provable/int.js'; +import { PublicKey } from '../provable/signature.js'; import { TokenId, ReceiptChainHash } from './base58-encodings.js'; import { genericLayoutFold } from '../../bindings/lib/from-layout.js'; import { @@ -10,7 +10,7 @@ import { TypeMap, } from '../../bindings/mina-transaction/gen/transaction.js'; import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; -import { ProvableExtended } from '../provable-types/struct.js'; +import { ProvableExtended } from '../provable/types/struct.js'; import { FetchedAccount } from './graphql.js'; export { Account, PartialAccount }; diff --git a/src/lib/mina/base58-encodings.ts b/src/lib/mina/base58-encodings.ts index c2f4335b06..142f882c9b 100644 --- a/src/lib/mina/base58-encodings.ts +++ b/src/lib/mina/base58-encodings.ts @@ -1,5 +1,5 @@ import { fieldEncodings } from '../util/base58.js'; -import { Field } from '../core.js'; +import { Field } from '../provable/core.js'; export { TokenId, ReceiptChainHash, LedgerHash, EpochSeed, StateHash }; diff --git a/src/lib/mina/errors.ts b/src/lib/mina/errors.ts index 0a2c51c97f..bb0deeefda 100644 --- a/src/lib/mina/errors.ts +++ b/src/lib/mina/errors.ts @@ -1,6 +1,6 @@ import { Types } from '../../bindings/mina-transaction/types.js'; import { TokenId } from './account-update.js'; -import { Int64 } from '../int.js'; +import { Int64 } from '../provable/int.js'; export { invalidTransactionError }; diff --git a/src/lib/mina/fetch.ts b/src/lib/mina/fetch.ts index 2c82608db8..96fbbc0f7b 100644 --- a/src/lib/mina/fetch.ts +++ b/src/lib/mina/fetch.ts @@ -1,8 +1,8 @@ import 'isomorphic-fetch'; -import { Field } from '../core.js'; -import { UInt32, UInt64 } from '../int.js'; +import { Field } from '../provable/core.js'; +import { UInt32, UInt64 } from '../provable/int.js'; import { Actions, TokenId } from './account-update.js'; -import { PublicKey, PrivateKey } from '../signature.js'; +import { PublicKey, PrivateKey } from '../provable/signature.js'; import { NetworkValue } from './precondition.js'; import { Types } from '../../bindings/mina-transaction/types.js'; import { ActionStates } from './mina.js'; diff --git a/src/lib/mina/graphql.ts b/src/lib/mina/graphql.ts index 4e8c14b3e6..f152c6e316 100644 --- a/src/lib/mina/graphql.ts +++ b/src/lib/mina/graphql.ts @@ -1,4 +1,4 @@ -import { UInt32 } from '../int.js'; +import { UInt32 } from '../provable/int.js'; import type { ZkappCommand } from './account-update.js'; import type { ActionStatesStringified } from './fetch.js'; import { Types } from '../../bindings/mina-transaction/types.js'; diff --git a/src/lib/mina/hash-input.unit-test.ts b/src/lib/mina/hash-input.unit-test.ts index 4879b2475d..2f6b102bf6 100644 --- a/src/lib/mina/hash-input.unit-test.ts +++ b/src/lib/mina/hash-input.unit-test.ts @@ -10,7 +10,7 @@ import { Json, provableFromLayout, } from '../../bindings/mina-transaction/gen/transaction.js'; -import { packToFields } from '../hash.js'; +import { packToFields } from '../provable/hash.js'; import { Random, test } from '../testing/property.js'; import { MlHashInput } from '../ml/conversion.js'; import { MlFieldConstArray } from '../ml/fields.js'; diff --git a/src/lib/mina/local-blockchain.ts b/src/lib/mina/local-blockchain.ts index 17a200fa08..f90ed18940 100644 --- a/src/lib/mina/local-blockchain.ts +++ b/src/lib/mina/local-blockchain.ts @@ -2,9 +2,9 @@ import { SimpleLedger } from './transaction-logic/ledger.js'; import { Ml } from '../ml/conversion.js'; import { transactionCommitments } from '../../mina-signer/src/sign-zkapp-command.js'; import { Ledger, Test } from '../../snarky.js'; -import { Field } from '../core.js'; -import { UInt32, UInt64 } from '../int.js'; -import { PrivateKey, PublicKey } from '../signature.js'; +import { Field } from '../provable/core.js'; +import { UInt32, UInt64 } from '../provable/int.js'; +import { PrivateKey, PublicKey } from '../provable/signature.js'; import { Account } from './account.js'; import { ZkappCommand, diff --git a/src/lib/mina/mina-instance.ts b/src/lib/mina/mina-instance.ts index 0cd271846b..ef660d6a52 100644 --- a/src/lib/mina/mina-instance.ts +++ b/src/lib/mina/mina-instance.ts @@ -1,9 +1,9 @@ /** * This module holds the global Mina instance and its interface. */ -import { Field } from '../core.js'; -import { UInt64, UInt32 } from '../int.js'; -import { PublicKey, PrivateKey } from '../signature.js'; +import { Field } from '../provable/core.js'; +import { UInt64, UInt32 } from '../provable/int.js'; +import { PublicKey } from '../provable/signature.js'; import type { EventActionFilterOptions } from '././../mina/graphql.js'; import type { NetworkId } from '../../mina-signer/src/types.js'; import type { Transaction, PendingTransaction } from './mina.js'; diff --git a/src/lib/mina/mina.ts b/src/lib/mina/mina.ts index 7e8aac1b33..7e2435d2d5 100644 --- a/src/lib/mina/mina.ts +++ b/src/lib/mina/mina.ts @@ -1,7 +1,7 @@ import { Test } from '../../snarky.js'; -import { Field } from '../core.js'; -import { UInt64 } from '../int.js'; -import { PublicKey } from '../signature.js'; +import { Field } from '../provable/core.js'; +import { UInt64 } from '../provable/int.js'; +import { PublicKey } from '../provable/signature.js'; import { ZkappCommand, TokenId, Authorization } from './account-update.js'; import * as Fetch from './fetch.js'; import { invalidTransactionError } from './errors.js'; diff --git a/src/lib/mina/precondition.ts b/src/lib/mina/precondition.ts index f0307d9597..9eea81d7e6 100644 --- a/src/lib/mina/precondition.ts +++ b/src/lib/mina/precondition.ts @@ -1,16 +1,16 @@ -import { Bool, Field } from '../core.js'; +import { Bool, Field } from '../provable/core.js'; import { circuitValueEquals, cloneCircuitValue, -} from '../provable-types/struct.js'; -import { Provable } from '../provable.js'; +} from '../provable/types/struct.js'; +import { Provable } from '../provable/provable.js'; import { activeInstance as Mina } from './mina-instance.js'; import type { AccountUpdate } from './account-update.js'; -import { Int64, UInt32, UInt64 } from '../int.js'; +import { Int64, UInt32, UInt64 } from '../provable/int.js'; import { Layout } from '../../bindings/mina-transaction/gen/transaction.js'; import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; -import { emptyReceiptChainHash, TokenSymbol } from '../hash.js'; -import { PublicKey } from '../signature.js'; +import { emptyReceiptChainHash, TokenSymbol } from '../provable/hash.js'; +import { PublicKey } from '../provable/signature.js'; import { Actions, ZkappUri, diff --git a/src/lib/mina/state.ts b/src/lib/mina/state.ts index 9b234d7ec2..8ca96bc3cf 100644 --- a/src/lib/mina/state.ts +++ b/src/lib/mina/state.ts @@ -1,13 +1,13 @@ -import { FlexibleProvablePure } from '../provable-types/struct.js'; +import { FlexibleProvablePure } from '../provable/types/struct.js'; import { AccountUpdate, TokenId } from './account-update.js'; -import { PublicKey } from '../signature.js'; +import { PublicKey } from '../provable/signature.js'; import * as Mina from './mina.js'; import { fetchAccount, networkConfig } from './fetch.js'; import { SmartContract } from './zkapp.js'; import { Account } from './account.js'; -import { Provable } from '../provable.js'; -import { Field } from '../core.js'; -import { ProvablePure } from '../provable-types/provable-intf.js'; +import { Provable } from '../provable/provable.js'; +import { Field } from '../provable/core.js'; +import { ProvablePure } from '../provable/types/provable-intf.js'; // external API export { State, state, declareState }; diff --git a/src/lib/mina/token/forest-iterator.ts b/src/lib/mina/token/forest-iterator.ts index 662f6add40..5d3a3c7fd0 100644 --- a/src/lib/mina/token/forest-iterator.ts +++ b/src/lib/mina/token/forest-iterator.ts @@ -4,14 +4,14 @@ import { AccountUpdateTreeBase, TokenId, } from '../account-update.js'; -import { Field } from '../../core.js'; -import { Provable } from '../../provable.js'; -import { Struct } from '../../provable-types/struct.js'; -import { assert } from '../../gadgets/common.js'; +import { Field } from '../../provable/core.js'; +import { Provable } from '../../provable/provable.js'; +import { Struct } from '../../provable/types/struct.js'; +import { assert } from '../../provable/gadgets/common.js'; import { MerkleListIterator, MerkleList, -} from '../../provable-types/merkle-list.js'; +} from '../../provable/types/merkle-list.js'; export { TokenAccountUpdateIterator }; diff --git a/src/lib/mina/token/forest-iterator.unit-test.ts b/src/lib/mina/token/forest-iterator.unit-test.ts index bd5ffd1320..723769e48e 100644 --- a/src/lib/mina/token/forest-iterator.unit-test.ts +++ b/src/lib/mina/token/forest-iterator.unit-test.ts @@ -14,8 +14,8 @@ import { callForestHash, } from '../../../mina-signer/src/sign-zkapp-command.js'; import assert from 'assert'; -import { Field, Bool } from '../../core.js'; -import { PublicKey } from '../../signature.js'; +import { Field, Bool } from '../../provable/core.js'; +import { PublicKey } from '../../provable/signature.js'; // RANDOM NUMBER GENERATORS for account updates diff --git a/src/lib/mina/token/token-contract.ts b/src/lib/mina/token/token-contract.ts index 836fec4758..1974bf7181 100644 --- a/src/lib/mina/token/token-contract.ts +++ b/src/lib/mina/token/token-contract.ts @@ -1,7 +1,7 @@ -import { Bool } from '../../core.js'; -import { UInt64, Int64 } from '../../int.js'; -import { Provable } from '../../provable.js'; -import { PublicKey } from '../../signature.js'; +import { Bool } from '../../provable/core.js'; +import { UInt64, Int64 } from '../../provable/int.js'; +import { Provable } from '../../provable/provable.js'; +import { PublicKey } from '../../provable/signature.js'; import { AccountUpdate, AccountUpdateForest, diff --git a/src/lib/mina/token/token-methods.ts b/src/lib/mina/token/token-methods.ts index 53136d1e21..0f61abb0b8 100644 --- a/src/lib/mina/token/token-methods.ts +++ b/src/lib/mina/token/token-methods.ts @@ -1,9 +1,9 @@ import { AccountUpdate, Authorization, TokenId } from '../account-update.js'; import { isSmartContract } from '../smart-contract-base.js'; -import { PublicKey } from '../../signature.js'; +import { PublicKey } from '../../provable/signature.js'; import type { SmartContract } from '../zkapp.js'; -import { UInt64 } from '../../int.js'; -import { Bool, Field } from '../../core.js'; +import { UInt64 } from '../../provable/int.js'; +import { Bool, Field } from '../../provable/core.js'; export { tokenMethods }; diff --git a/src/lib/mina/transaction-context.ts b/src/lib/mina/transaction-context.ts index 412ecbf516..6a85b23486 100644 --- a/src/lib/mina/transaction-context.ts +++ b/src/lib/mina/transaction-context.ts @@ -1,5 +1,5 @@ import type { AccountUpdateLayout } from './account-update.js'; -import type { PublicKey } from '../signature.js'; +import type { PublicKey } from '../provable/signature.js'; import { Context } from '../util/global-context.js'; export { currentTransaction, CurrentTransaction, FetchMode }; diff --git a/src/lib/mina/transaction-logic/ledger.ts b/src/lib/mina/transaction-logic/ledger.ts index b79f535d02..305def3c7b 100644 --- a/src/lib/mina/transaction-logic/ledger.ts +++ b/src/lib/mina/transaction-logic/ledger.ts @@ -1,10 +1,10 @@ /** * A ledger of accounts - simple model of a local blockchain. */ -import { PublicKey } from '../../signature.js'; +import { PublicKey } from '../../provable/signature.js'; import type { AccountUpdate } from '../account-update.js'; import { Account, newAccount } from '../account.js'; -import { Field } from '../../field.js'; +import { Field } from '../../provable/field.js'; import { applyAccountUpdate } from './apply.js'; import { Types } from '../../../bindings/mina-transaction/types.js'; diff --git a/src/lib/mina/transaction-validation.ts b/src/lib/mina/transaction-validation.ts index a162c72c5c..73562bd1ea 100644 --- a/src/lib/mina/transaction-validation.ts +++ b/src/lib/mina/transaction-validation.ts @@ -9,14 +9,14 @@ import { AccountUpdate, dummySignature, } from './account-update.js'; -import { Field } from '../core.js'; -import { UInt64, UInt32 } from '../int.js'; -import { PublicKey } from '../signature.js'; +import { Field } from '../provable/core.js'; +import { UInt64, UInt32 } from '../provable/int.js'; +import { PublicKey } from '../provable/signature.js'; import { JsonProof, verify } from '../proof-system/zkprogram.js'; import { verifyAccountUpdateSignature } from '../../mina-signer/src/sign-zkapp-command.js'; import { TransactionCost, TransactionLimits } from './constants.js'; -import { cloneCircuitValue } from '../provable-types/struct.js'; -import { assert } from '../gadgets/common.js'; +import { cloneCircuitValue } from '../provable/types/struct.js'; +import { assert } from '../provable/gadgets/common.js'; import { Types, TypesBigint } from '../../bindings/mina-transaction/types.js'; import type { NetworkId } from '../../mina-signer/src/types.js'; import type { Account } from './account.js'; diff --git a/src/lib/mina/transaction.ts b/src/lib/mina/transaction.ts index f79ead286b..520cd982ea 100644 --- a/src/lib/mina/transaction.ts +++ b/src/lib/mina/transaction.ts @@ -8,12 +8,12 @@ import { TokenId, addMissingProofs, } from './account-update.js'; -import { Field } from '../core.js'; -import { PrivateKey, PublicKey } from '../signature.js'; -import { UInt32, UInt64 } from '../int.js'; +import { Field } from '../provable/core.js'; +import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { UInt32, UInt64 } from '../provable/int.js'; import { Empty, Proof } from '../proof-system/zkprogram.js'; import { currentTransaction } from './transaction-context.js'; -import { Provable } from '../provable.js'; +import { Provable } from '../provable/provable.js'; import { assertPreconditionInvariants } from './precondition.js'; import { Account } from './account.js'; import { type FeePayerSpec, activeInstance } from './mina-instance.js'; diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index 515a5d132a..f5b9c407a9 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -1,6 +1,6 @@ import 'reflect-metadata'; import { Gate, Pickles } from '../../snarky.js'; -import { Field, Bool } from '../core.js'; +import { Field, Bool } from '../provable/core.js'; import { AccountUpdate, Authorization, @@ -8,7 +8,6 @@ import { Events, Permissions, Actions, - SetOrKeep, TokenId, ZkappCommand, zkAppProver, @@ -23,8 +22,12 @@ import { FlexibleProvablePure, InferProvable, provable, -} from '../provable-types/struct.js'; -import { Provable, getBlindingValue, memoizationContext } from '../provable.js'; +} from '../provable/types/struct.js'; +import { + Provable, + getBlindingValue, + memoizationContext, +} from '../provable/provable.js'; import * as Encoding from '../../bindings/lib/encoding.js'; import { HashInput, @@ -32,8 +35,8 @@ import { hashConstant, isHashable, packToFields, -} from '../hash.js'; -import { UInt32, UInt64 } from '../int.js'; +} from '../provable/hash.js'; +import { UInt32, UInt64 } from '../provable/int.js'; import * as Mina from './mina.js'; import { assertPreconditionInvariants, @@ -51,16 +54,16 @@ import { Proof, sortMethodArguments, } from '../proof-system/zkprogram.js'; -import { PrivateKey, PublicKey } from '../signature.js'; +import { PublicKey } from '../provable/signature.js'; import { assertStatePrecondition, cleanStatePrecondition } from './state.js'; import { inAnalyze, inCheckedComputation, inCompile, inProver, -} from '../provable-context.js'; +} from '../provable/provable-context.js'; import { Cache } from '../proof-system/cache.js'; -import { assert } from '../gadgets/common.js'; +import { assert } from '../provable/gadgets/common.js'; import { SmartContractBase } from './smart-contract-base.js'; import { ZkappStateLength } from './mina-instance.js'; import { @@ -69,7 +72,7 @@ import { smartContractContext, } from './smart-contract-context.js'; import { assertPromise } from '../util/assert.js'; -import { ProvablePure } from '../provable-types/provable-intf.js'; +import { ProvablePure } from '../provable/types/provable-intf.js'; // external API export { SmartContract, method, DeployArgs, declareMethods, Account, Reducer }; diff --git a/src/lib/ml/consistency.unit-test.ts b/src/lib/ml/consistency.unit-test.ts index a5cca0ea4e..b4167d0387 100644 --- a/src/lib/ml/consistency.unit-test.ts +++ b/src/lib/ml/consistency.unit-test.ts @@ -1,13 +1,13 @@ import { Test } from '../../snarky.js'; import { Random, test } from '../testing/property.js'; -import { Field, Bool } from '../core.js'; -import { PrivateKey, PublicKey } from '../signature.js'; +import { Field, Bool } from '../provable/core.js'; +import { PrivateKey, PublicKey } from '../provable/signature.js'; import { TokenId, dummySignature } from '../mina/account-update.js'; import { Ml } from './conversion.js'; import { expect } from 'expect'; -import { FieldConst } from '../provable-core/fieldvar.js'; -import { Provable } from '../provable.js'; -import { runAndCheckSync } from '../provable-context.js'; +import { FieldConst } from '../provable/core/fieldvar.js'; +import { Provable } from '../provable/provable.js'; +import { runAndCheckSync } from '../provable/provable-context.js'; // PrivateKey.toBase58, fromBase58 diff --git a/src/lib/ml/conversion.ts b/src/lib/ml/conversion.ts index f97db2ace8..d0b6ed7d98 100644 --- a/src/lib/ml/conversion.ts +++ b/src/lib/ml/conversion.ts @@ -3,11 +3,11 @@ */ import type { MlPublicKey, MlPublicKeyVar } from '../../snarky.js'; -import { HashInput } from '../provable-types/struct.js'; -import { Bool, Field } from '../core.js'; -import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; -import { Scalar, ScalarConst } from '../scalar.js'; -import { PrivateKey, PublicKey } from '../signature.js'; +import { HashInput } from '../provable/types/struct.js'; +import { Bool, Field } from '../provable/core.js'; +import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; +import { Scalar, ScalarConst } from '../provable/scalar.js'; +import { PrivateKey, PublicKey } from '../provable/signature.js'; import { MlPair, MlBool, MlArray } from './base.js'; import { MlFieldConstArray } from './fields.js'; diff --git a/src/lib/ml/fields.ts b/src/lib/ml/fields.ts index 2766e33a8b..b9b70006ab 100644 --- a/src/lib/ml/fields.ts +++ b/src/lib/ml/fields.ts @@ -1,5 +1,5 @@ -import { ConstantField, Field } from '../field.js'; -import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; +import { ConstantField, Field } from '../provable/field.js'; +import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; import { MlArray } from './base.js'; export { MlFieldArray, MlFieldConstArray }; diff --git a/src/lib/proof-system/circuit.ts b/src/lib/proof-system/circuit.ts index b118e44658..a0a0b6c9a6 100644 --- a/src/lib/proof-system/circuit.ts +++ b/src/lib/proof-system/circuit.ts @@ -2,13 +2,13 @@ import 'reflect-metadata'; import { Snarky } from '../../snarky.js'; import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; import { withThreadPool } from '../../snarky.js'; -import { Provable } from '../provable.js'; -import { snarkContext, gatesFromJson } from '../provable-context.js'; +import { Provable } from '../provable/provable.js'; +import { snarkContext, gatesFromJson } from '../provable/provable-context.js'; import { prettifyStacktrace, prettifyStacktracePromise, } from '../util/errors.js'; -import { ProvablePure } from '../provable-types/provable-intf.js'; +import { ProvablePure } from '../provable/types/provable-intf.js'; // external API export { public_, circuitMain, Circuit, Keypair, Proof, VerificationKey }; diff --git a/src/lib/proof-system/proof-system.unit-test.ts b/src/lib/proof-system/proof-system.unit-test.ts index 892bf751ed..ea8b962b1d 100644 --- a/src/lib/proof-system/proof-system.unit-test.ts +++ b/src/lib/proof-system/proof-system.unit-test.ts @@ -1,6 +1,6 @@ -import { Field, Bool } from '../core.js'; -import { Struct } from '../provable-types/struct.js'; -import { UInt64 } from '../int.js'; +import { Field, Bool } from '../provable/core.js'; +import { Struct } from '../provable/types/struct.js'; +import { UInt64 } from '../provable/int.js'; import { CompiledTag, Empty, @@ -12,12 +12,12 @@ import { import { expect } from 'expect'; import { Pickles, Snarky } from '../../snarky.js'; import { AnyFunction } from '../util/types.js'; -import { snarkContext } from '../provable-context.js'; +import { snarkContext } from '../provable/provable-context.js'; import { it } from 'node:test'; -import { Provable } from '../provable.js'; +import { Provable } from '../provable/provable.js'; import { bool, equivalentAsync, field, record } from '../testing/equivalent.js'; -import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; -import { ProvablePure } from '../provable-types/provable-intf.js'; +import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; +import { ProvablePure } from '../provable/types/provable-intf.js'; const EmptyProgram = ZkProgram({ name: 'empty', diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index 85674f751c..20f7a814f4 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -11,7 +11,7 @@ import { Gate, GateType, } from '../../snarky.js'; -import { Field, Bool } from '../core.js'; +import { Field, Bool } from '../provable/core.js'; import { FlexibleProvable, FlexibleProvablePure, @@ -20,14 +20,14 @@ import { Struct, provable, provablePure, -} from '../provable-types/struct.js'; -import { Provable } from '../provable.js'; +} from '../provable/types/struct.js'; +import { Provable } from '../provable/provable.js'; import { assert, prettifyStacktracePromise } from '../util/errors.js'; -import { snarkContext } from '../provable-context.js'; -import { hashConstant } from '../hash.js'; +import { snarkContext } from '../provable/provable-context.js'; +import { hashConstant } from '../provable/hash.js'; import { MlArray, MlBool, MlResult, MlPair } from '../ml/base.js'; import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; -import { FieldVar, FieldConst } from '../provable-core/fieldvar.js'; +import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; import { Cache, readCache, writeCache } from './cache.js'; import { decodeProverKey, @@ -38,7 +38,7 @@ import { setSrsCache, unsetSrsCache, } from '../../bindings/crypto/bindings/srs.js'; -import { ProvablePure } from '../provable-types/provable-intf.js'; +import { ProvablePure } from '../provable/types/provable-intf.js'; // public API export { diff --git a/src/lib/bool.ts b/src/lib/provable/bool.ts similarity index 96% rename from src/lib/bool.ts rename to src/lib/provable/bool.ts index 164d1e4c32..78ec29eab5 100644 --- a/src/lib/bool.ts +++ b/src/lib/provable/bool.ts @@ -1,12 +1,12 @@ -import { Snarky } from '../snarky.js'; +import { Snarky } from '../../snarky.js'; import { Field, readVarMessage, withMessage } from './field.js'; -import { FieldVar, FieldConst, FieldType } from './provable-core/fieldvar.js'; -import { defineBinable } from '../bindings/lib/binable.js'; -import { NonNegativeInteger } from '../bindings/crypto/non-negative.js'; +import { FieldVar, FieldConst, FieldType } from './core/fieldvar.js'; +import { defineBinable } from '../../bindings/lib/binable.js'; +import { NonNegativeInteger } from '../../bindings/crypto/non-negative.js'; import { asProver } from './provable-context.js'; -import { existsOne } from './provable-core/exists.js'; +import { existsOne } from './core/exists.js'; import { assertMul } from './gadgets/compatible.js'; -import { setBoolConstructor } from './provable-core/field-constructor.js'; +import { setBoolConstructor } from './core/field-constructor.js'; export { BoolVar, Bool }; diff --git a/src/lib/core.ts b/src/lib/provable/core.ts similarity index 100% rename from src/lib/core.ts rename to src/lib/provable/core.ts diff --git a/src/lib/provable-core/exists.ts b/src/lib/provable/core/exists.ts similarity index 93% rename from src/lib/provable-core/exists.ts rename to src/lib/provable/core/exists.ts index 30ae28bbe5..f4f0a2fac2 100644 --- a/src/lib/provable-core/exists.ts +++ b/src/lib/provable/core/exists.ts @@ -1,9 +1,9 @@ -import { Snarky } from '../../snarky.js'; -import { FieldConst, VarFieldVar } from '../provable-core/fieldvar.js'; +import { Snarky } from '../../../snarky.js'; +import { FieldConst, VarFieldVar } from './fieldvar.js'; import type { VarField } from '../field.js'; -import { MlArray, MlOption } from '../ml/base.js'; +import { MlArray, MlOption } from '../../ml/base.js'; import { createField } from './field-constructor.js'; -import { TupleN } from '../util/types.js'; +import { TupleN } from '../../util/types.js'; export { createVarField, exists, existsAsync, existsOne }; diff --git a/src/lib/provable-core/field-constructor.ts b/src/lib/provable/core/field-constructor.ts similarity index 100% rename from src/lib/provable-core/field-constructor.ts rename to src/lib/provable/core/field-constructor.ts diff --git a/src/lib/provable-core/fieldvar.ts b/src/lib/provable/core/fieldvar.ts similarity index 98% rename from src/lib/provable-core/fieldvar.ts rename to src/lib/provable/core/fieldvar.ts index 363e2dc5d1..a65f4d93eb 100644 --- a/src/lib/provable-core/fieldvar.ts +++ b/src/lib/provable/core/fieldvar.ts @@ -1,4 +1,4 @@ -import { Fp } from '../../bindings/crypto/finite-field.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; // internal API export { FieldType, FieldVar, FieldConst, ConstantFieldVar, VarFieldVar }; diff --git a/src/lib/crypto.ts b/src/lib/provable/crypto.ts similarity index 80% rename from src/lib/crypto.ts rename to src/lib/provable/crypto.ts index c58a220277..27af0d7a19 100644 --- a/src/lib/crypto.ts +++ b/src/lib/provable/crypto.ts @@ -1,8 +1,8 @@ -import { CurveParams as CurveParams_ } from '../bindings/crypto/elliptic-curve-examples.js'; +import { CurveParams as CurveParams_ } from '../../bindings/crypto/elliptic-curve-examples.js'; import { CurveAffine, createCurveAffine, -} from '../bindings/crypto/elliptic-curve.js'; +} from '../../bindings/crypto/elliptic-curve.js'; // crypto namespace const Crypto = { diff --git a/src/lib/encryption.ts b/src/lib/provable/encryption.ts similarity index 100% rename from src/lib/encryption.ts rename to src/lib/provable/encryption.ts diff --git a/src/lib/field.ts b/src/lib/provable/field.ts similarity index 98% rename from src/lib/field.ts rename to src/lib/provable/field.ts index 87ed88d4b0..6192dbd28b 100644 --- a/src/lib/field.ts +++ b/src/lib/provable/field.ts @@ -1,11 +1,11 @@ -import { Snarky } from '../snarky.js'; -import { Fp } from '../bindings/crypto/finite-field.js'; -import { BinableFp, SignableFp } from '../mina-signer/src/field-bigint.js'; -import { defineBinable } from '../bindings/lib/binable.js'; -import type { NonNegativeInteger } from '../bindings/crypto/non-negative.js'; +import { Snarky } from '../../snarky.js'; +import { Fp } from '../../bindings/crypto/finite-field.js'; +import { BinableFp, SignableFp } from '../../mina-signer/src/field-bigint.js'; +import { defineBinable } from '../../bindings/lib/binable.js'; +import type { NonNegativeInteger } from '../../bindings/crypto/non-negative.js'; import { asProver, inCheckedComputation } from './provable-context.js'; import { Bool } from './bool.js'; -import { assert } from './util/errors.js'; +import { assert } from '../util/errors.js'; import { Provable } from './provable.js'; import { assertEqual, @@ -20,9 +20,9 @@ import { FieldConst, VarFieldVar, ConstantFieldVar, -} from './provable-core/fieldvar.js'; -import { exists, existsOne } from './provable-core/exists.js'; -import { setFieldConstructor } from './provable-core/field-constructor.js'; +} from './core/fieldvar.js'; +import { exists, existsOne } from './core/exists.js'; +import { setFieldConstructor } from './core/field-constructor.js'; // external API export { Field }; diff --git a/src/lib/field.unit-test.ts b/src/lib/provable/field.unit-test.ts similarity index 93% rename from src/lib/field.unit-test.ts rename to src/lib/provable/field.unit-test.ts index 8297d2565c..cc48553e7d 100644 --- a/src/lib/field.unit-test.ts +++ b/src/lib/provable/field.unit-test.ts @@ -1,12 +1,12 @@ import { Field } from './core.js'; -import { Fp } from '../bindings/crypto/finite-field.js'; -import { BinableFp } from '../mina-signer/src/field-bigint.js'; -import { test, Random } from './testing/property.js'; +import { Fp } from '../../bindings/crypto/finite-field.js'; +import { BinableFp } from '../../mina-signer/src/field-bigint.js'; +import { test, Random } from '../testing/property.js'; import { deepEqual, throws } from 'node:assert/strict'; import { Provable } from './provable.js'; -import { Binable } from '../bindings/lib/binable.js'; -import { ProvableExtended } from './provable-types/struct.js'; -import { FieldType } from './provable-core/fieldvar.js'; +import { Binable } from '../../bindings/lib/binable.js'; +import { ProvableExtended } from './types/struct.js'; +import { FieldType } from './core/fieldvar.js'; import { equivalentProvable as equivalent, oneOf, @@ -16,9 +16,9 @@ import { unit, bool, Spec, -} from './testing/equivalent.js'; +} from '../testing/equivalent.js'; import { runAndCheckSync } from './provable-context.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +import { ProvablePure } from './types/provable-intf.js'; // types Field satisfies Provable; diff --git a/src/lib/foreign-curve.ts b/src/lib/provable/foreign-curve.ts similarity index 97% rename from src/lib/foreign-curve.ts rename to src/lib/provable/foreign-curve.ts index cfaf5756f3..a122b7d274 100644 --- a/src/lib/foreign-curve.ts +++ b/src/lib/provable/foreign-curve.ts @@ -2,15 +2,15 @@ import { CurveParams, CurveAffine, createCurveAffine, -} from '../bindings/crypto/elliptic-curve.js'; +} from '../../bindings/crypto/elliptic-curve.js'; import type { Group } from './group.js'; -import { ProvablePureExtended } from './provable-types/struct.js'; +import { ProvablePureExtended } from './types/struct.js'; import { AlmostForeignField, createForeignField } from './foreign-field.js'; import { EllipticCurve, Point } from './gadgets/elliptic-curve.js'; import { Field3 } from './gadgets/foreign-field.js'; import { assert } from './gadgets/common.js'; import { Provable } from './provable.js'; -import { provableFromClass } from './provable-types/provable-derivers.js'; +import { provableFromClass } from './types/provable-derivers.js'; // external API export { createForeignCurve, ForeignCurve }; diff --git a/src/lib/foreign-curve.unit-test.ts b/src/lib/provable/foreign-curve.unit-test.ts similarity index 91% rename from src/lib/foreign-curve.unit-test.ts rename to src/lib/provable/foreign-curve.unit-test.ts index d31a6dd76e..410c74602c 100644 --- a/src/lib/foreign-curve.unit-test.ts +++ b/src/lib/provable/foreign-curve.unit-test.ts @@ -1,6 +1,6 @@ import { createForeignCurve } from './foreign-curve.js'; -import { Fq } from '../bindings/crypto/finite-field.js'; -import { Vesta as V } from '../bindings/crypto/elliptic-curve.js'; +import { Fq } from '../../bindings/crypto/finite-field.js'; +import { Vesta as V } from '../../bindings/crypto/elliptic-curve.js'; import { Provable } from './provable.js'; import { Field } from './field.js'; import { Crypto } from './crypto.js'; diff --git a/src/lib/foreign-ecdsa.ts b/src/lib/provable/foreign-ecdsa.ts similarity index 97% rename from src/lib/foreign-ecdsa.ts rename to src/lib/provable/foreign-ecdsa.ts index 6c829daac9..5556d687fc 100644 --- a/src/lib/foreign-ecdsa.ts +++ b/src/lib/provable/foreign-ecdsa.ts @@ -1,6 +1,6 @@ -import { provableFromClass } from './provable-types/provable-derivers.js'; -import { CurveParams } from '../bindings/crypto/elliptic-curve.js'; -import { ProvablePureExtended } from './provable-types/struct.js'; +import { provableFromClass } from './types/provable-derivers.js'; +import { CurveParams } from '../../bindings/crypto/elliptic-curve.js'; +import { ProvablePureExtended } from './types/struct.js'; import { FlexiblePoint, ForeignCurve, @@ -13,7 +13,7 @@ import { Field3 } from './gadgets/foreign-field.js'; import { Ecdsa } from './gadgets/elliptic-curve.js'; import { l } from './gadgets/range-check.js'; import { Keccak } from './keccak.js'; -import { Bytes } from './provable-types/provable-types.js'; +import { Bytes } from './types/provable-types.js'; import { UInt8 } from './int.js'; // external API diff --git a/src/lib/foreign-field.ts b/src/lib/provable/foreign-field.ts similarity index 99% rename from src/lib/foreign-field.ts rename to src/lib/provable/foreign-field.ts index b6d83f3ccf..e9f658682b 100644 --- a/src/lib/foreign-field.ts +++ b/src/lib/provable/foreign-field.ts @@ -3,17 +3,17 @@ import { Fp, FiniteField, createField, -} from '../bindings/crypto/finite-field.js'; +} from '../../bindings/crypto/finite-field.js'; import { Field, checkBitLength, withMessage } from './field.js'; import { Provable } from './provable.js'; import { Bool } from './bool.js'; -import { Tuple, TupleMap, TupleN } from './util/types.js'; +import { Tuple, TupleMap, TupleN } from '../util/types.js'; import { Field3 } from './gadgets/foreign-field.js'; import { Gadgets } from './gadgets/gadgets.js'; import { ForeignField as FF } from './gadgets/foreign-field.js'; import { assert } from './gadgets/common.js'; import { l3, l } from './gadgets/range-check.js'; -import { ProvablePureExtended } from './provable-types/struct.js'; +import { ProvablePureExtended } from './types/struct.js'; // external API export { createForeignField }; diff --git a/src/lib/foreign-field.unit-test.ts b/src/lib/provable/foreign-field.unit-test.ts similarity index 94% rename from src/lib/foreign-field.unit-test.ts rename to src/lib/provable/foreign-field.unit-test.ts index 24e171ecd1..9848846bed 100644 --- a/src/lib/foreign-field.unit-test.ts +++ b/src/lib/provable/foreign-field.unit-test.ts @@ -1,7 +1,7 @@ import { Field, Group } from './core.js'; import { ForeignField, createForeignField } from './foreign-field.js'; -import { Fq } from '../bindings/crypto/finite-field.js'; -import { Pallas } from '../bindings/crypto/elliptic-curve.js'; +import { Fq } from '../../bindings/crypto/finite-field.js'; +import { Pallas } from '../../bindings/crypto/elliptic-curve.js'; import { expect } from 'expect'; import { bool, @@ -11,14 +11,14 @@ import { spec, throwError, unit, -} from './testing/equivalent.js'; -import { test, Random } from './testing/property.js'; +} from '../testing/equivalent.js'; +import { test, Random } from '../testing/property.js'; import { Provable } from './provable.js'; -import { Circuit, circuitMain } from './proof-system/circuit.js'; +import { Circuit, circuitMain } from '../proof-system/circuit.js'; import { Scalar } from './scalar.js'; import { l } from './gadgets/range-check.js'; import { assert } from './gadgets/common.js'; -import { ProvablePure } from './provable-types/provable-intf.js'; +import { ProvablePure } from './types/provable-intf.js'; // toy example - F_17 diff --git a/src/lib/gadgets/arithmetic.ts b/src/lib/provable/gadgets/arithmetic.ts similarity index 91% rename from src/lib/gadgets/arithmetic.ts rename to src/lib/provable/gadgets/arithmetic.ts index 56b8efb39c..ea0922ff4e 100644 --- a/src/lib/gadgets/arithmetic.ts +++ b/src/lib/provable/gadgets/arithmetic.ts @@ -1,6 +1,6 @@ -import { provableTuple } from '../provable-types/struct.js'; +import { provableTuple } from '../types/struct.js'; import { Field } from '../core.js'; -import { assert } from '../util/errors.js'; +import { assert } from '../../util/errors.js'; import { Provable } from '../provable.js'; import { rangeCheck32, rangeCheckN } from './range-check.js'; diff --git a/src/lib/gadgets/arithmetic.unit-test.ts b/src/lib/provable/gadgets/arithmetic.unit-test.ts similarity index 89% rename from src/lib/gadgets/arithmetic.unit-test.ts rename to src/lib/provable/gadgets/arithmetic.unit-test.ts index 121a09e9a7..5b2be3b562 100644 --- a/src/lib/gadgets/arithmetic.unit-test.ts +++ b/src/lib/provable/gadgets/arithmetic.unit-test.ts @@ -1,13 +1,13 @@ -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { equivalentProvable as equivalent, equivalentAsync, field, record, -} from '../testing/equivalent.js'; +} from '../../testing/equivalent.js'; import { Field } from '../core.js'; import { Gadgets } from './gadgets.js'; -import { provable } from '../provable-types/struct.js'; +import { provable } from '../types/struct.js'; import { assert } from './common.js'; let Arithmetic = ZkProgram({ diff --git a/src/lib/gadgets/basic.ts b/src/lib/provable/gadgets/basic.ts similarity index 97% rename from src/lib/gadgets/basic.ts rename to src/lib/provable/gadgets/basic.ts index 8e9945dd9f..31f2f1aac4 100644 --- a/src/lib/gadgets/basic.ts +++ b/src/lib/provable/gadgets/basic.ts @@ -1,18 +1,18 @@ /** * Basic gadgets that only use generic gates */ -import { Fp } from '../../bindings/crypto/finite-field.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; import { Field, VarField } from '../field.js'; import { FieldType, FieldVar, FieldConst, VarFieldVar, -} from '../provable-core/fieldvar.js'; +} from '../core/fieldvar.js'; import { toVar } from './common.js'; import { Gates, fieldVar } from '../gates.js'; -import { TupleN } from '../util/types.js'; -import { existsOne } from '../provable-core/exists.js'; +import { TupleN } from '../../util/types.js'; +import { existsOne } from '../core/exists.js'; export { assertMul, arrayGet, assertOneOf }; diff --git a/src/lib/gadgets/bit-slices.ts b/src/lib/provable/gadgets/bit-slices.ts similarity index 96% rename from src/lib/gadgets/bit-slices.ts rename to src/lib/provable/gadgets/bit-slices.ts index 4d359ad92b..68d132b51a 100644 --- a/src/lib/gadgets/bit-slices.ts +++ b/src/lib/provable/gadgets/bit-slices.ts @@ -1,12 +1,12 @@ /** * Gadgets for converting between field elements and bit slices of various lengths */ -import { bigIntToBits } from '../../bindings/crypto/bigint-helpers.js'; +import { bigIntToBits } from '../../../bindings/crypto/bigint-helpers.js'; import { Field } from '../field.js'; import { UInt8 } from '../int.js'; -import { exists } from '../provable-core/exists.js'; +import { exists } from '../core/exists.js'; import { Provable } from '../provable.js'; -import { chunk } from '../util/arrays.js'; +import { chunk } from '../../util/arrays.js'; import { assert } from './common.js'; import type { Field3 } from './foreign-field.js'; import { l } from './range-check.js'; diff --git a/src/lib/gadgets/bitwise.ts b/src/lib/provable/gadgets/bitwise.ts similarity index 98% rename from src/lib/gadgets/bitwise.ts rename to src/lib/provable/gadgets/bitwise.ts index c1bfab2b6e..b711f8dd16 100644 --- a/src/lib/gadgets/bitwise.ts +++ b/src/lib/provable/gadgets/bitwise.ts @@ -1,11 +1,11 @@ import { Provable } from '../provable.js'; -import { Fp } from '../../bindings/crypto/finite-field.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../field.js'; import { Gates } from '../gates.js'; import { assert, divideWithRemainder, toVar, bitSlice } from './common.js'; import { rangeCheck32, rangeCheck64 } from './range-check.js'; import { divMod32 } from './arithmetic.js'; -import { exists } from '../provable-core/exists.js'; +import { exists } from '../../provable/core/exists.js'; export { xor, diff --git a/src/lib/gadgets/bitwise.unit-test.ts b/src/lib/provable/gadgets/bitwise.unit-test.ts similarity index 95% rename from src/lib/gadgets/bitwise.unit-test.ts rename to src/lib/provable/gadgets/bitwise.unit-test.ts index f3c7270673..1c4e1efbed 100644 --- a/src/lib/gadgets/bitwise.unit-test.ts +++ b/src/lib/provable/gadgets/bitwise.unit-test.ts @@ -1,14 +1,14 @@ -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { equivalentProvable as equivalent, equivalentAsync, field, fieldWithRng, -} from '../testing/equivalent.js'; -import { Fp, mod } from '../../bindings/crypto/finite-field.js'; +} from '../../testing/equivalent.js'; +import { Fp, mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../core.js'; import { Gadgets } from './gadgets.js'; -import { Random } from '../testing/property.js'; +import { Random } from '../../testing/property.js'; import { constraintSystem, contains, @@ -17,8 +17,8 @@ import { repeat, and, withoutGenerics, -} from '../testing/constraint-system.js'; -import { GateType } from '../../snarky.js'; +} from '../../testing/constraint-system.js'; +import { GateType } from '../../../snarky.js'; const maybeField = { ...field, diff --git a/src/lib/gadgets/common.ts b/src/lib/provable/gadgets/common.ts similarity index 91% rename from src/lib/gadgets/common.ts rename to src/lib/provable/gadgets/common.ts index bbfae9cf47..1fbd9c53f4 100644 --- a/src/lib/gadgets/common.ts +++ b/src/lib/provable/gadgets/common.ts @@ -1,9 +1,9 @@ import { Field, VarField } from '../field.js'; -import { FieldVar, VarFieldVar } from '../provable-core/fieldvar.js'; -import { Tuple } from '../util/types.js'; +import { FieldVar, VarFieldVar } from '../core/fieldvar.js'; +import { Tuple } from '../../util/types.js'; import type { Bool } from '../bool.js'; import { fieldVar } from '../gates.js'; -import { existsOne } from '../provable-core/exists.js'; +import { existsOne } from '../core/exists.js'; export { toVars, toVar, isVar, assert, bitSlice, divideWithRemainder }; diff --git a/src/lib/gadgets/compatible.ts b/src/lib/provable/gadgets/compatible.ts similarity index 97% rename from src/lib/gadgets/compatible.ts rename to src/lib/provable/gadgets/compatible.ts index 7c12c21d18..a10382497e 100644 --- a/src/lib/gadgets/compatible.ts +++ b/src/lib/provable/gadgets/compatible.ts @@ -2,13 +2,13 @@ * Basic gadgets that only use generic gates, and are compatible with (create the same constraints as) * `plonk_constraint_system.ml` / R1CS_constraint_system. */ -import { Fp } from '../../bindings/crypto/finite-field.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../field.js'; -import { FieldVar } from '../provable-core/fieldvar.js'; +import { FieldVar } from '../core/fieldvar.js'; import { assert } from './common.js'; import { Gates } from '../gates.js'; import { ScaledVar, emptyCell, reduceToScaledVar } from './basic.js'; -import { Snarky } from '../../snarky.js'; +import { Snarky } from '../../../snarky.js'; export { assertMulCompatible as assertMul, diff --git a/src/lib/gadgets/ecdsa.unit-test.ts b/src/lib/provable/gadgets/ecdsa.unit-test.ts similarity index 93% rename from src/lib/gadgets/ecdsa.unit-test.ts rename to src/lib/provable/gadgets/ecdsa.unit-test.ts index 2d89ec8458..0cfab362e3 100644 --- a/src/lib/gadgets/ecdsa.unit-test.ts +++ b/src/lib/provable/gadgets/ecdsa.unit-test.ts @@ -1,4 +1,4 @@ -import { createCurveAffine } from '../../bindings/crypto/elliptic-curve.js'; +import { createCurveAffine } from '../../../bindings/crypto/elliptic-curve.js'; import { Ecdsa, EllipticCurve, @@ -7,9 +7,9 @@ import { verifyEcdsaConstant, } from './elliptic-curve.js'; import { Field3 } from './foreign-field.js'; -import { CurveParams } from '../../bindings/crypto/elliptic-curve-examples.js'; +import { CurveParams } from '../../../bindings/crypto/elliptic-curve-examples.js'; import { Provable } from '../provable.js'; -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { assert } from './common.js'; import { foreignField, uniformForeignField } from './test-utils.js'; import { @@ -21,9 +21,9 @@ import { map, oneOf, record, -} from '../testing/equivalent.js'; -import { Bool } from '../bool.js'; -import { Random } from '../testing/random.js'; +} from '../../testing/equivalent.js'; +import { Bool } from '../../provable/bool.js'; +import { Random } from '../../testing/random.js'; // quick tests const Secp256k1 = createCurveAffine(CurveParams.Secp256k1); diff --git a/src/lib/gadgets/elliptic-curve.ts b/src/lib/provable/gadgets/elliptic-curve.ts similarity index 98% rename from src/lib/gadgets/elliptic-curve.ts rename to src/lib/provable/gadgets/elliptic-curve.ts index a1cb212671..b23be4b455 100644 --- a/src/lib/gadgets/elliptic-curve.ts +++ b/src/lib/provable/gadgets/elliptic-curve.ts @@ -1,4 +1,4 @@ -import { inverse, mod } from '../../bindings/crypto/finite-field.js'; +import { inverse, mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../field.js'; import { Provable } from '../provable.js'; import { assert } from './common.js'; @@ -8,19 +8,19 @@ import { sha256 } from 'js-sha256'; import { bigIntToBytes, bytesToBigInt, -} from '../../bindings/crypto/bigint-helpers.js'; +} from '../../../bindings/crypto/bigint-helpers.js'; import { CurveAffine, affineAdd, affineDouble, -} from '../../bindings/crypto/elliptic-curve.js'; +} from '../../../bindings/crypto/elliptic-curve.js'; import { Bool } from '../bool.js'; -import { provable } from '../provable-types/struct.js'; -import { assertPositiveInteger } from '../../bindings/crypto/non-negative.js'; +import { provable } from '../types/struct.js'; +import { assertPositiveInteger } from '../../../bindings/crypto/non-negative.js'; import { arrayGet } from './basic.js'; import { sliceField3 } from './bit-slices.js'; -import { Hashed } from '../provable-types/packed.js'; -import { exists } from '../provable-core/exists.js'; +import { Hashed } from '../types/packed.js'; +import { exists } from '../core/exists.js'; // external API export { EllipticCurve, Point, Ecdsa }; diff --git a/src/lib/gadgets/elliptic-curve.unit-test.ts b/src/lib/provable/gadgets/elliptic-curve.unit-test.ts similarity index 89% rename from src/lib/gadgets/elliptic-curve.unit-test.ts rename to src/lib/provable/gadgets/elliptic-curve.unit-test.ts index 0119829060..2dfa76d0fb 100644 --- a/src/lib/gadgets/elliptic-curve.unit-test.ts +++ b/src/lib/provable/gadgets/elliptic-curve.unit-test.ts @@ -1,5 +1,5 @@ -import { CurveParams } from '../../bindings/crypto/elliptic-curve-examples.js'; -import { createCurveAffine } from '../../bindings/crypto/elliptic-curve.js'; +import { CurveParams } from '../../../bindings/crypto/elliptic-curve-examples.js'; +import { createCurveAffine } from '../../../bindings/crypto/elliptic-curve.js'; import { array, equivalentProvable, @@ -7,8 +7,8 @@ import { onlyIf, spec, unit, -} from '../testing/equivalent.js'; -import { Random } from '../testing/random.js'; +} from '../../testing/equivalent.js'; +import { Random } from '../../testing/random.js'; import { assert } from './common.js'; import { EllipticCurve, Point, simpleMapToCurve } from './elliptic-curve.js'; import { foreignField, throwError } from './test-utils.js'; diff --git a/src/lib/gadgets/foreign-field.ts b/src/lib/provable/gadgets/foreign-field.ts similarity index 98% rename from src/lib/gadgets/foreign-field.ts rename to src/lib/provable/gadgets/foreign-field.ts index 4299dbcc38..71744eb4b3 100644 --- a/src/lib/gadgets/foreign-field.ts +++ b/src/lib/provable/gadgets/foreign-field.ts @@ -4,15 +4,15 @@ import { inverse as modInverse, mod, -} from '../../bindings/crypto/finite-field.js'; -import { provableTuple } from '../provable-types/provable-derivers.js'; +} from '../../../bindings/crypto/finite-field.js'; +import { provableTuple } from '../types/provable-derivers.js'; import { Bool } from '../bool.js'; -import { Unconstrained } from '../provable-types/unconstrained.js'; +import { Unconstrained } from '../types/unconstrained.js'; import { Field } from '../field.js'; import { Gates, foreignFieldAdd } from '../gates.js'; -import { exists } from '../provable-core/exists.js'; -import { modifiedField } from '../provable-types/fields.js'; -import { Tuple, TupleN } from '../util/types.js'; +import { exists } from '../core/exists.js'; +import { modifiedField } from '../types/fields.js'; +import { Tuple, TupleN } from '../../util/types.js'; import { assertOneOf } from './basic.js'; import { assert, bitSlice, toVar, toVars } from './common.js'; import { diff --git a/src/lib/gadgets/foreign-field.unit-test.ts b/src/lib/provable/gadgets/foreign-field.unit-test.ts similarity index 95% rename from src/lib/gadgets/foreign-field.unit-test.ts rename to src/lib/provable/gadgets/foreign-field.unit-test.ts index da57ab05d9..e5213da894 100644 --- a/src/lib/gadgets/foreign-field.unit-test.ts +++ b/src/lib/provable/gadgets/foreign-field.unit-test.ts @@ -1,5 +1,5 @@ -import type { FiniteField } from '../../bindings/crypto/finite-field.js'; -import { exampleFields } from '../../bindings/crypto/finite-field-examples.js'; +import type { FiniteField } from '../../../bindings/crypto/finite-field.js'; +import { exampleFields } from '../../../bindings/crypto/finite-field-examples.js'; import { array, equivalent, @@ -8,10 +8,10 @@ import { fromRandom, record, unit, -} from '../testing/equivalent.js'; -import { Random } from '../testing/random.js'; +} from '../../testing/equivalent.js'; +import { Random } from '../../testing/random.js'; import { Field3, Gadgets } from './gadgets.js'; -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Provable } from '../provable.js'; import { assert } from './common.js'; import { @@ -25,9 +25,9 @@ import { or, repeat, withoutGenerics, -} from '../testing/constraint-system.js'; -import { GateType } from '../../snarky.js'; -import { AnyTuple } from '../util/types.js'; +} from '../../testing/constraint-system.js'; +import { GateType } from '../../../snarky.js'; +import { AnyTuple } from '../../util/types.js'; import { foreignField, throwError, diff --git a/src/lib/gadgets/gadgets.ts b/src/lib/provable/gadgets/gadgets.ts similarity index 100% rename from src/lib/gadgets/gadgets.ts rename to src/lib/provable/gadgets/gadgets.ts diff --git a/src/lib/gadgets/range-check.ts b/src/lib/provable/gadgets/range-check.ts similarity index 97% rename from src/lib/gadgets/range-check.ts rename to src/lib/provable/gadgets/range-check.ts index b47a406f58..860b8628cf 100644 --- a/src/lib/gadgets/range-check.ts +++ b/src/lib/provable/gadgets/range-check.ts @@ -1,11 +1,11 @@ -import { Snarky } from '../../snarky.js'; -import { Fp } from '../../bindings/crypto/finite-field.js'; -import { BinableFp } from '../../mina-signer/src/field-bigint.js'; +import { Snarky } from '../../../snarky.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; +import { BinableFp } from '../../../mina-signer/src/field-bigint.js'; import { Field } from '../field.js'; import { Gates } from '../gates.js'; import { assert, bitSlice, toVar, toVars } from './common.js'; import { Bool } from '../bool.js'; -import { exists } from '../provable-core/exists.js'; +import { exists } from '../core/exists.js'; export { rangeCheck64, diff --git a/src/lib/gadgets/range-check.unit-test.ts b/src/lib/provable/gadgets/range-check.unit-test.ts similarity index 92% rename from src/lib/gadgets/range-check.unit-test.ts rename to src/lib/provable/gadgets/range-check.unit-test.ts index fec7973b86..a9b5dce44d 100644 --- a/src/lib/gadgets/range-check.unit-test.ts +++ b/src/lib/provable/gadgets/range-check.unit-test.ts @@ -1,13 +1,13 @@ -import { mod } from '../../bindings/crypto/finite-field.js'; -import { Field } from '../../lib/core.js'; -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { mod } from '../../../bindings/crypto/finite-field.js'; +import { Field } from '../core.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Spec, boolean, equivalentAsync, fieldWithRng, -} from '../testing/equivalent.js'; -import { Random } from '../testing/property.js'; +} from '../../testing/equivalent.js'; +import { Random } from '../../testing/property.js'; import { assert } from './common.js'; import { Gadgets } from './gadgets.js'; import { l } from './range-check.js'; @@ -17,7 +17,7 @@ import { equals, ifNotAllConstant, withoutGenerics, -} from '../testing/constraint-system.js'; +} from '../../testing/constraint-system.js'; let uint = (n: number | bigint): Spec => { let uint = Random.bignat((1n << BigInt(n)) - 1n); diff --git a/src/lib/gadgets/sha256.ts b/src/lib/provable/gadgets/sha256.ts similarity index 96% rename from src/lib/gadgets/sha256.ts rename to src/lib/provable/gadgets/sha256.ts index 7b65172052..ba540ff8fc 100644 --- a/src/lib/gadgets/sha256.ts +++ b/src/lib/provable/gadgets/sha256.ts @@ -1,12 +1,12 @@ // https://csrc.nist.gov/pubs/fips/180-4/upd1/final -import { mod } from '../../bindings/crypto/finite-field.js'; +import { mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../core.js'; import { UInt32, UInt8 } from '../int.js'; -import { exists } from '../provable-core/exists.js'; -import { FlexibleBytes } from '../provable-types/bytes.js'; -import { Bytes } from '../provable-types/provable-types.js'; -import { chunk } from '../util/arrays.js'; -import { TupleN } from '../util/types.js'; +import { exists } from '../core/exists.js'; +import { FlexibleBytes } from '../types/bytes.js'; +import { Bytes } from '../types/provable-types.js'; +import { chunk } from '../../util/arrays.js'; +import { TupleN } from '../../util/types.js'; import { divMod32 } from './arithmetic.js'; import { bytesToWord, wordToBytes } from './bit-slices.js'; import { bitSlice } from './common.js'; diff --git a/src/lib/gadgets/sha256.unit-test.ts b/src/lib/provable/gadgets/sha256.unit-test.ts similarity index 87% rename from src/lib/gadgets/sha256.unit-test.ts rename to src/lib/provable/gadgets/sha256.unit-test.ts index 1ccbf2ef91..ec8d58ecf0 100644 --- a/src/lib/gadgets/sha256.unit-test.ts +++ b/src/lib/provable/gadgets/sha256.unit-test.ts @@ -1,10 +1,13 @@ -import { ZkProgram } from '../proof-system/zkprogram.js'; -import { Bytes } from '../provable-types/provable-types.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; +import { Bytes } from '../types/provable-types.js'; import { Gadgets } from './gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; import { bytes } from './test-utils.js'; -import { equivalentAsync, equivalentProvable } from '../testing/equivalent.js'; -import { Random, sample } from '../testing/random.js'; +import { + equivalentAsync, + equivalentProvable, +} from '../../testing/equivalent.js'; +import { Random, sample } from '../../testing/random.js'; import { expect } from 'expect'; sample(Random.nat(400), 5).forEach((preimageLength) => { diff --git a/src/lib/gadgets/test-utils.ts b/src/lib/provable/gadgets/test-utils.ts similarity index 86% rename from src/lib/gadgets/test-utils.ts rename to src/lib/provable/gadgets/test-utils.ts index cc15759e6b..0214fd40a6 100644 --- a/src/lib/gadgets/test-utils.ts +++ b/src/lib/provable/gadgets/test-utils.ts @@ -1,9 +1,9 @@ -import type { FiniteField } from '../../bindings/crypto/finite-field.js'; -import { ProvableSpec, spec } from '../testing/equivalent.js'; -import { Random } from '../testing/random.js'; +import type { FiniteField } from '../../../bindings/crypto/finite-field.js'; +import { ProvableSpec, spec } from '../../testing/equivalent.js'; +import { Random } from '../../testing/random.js'; import { Field3 } from './gadgets.js'; import { assert } from './common.js'; -import { Bytes } from '../provable-types/provable-types.js'; +import { Bytes } from '../types/provable-types.js'; export { foreignField, diff --git a/src/lib/gates.ts b/src/lib/provable/gates.ts similarity index 95% rename from src/lib/gates.ts rename to src/lib/provable/gates.ts index 6389273224..ed25ea1bf5 100644 --- a/src/lib/gates.ts +++ b/src/lib/provable/gates.ts @@ -1,9 +1,9 @@ -import { Snarky } from '../snarky.js'; +import { Snarky } from '../../snarky.js'; import type { Field } from './field.js'; -import { FieldVar, FieldConst } from './provable-core/fieldvar.js'; -import { MlArray, MlTuple } from './ml/base.js'; -import { exists } from './provable-core/exists.js'; -import { TupleN } from './util/types.js'; +import { FieldVar, FieldConst } from './core/fieldvar.js'; +import { MlArray, MlTuple } from '../ml/base.js'; +import { exists } from './core/exists.js'; +import { TupleN } from '../util/types.js'; export { Gates, diff --git a/src/lib/group.test.ts b/src/lib/provable/group.test.ts similarity index 100% rename from src/lib/group.test.ts rename to src/lib/provable/group.test.ts diff --git a/src/lib/group.ts b/src/lib/provable/group.ts similarity index 97% rename from src/lib/group.ts rename to src/lib/provable/group.ts index ad016cdd72..31cee90cfd 100644 --- a/src/lib/group.ts +++ b/src/lib/provable/group.ts @@ -1,9 +1,9 @@ import { Field } from './field.js'; -import { FieldVar } from './provable-core/fieldvar.js'; +import { FieldVar } from './core/fieldvar.js'; import { Scalar } from './scalar.js'; -import { Snarky } from '../snarky.js'; -import { Fp } from '../bindings/crypto/finite-field.js'; -import { GroupAffine, Pallas } from '../bindings/crypto/elliptic-curve.js'; +import { Snarky } from '../../snarky.js'; +import { Fp } from '../../bindings/crypto/finite-field.js'; +import { GroupAffine, Pallas } from '../../bindings/crypto/elliptic-curve.js'; import { Provable } from './provable.js'; import { Bool } from './bool.js'; diff --git a/src/lib/group.unit-test.ts b/src/lib/provable/group.unit-test.ts similarity index 94% rename from src/lib/group.unit-test.ts rename to src/lib/provable/group.unit-test.ts index 12f51b68bc..ee23b1cc0b 100644 --- a/src/lib/group.unit-test.ts +++ b/src/lib/provable/group.unit-test.ts @@ -1,7 +1,7 @@ import { Group } from './core.js'; -import { test, Random } from './testing/property.js'; +import { test, Random } from '../testing/property.js'; import { Provable } from './provable.js'; -import { Poseidon } from '../mina-signer/src/poseidon-bigint.js'; +import { Poseidon } from '../../mina-signer/src/poseidon-bigint.js'; import { runAndCheckSync } from './provable-context.js'; console.log('group consistency tests'); diff --git a/src/lib/hash-generic.ts b/src/lib/provable/hash-generic.ts similarity index 84% rename from src/lib/hash-generic.ts rename to src/lib/provable/hash-generic.ts index 7e76c8ceee..0d1facfc5d 100644 --- a/src/lib/hash-generic.ts +++ b/src/lib/provable/hash-generic.ts @@ -1,5 +1,5 @@ -import { GenericSignableField } from '../bindings/lib/generic.js'; -import { prefixToField } from '../bindings/lib/binable.js'; +import { GenericSignableField } from '../../bindings/lib/generic.js'; +import { prefixToField } from '../../bindings/lib/binable.js'; export { createHashHelpers, HashHelpers }; diff --git a/src/lib/hash.ts b/src/lib/provable/hash.ts similarity index 94% rename from src/lib/hash.ts rename to src/lib/provable/hash.ts index d1b15b1570..71d62822ec 100644 --- a/src/lib/hash.ts +++ b/src/lib/provable/hash.ts @@ -1,17 +1,13 @@ -import { - HashInput, - ProvableExtended, - Struct, -} from './provable-types/struct.js'; -import { Snarky } from '../snarky.js'; +import { HashInput, ProvableExtended, Struct } from './types/struct.js'; +import { Snarky } from '../../snarky.js'; import { Field } from './core.js'; import { createHashHelpers } from './hash-generic.js'; import { Provable } from './provable.js'; -import { MlFieldArray } from './ml/fields.js'; -import { Poseidon as PoseidonBigint } from '../bindings/crypto/poseidon.js'; -import { assert } from './util/errors.js'; +import { MlFieldArray } from '../ml/fields.js'; +import { Poseidon as PoseidonBigint } from '../../bindings/crypto/poseidon.js'; +import { assert } from '../util/errors.js'; import { rangeCheckN } from './gadgets/range-check.js'; -import { TupleN } from './util/types.js'; +import { TupleN } from '../util/types.js'; // external API export { Poseidon, TokenSymbol }; diff --git a/src/lib/hashes-combined.ts b/src/lib/provable/hashes-combined.ts similarity index 98% rename from src/lib/hashes-combined.ts rename to src/lib/provable/hashes-combined.ts index edd64f8355..a2bb8b890f 100644 --- a/src/lib/hashes-combined.ts +++ b/src/lib/provable/hashes-combined.ts @@ -1,7 +1,7 @@ import { Gadgets } from './gadgets/gadgets.js'; import { Poseidon } from './hash.js'; import { Keccak } from './keccak.js'; -import { Bytes } from './provable-types/provable-types.js'; +import { Bytes } from './types/provable-types.js'; export { Hash }; diff --git a/src/lib/int.test.ts b/src/lib/provable/int.test.ts similarity index 100% rename from src/lib/int.test.ts rename to src/lib/provable/int.test.ts diff --git a/src/lib/int.ts b/src/lib/provable/int.ts similarity index 99% rename from src/lib/int.ts rename to src/lib/provable/int.ts index 430bb82c72..69c9dd4630 100644 --- a/src/lib/int.ts +++ b/src/lib/provable/int.ts @@ -1,6 +1,6 @@ import { Field, Bool } from './core.js'; -import { AnyConstructor, Struct } from './provable-types/struct.js'; -import { Types } from '../bindings/mina-transaction/types.js'; +import { AnyConstructor, Struct } from './types/struct.js'; +import { Types } from '../../bindings/mina-transaction/types.js'; import { HashInput } from './hash.js'; import { Provable } from './provable.js'; import * as RangeCheck from './gadgets/range-check.js'; @@ -8,8 +8,8 @@ import * as Bitwise from './gadgets/bitwise.js'; import { addMod32 } from './gadgets/arithmetic.js'; import type { Gadgets } from './gadgets/gadgets.js'; import { withMessage } from './field.js'; -import { FieldVar } from './provable-core/fieldvar.js'; -import { CircuitValue, prop } from './provable-types/circuit-value.js'; +import { FieldVar } from './core/fieldvar.js'; +import { CircuitValue, prop } from './types/circuit-value.js'; // external API export { UInt8, UInt32, UInt64, Int64, Sign }; diff --git a/src/lib/keccak.ts b/src/lib/provable/keccak.ts similarity index 99% rename from src/lib/keccak.ts rename to src/lib/provable/keccak.ts index e4b7c9e746..31103e9604 100644 --- a/src/lib/keccak.ts +++ b/src/lib/provable/keccak.ts @@ -1,9 +1,9 @@ import { Field } from './field.js'; import { Gadgets } from './gadgets/gadgets.js'; -import { assert } from './util/errors.js'; -import { FlexibleBytes } from './provable-types/bytes.js'; +import { assert } from '../util/errors.js'; +import { FlexibleBytes } from './types/bytes.js'; import { UInt8 } from './int.js'; -import { Bytes } from './provable-types/provable-types.js'; +import { Bytes } from './types/provable-types.js'; import { bytesToWords, wordsToBytes } from './gadgets/bit-slices.js'; export { Keccak }; diff --git a/src/lib/keccak.unit-test.ts b/src/lib/provable/keccak.unit-test.ts similarity index 97% rename from src/lib/keccak.unit-test.ts rename to src/lib/provable/keccak.unit-test.ts index 066698313e..e33e36fe47 100644 --- a/src/lib/keccak.unit-test.ts +++ b/src/lib/provable/keccak.unit-test.ts @@ -1,10 +1,10 @@ import { Keccak } from './keccak.js'; -import { ZkProgram } from './proof-system/zkprogram.js'; +import { ZkProgram } from '../proof-system/zkprogram.js'; import { equivalentProvable, equivalent, equivalentAsync, -} from './testing/equivalent.js'; +} from '../testing/equivalent.js'; import { keccak_224, keccak_256, @@ -15,10 +15,10 @@ import { sha3_384, sha3_512, } from '@noble/hashes/sha3'; -import { Bytes } from './provable-types/provable-types.js'; +import { Bytes } from './types/provable-types.js'; import { bytes } from './gadgets/test-utils.js'; import { UInt8 } from './int.js'; -import { test, Random, sample } from './testing/property.js'; +import { test, Random, sample } from '../testing/property.js'; import { expect } from 'expect'; const RUNS = 1; diff --git a/src/lib/nullifier.ts b/src/lib/provable/nullifier.ts similarity index 97% rename from src/lib/nullifier.ts rename to src/lib/provable/nullifier.ts index d8a217f030..39b5240749 100644 --- a/src/lib/nullifier.ts +++ b/src/lib/provable/nullifier.ts @@ -1,8 +1,8 @@ -import type { Nullifier as JsonNullifier } from '../mina-signer/src/types.js'; -import { Struct } from './provable-types/struct.js'; +import type { Nullifier as JsonNullifier } from '../../mina-signer/src/types.js'; +import { Struct } from './types/struct.js'; import { Field, Group, Scalar } from './core.js'; import { Poseidon } from './hash.js'; -import { MerkleMapWitness } from './provable-types/merkle-map.js'; +import { MerkleMapWitness } from './types/merkle-map.js'; import { PrivateKey, PublicKey, scaleShifted } from './signature.js'; import { Provable } from './provable.js'; diff --git a/src/lib/nullifier.unit-test.ts b/src/lib/provable/nullifier.unit-test.ts similarity index 95% rename from src/lib/nullifier.unit-test.ts rename to src/lib/provable/nullifier.unit-test.ts index 50af523e26..e55dc68408 100644 --- a/src/lib/nullifier.unit-test.ts +++ b/src/lib/provable/nullifier.unit-test.ts @@ -1,4 +1,4 @@ -import { createNullifier } from '../mina-signer/src/nullifier.js'; +import { createNullifier } from '../../mina-signer/src/nullifier.js'; import { Field } from './core.js'; import { Nullifier } from './nullifier.js'; import { PrivateKey } from './signature.js'; diff --git a/src/lib/primitives.test.ts b/src/lib/provable/primitives.test.ts similarity index 100% rename from src/lib/primitives.test.ts rename to src/lib/provable/primitives.test.ts diff --git a/src/lib/primitives.unit-test.ts b/src/lib/provable/primitives.unit-test.ts similarity index 91% rename from src/lib/primitives.unit-test.ts rename to src/lib/provable/primitives.unit-test.ts index fa206b2699..c4aea5e64c 100644 --- a/src/lib/primitives.unit-test.ts +++ b/src/lib/provable/primitives.unit-test.ts @@ -1,4 +1,4 @@ -import { Circuit, circuitMain } from './proof-system/circuit.js'; +import { Circuit, circuitMain } from '../proof-system/circuit.js'; import { UInt64, UInt32 } from './int.js'; import { expect } from 'expect'; import { Provable } from './provable.js'; diff --git a/src/lib/provable-context.ts b/src/lib/provable/provable-context.ts similarity index 94% rename from src/lib/provable-context.ts rename to src/lib/provable/provable-context.ts index a84dd471f9..ba930e0222 100644 --- a/src/lib/provable-context.ts +++ b/src/lib/provable/provable-context.ts @@ -1,9 +1,9 @@ -import { Context } from './util/global-context.js'; -import { Gate, GateType, JsonGate, Snarky } from '../snarky.js'; -import { parseHexString32 } from '../bindings/crypto/bigint-helpers.js'; -import { prettifyStacktrace } from './util/errors.js'; -import { Fp } from '../bindings/crypto/finite-field.js'; -import { MlBool } from './ml/base.js'; +import { Context } from '../util/global-context.js'; +import { Gate, GateType, JsonGate, Snarky } from '../../snarky.js'; +import { parseHexString32 } from '../../bindings/crypto/bigint-helpers.js'; +import { prettifyStacktrace } from '../util/errors.js'; +import { Fp } from '../../bindings/crypto/finite-field.js'; +import { MlBool } from '../ml/base.js'; // internal API export { diff --git a/src/lib/provable.test.ts b/src/lib/provable/provable.test.ts similarity index 100% rename from src/lib/provable.test.ts rename to src/lib/provable/provable.test.ts diff --git a/src/lib/provable.ts b/src/lib/provable/provable.ts similarity index 98% rename from src/lib/provable.ts rename to src/lib/provable/provable.ts index 36ef679fca..6e8fcc445a 100644 --- a/src/lib/provable.ts +++ b/src/lib/provable/provable.ts @@ -5,18 +5,15 @@ */ import { Bool } from './bool.js'; import { Field } from './field.js'; -import type { Provable as Provable_ } from './provable-types/provable-intf.js'; -import type { - FlexibleProvable, - ProvableExtended, -} from './provable-types/struct.js'; -import { Context } from './util/global-context.js'; +import type { Provable as Provable_ } from './types/provable-intf.js'; +import type { FlexibleProvable, ProvableExtended } from './types/struct.js'; +import { Context } from '../util/global-context.js'; import { HashInput, InferJson, InferProvable, InferredProvable, -} from './provable-types/provable-derivers.js'; +} from './types/provable-derivers.js'; import { inCheckedComputation, inProver, @@ -25,7 +22,7 @@ import { constraintSystem, generateWitness, } from './provable-context.js'; -import { exists, existsAsync } from './provable-core/exists.js'; +import { exists, existsAsync } from './core/exists.js'; // external API export { Provable }; diff --git a/src/lib/provable.unit-test.ts b/src/lib/provable/provable.unit-test.ts similarity index 91% rename from src/lib/provable.unit-test.ts rename to src/lib/provable/provable.unit-test.ts index d1a6991dba..ff89555e75 100644 --- a/src/lib/provable.unit-test.ts +++ b/src/lib/provable/provable.unit-test.ts @@ -2,7 +2,7 @@ import { it } from 'node:test'; import { Provable } from './provable.js'; import { Field } from './field.js'; import { expect } from 'expect'; -import { exists } from './provable-core/exists.js'; +import { exists } from './core/exists.js'; await it('can witness large field array', async () => { let N = 100_000; diff --git a/src/lib/scalar.test.ts b/src/lib/provable/scalar.test.ts similarity index 100% rename from src/lib/scalar.test.ts rename to src/lib/provable/scalar.test.ts diff --git a/src/lib/scalar.ts b/src/lib/provable/scalar.ts similarity index 97% rename from src/lib/scalar.ts rename to src/lib/provable/scalar.ts index fa5a03b222..87b9f1ce76 100644 --- a/src/lib/scalar.ts +++ b/src/lib/provable/scalar.ts @@ -1,9 +1,9 @@ -import { Snarky } from '../snarky.js'; -import { Fq } from '../bindings/crypto/finite-field.js'; -import { Scalar as SignableFq } from '../mina-signer/src/curve-bigint.js'; +import { Snarky } from '../../snarky.js'; +import { Fq } from '../../bindings/crypto/finite-field.js'; +import { Scalar as SignableFq } from '../../mina-signer/src/curve-bigint.js'; import { Field } from './field.js'; -import { FieldVar, FieldConst } from './provable-core/fieldvar.js'; -import { MlArray } from './ml/base.js'; +import { FieldVar, FieldConst } from './core/fieldvar.js'; +import { MlArray } from '../ml/base.js'; import { Bool } from './bool.js'; export { Scalar, ScalarConst, unshift, shift }; diff --git a/src/lib/signature.ts b/src/lib/provable/signature.ts similarity index 97% rename from src/lib/signature.ts rename to src/lib/provable/signature.ts index 0462ce7820..369cb26ae4 100644 --- a/src/lib/signature.ts +++ b/src/lib/provable/signature.ts @@ -1,19 +1,19 @@ import { Field, Bool, Group, Scalar } from './core.js'; -import { AnyConstructor } from './provable-types/struct.js'; +import { AnyConstructor } from './types/struct.js'; import { hashWithPrefix } from './hash.js'; -import { Fq } from '../bindings/crypto/finite-field.js'; +import { Fq } from '../../bindings/crypto/finite-field.js'; import { deriveNonce, Signature as SignatureBigint, signaturePrefix, -} from '../mina-signer/src/signature.js'; +} from '../../mina-signer/src/signature.js'; import { PrivateKey as PrivateKeyBigint, PublicKey as PublicKeyBigint, -} from '../mina-signer/src/curve-bigint.js'; +} from '../../mina-signer/src/curve-bigint.js'; import { constantScalarToBigint } from './scalar.js'; import { toConstantField } from './field.js'; -import { CircuitValue, prop } from './provable-types/circuit-value.js'; +import { CircuitValue, prop } from './types/circuit-value.js'; // external API export { PrivateKey, PublicKey, Signature }; diff --git a/src/lib/provable-types/auxiliary.ts b/src/lib/provable/types/auxiliary.ts similarity index 100% rename from src/lib/provable-types/auxiliary.ts rename to src/lib/provable/types/auxiliary.ts diff --git a/src/lib/provable-types/bytes.ts b/src/lib/provable/types/bytes.ts similarity index 96% rename from src/lib/provable-types/bytes.ts rename to src/lib/provable/types/bytes.ts index 078d936890..08cfad037e 100644 --- a/src/lib/provable-types/bytes.ts +++ b/src/lib/provable/types/bytes.ts @@ -1,10 +1,10 @@ import { provableFromClass } from './provable-derivers.js'; import type { ProvablePureExtended } from './struct.js'; import { assert } from '../gadgets/common.js'; -import { chunkString } from '../util/arrays.js'; +import { chunkString } from '../../util/arrays.js'; import { Provable } from '../provable.js'; import { UInt8 } from '../int.js'; -import { randomBytes } from '../../bindings/crypto/random.js'; +import { randomBytes } from '../../../bindings/crypto/random.js'; // external API export { Bytes }; diff --git a/src/lib/provable-types/circuit-value.ts b/src/lib/provable/types/circuit-value.ts similarity index 100% rename from src/lib/provable-types/circuit-value.ts rename to src/lib/provable/types/circuit-value.ts diff --git a/src/lib/provable-types/fields.ts b/src/lib/provable/types/fields.ts similarity index 100% rename from src/lib/provable-types/fields.ts rename to src/lib/provable/types/fields.ts diff --git a/src/lib/provable-types/merkle-list.ts b/src/lib/provable/types/merkle-list.ts similarity index 100% rename from src/lib/provable-types/merkle-list.ts rename to src/lib/provable/types/merkle-list.ts diff --git a/src/lib/provable-types/merkle-map.test.ts b/src/lib/provable/types/merkle-map.test.ts similarity index 100% rename from src/lib/provable-types/merkle-map.test.ts rename to src/lib/provable/types/merkle-map.test.ts diff --git a/src/lib/provable-types/merkle-map.ts b/src/lib/provable/types/merkle-map.ts similarity index 100% rename from src/lib/provable-types/merkle-map.ts rename to src/lib/provable/types/merkle-map.ts diff --git a/src/lib/provable-types/merkle-tree.test.ts b/src/lib/provable/types/merkle-tree.test.ts similarity index 100% rename from src/lib/provable-types/merkle-tree.test.ts rename to src/lib/provable/types/merkle-tree.test.ts diff --git a/src/lib/provable-types/merkle-tree.ts b/src/lib/provable/types/merkle-tree.ts similarity index 100% rename from src/lib/provable-types/merkle-tree.ts rename to src/lib/provable/types/merkle-tree.ts diff --git a/src/lib/provable-types/merkle-tree.unit-test.ts b/src/lib/provable/types/merkle-tree.unit-test.ts similarity index 89% rename from src/lib/provable-types/merkle-tree.unit-test.ts rename to src/lib/provable/types/merkle-tree.unit-test.ts index ea2d4620c4..3e5c3d378c 100644 --- a/src/lib/provable-types/merkle-tree.unit-test.ts +++ b/src/lib/provable/types/merkle-tree.unit-test.ts @@ -1,6 +1,6 @@ import { Bool, Field } from '../core.js'; import { maybeSwap } from './merkle-tree.js'; -import { Random, test } from '../testing/property.js'; +import { Random, test } from '../../testing/property.js'; import { expect } from 'expect'; test(Random.bool, Random.field, Random.field, (b, x, y) => { diff --git a/src/lib/provable-types/packed.ts b/src/lib/provable/types/packed.ts similarity index 100% rename from src/lib/provable-types/packed.ts rename to src/lib/provable/types/packed.ts diff --git a/src/lib/provable-types/provable-derivers.ts b/src/lib/provable/types/provable-derivers.ts similarity index 93% rename from src/lib/provable-types/provable-derivers.ts rename to src/lib/provable/types/provable-derivers.ts index faaea81f1c..a1871b3c7c 100644 --- a/src/lib/provable-types/provable-derivers.ts +++ b/src/lib/provable/types/provable-derivers.ts @@ -9,9 +9,9 @@ import { IsPure as GenericIsPure, createHashInput, Constructor, -} from '../../bindings/lib/provable-generic.js'; -import { Tuple } from '../util/types.js'; -import { GenericHashInput } from '../../bindings/lib/generic.js'; +} from '../../../bindings/lib/provable-generic.js'; +import { Tuple } from '../../util/types.js'; +import { GenericHashInput } from '../../../bindings/lib/generic.js'; // external API export { diff --git a/src/lib/provable-types/provable-intf.ts b/src/lib/provable/types/provable-intf.ts similarity index 100% rename from src/lib/provable-types/provable-intf.ts rename to src/lib/provable/types/provable-intf.ts diff --git a/src/lib/provable-types/provable-types.ts b/src/lib/provable/types/provable-types.ts similarity index 100% rename from src/lib/provable-types/provable-types.ts rename to src/lib/provable/types/provable-types.ts diff --git a/src/lib/provable-types/string.test.ts b/src/lib/provable/types/string.test.ts similarity index 100% rename from src/lib/provable-types/string.test.ts rename to src/lib/provable/types/string.test.ts diff --git a/src/lib/provable-types/string.ts b/src/lib/provable/types/string.ts similarity index 100% rename from src/lib/provable-types/string.ts rename to src/lib/provable/types/string.ts diff --git a/src/lib/provable-types/struct.ts b/src/lib/provable/types/struct.ts similarity index 99% rename from src/lib/provable-types/struct.ts rename to src/lib/provable/types/struct.ts index e4bf6e7893..f20dbda0c4 100644 --- a/src/lib/provable-types/struct.ts +++ b/src/lib/provable/types/struct.ts @@ -13,7 +13,7 @@ import type { IsPure, } from './provable-derivers.js'; import { Provable } from '../provable.js'; -import { Proof } from '../proof-system/zkprogram.js'; +import { Proof } from '../../proof-system/zkprogram.js'; import { ProvablePure } from './provable-intf.js'; // external API diff --git a/src/lib/provable-types/struct.unit-test.ts b/src/lib/provable/types/struct.unit-test.ts similarity index 95% rename from src/lib/provable-types/struct.unit-test.ts rename to src/lib/provable/types/struct.unit-test.ts index 5a67b0b2f4..6fd4c4a92c 100644 --- a/src/lib/provable-types/struct.unit-test.ts +++ b/src/lib/provable/types/struct.unit-test.ts @@ -3,14 +3,14 @@ import { Unconstrained } from './unconstrained.js'; import { UInt32 } from '../int.js'; import { PrivateKey, PublicKey } from '../signature.js'; import { expect } from 'expect'; -import { method, SmartContract } from '../mina/zkapp.js'; +import { method, SmartContract } from '../../mina/zkapp.js'; import { LocalBlockchain, setActiveInstance, transaction, -} from '../mina/mina.js'; -import { State, state } from '../mina/state.js'; -import { AccountUpdate } from '../mina/account-update.js'; +} from '../../mina/mina.js'; +import { State, state } from '../../mina/state.js'; +import { AccountUpdate } from '../../mina/account-update.js'; import { Provable } from '../provable.js'; import { Field } from '../core.js'; diff --git a/src/lib/provable-types/unconstrained.ts b/src/lib/provable/types/unconstrained.ts similarity index 97% rename from src/lib/provable-types/unconstrained.ts rename to src/lib/provable/types/unconstrained.ts index f4241e7888..7bdc9647e8 100644 --- a/src/lib/provable-types/unconstrained.ts +++ b/src/lib/provable/types/unconstrained.ts @@ -1,7 +1,7 @@ -import { Snarky } from '../../snarky.js'; +import { Snarky } from '../../../snarky.js'; import { Field } from '../field.js'; import { Provable } from '../provable.js'; -import { assert } from '../util/errors.js'; +import { assert } from '../../util/errors.js'; import { inCheckedComputation } from '../provable-context.js'; export { Unconstrained }; diff --git a/src/lib/testing/constraint-system.ts b/src/lib/testing/constraint-system.ts index dc174ac2fd..502d91de68 100644 --- a/src/lib/testing/constraint-system.ts +++ b/src/lib/testing/constraint-system.ts @@ -6,14 +6,17 @@ */ import { Gate, GateType } from '../../snarky.js'; import { randomBytes } from '../../bindings/crypto/random.js'; -import { Field } from '../field.js'; -import { FieldType, FieldVar } from '../provable-core/fieldvar.js'; -import { Provable } from '../provable.js'; +import { Field } from '../provable/field.js'; +import { FieldType, FieldVar } from '../provable/core/fieldvar.js'; +import { Provable } from '../provable/provable.js'; import { Tuple } from '../util/types.js'; import { Random } from './random.js'; import { test } from './property.js'; import { Undefined, ZkProgram } from '../proof-system/zkprogram.js'; -import { constraintSystemSync, printGates } from '../provable-context.js'; +import { + constraintSystemSync, + printGates, +} from '../provable/provable-context.js'; export { constraintSystem, diff --git a/src/lib/testing/equivalent.ts b/src/lib/testing/equivalent.ts index e44527c858..52d5e54e44 100644 --- a/src/lib/testing/equivalent.ts +++ b/src/lib/testing/equivalent.ts @@ -2,13 +2,13 @@ * helpers for testing equivalence of two implementations, one of them on bigints */ import { test, Random } from '../testing/property.js'; -import { Provable } from '../provable.js'; +import { Provable } from '../provable/provable.js'; import { deepEqual } from 'node:assert/strict'; -import { Bool, Field } from '../core.js'; +import { Bool, Field } from '../provable/core.js'; import { AnyFunction, Tuple } from '../util/types.js'; -import { provable } from '../provable-types/struct.js'; -import { assert } from '../gadgets/common.js'; -import { runAndCheckSync } from '../provable-context.js'; +import { provable } from '../provable/types/struct.js'; +import { assert } from '../provable/gadgets/common.js'; +import { runAndCheckSync } from '../provable/provable-context.js'; export { equivalent, diff --git a/src/lib/util/arrays.ts b/src/lib/util/arrays.ts index 2a1a913eef..891de81015 100644 --- a/src/lib/util/arrays.ts +++ b/src/lib/util/arrays.ts @@ -1,4 +1,4 @@ -import { assert } from '../gadgets/common.js'; +import { assert } from './errors.js'; export { chunk, chunkString }; diff --git a/src/mina-signer/src/poseidon-bigint.ts b/src/mina-signer/src/poseidon-bigint.ts index 5ab0dbfa20..19a46bcf00 100644 --- a/src/mina-signer/src/poseidon-bigint.ts +++ b/src/mina-signer/src/poseidon-bigint.ts @@ -3,7 +3,7 @@ import { Poseidon, PoseidonLegacy } from '../../bindings/crypto/poseidon.js'; import { prefixes } from '../../bindings/crypto/constants.js'; import { createHashInput } from '../../bindings/lib/provable-generic.js'; import { GenericHashInput } from '../../bindings/lib/generic.js'; -import { createHashHelpers } from '../../lib/hash-generic.js'; +import { createHashHelpers } from '../../lib/provable/hash-generic.js'; export { Poseidon, diff --git a/src/mina-signer/src/sign-zkapp-command.unit-test.ts b/src/mina-signer/src/sign-zkapp-command.unit-test.ts index cf0739f5a4..d3adf5f05e 100644 --- a/src/mina-signer/src/sign-zkapp-command.unit-test.ts +++ b/src/mina-signer/src/sign-zkapp-command.unit-test.ts @@ -11,14 +11,14 @@ import { AccountUpdate as AccountUpdateSnarky, ZkappCommand as ZkappCommandSnarky, } from '../../lib/mina/account-update.js'; -import { FieldConst } from '../../lib/provable-core/fieldvar.js'; -import { packToFields as packToFieldsSnarky } from '../../lib/hash.js'; +import { FieldConst } from '../../lib/provable/core/fieldvar.js'; +import { packToFields as packToFieldsSnarky } from '../../lib/provable/hash.js'; import { Network, setActiveInstance } from '../../lib/mina/mina.js'; import { Ml, MlHashInput } from '../../lib/ml/conversion.js'; import { PrivateKey as PrivateKeySnarky, PublicKey as PublicKeySnarky, -} from '../../lib/signature.js'; +} from '../../lib/provable/signature.js'; import { Random, test, withHardCoded } from '../../lib/testing/property.js'; import { PrivateKey, PublicKey } from './curve-bigint.js'; import { hashWithPrefix, packToFields, prefixes } from './poseidon-bigint.js'; diff --git a/src/mina-signer/src/signature.unit-test.ts b/src/mina-signer/src/signature.unit-test.ts index 786e64dfd1..a1671b97b6 100644 --- a/src/mina-signer/src/signature.unit-test.ts +++ b/src/mina-signer/src/signature.unit-test.ts @@ -10,12 +10,12 @@ import { import { Test } from '../../snarky.js'; import { Field } from './field-bigint.js'; import { PrivateKey, PublicKey } from './curve-bigint.js'; -import { PrivateKey as PrivateKeySnarky } from '../../lib/signature.js'; +import { PrivateKey as PrivateKeySnarky } from '../../lib/provable/signature.js'; import { p } from '../../bindings/crypto/finite-field.js'; import { AccountUpdate } from '../../bindings/mina-transaction/gen/transaction-bigint.js'; import { HashInput } from './derivers-bigint.js'; import { Ml } from '../../lib/ml/conversion.js'; -import { FieldConst } from '../../lib/provable-core/fieldvar.js'; +import { FieldConst } from '../../lib/provable/core/fieldvar.js'; import { NetworkId } from './types.js'; // check consistency with OCaml, where we expose the function to sign 1 field element with "testnet" diff --git a/src/mina-signer/tests/verify-in-snark.unit-test.ts b/src/mina-signer/tests/verify-in-snark.unit-test.ts index bd4d401882..481660f962 100644 --- a/src/mina-signer/tests/verify-in-snark.unit-test.ts +++ b/src/mina-signer/tests/verify-in-snark.unit-test.ts @@ -1,9 +1,9 @@ -import { Field } from '../../lib/core.js'; +import { Field } from '../../lib/provable/core.js'; import { ZkProgram } from '../../lib/proof-system/zkprogram.js'; import Client from '../mina-signer.js'; -import { PrivateKey, Signature } from '../../lib/signature.js'; +import { PrivateKey, Signature } from '../../lib/provable/signature.js'; import { expect } from 'expect'; -import { Provable } from '../../lib/provable.js'; +import { Provable } from '../../lib/provable/provable.js'; let fields = [10n, 20n, 30n, 340817401n, 2091283n, 1n, 0n]; let privateKey = 'EKENaWFuAiqktsnWmxq8zaoR8bSgVdscsghJE5tV6hPoNm8qBKWM'; diff --git a/src/mina-signer/tests/zkapp.unit-test.ts b/src/mina-signer/tests/zkapp.unit-test.ts index 165ab7fb0f..ddf7779b09 100644 --- a/src/mina-signer/tests/zkapp.unit-test.ts +++ b/src/mina-signer/tests/zkapp.unit-test.ts @@ -4,7 +4,7 @@ import Client from '../mina-signer.js'; import { accountUpdateExample } from '../src/test-vectors/accountUpdate.js'; import { expect } from 'expect'; import { Transaction } from '../../lib/mina/mina.js'; -import { PrivateKey } from '../../lib/signature.js'; +import { PrivateKey } from '../../lib/provable/signature.js'; import { Signature } from '../src/signature.js'; import { mocks } from '../../bindings/crypto/constants.js'; diff --git a/src/snarky.d.ts b/src/snarky.d.ts index 27a2663e88..d7e984dfcb 100644 --- a/src/snarky.d.ts +++ b/src/snarky.d.ts @@ -1,12 +1,12 @@ import type { Account as JsonAccount } from './bindings/mina-transaction/gen/transaction-json.js'; -import type { Field } from './lib/field.js'; +import type { Field } from './lib/provable/field.js'; import type { FieldVar, FieldConst, VarFieldVar, -} from './lib/provable-core/fieldvar.ts'; -import type { BoolVar, Bool } from './lib/bool.js'; -import type { ScalarConst } from './lib/scalar.js'; +} from './lib/provable/core/fieldvar.ts'; +import type { BoolVar } from './lib/provable/bool.ts'; +import type { ScalarConst } from './lib/provable/scalar.js'; import type { MlArray, MlPair, @@ -30,8 +30,8 @@ import type { WasmFqSrs, } from './bindings/compiled/node_bindings/plonk_wasm.cjs'; import * as wasm from './bindings/compiled/node_bindings/plonk_wasm.cjs'; -import type { KimchiGateType } from './lib/gates.ts'; -import type { MlConstraintSystem } from './lib/provable-context.ts'; +import type { KimchiGateType } from './lib/provable/gates.ts'; +import type { MlConstraintSystem } from './lib/provable/provable-context.ts'; import type { FieldVector } from './bindings/crypto/bindings/vector.ts'; export { Ledger, Pickles, Gate, GateType, wasm }; From 5106fb85fc0d0c921154241ba24b9353c7e6b161 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 14:19:54 +0100 Subject: [PATCH 5/7] more lib/provable restructure --- src/bindings | 2 +- src/index.ts | 39 +++++++++---------- src/lib/mina/account-update.ts | 12 ++++-- src/lib/mina/account.ts | 2 +- src/lib/mina/fetch.ts | 2 +- src/lib/mina/hash-input.unit-test.ts | 2 +- src/lib/mina/local-blockchain.ts | 2 +- src/lib/mina/mina-instance.ts | 2 +- src/lib/mina/mina.ts | 2 +- src/lib/mina/precondition.ts | 7 +++- src/lib/mina/state.ts | 2 +- src/lib/mina/token/forest-iterator.ts | 5 +-- .../mina/token/forest-iterator.unit-test.ts | 2 +- src/lib/mina/token/token-contract.ts | 2 +- src/lib/mina/token/token-methods.ts | 2 +- src/lib/mina/transaction-context.ts | 2 +- src/lib/mina/transaction-logic/ledger.ts | 2 +- src/lib/mina/transaction-validation.ts | 2 +- src/lib/mina/transaction.ts | 2 +- src/lib/mina/zkapp.ts | 6 +-- src/lib/ml/consistency.unit-test.ts | 4 +- src/lib/ml/conversion.ts | 2 +- src/lib/proof-system/circuit.ts | 5 ++- .../proof-system/proof-system.unit-test.ts | 2 +- src/lib/proof-system/zkprogram.ts | 4 +- src/lib/provable/bool.ts | 2 +- src/lib/provable/{types => }/bytes.ts | 14 +++---- .../provable/{ => core}/provable-context.ts | 12 +++--- src/lib/provable/{ => crypto}/crypto.ts | 4 +- src/lib/provable/{ => crypto}/encryption.ts | 6 +-- .../provable/{ => crypto}/foreign-curve.ts | 18 ++++----- .../provable/{ => crypto}/foreign-ecdsa.ts | 20 +++++----- src/lib/provable/{ => crypto}/hash-generic.ts | 4 +- .../{hashes-combined.ts => crypto/hash.ts} | 6 +-- src/lib/provable/{ => crypto}/keccak.ts | 14 +++---- src/lib/provable/{ => crypto}/nullifier.ts | 12 +++--- .../provable/{hash.ts => crypto/poseidon.ts} | 18 ++++----- src/lib/provable/{ => crypto}/signature.ts | 18 ++++----- src/lib/provable/field.ts | 2 +- src/lib/provable/{types => }/fields.ts | 4 +- src/lib/provable/gadgets/elliptic-curve.ts | 2 +- src/lib/provable/gadgets/foreign-field.ts | 2 +- src/lib/provable/gadgets/sha256.ts | 4 +- src/lib/provable/gadgets/sha256.unit-test.ts | 2 +- src/lib/provable/gadgets/test-utils.ts | 2 +- src/lib/provable/int.ts | 2 +- src/lib/provable/{types => }/merkle-list.ts | 14 +++---- src/lib/provable/{types => }/merkle-map.ts | 8 ++-- src/lib/provable/{types => }/merkle-tree.ts | 8 ++-- src/lib/provable/{types => }/packed.ts | 14 +++---- .../provable/{types => }/provable-types.ts | 0 src/lib/provable/provable.ts | 2 +- src/lib/provable/{types => }/string.ts | 10 ++--- .../provable/{ => test}/field.unit-test.ts | 22 +++++------ .../{ => test}/foreign-curve.unit-test.ts | 12 +++--- .../{ => test}/foreign-field.unit-test.ts | 24 ++++++------ src/lib/provable/{ => test}/group.test.ts | 0 .../provable/{ => test}/group.unit-test.ts | 10 ++--- src/lib/provable/{ => test}/int.test.ts | 0 .../provable/{ => test}/keccak.unit-test.ts | 14 +++---- .../{types => test}/merkle-map.test.ts | 0 .../{types => test}/merkle-tree.test.ts | 0 .../{types => test}/merkle-tree.unit-test.ts | 2 +- .../{ => test}/nullifier.unit-test.ts | 8 ++-- .../provable/{ => test}/primitives.test.ts | 0 .../{ => test}/primitives.unit-test.ts | 6 +-- src/lib/provable/{ => test}/provable.test.ts | 0 .../provable/{ => test}/provable.unit-test.ts | 6 +-- src/lib/provable/{ => test}/scalar.test.ts | 0 .../provable/{types => test}/string.test.ts | 0 .../{types => test}/struct.unit-test.ts | 6 +-- src/lib/provable/types/auxiliary.ts | 2 +- src/lib/provable/types/unconstrained.ts | 2 +- src/lib/testing/constraint-system.ts | 2 +- src/lib/testing/equivalent.ts | 2 +- src/mina-signer/src/poseidon-bigint.ts | 2 +- .../src/sign-zkapp-command.unit-test.ts | 4 +- src/mina-signer/src/signature.unit-test.ts | 2 +- .../tests/verify-in-snark.unit-test.ts | 2 +- src/mina-signer/tests/zkapp.unit-test.ts | 2 +- src/snarky.d.ts | 2 +- 81 files changed, 238 insertions(+), 234 deletions(-) rename src/lib/provable/{types => }/bytes.ts (88%) rename src/lib/provable/{ => core}/provable-context.ts (93%) rename src/lib/provable/{ => crypto}/crypto.ts (79%) rename src/lib/provable/{ => crypto}/encryption.ts (93%) rename src/lib/provable/{ => crypto}/foreign-curve.ts (94%) rename src/lib/provable/{ => crypto}/foreign-ecdsa.ts (94%) rename src/lib/provable/{ => crypto}/hash-generic.ts (83%) rename src/lib/provable/{hashes-combined.ts => crypto/hash.ts} (96%) rename src/lib/provable/{ => crypto}/keccak.ts (98%) rename src/lib/provable/{ => crypto}/nullifier.ts (95%) rename src/lib/provable/{hash.ts => crypto/poseidon.ts} (92%) rename src/lib/provable/{ => crypto}/signature.ts (95%) rename src/lib/provable/{types => }/fields.ts (91%) rename src/lib/provable/{types => }/merkle-list.ts (97%) rename src/lib/provable/{types => }/merkle-map.ts (95%) rename src/lib/provable/{types => }/merkle-tree.ts (97%) rename src/lib/provable/{types => }/packed.ts (94%) rename src/lib/provable/{types => }/provable-types.ts (100%) rename src/lib/provable/{types => }/string.ts (95%) rename src/lib/provable/{ => test}/field.unit-test.ts (91%) rename src/lib/provable/{ => test}/foreign-curve.unit-test.ts (78%) rename src/lib/provable/{ => test}/foreign-field.unit-test.ts (88%) rename src/lib/provable/{ => test}/group.test.ts (100%) rename src/lib/provable/{ => test}/group.unit-test.ts (88%) rename src/lib/provable/{ => test}/int.test.ts (100%) rename src/lib/provable/{ => test}/keccak.unit-test.ts (95%) rename src/lib/provable/{types => test}/merkle-map.test.ts (100%) rename src/lib/provable/{types => test}/merkle-tree.test.ts (100%) rename src/lib/provable/{types => test}/merkle-tree.unit-test.ts (91%) rename src/lib/provable/{ => test}/nullifier.unit-test.ts (87%) rename src/lib/provable/{ => test}/primitives.test.ts (100%) rename src/lib/provable/{ => test}/primitives.unit-test.ts (79%) rename src/lib/provable/{ => test}/provable.test.ts (100%) rename src/lib/provable/{ => test}/provable.unit-test.ts (79%) rename src/lib/provable/{ => test}/scalar.test.ts (100%) rename src/lib/provable/{types => test}/string.test.ts (100%) rename src/lib/provable/{types => test}/struct.unit-test.ts (96%) diff --git a/src/bindings b/src/bindings index 4c2d2e01ee..6e9cf7da3f 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 4c2d2e01ee6dd3215d29cd39440ca1b13cf4b16a +Subproject commit 6e9cf7da3f82b6c1ac9b6e6c718cd267a5db5970 diff --git a/src/index.ts b/src/index.ts index 6722a4ea7b..86ccf13e46 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,19 +10,22 @@ export { export { createForeignCurve, ForeignCurve, -} from './lib/provable/foreign-curve.js'; -export { createEcdsa, EcdsaSignature } from './lib/provable/foreign-ecdsa.js'; +} from './lib/provable/crypto/foreign-curve.js'; +export { + createEcdsa, + EcdsaSignature, +} from './lib/provable/crypto/foreign-ecdsa.js'; export { Poseidon, TokenSymbol, ProvableHashable, -} from './lib/provable/hash.js'; -export { Keccak } from './lib/provable/keccak.js'; -export { Hash } from './lib/provable/hashes-combined.js'; +} from './lib/provable/crypto/poseidon.js'; +export { Keccak } from './lib/provable/crypto/keccak.js'; +export { Hash } from './lib/provable/crypto/hash.js'; export { assert } from './lib/provable/gadgets/common.js'; -export * from './lib/provable/signature.js'; +export * from './lib/provable/crypto/signature.js'; export type { ProvableExtended, FlexibleProvable, @@ -39,15 +42,12 @@ export { circuitMain, } from './lib/proof-system/circuit.js'; export { UInt32, UInt64, Int64, Sign, UInt8 } from './lib/provable/int.js'; -export { Bytes } from './lib/provable/types/provable-types.js'; -export { Packed, Hashed } from './lib/provable/types/packed.js'; +export { Bytes } from './lib/provable/provable-types.js'; +export { Packed, Hashed } from './lib/provable/packed.js'; export { Gadgets } from './lib/provable/gadgets/gadgets.js'; export { Types } from './bindings/mina-transaction/types.js'; -export { - MerkleList, - MerkleListIterator, -} from './lib/provable/types/merkle-list.js'; +export { MerkleList, MerkleListIterator } from './lib/provable/merkle-list.js'; export * as Mina from './lib/mina/mina.js'; export { @@ -105,20 +105,17 @@ export { sendZkapp, Lightnet, } from './lib/mina/fetch.js'; -export * as Encryption from './lib/provable/encryption.js'; +export * as Encryption from './lib/provable/crypto/encryption.js'; export * as Encoding from './bindings/lib/encoding.js'; -export { Character, CircuitString } from './lib/provable/types/string.js'; -export { MerkleTree, MerkleWitness } from './lib/provable/types/merkle-tree.js'; -export { - MerkleMap, - MerkleMapWitness, -} from './lib/provable/types/merkle-map.js'; +export { Character, CircuitString } from './lib/provable/string.js'; +export { MerkleTree, MerkleWitness } from './lib/provable/merkle-tree.js'; +export { MerkleMap, MerkleMapWitness } from './lib/provable/merkle-map.js'; -export { Nullifier } from './lib/provable/nullifier.js'; +export { Nullifier } from './lib/provable/crypto/nullifier.js'; export { ZkProgram } from './lib/proof-system/zkprogram.js'; -export { Crypto } from './lib/provable/crypto.js'; +export { Crypto } from './lib/provable/crypto/crypto.js'; export type { NetworkId } from './mina-signer/mina-signer.js'; diff --git a/src/lib/mina/account-update.ts b/src/lib/mina/account-update.ts index a6f3ac412c..7f6fb46284 100644 --- a/src/lib/mina/account-update.ts +++ b/src/lib/mina/account-update.ts @@ -18,7 +18,7 @@ import { TypesBigint, toJSONEssential, } from '../../bindings/mina-transaction/types.js'; -import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { UInt64, UInt32, Int64, Sign } from '../provable/int.js'; import type { SmartContract } from './zkapp.js'; import { @@ -43,7 +43,11 @@ import { Actions, } from '../../bindings/mina-transaction/transaction-leaves.js'; import { TokenId as Base58TokenId } from './base58-encodings.js'; -import { hashWithPrefix, packToFields, Poseidon } from '../provable/hash.js'; +import { + hashWithPrefix, + packToFields, + Poseidon, +} from '../provable/crypto/poseidon.js'; import { mocks, prefixes, @@ -70,8 +74,8 @@ import { genericHash, MerkleList, MerkleListBase, -} from '../provable/types/merkle-list.js'; -import { Hashed } from '../provable/types/packed.js'; +} from '../provable/merkle-list.js'; +import { Hashed } from '../provable/packed.js'; import { accountUpdateLayout, smartContractContext, diff --git a/src/lib/mina/account.ts b/src/lib/mina/account.ts index 4877f2e2ba..f1f38eabe2 100644 --- a/src/lib/mina/account.ts +++ b/src/lib/mina/account.ts @@ -2,7 +2,7 @@ import { Types } from '../../bindings/mina-transaction/types.js'; import { Bool, Field } from '../provable/core.js'; import { Permissions } from './account-update.js'; import { UInt32, UInt64 } from '../provable/int.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import { TokenId, ReceiptChainHash } from './base58-encodings.js'; import { genericLayoutFold } from '../../bindings/lib/from-layout.js'; import { diff --git a/src/lib/mina/fetch.ts b/src/lib/mina/fetch.ts index 96fbbc0f7b..b03439d619 100644 --- a/src/lib/mina/fetch.ts +++ b/src/lib/mina/fetch.ts @@ -2,7 +2,7 @@ import 'isomorphic-fetch'; import { Field } from '../provable/core.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { Actions, TokenId } from './account-update.js'; -import { PublicKey, PrivateKey } from '../provable/signature.js'; +import { PublicKey, PrivateKey } from '../provable/crypto/signature.js'; import { NetworkValue } from './precondition.js'; import { Types } from '../../bindings/mina-transaction/types.js'; import { ActionStates } from './mina.js'; diff --git a/src/lib/mina/hash-input.unit-test.ts b/src/lib/mina/hash-input.unit-test.ts index 2f6b102bf6..3f22d65d62 100644 --- a/src/lib/mina/hash-input.unit-test.ts +++ b/src/lib/mina/hash-input.unit-test.ts @@ -10,7 +10,7 @@ import { Json, provableFromLayout, } from '../../bindings/mina-transaction/gen/transaction.js'; -import { packToFields } from '../provable/hash.js'; +import { packToFields } from '../provable/crypto/poseidon.js'; import { Random, test } from '../testing/property.js'; import { MlHashInput } from '../ml/conversion.js'; import { MlFieldConstArray } from '../ml/fields.js'; diff --git a/src/lib/mina/local-blockchain.ts b/src/lib/mina/local-blockchain.ts index f90ed18940..5833d7cc6a 100644 --- a/src/lib/mina/local-blockchain.ts +++ b/src/lib/mina/local-blockchain.ts @@ -4,7 +4,7 @@ import { transactionCommitments } from '../../mina-signer/src/sign-zkapp-command import { Ledger, Test } from '../../snarky.js'; import { Field } from '../provable/core.js'; import { UInt32, UInt64 } from '../provable/int.js'; -import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { Account } from './account.js'; import { ZkappCommand, diff --git a/src/lib/mina/mina-instance.ts b/src/lib/mina/mina-instance.ts index ef660d6a52..0a657c79a9 100644 --- a/src/lib/mina/mina-instance.ts +++ b/src/lib/mina/mina-instance.ts @@ -3,7 +3,7 @@ */ import { Field } from '../provable/core.js'; import { UInt64, UInt32 } from '../provable/int.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import type { EventActionFilterOptions } from '././../mina/graphql.js'; import type { NetworkId } from '../../mina-signer/src/types.js'; import type { Transaction, PendingTransaction } from './mina.js'; diff --git a/src/lib/mina/mina.ts b/src/lib/mina/mina.ts index 7e2435d2d5..7745c8a8b7 100644 --- a/src/lib/mina/mina.ts +++ b/src/lib/mina/mina.ts @@ -1,7 +1,7 @@ import { Test } from '../../snarky.js'; import { Field } from '../provable/core.js'; import { UInt64 } from '../provable/int.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import { ZkappCommand, TokenId, Authorization } from './account-update.js'; import * as Fetch from './fetch.js'; import { invalidTransactionError } from './errors.js'; diff --git a/src/lib/mina/precondition.ts b/src/lib/mina/precondition.ts index 9eea81d7e6..96d55588c9 100644 --- a/src/lib/mina/precondition.ts +++ b/src/lib/mina/precondition.ts @@ -9,8 +9,11 @@ import type { AccountUpdate } from './account-update.js'; import { Int64, UInt32, UInt64 } from '../provable/int.js'; import { Layout } from '../../bindings/mina-transaction/gen/transaction.js'; import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; -import { emptyReceiptChainHash, TokenSymbol } from '../provable/hash.js'; -import { PublicKey } from '../provable/signature.js'; +import { + emptyReceiptChainHash, + TokenSymbol, +} from '../provable/crypto/poseidon.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import { Actions, ZkappUri, diff --git a/src/lib/mina/state.ts b/src/lib/mina/state.ts index 8ca96bc3cf..61a82e3855 100644 --- a/src/lib/mina/state.ts +++ b/src/lib/mina/state.ts @@ -1,6 +1,6 @@ import { FlexibleProvablePure } from '../provable/types/struct.js'; import { AccountUpdate, TokenId } from './account-update.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import * as Mina from './mina.js'; import { fetchAccount, networkConfig } from './fetch.js'; import { SmartContract } from './zkapp.js'; diff --git a/src/lib/mina/token/forest-iterator.ts b/src/lib/mina/token/forest-iterator.ts index 5d3a3c7fd0..67cdaf6f35 100644 --- a/src/lib/mina/token/forest-iterator.ts +++ b/src/lib/mina/token/forest-iterator.ts @@ -8,10 +8,7 @@ import { Field } from '../../provable/core.js'; import { Provable } from '../../provable/provable.js'; import { Struct } from '../../provable/types/struct.js'; import { assert } from '../../provable/gadgets/common.js'; -import { - MerkleListIterator, - MerkleList, -} from '../../provable/types/merkle-list.js'; +import { MerkleListIterator, MerkleList } from '../../provable/merkle-list.js'; export { TokenAccountUpdateIterator }; diff --git a/src/lib/mina/token/forest-iterator.unit-test.ts b/src/lib/mina/token/forest-iterator.unit-test.ts index 723769e48e..7072dc5756 100644 --- a/src/lib/mina/token/forest-iterator.unit-test.ts +++ b/src/lib/mina/token/forest-iterator.unit-test.ts @@ -15,7 +15,7 @@ import { } from '../../../mina-signer/src/sign-zkapp-command.js'; import assert from 'assert'; import { Field, Bool } from '../../provable/core.js'; -import { PublicKey } from '../../provable/signature.js'; +import { PublicKey } from '../../provable/crypto/signature.js'; // RANDOM NUMBER GENERATORS for account updates diff --git a/src/lib/mina/token/token-contract.ts b/src/lib/mina/token/token-contract.ts index 1974bf7181..b62b2ad75b 100644 --- a/src/lib/mina/token/token-contract.ts +++ b/src/lib/mina/token/token-contract.ts @@ -1,7 +1,7 @@ import { Bool } from '../../provable/core.js'; import { UInt64, Int64 } from '../../provable/int.js'; import { Provable } from '../../provable/provable.js'; -import { PublicKey } from '../../provable/signature.js'; +import { PublicKey } from '../../provable/crypto/signature.js'; import { AccountUpdate, AccountUpdateForest, diff --git a/src/lib/mina/token/token-methods.ts b/src/lib/mina/token/token-methods.ts index 0f61abb0b8..7e54acfa4e 100644 --- a/src/lib/mina/token/token-methods.ts +++ b/src/lib/mina/token/token-methods.ts @@ -1,6 +1,6 @@ import { AccountUpdate, Authorization, TokenId } from '../account-update.js'; import { isSmartContract } from '../smart-contract-base.js'; -import { PublicKey } from '../../provable/signature.js'; +import { PublicKey } from '../../provable/crypto/signature.js'; import type { SmartContract } from '../zkapp.js'; import { UInt64 } from '../../provable/int.js'; import { Bool, Field } from '../../provable/core.js'; diff --git a/src/lib/mina/transaction-context.ts b/src/lib/mina/transaction-context.ts index 6a85b23486..d10a4d7113 100644 --- a/src/lib/mina/transaction-context.ts +++ b/src/lib/mina/transaction-context.ts @@ -1,5 +1,5 @@ import type { AccountUpdateLayout } from './account-update.js'; -import type { PublicKey } from '../provable/signature.js'; +import type { PublicKey } from '../provable/crypto/signature.js'; import { Context } from '../util/global-context.js'; export { currentTransaction, CurrentTransaction, FetchMode }; diff --git a/src/lib/mina/transaction-logic/ledger.ts b/src/lib/mina/transaction-logic/ledger.ts index 305def3c7b..0ae1ce4dc3 100644 --- a/src/lib/mina/transaction-logic/ledger.ts +++ b/src/lib/mina/transaction-logic/ledger.ts @@ -1,7 +1,7 @@ /** * A ledger of accounts - simple model of a local blockchain. */ -import { PublicKey } from '../../provable/signature.js'; +import { PublicKey } from '../../provable/crypto/signature.js'; import type { AccountUpdate } from '../account-update.js'; import { Account, newAccount } from '../account.js'; import { Field } from '../../provable/field.js'; diff --git a/src/lib/mina/transaction-validation.ts b/src/lib/mina/transaction-validation.ts index 73562bd1ea..9df24d90e5 100644 --- a/src/lib/mina/transaction-validation.ts +++ b/src/lib/mina/transaction-validation.ts @@ -11,7 +11,7 @@ import { } from './account-update.js'; import { Field } from '../provable/core.js'; import { UInt64, UInt32 } from '../provable/int.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import { JsonProof, verify } from '../proof-system/zkprogram.js'; import { verifyAccountUpdateSignature } from '../../mina-signer/src/sign-zkapp-command.js'; import { TransactionCost, TransactionLimits } from './constants.js'; diff --git a/src/lib/mina/transaction.ts b/src/lib/mina/transaction.ts index 520cd982ea..4a028026ae 100644 --- a/src/lib/mina/transaction.ts +++ b/src/lib/mina/transaction.ts @@ -9,7 +9,7 @@ import { addMissingProofs, } from './account-update.js'; import { Field } from '../provable/core.js'; -import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { Empty, Proof } from '../proof-system/zkprogram.js'; import { currentTransaction } from './transaction-context.js'; diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index f5b9c407a9..f81f778caa 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -35,7 +35,7 @@ import { hashConstant, isHashable, packToFields, -} from '../provable/hash.js'; +} from '../provable/crypto/poseidon.js'; import { UInt32, UInt64 } from '../provable/int.js'; import * as Mina from './mina.js'; import { @@ -54,14 +54,14 @@ import { Proof, sortMethodArguments, } from '../proof-system/zkprogram.js'; -import { PublicKey } from '../provable/signature.js'; +import { PublicKey } from '../provable/crypto/signature.js'; import { assertStatePrecondition, cleanStatePrecondition } from './state.js'; import { inAnalyze, inCheckedComputation, inCompile, inProver, -} from '../provable/provable-context.js'; +} from '../provable/core/provable-context.js'; import { Cache } from '../proof-system/cache.js'; import { assert } from '../provable/gadgets/common.js'; import { SmartContractBase } from './smart-contract-base.js'; diff --git a/src/lib/ml/consistency.unit-test.ts b/src/lib/ml/consistency.unit-test.ts index b4167d0387..93647d16b7 100644 --- a/src/lib/ml/consistency.unit-test.ts +++ b/src/lib/ml/consistency.unit-test.ts @@ -1,13 +1,13 @@ import { Test } from '../../snarky.js'; import { Random, test } from '../testing/property.js'; import { Field, Bool } from '../provable/core.js'; -import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { TokenId, dummySignature } from '../mina/account-update.js'; import { Ml } from './conversion.js'; import { expect } from 'expect'; import { FieldConst } from '../provable/core/fieldvar.js'; import { Provable } from '../provable/provable.js'; -import { runAndCheckSync } from '../provable/provable-context.js'; +import { runAndCheckSync } from '../provable/core/provable-context.js'; // PrivateKey.toBase58, fromBase58 diff --git a/src/lib/ml/conversion.ts b/src/lib/ml/conversion.ts index d0b6ed7d98..4068fef636 100644 --- a/src/lib/ml/conversion.ts +++ b/src/lib/ml/conversion.ts @@ -7,7 +7,7 @@ import { HashInput } from '../provable/types/struct.js'; import { Bool, Field } from '../provable/core.js'; import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; import { Scalar, ScalarConst } from '../provable/scalar.js'; -import { PrivateKey, PublicKey } from '../provable/signature.js'; +import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { MlPair, MlBool, MlArray } from './base.js'; import { MlFieldConstArray } from './fields.js'; diff --git a/src/lib/proof-system/circuit.ts b/src/lib/proof-system/circuit.ts index a0a0b6c9a6..320e01b25b 100644 --- a/src/lib/proof-system/circuit.ts +++ b/src/lib/proof-system/circuit.ts @@ -3,7 +3,10 @@ import { Snarky } from '../../snarky.js'; import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; import { withThreadPool } from '../../snarky.js'; import { Provable } from '../provable/provable.js'; -import { snarkContext, gatesFromJson } from '../provable/provable-context.js'; +import { + snarkContext, + gatesFromJson, +} from '../provable/core/provable-context.js'; import { prettifyStacktrace, prettifyStacktracePromise, diff --git a/src/lib/proof-system/proof-system.unit-test.ts b/src/lib/proof-system/proof-system.unit-test.ts index ea8b962b1d..f6787b1e7f 100644 --- a/src/lib/proof-system/proof-system.unit-test.ts +++ b/src/lib/proof-system/proof-system.unit-test.ts @@ -12,7 +12,7 @@ import { import { expect } from 'expect'; import { Pickles, Snarky } from '../../snarky.js'; import { AnyFunction } from '../util/types.js'; -import { snarkContext } from '../provable/provable-context.js'; +import { snarkContext } from '../provable/core/provable-context.js'; import { it } from 'node:test'; import { Provable } from '../provable/provable.js'; import { bool, equivalentAsync, field, record } from '../testing/equivalent.js'; diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index 20f7a814f4..e09d23edfa 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -23,8 +23,8 @@ import { } from '../provable/types/struct.js'; import { Provable } from '../provable/provable.js'; import { assert, prettifyStacktracePromise } from '../util/errors.js'; -import { snarkContext } from '../provable/provable-context.js'; -import { hashConstant } from '../provable/hash.js'; +import { snarkContext } from '../provable/core/provable-context.js'; +import { hashConstant } from '../provable/crypto/poseidon.js'; import { MlArray, MlBool, MlResult, MlPair } from '../ml/base.js'; import { MlFieldArray, MlFieldConstArray } from '../ml/fields.js'; import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; diff --git a/src/lib/provable/bool.ts b/src/lib/provable/bool.ts index 78ec29eab5..8e6c7b4f9f 100644 --- a/src/lib/provable/bool.ts +++ b/src/lib/provable/bool.ts @@ -3,7 +3,7 @@ import { Field, readVarMessage, withMessage } from './field.js'; import { FieldVar, FieldConst, FieldType } from './core/fieldvar.js'; import { defineBinable } from '../../bindings/lib/binable.js'; import { NonNegativeInteger } from '../../bindings/crypto/non-negative.js'; -import { asProver } from './provable-context.js'; +import { asProver } from './core/provable-context.js'; import { existsOne } from './core/exists.js'; import { assertMul } from './gadgets/compatible.js'; import { setBoolConstructor } from './core/field-constructor.js'; diff --git a/src/lib/provable/types/bytes.ts b/src/lib/provable/bytes.ts similarity index 88% rename from src/lib/provable/types/bytes.ts rename to src/lib/provable/bytes.ts index 08cfad037e..e83b09fba0 100644 --- a/src/lib/provable/types/bytes.ts +++ b/src/lib/provable/bytes.ts @@ -1,10 +1,10 @@ -import { provableFromClass } from './provable-derivers.js'; -import type { ProvablePureExtended } from './struct.js'; -import { assert } from '../gadgets/common.js'; -import { chunkString } from '../../util/arrays.js'; -import { Provable } from '../provable.js'; -import { UInt8 } from '../int.js'; -import { randomBytes } from '../../../bindings/crypto/random.js'; +import { provableFromClass } from './types/provable-derivers.js'; +import type { ProvablePureExtended } from './types/struct.js'; +import { assert } from './gadgets/common.js'; +import { chunkString } from '../util/arrays.js'; +import { Provable } from './provable.js'; +import { UInt8 } from './int.js'; +import { randomBytes } from '../../bindings/crypto/random.js'; // external API export { Bytes }; diff --git a/src/lib/provable/provable-context.ts b/src/lib/provable/core/provable-context.ts similarity index 93% rename from src/lib/provable/provable-context.ts rename to src/lib/provable/core/provable-context.ts index ba930e0222..141d5302db 100644 --- a/src/lib/provable/provable-context.ts +++ b/src/lib/provable/core/provable-context.ts @@ -1,9 +1,9 @@ -import { Context } from '../util/global-context.js'; -import { Gate, GateType, JsonGate, Snarky } from '../../snarky.js'; -import { parseHexString32 } from '../../bindings/crypto/bigint-helpers.js'; -import { prettifyStacktrace } from '../util/errors.js'; -import { Fp } from '../../bindings/crypto/finite-field.js'; -import { MlBool } from '../ml/base.js'; +import { Context } from '../../util/global-context.js'; +import { Gate, GateType, JsonGate, Snarky } from '../../../snarky.js'; +import { parseHexString32 } from '../../../bindings/crypto/bigint-helpers.js'; +import { prettifyStacktrace } from '../../util/errors.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; +import { MlBool } from '../../ml/base.js'; // internal API export { diff --git a/src/lib/provable/crypto.ts b/src/lib/provable/crypto/crypto.ts similarity index 79% rename from src/lib/provable/crypto.ts rename to src/lib/provable/crypto/crypto.ts index 27af0d7a19..8a16637195 100644 --- a/src/lib/provable/crypto.ts +++ b/src/lib/provable/crypto/crypto.ts @@ -1,8 +1,8 @@ -import { CurveParams as CurveParams_ } from '../../bindings/crypto/elliptic-curve-examples.js'; +import { CurveParams as CurveParams_ } from '../../../bindings/crypto/elliptic-curve-examples.js'; import { CurveAffine, createCurveAffine, -} from '../../bindings/crypto/elliptic-curve.js'; +} from '../../../bindings/crypto/elliptic-curve.js'; // crypto namespace const Crypto = { diff --git a/src/lib/provable/encryption.ts b/src/lib/provable/crypto/encryption.ts similarity index 93% rename from src/lib/provable/encryption.ts rename to src/lib/provable/crypto/encryption.ts index 900db46281..14dee36bf1 100644 --- a/src/lib/provable/encryption.ts +++ b/src/lib/provable/crypto/encryption.ts @@ -1,6 +1,6 @@ -import { Field, Scalar, Group } from './core.js'; -import { Poseidon } from './hash.js'; -import { Provable } from './provable.js'; +import { Field, Scalar, Group } from '../core.js'; +import { Poseidon } from './poseidon.js'; +import { Provable } from '../provable.js'; import { PrivateKey, PublicKey } from './signature.js'; export { encrypt, decrypt }; diff --git a/src/lib/provable/foreign-curve.ts b/src/lib/provable/crypto/foreign-curve.ts similarity index 94% rename from src/lib/provable/foreign-curve.ts rename to src/lib/provable/crypto/foreign-curve.ts index a122b7d274..a47976bba1 100644 --- a/src/lib/provable/foreign-curve.ts +++ b/src/lib/provable/crypto/foreign-curve.ts @@ -2,15 +2,15 @@ import { CurveParams, CurveAffine, createCurveAffine, -} from '../../bindings/crypto/elliptic-curve.js'; -import type { Group } from './group.js'; -import { ProvablePureExtended } from './types/struct.js'; -import { AlmostForeignField, createForeignField } from './foreign-field.js'; -import { EllipticCurve, Point } from './gadgets/elliptic-curve.js'; -import { Field3 } from './gadgets/foreign-field.js'; -import { assert } from './gadgets/common.js'; -import { Provable } from './provable.js'; -import { provableFromClass } from './types/provable-derivers.js'; +} from '../../../bindings/crypto/elliptic-curve.js'; +import type { Group } from '../group.js'; +import { ProvablePureExtended } from '../types/struct.js'; +import { AlmostForeignField, createForeignField } from '../foreign-field.js'; +import { EllipticCurve, Point } from '../gadgets/elliptic-curve.js'; +import { Field3 } from '../gadgets/foreign-field.js'; +import { assert } from '../gadgets/common.js'; +import { Provable } from '../provable.js'; +import { provableFromClass } from '../types/provable-derivers.js'; // external API export { createForeignCurve, ForeignCurve }; diff --git a/src/lib/provable/foreign-ecdsa.ts b/src/lib/provable/crypto/foreign-ecdsa.ts similarity index 94% rename from src/lib/provable/foreign-ecdsa.ts rename to src/lib/provable/crypto/foreign-ecdsa.ts index 5556d687fc..56998a421b 100644 --- a/src/lib/provable/foreign-ecdsa.ts +++ b/src/lib/provable/crypto/foreign-ecdsa.ts @@ -1,20 +1,20 @@ -import { provableFromClass } from './types/provable-derivers.js'; -import { CurveParams } from '../../bindings/crypto/elliptic-curve.js'; -import { ProvablePureExtended } from './types/struct.js'; +import { provableFromClass } from '../types/provable-derivers.js'; +import { CurveParams } from '../../../bindings/crypto/elliptic-curve.js'; +import { ProvablePureExtended } from '../types/struct.js'; import { FlexiblePoint, ForeignCurve, createForeignCurve, toPoint, } from './foreign-curve.js'; -import { AlmostForeignField } from './foreign-field.js'; -import { assert } from './gadgets/common.js'; -import { Field3 } from './gadgets/foreign-field.js'; -import { Ecdsa } from './gadgets/elliptic-curve.js'; -import { l } from './gadgets/range-check.js'; +import { AlmostForeignField } from '../foreign-field.js'; +import { assert } from '../gadgets/common.js'; +import { Field3 } from '../gadgets/foreign-field.js'; +import { Ecdsa } from '../gadgets/elliptic-curve.js'; +import { l } from '../gadgets/range-check.js'; import { Keccak } from './keccak.js'; -import { Bytes } from './types/provable-types.js'; -import { UInt8 } from './int.js'; +import { Bytes } from '../provable-types.js'; +import { UInt8 } from '../int.js'; // external API export { createEcdsa, EcdsaSignature }; diff --git a/src/lib/provable/hash-generic.ts b/src/lib/provable/crypto/hash-generic.ts similarity index 83% rename from src/lib/provable/hash-generic.ts rename to src/lib/provable/crypto/hash-generic.ts index 0d1facfc5d..7ea9bdd353 100644 --- a/src/lib/provable/hash-generic.ts +++ b/src/lib/provable/crypto/hash-generic.ts @@ -1,5 +1,5 @@ -import { GenericSignableField } from '../../bindings/lib/generic.js'; -import { prefixToField } from '../../bindings/lib/binable.js'; +import { GenericSignableField } from '../../../bindings/lib/generic.js'; +import { prefixToField } from '../../../bindings/lib/binable.js'; export { createHashHelpers, HashHelpers }; diff --git a/src/lib/provable/hashes-combined.ts b/src/lib/provable/crypto/hash.ts similarity index 96% rename from src/lib/provable/hashes-combined.ts rename to src/lib/provable/crypto/hash.ts index a2bb8b890f..3f1cd87efa 100644 --- a/src/lib/provable/hashes-combined.ts +++ b/src/lib/provable/crypto/hash.ts @@ -1,7 +1,7 @@ -import { Gadgets } from './gadgets/gadgets.js'; -import { Poseidon } from './hash.js'; +import { Gadgets } from '../gadgets/gadgets.js'; +import { Poseidon } from './poseidon.js'; import { Keccak } from './keccak.js'; -import { Bytes } from './types/provable-types.js'; +import { Bytes } from '../provable-types.js'; export { Hash }; diff --git a/src/lib/provable/keccak.ts b/src/lib/provable/crypto/keccak.ts similarity index 98% rename from src/lib/provable/keccak.ts rename to src/lib/provable/crypto/keccak.ts index 31103e9604..d1560c5a3c 100644 --- a/src/lib/provable/keccak.ts +++ b/src/lib/provable/crypto/keccak.ts @@ -1,10 +1,10 @@ -import { Field } from './field.js'; -import { Gadgets } from './gadgets/gadgets.js'; -import { assert } from '../util/errors.js'; -import { FlexibleBytes } from './types/bytes.js'; -import { UInt8 } from './int.js'; -import { Bytes } from './types/provable-types.js'; -import { bytesToWords, wordsToBytes } from './gadgets/bit-slices.js'; +import { Field } from '../field.js'; +import { Gadgets } from '../gadgets/gadgets.js'; +import { assert } from '../../util/errors.js'; +import { FlexibleBytes } from '../bytes.js'; +import { UInt8 } from '../int.js'; +import { Bytes } from '../provable-types.js'; +import { bytesToWords, wordsToBytes } from '../gadgets/bit-slices.js'; export { Keccak }; diff --git a/src/lib/provable/nullifier.ts b/src/lib/provable/crypto/nullifier.ts similarity index 95% rename from src/lib/provable/nullifier.ts rename to src/lib/provable/crypto/nullifier.ts index 39b5240749..7f29948369 100644 --- a/src/lib/provable/nullifier.ts +++ b/src/lib/provable/crypto/nullifier.ts @@ -1,10 +1,10 @@ -import type { Nullifier as JsonNullifier } from '../../mina-signer/src/types.js'; -import { Struct } from './types/struct.js'; -import { Field, Group, Scalar } from './core.js'; -import { Poseidon } from './hash.js'; -import { MerkleMapWitness } from './types/merkle-map.js'; +import type { Nullifier as JsonNullifier } from '../../../mina-signer/src/types.js'; +import { Struct } from '../types/struct.js'; +import { Field, Group, Scalar } from '../core.js'; +import { Poseidon } from './poseidon.js'; +import { MerkleMapWitness } from '../merkle-map.js'; import { PrivateKey, PublicKey, scaleShifted } from './signature.js'; -import { Provable } from './provable.js'; +import { Provable } from '../provable.js'; export { Nullifier }; diff --git a/src/lib/provable/hash.ts b/src/lib/provable/crypto/poseidon.ts similarity index 92% rename from src/lib/provable/hash.ts rename to src/lib/provable/crypto/poseidon.ts index 71d62822ec..e7d4124f50 100644 --- a/src/lib/provable/hash.ts +++ b/src/lib/provable/crypto/poseidon.ts @@ -1,13 +1,13 @@ -import { HashInput, ProvableExtended, Struct } from './types/struct.js'; -import { Snarky } from '../../snarky.js'; -import { Field } from './core.js'; +import { HashInput, ProvableExtended, Struct } from '../types/struct.js'; +import { Snarky } from '../../../snarky.js'; +import { Field } from '../core.js'; import { createHashHelpers } from './hash-generic.js'; -import { Provable } from './provable.js'; -import { MlFieldArray } from '../ml/fields.js'; -import { Poseidon as PoseidonBigint } from '../../bindings/crypto/poseidon.js'; -import { assert } from '../util/errors.js'; -import { rangeCheckN } from './gadgets/range-check.js'; -import { TupleN } from '../util/types.js'; +import { Provable } from '../provable.js'; +import { MlFieldArray } from '../../ml/fields.js'; +import { Poseidon as PoseidonBigint } from '../../../bindings/crypto/poseidon.js'; +import { assert } from '../../util/errors.js'; +import { rangeCheckN } from '../gadgets/range-check.js'; +import { TupleN } from '../../util/types.js'; // external API export { Poseidon, TokenSymbol }; diff --git a/src/lib/provable/signature.ts b/src/lib/provable/crypto/signature.ts similarity index 95% rename from src/lib/provable/signature.ts rename to src/lib/provable/crypto/signature.ts index 369cb26ae4..8eb0c849b5 100644 --- a/src/lib/provable/signature.ts +++ b/src/lib/provable/crypto/signature.ts @@ -1,19 +1,19 @@ -import { Field, Bool, Group, Scalar } from './core.js'; -import { AnyConstructor } from './types/struct.js'; -import { hashWithPrefix } from './hash.js'; -import { Fq } from '../../bindings/crypto/finite-field.js'; +import { Field, Bool, Group, Scalar } from '../core.js'; +import { AnyConstructor } from '../types/struct.js'; +import { hashWithPrefix } from './poseidon.js'; +import { Fq } from '../../../bindings/crypto/finite-field.js'; import { deriveNonce, Signature as SignatureBigint, signaturePrefix, -} from '../../mina-signer/src/signature.js'; +} from '../../../mina-signer/src/signature.js'; import { PrivateKey as PrivateKeyBigint, PublicKey as PublicKeyBigint, -} from '../../mina-signer/src/curve-bigint.js'; -import { constantScalarToBigint } from './scalar.js'; -import { toConstantField } from './field.js'; -import { CircuitValue, prop } from './types/circuit-value.js'; +} from '../../../mina-signer/src/curve-bigint.js'; +import { constantScalarToBigint } from '../scalar.js'; +import { toConstantField } from '../field.js'; +import { CircuitValue, prop } from '../types/circuit-value.js'; // external API export { PrivateKey, PublicKey, Signature }; diff --git a/src/lib/provable/field.ts b/src/lib/provable/field.ts index 6192dbd28b..836386b83b 100644 --- a/src/lib/provable/field.ts +++ b/src/lib/provable/field.ts @@ -3,7 +3,7 @@ import { Fp } from '../../bindings/crypto/finite-field.js'; import { BinableFp, SignableFp } from '../../mina-signer/src/field-bigint.js'; import { defineBinable } from '../../bindings/lib/binable.js'; import type { NonNegativeInteger } from '../../bindings/crypto/non-negative.js'; -import { asProver, inCheckedComputation } from './provable-context.js'; +import { asProver, inCheckedComputation } from './core/provable-context.js'; import { Bool } from './bool.js'; import { assert } from '../util/errors.js'; import { Provable } from './provable.js'; diff --git a/src/lib/provable/types/fields.ts b/src/lib/provable/fields.ts similarity index 91% rename from src/lib/provable/types/fields.ts rename to src/lib/provable/fields.ts index e92cd0d51e..419ba9d203 100644 --- a/src/lib/provable/types/fields.ts +++ b/src/lib/provable/fields.ts @@ -1,5 +1,5 @@ -import { ProvablePureExtended } from './struct.js'; -import { Field } from '../field.js'; +import { ProvablePureExtended } from './types/struct.js'; +import { Field } from './field.js'; export { modifiedField, fields }; diff --git a/src/lib/provable/gadgets/elliptic-curve.ts b/src/lib/provable/gadgets/elliptic-curve.ts index b23be4b455..b4f2dd4666 100644 --- a/src/lib/provable/gadgets/elliptic-curve.ts +++ b/src/lib/provable/gadgets/elliptic-curve.ts @@ -19,7 +19,7 @@ import { provable } from '../types/struct.js'; import { assertPositiveInteger } from '../../../bindings/crypto/non-negative.js'; import { arrayGet } from './basic.js'; import { sliceField3 } from './bit-slices.js'; -import { Hashed } from '../types/packed.js'; +import { Hashed } from '../packed.js'; import { exists } from '../core/exists.js'; // external API diff --git a/src/lib/provable/gadgets/foreign-field.ts b/src/lib/provable/gadgets/foreign-field.ts index 71744eb4b3..b955521024 100644 --- a/src/lib/provable/gadgets/foreign-field.ts +++ b/src/lib/provable/gadgets/foreign-field.ts @@ -11,7 +11,7 @@ import { Unconstrained } from '../types/unconstrained.js'; import { Field } from '../field.js'; import { Gates, foreignFieldAdd } from '../gates.js'; import { exists } from '../core/exists.js'; -import { modifiedField } from '../types/fields.js'; +import { modifiedField } from '../fields.js'; import { Tuple, TupleN } from '../../util/types.js'; import { assertOneOf } from './basic.js'; import { assert, bitSlice, toVar, toVars } from './common.js'; diff --git a/src/lib/provable/gadgets/sha256.ts b/src/lib/provable/gadgets/sha256.ts index ba540ff8fc..27d7983bb5 100644 --- a/src/lib/provable/gadgets/sha256.ts +++ b/src/lib/provable/gadgets/sha256.ts @@ -3,8 +3,8 @@ import { mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../core.js'; import { UInt32, UInt8 } from '../int.js'; import { exists } from '../core/exists.js'; -import { FlexibleBytes } from '../types/bytes.js'; -import { Bytes } from '../types/provable-types.js'; +import { FlexibleBytes } from '../bytes.js'; +import { Bytes } from '../provable-types.js'; import { chunk } from '../../util/arrays.js'; import { TupleN } from '../../util/types.js'; import { divMod32 } from './arithmetic.js'; diff --git a/src/lib/provable/gadgets/sha256.unit-test.ts b/src/lib/provable/gadgets/sha256.unit-test.ts index ec8d58ecf0..6238576405 100644 --- a/src/lib/provable/gadgets/sha256.unit-test.ts +++ b/src/lib/provable/gadgets/sha256.unit-test.ts @@ -1,5 +1,5 @@ import { ZkProgram } from '../../proof-system/zkprogram.js'; -import { Bytes } from '../types/provable-types.js'; +import { Bytes } from '../provable-types.js'; import { Gadgets } from './gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; import { bytes } from './test-utils.js'; diff --git a/src/lib/provable/gadgets/test-utils.ts b/src/lib/provable/gadgets/test-utils.ts index 0214fd40a6..efd4d177d8 100644 --- a/src/lib/provable/gadgets/test-utils.ts +++ b/src/lib/provable/gadgets/test-utils.ts @@ -3,7 +3,7 @@ import { ProvableSpec, spec } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; import { Field3 } from './gadgets.js'; import { assert } from './common.js'; -import { Bytes } from '../types/provable-types.js'; +import { Bytes } from '../provable-types.js'; export { foreignField, diff --git a/src/lib/provable/int.ts b/src/lib/provable/int.ts index 69c9dd4630..f7312a4ad6 100644 --- a/src/lib/provable/int.ts +++ b/src/lib/provable/int.ts @@ -1,7 +1,7 @@ import { Field, Bool } from './core.js'; import { AnyConstructor, Struct } from './types/struct.js'; import { Types } from '../../bindings/mina-transaction/types.js'; -import { HashInput } from './hash.js'; +import { HashInput } from './crypto/poseidon.js'; import { Provable } from './provable.js'; import * as RangeCheck from './gadgets/range-check.js'; import * as Bitwise from './gadgets/bitwise.js'; diff --git a/src/lib/provable/types/merkle-list.ts b/src/lib/provable/merkle-list.ts similarity index 97% rename from src/lib/provable/types/merkle-list.ts rename to src/lib/provable/merkle-list.ts index 83cc9b49c1..3d55cadbb4 100644 --- a/src/lib/provable/types/merkle-list.ts +++ b/src/lib/provable/merkle-list.ts @@ -1,10 +1,10 @@ -import { Bool, Field } from '../core.js'; -import { Provable } from '../provable.js'; -import { Struct } from './struct.js'; -import { assert } from '../gadgets/common.js'; -import { provableFromClass } from './provable-derivers.js'; -import { Poseidon, packToFields, ProvableHashable } from '../hash.js'; -import { Unconstrained } from './unconstrained.js'; +import { Bool, Field } from './core.js'; +import { Provable } from './provable.js'; +import { Struct } from './types/struct.js'; +import { assert } from './gadgets/common.js'; +import { provableFromClass } from './types/provable-derivers.js'; +import { Poseidon, packToFields, ProvableHashable } from './crypto/poseidon.js'; +import { Unconstrained } from './types/unconstrained.js'; export { MerkleListBase, diff --git a/src/lib/provable/types/merkle-map.ts b/src/lib/provable/merkle-map.ts similarity index 95% rename from src/lib/provable/types/merkle-map.ts rename to src/lib/provable/merkle-map.ts index 4f0be85407..54b9e23cbe 100644 --- a/src/lib/provable/types/merkle-map.ts +++ b/src/lib/provable/merkle-map.ts @@ -1,8 +1,8 @@ -import { arrayProp, CircuitValue } from './circuit-value.js'; -import { Field, Bool } from '../core.js'; -import { Poseidon } from '../hash.js'; +import { arrayProp, CircuitValue } from './types/circuit-value.js'; +import { Field, Bool } from './core.js'; +import { Poseidon } from './crypto/poseidon.js'; import { MerkleTree, MerkleWitness } from './merkle-tree.js'; -import { Provable } from '../provable.js'; +import { Provable } from './provable.js'; const bits = 255; const printDebugs = false; diff --git a/src/lib/provable/types/merkle-tree.ts b/src/lib/provable/merkle-tree.ts similarity index 97% rename from src/lib/provable/types/merkle-tree.ts rename to src/lib/provable/merkle-tree.ts index 6bb3197644..98d2264236 100644 --- a/src/lib/provable/types/merkle-tree.ts +++ b/src/lib/provable/merkle-tree.ts @@ -2,10 +2,10 @@ * This file contains all code related to the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) implementation available in o1js. */ -import { CircuitValue, arrayProp } from './circuit-value.js'; -import { Poseidon } from '../hash.js'; -import { Bool, Field } from '../core.js'; -import { Provable } from '../provable.js'; +import { CircuitValue, arrayProp } from './types/circuit-value.js'; +import { Poseidon } from './crypto/poseidon.js'; +import { Bool, Field } from './core.js'; +import { Provable } from './provable.js'; // external API export { Witness, MerkleTree, MerkleWitness, BaseMerkleWitness }; diff --git a/src/lib/provable/types/packed.ts b/src/lib/provable/packed.ts similarity index 94% rename from src/lib/provable/types/packed.ts rename to src/lib/provable/packed.ts index 01e53e3221..966e8baf70 100644 --- a/src/lib/provable/types/packed.ts +++ b/src/lib/provable/packed.ts @@ -1,10 +1,10 @@ -import { provableFromClass } from './provable-derivers.js'; -import { HashInput, ProvableExtended } from './struct.js'; -import { Unconstrained } from './unconstrained.js'; -import { Field } from '../field.js'; -import { assert } from '../gadgets/common.js'; -import { Poseidon, ProvableHashable, packToFields } from '../hash.js'; -import { Provable } from '../provable.js'; +import { provableFromClass } from './types/provable-derivers.js'; +import { HashInput, ProvableExtended } from './types/struct.js'; +import { Unconstrained } from './types/unconstrained.js'; +import { Field } from './field.js'; +import { assert } from './gadgets/common.js'; +import { Poseidon, ProvableHashable, packToFields } from './crypto/poseidon.js'; +import { Provable } from './provable.js'; import { fields, modifiedField } from './fields.js'; export { Packed, Hashed }; diff --git a/src/lib/provable/types/provable-types.ts b/src/lib/provable/provable-types.ts similarity index 100% rename from src/lib/provable/types/provable-types.ts rename to src/lib/provable/provable-types.ts diff --git a/src/lib/provable/provable.ts b/src/lib/provable/provable.ts index 6e8fcc445a..765ba86d20 100644 --- a/src/lib/provable/provable.ts +++ b/src/lib/provable/provable.ts @@ -21,7 +21,7 @@ import { asProver, constraintSystem, generateWitness, -} from './provable-context.js'; +} from './core/provable-context.js'; import { exists, existsAsync } from './core/exists.js'; // external API diff --git a/src/lib/provable/types/string.ts b/src/lib/provable/string.ts similarity index 95% rename from src/lib/provable/types/string.ts rename to src/lib/provable/string.ts index 25e7c88832..f6b9d57afe 100644 --- a/src/lib/provable/types/string.ts +++ b/src/lib/provable/string.ts @@ -1,8 +1,8 @@ -import { Bool, Field } from '../core.js'; -import { Provable } from '../provable.js'; -import { Poseidon } from '../hash.js'; -import { Gadgets } from '../gadgets/gadgets.js'; -import { CircuitValue, arrayProp, prop } from './circuit-value.js'; +import { Bool, Field } from './core.js'; +import { Provable } from './provable.js'; +import { Poseidon } from './crypto/poseidon.js'; +import { Gadgets } from './gadgets/gadgets.js'; +import { CircuitValue, arrayProp, prop } from './types/circuit-value.js'; export { Character, CircuitString }; diff --git a/src/lib/provable/field.unit-test.ts b/src/lib/provable/test/field.unit-test.ts similarity index 91% rename from src/lib/provable/field.unit-test.ts rename to src/lib/provable/test/field.unit-test.ts index cc48553e7d..c65aacad4d 100644 --- a/src/lib/provable/field.unit-test.ts +++ b/src/lib/provable/test/field.unit-test.ts @@ -1,12 +1,12 @@ -import { Field } from './core.js'; -import { Fp } from '../../bindings/crypto/finite-field.js'; -import { BinableFp } from '../../mina-signer/src/field-bigint.js'; -import { test, Random } from '../testing/property.js'; +import { Field } from '../core.js'; +import { Fp } from '../../../bindings/crypto/finite-field.js'; +import { BinableFp } from '../../../mina-signer/src/field-bigint.js'; +import { test, Random } from '../../testing/property.js'; import { deepEqual, throws } from 'node:assert/strict'; -import { Provable } from './provable.js'; -import { Binable } from '../../bindings/lib/binable.js'; -import { ProvableExtended } from './types/struct.js'; -import { FieldType } from './core/fieldvar.js'; +import { Provable } from '../provable.js'; +import { Binable } from '../../../bindings/lib/binable.js'; +import { ProvableExtended } from '../types/struct.js'; +import { FieldType } from '../core/fieldvar.js'; import { equivalentProvable as equivalent, oneOf, @@ -16,9 +16,9 @@ import { unit, bool, Spec, -} from '../testing/equivalent.js'; -import { runAndCheckSync } from './provable-context.js'; -import { ProvablePure } from './types/provable-intf.js'; +} from '../../testing/equivalent.js'; +import { runAndCheckSync } from '../core/provable-context.js'; +import { ProvablePure } from '../types/provable-intf.js'; // types Field satisfies Provable; diff --git a/src/lib/provable/foreign-curve.unit-test.ts b/src/lib/provable/test/foreign-curve.unit-test.ts similarity index 78% rename from src/lib/provable/foreign-curve.unit-test.ts rename to src/lib/provable/test/foreign-curve.unit-test.ts index 410c74602c..2861002421 100644 --- a/src/lib/provable/foreign-curve.unit-test.ts +++ b/src/lib/provable/test/foreign-curve.unit-test.ts @@ -1,9 +1,9 @@ -import { createForeignCurve } from './foreign-curve.js'; -import { Fq } from '../../bindings/crypto/finite-field.js'; -import { Vesta as V } from '../../bindings/crypto/elliptic-curve.js'; -import { Provable } from './provable.js'; -import { Field } from './field.js'; -import { Crypto } from './crypto.js'; +import { createForeignCurve } from '../crypto/foreign-curve.js'; +import { Fq } from '../../../bindings/crypto/finite-field.js'; +import { Vesta as V } from '../../../bindings/crypto/elliptic-curve.js'; +import { Provable } from '../provable.js'; +import { Field } from '../field.js'; +import { Crypto } from '../crypto/crypto.js'; class Vesta extends createForeignCurve(Crypto.CurveParams.Vesta) {} class Fp extends Vesta.Scalar {} diff --git a/src/lib/provable/foreign-field.unit-test.ts b/src/lib/provable/test/foreign-field.unit-test.ts similarity index 88% rename from src/lib/provable/foreign-field.unit-test.ts rename to src/lib/provable/test/foreign-field.unit-test.ts index 9848846bed..cca08c78ba 100644 --- a/src/lib/provable/foreign-field.unit-test.ts +++ b/src/lib/provable/test/foreign-field.unit-test.ts @@ -1,7 +1,7 @@ -import { Field, Group } from './core.js'; -import { ForeignField, createForeignField } from './foreign-field.js'; -import { Fq } from '../../bindings/crypto/finite-field.js'; -import { Pallas } from '../../bindings/crypto/elliptic-curve.js'; +import { Field, Group } from '../core.js'; +import { ForeignField, createForeignField } from '../foreign-field.js'; +import { Fq } from '../../../bindings/crypto/finite-field.js'; +import { Pallas } from '../../../bindings/crypto/elliptic-curve.js'; import { expect } from 'expect'; import { bool, @@ -11,14 +11,14 @@ import { spec, throwError, unit, -} from '../testing/equivalent.js'; -import { test, Random } from '../testing/property.js'; -import { Provable } from './provable.js'; -import { Circuit, circuitMain } from '../proof-system/circuit.js'; -import { Scalar } from './scalar.js'; -import { l } from './gadgets/range-check.js'; -import { assert } from './gadgets/common.js'; -import { ProvablePure } from './types/provable-intf.js'; +} from '../../testing/equivalent.js'; +import { test, Random } from '../../testing/property.js'; +import { Provable } from '../provable.js'; +import { Circuit, circuitMain } from '../../proof-system/circuit.js'; +import { Scalar } from '../scalar.js'; +import { l } from '../gadgets/range-check.js'; +import { assert } from '../gadgets/common.js'; +import { ProvablePure } from '../types/provable-intf.js'; // toy example - F_17 diff --git a/src/lib/provable/group.test.ts b/src/lib/provable/test/group.test.ts similarity index 100% rename from src/lib/provable/group.test.ts rename to src/lib/provable/test/group.test.ts diff --git a/src/lib/provable/group.unit-test.ts b/src/lib/provable/test/group.unit-test.ts similarity index 88% rename from src/lib/provable/group.unit-test.ts rename to src/lib/provable/test/group.unit-test.ts index ee23b1cc0b..7fae17625a 100644 --- a/src/lib/provable/group.unit-test.ts +++ b/src/lib/provable/test/group.unit-test.ts @@ -1,8 +1,8 @@ -import { Group } from './core.js'; -import { test, Random } from '../testing/property.js'; -import { Provable } from './provable.js'; -import { Poseidon } from '../../mina-signer/src/poseidon-bigint.js'; -import { runAndCheckSync } from './provable-context.js'; +import { Group } from '../core.js'; +import { test, Random } from '../../testing/property.js'; +import { Provable } from '../provable.js'; +import { Poseidon } from '../../../mina-signer/src/poseidon-bigint.js'; +import { runAndCheckSync } from '../core/provable-context.js'; console.log('group consistency tests'); diff --git a/src/lib/provable/int.test.ts b/src/lib/provable/test/int.test.ts similarity index 100% rename from src/lib/provable/int.test.ts rename to src/lib/provable/test/int.test.ts diff --git a/src/lib/provable/keccak.unit-test.ts b/src/lib/provable/test/keccak.unit-test.ts similarity index 95% rename from src/lib/provable/keccak.unit-test.ts rename to src/lib/provable/test/keccak.unit-test.ts index e33e36fe47..6a61c35bf2 100644 --- a/src/lib/provable/keccak.unit-test.ts +++ b/src/lib/provable/test/keccak.unit-test.ts @@ -1,10 +1,10 @@ -import { Keccak } from './keccak.js'; -import { ZkProgram } from '../proof-system/zkprogram.js'; +import { Keccak } from '../crypto/keccak.js'; +import { ZkProgram } from '../../proof-system/zkprogram.js'; import { equivalentProvable, equivalent, equivalentAsync, -} from '../testing/equivalent.js'; +} from '../../testing/equivalent.js'; import { keccak_224, keccak_256, @@ -15,10 +15,10 @@ import { sha3_384, sha3_512, } from '@noble/hashes/sha3'; -import { Bytes } from './types/provable-types.js'; -import { bytes } from './gadgets/test-utils.js'; -import { UInt8 } from './int.js'; -import { test, Random, sample } from '../testing/property.js'; +import { Bytes } from '../provable-types.js'; +import { bytes } from '../gadgets/test-utils.js'; +import { UInt8 } from '../int.js'; +import { test, Random, sample } from '../../testing/property.js'; import { expect } from 'expect'; const RUNS = 1; diff --git a/src/lib/provable/types/merkle-map.test.ts b/src/lib/provable/test/merkle-map.test.ts similarity index 100% rename from src/lib/provable/types/merkle-map.test.ts rename to src/lib/provable/test/merkle-map.test.ts diff --git a/src/lib/provable/types/merkle-tree.test.ts b/src/lib/provable/test/merkle-tree.test.ts similarity index 100% rename from src/lib/provable/types/merkle-tree.test.ts rename to src/lib/provable/test/merkle-tree.test.ts diff --git a/src/lib/provable/types/merkle-tree.unit-test.ts b/src/lib/provable/test/merkle-tree.unit-test.ts similarity index 91% rename from src/lib/provable/types/merkle-tree.unit-test.ts rename to src/lib/provable/test/merkle-tree.unit-test.ts index 3e5c3d378c..8c1e7b8a25 100644 --- a/src/lib/provable/types/merkle-tree.unit-test.ts +++ b/src/lib/provable/test/merkle-tree.unit-test.ts @@ -1,5 +1,5 @@ import { Bool, Field } from '../core.js'; -import { maybeSwap } from './merkle-tree.js'; +import { maybeSwap } from '../merkle-tree.js'; import { Random, test } from '../../testing/property.js'; import { expect } from 'expect'; diff --git a/src/lib/provable/nullifier.unit-test.ts b/src/lib/provable/test/nullifier.unit-test.ts similarity index 87% rename from src/lib/provable/nullifier.unit-test.ts rename to src/lib/provable/test/nullifier.unit-test.ts index e55dc68408..77fe49ce4c 100644 --- a/src/lib/provable/nullifier.unit-test.ts +++ b/src/lib/provable/test/nullifier.unit-test.ts @@ -1,7 +1,7 @@ -import { createNullifier } from '../../mina-signer/src/nullifier.js'; -import { Field } from './core.js'; -import { Nullifier } from './nullifier.js'; -import { PrivateKey } from './signature.js'; +import { createNullifier } from '../../../mina-signer/src/nullifier.js'; +import { Field } from '../core.js'; +import { Nullifier } from '../crypto/nullifier.js'; +import { PrivateKey } from '../crypto/signature.js'; let priv = PrivateKey.random(); diff --git a/src/lib/provable/primitives.test.ts b/src/lib/provable/test/primitives.test.ts similarity index 100% rename from src/lib/provable/primitives.test.ts rename to src/lib/provable/test/primitives.test.ts diff --git a/src/lib/provable/primitives.unit-test.ts b/src/lib/provable/test/primitives.unit-test.ts similarity index 79% rename from src/lib/provable/primitives.unit-test.ts rename to src/lib/provable/test/primitives.unit-test.ts index c4aea5e64c..2a0d7a78bc 100644 --- a/src/lib/provable/primitives.unit-test.ts +++ b/src/lib/provable/test/primitives.unit-test.ts @@ -1,7 +1,7 @@ -import { Circuit, circuitMain } from '../proof-system/circuit.js'; -import { UInt64, UInt32 } from './int.js'; +import { Circuit, circuitMain } from '../../proof-system/circuit.js'; +import { UInt64, UInt32 } from '../int.js'; import { expect } from 'expect'; -import { Provable } from './provable.js'; +import { Provable } from '../provable.js'; class Primitives extends Circuit { @circuitMain diff --git a/src/lib/provable/provable.test.ts b/src/lib/provable/test/provable.test.ts similarity index 100% rename from src/lib/provable/provable.test.ts rename to src/lib/provable/test/provable.test.ts diff --git a/src/lib/provable/provable.unit-test.ts b/src/lib/provable/test/provable.unit-test.ts similarity index 79% rename from src/lib/provable/provable.unit-test.ts rename to src/lib/provable/test/provable.unit-test.ts index ff89555e75..efa4b3483f 100644 --- a/src/lib/provable/provable.unit-test.ts +++ b/src/lib/provable/test/provable.unit-test.ts @@ -1,8 +1,8 @@ import { it } from 'node:test'; -import { Provable } from './provable.js'; -import { Field } from './field.js'; +import { Provable } from '../provable.js'; +import { Field } from '../field.js'; import { expect } from 'expect'; -import { exists } from './core/exists.js'; +import { exists } from '../core/exists.js'; await it('can witness large field array', async () => { let N = 100_000; diff --git a/src/lib/provable/scalar.test.ts b/src/lib/provable/test/scalar.test.ts similarity index 100% rename from src/lib/provable/scalar.test.ts rename to src/lib/provable/test/scalar.test.ts diff --git a/src/lib/provable/types/string.test.ts b/src/lib/provable/test/string.test.ts similarity index 100% rename from src/lib/provable/types/string.test.ts rename to src/lib/provable/test/string.test.ts diff --git a/src/lib/provable/types/struct.unit-test.ts b/src/lib/provable/test/struct.unit-test.ts similarity index 96% rename from src/lib/provable/types/struct.unit-test.ts rename to src/lib/provable/test/struct.unit-test.ts index 6fd4c4a92c..7a19ab86d3 100644 --- a/src/lib/provable/types/struct.unit-test.ts +++ b/src/lib/provable/test/struct.unit-test.ts @@ -1,7 +1,7 @@ -import { provable, Struct } from './struct.js'; -import { Unconstrained } from './unconstrained.js'; +import { provable, Struct } from '../types/struct.js'; +import { Unconstrained } from '../types/unconstrained.js'; import { UInt32 } from '../int.js'; -import { PrivateKey, PublicKey } from '../signature.js'; +import { PrivateKey, PublicKey } from '../crypto/signature.js'; import { expect } from 'expect'; import { method, SmartContract } from '../../mina/zkapp.js'; import { diff --git a/src/lib/provable/types/auxiliary.ts b/src/lib/provable/types/auxiliary.ts index 46ee535526..d9c1c76dd2 100644 --- a/src/lib/provable/types/auxiliary.ts +++ b/src/lib/provable/types/auxiliary.ts @@ -1,4 +1,4 @@ -import type { ProvableHashable } from '../hash.js'; +import type { ProvableHashable } from '../crypto/poseidon.js'; export { RandomId }; diff --git a/src/lib/provable/types/unconstrained.ts b/src/lib/provable/types/unconstrained.ts index 7bdc9647e8..c9ada25352 100644 --- a/src/lib/provable/types/unconstrained.ts +++ b/src/lib/provable/types/unconstrained.ts @@ -2,7 +2,7 @@ import { Snarky } from '../../../snarky.js'; import { Field } from '../field.js'; import { Provable } from '../provable.js'; import { assert } from '../../util/errors.js'; -import { inCheckedComputation } from '../provable-context.js'; +import { inCheckedComputation } from '../core/provable-context.js'; export { Unconstrained }; diff --git a/src/lib/testing/constraint-system.ts b/src/lib/testing/constraint-system.ts index 502d91de68..4189ffa6bf 100644 --- a/src/lib/testing/constraint-system.ts +++ b/src/lib/testing/constraint-system.ts @@ -16,7 +16,7 @@ import { Undefined, ZkProgram } from '../proof-system/zkprogram.js'; import { constraintSystemSync, printGates, -} from '../provable/provable-context.js'; +} from '../provable/core/provable-context.js'; export { constraintSystem, diff --git a/src/lib/testing/equivalent.ts b/src/lib/testing/equivalent.ts index 52d5e54e44..84e28c27bc 100644 --- a/src/lib/testing/equivalent.ts +++ b/src/lib/testing/equivalent.ts @@ -8,7 +8,7 @@ import { Bool, Field } from '../provable/core.js'; import { AnyFunction, Tuple } from '../util/types.js'; import { provable } from '../provable/types/struct.js'; import { assert } from '../provable/gadgets/common.js'; -import { runAndCheckSync } from '../provable/provable-context.js'; +import { runAndCheckSync } from '../provable/core/provable-context.js'; export { equivalent, diff --git a/src/mina-signer/src/poseidon-bigint.ts b/src/mina-signer/src/poseidon-bigint.ts index 19a46bcf00..7d8676c2b4 100644 --- a/src/mina-signer/src/poseidon-bigint.ts +++ b/src/mina-signer/src/poseidon-bigint.ts @@ -3,7 +3,7 @@ import { Poseidon, PoseidonLegacy } from '../../bindings/crypto/poseidon.js'; import { prefixes } from '../../bindings/crypto/constants.js'; import { createHashInput } from '../../bindings/lib/provable-generic.js'; import { GenericHashInput } from '../../bindings/lib/generic.js'; -import { createHashHelpers } from '../../lib/provable/hash-generic.js'; +import { createHashHelpers } from '../../lib/provable/crypto/hash-generic.js'; export { Poseidon, diff --git a/src/mina-signer/src/sign-zkapp-command.unit-test.ts b/src/mina-signer/src/sign-zkapp-command.unit-test.ts index d3adf5f05e..3b39f330b4 100644 --- a/src/mina-signer/src/sign-zkapp-command.unit-test.ts +++ b/src/mina-signer/src/sign-zkapp-command.unit-test.ts @@ -12,13 +12,13 @@ import { ZkappCommand as ZkappCommandSnarky, } from '../../lib/mina/account-update.js'; import { FieldConst } from '../../lib/provable/core/fieldvar.js'; -import { packToFields as packToFieldsSnarky } from '../../lib/provable/hash.js'; +import { packToFields as packToFieldsSnarky } from '../../lib/provable/crypto/poseidon.js'; import { Network, setActiveInstance } from '../../lib/mina/mina.js'; import { Ml, MlHashInput } from '../../lib/ml/conversion.js'; import { PrivateKey as PrivateKeySnarky, PublicKey as PublicKeySnarky, -} from '../../lib/provable/signature.js'; +} from '../../lib/provable/crypto/signature.js'; import { Random, test, withHardCoded } from '../../lib/testing/property.js'; import { PrivateKey, PublicKey } from './curve-bigint.js'; import { hashWithPrefix, packToFields, prefixes } from './poseidon-bigint.js'; diff --git a/src/mina-signer/src/signature.unit-test.ts b/src/mina-signer/src/signature.unit-test.ts index a1671b97b6..c26d2cd45b 100644 --- a/src/mina-signer/src/signature.unit-test.ts +++ b/src/mina-signer/src/signature.unit-test.ts @@ -10,7 +10,7 @@ import { import { Test } from '../../snarky.js'; import { Field } from './field-bigint.js'; import { PrivateKey, PublicKey } from './curve-bigint.js'; -import { PrivateKey as PrivateKeySnarky } from '../../lib/provable/signature.js'; +import { PrivateKey as PrivateKeySnarky } from '../../lib/provable/crypto/signature.js'; import { p } from '../../bindings/crypto/finite-field.js'; import { AccountUpdate } from '../../bindings/mina-transaction/gen/transaction-bigint.js'; import { HashInput } from './derivers-bigint.js'; diff --git a/src/mina-signer/tests/verify-in-snark.unit-test.ts b/src/mina-signer/tests/verify-in-snark.unit-test.ts index 481660f962..04cd42d01b 100644 --- a/src/mina-signer/tests/verify-in-snark.unit-test.ts +++ b/src/mina-signer/tests/verify-in-snark.unit-test.ts @@ -1,7 +1,7 @@ import { Field } from '../../lib/provable/core.js'; import { ZkProgram } from '../../lib/proof-system/zkprogram.js'; import Client from '../mina-signer.js'; -import { PrivateKey, Signature } from '../../lib/provable/signature.js'; +import { PrivateKey, Signature } from '../../lib/provable/crypto/signature.js'; import { expect } from 'expect'; import { Provable } from '../../lib/provable/provable.js'; diff --git a/src/mina-signer/tests/zkapp.unit-test.ts b/src/mina-signer/tests/zkapp.unit-test.ts index ddf7779b09..1b3ffb66c3 100644 --- a/src/mina-signer/tests/zkapp.unit-test.ts +++ b/src/mina-signer/tests/zkapp.unit-test.ts @@ -4,7 +4,7 @@ import Client from '../mina-signer.js'; import { accountUpdateExample } from '../src/test-vectors/accountUpdate.js'; import { expect } from 'expect'; import { Transaction } from '../../lib/mina/mina.js'; -import { PrivateKey } from '../../lib/provable/signature.js'; +import { PrivateKey } from '../../lib/provable/crypto/signature.js'; import { Signature } from '../src/signature.js'; import { mocks } from '../../bindings/crypto/constants.js'; diff --git a/src/snarky.d.ts b/src/snarky.d.ts index d7e984dfcb..b83d5a2711 100644 --- a/src/snarky.d.ts +++ b/src/snarky.d.ts @@ -31,7 +31,7 @@ import type { } from './bindings/compiled/node_bindings/plonk_wasm.cjs'; import * as wasm from './bindings/compiled/node_bindings/plonk_wasm.cjs'; import type { KimchiGateType } from './lib/provable/gates.ts'; -import type { MlConstraintSystem } from './lib/provable/provable-context.ts'; +import type { MlConstraintSystem } from './lib/provable/core/provable-context.ts'; import type { FieldVector } from './bindings/crypto/bindings/vector.ts'; export { Ledger, Pickles, Gate, GateType, wasm }; From 7b833628d649ad320a8279c953c6b673fcb1686f Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 14:33:03 +0100 Subject: [PATCH 6/7] core / provable-types -> wrapped --- src/bindings | 2 +- src/index.ts | 4 ++-- src/lib/mina/account-update.ts | 2 +- src/lib/mina/account.ts | 2 +- src/lib/mina/base58-encodings.ts | 2 +- src/lib/mina/fetch.ts | 2 +- src/lib/mina/local-blockchain.ts | 2 +- src/lib/mina/mina-instance.ts | 2 +- src/lib/mina/mina.ts | 2 +- src/lib/mina/precondition.ts | 2 +- src/lib/mina/state.ts | 2 +- src/lib/mina/token/forest-iterator.ts | 2 +- src/lib/mina/token/forest-iterator.unit-test.ts | 2 +- src/lib/mina/token/token-contract.ts | 2 +- src/lib/mina/token/token-methods.ts | 2 +- src/lib/mina/transaction-validation.ts | 2 +- src/lib/mina/transaction.ts | 2 +- src/lib/mina/zkapp.ts | 2 +- src/lib/ml/consistency.unit-test.ts | 2 +- src/lib/ml/conversion.ts | 2 +- src/lib/proof-system/proof-system.unit-test.ts | 2 +- src/lib/proof-system/zkprogram.ts | 2 +- src/lib/provable/crypto/encryption.ts | 2 +- src/lib/provable/crypto/foreign-ecdsa.ts | 2 +- src/lib/provable/crypto/hash.ts | 2 +- src/lib/provable/crypto/keccak.ts | 2 +- src/lib/provable/crypto/nullifier.ts | 2 +- src/lib/provable/crypto/poseidon.ts | 2 +- src/lib/provable/crypto/signature.ts | 2 +- src/lib/provable/gadgets/arithmetic.ts | 2 +- src/lib/provable/gadgets/arithmetic.unit-test.ts | 2 +- src/lib/provable/gadgets/bitwise.unit-test.ts | 2 +- src/lib/provable/gadgets/gadgets.ts | 2 +- src/lib/provable/gadgets/range-check.unit-test.ts | 2 +- src/lib/provable/gadgets/sha256.ts | 4 ++-- src/lib/provable/gadgets/sha256.unit-test.ts | 2 +- src/lib/provable/gadgets/test-utils.ts | 2 +- src/lib/provable/int.ts | 2 +- src/lib/provable/merkle-list.ts | 2 +- src/lib/provable/merkle-map.ts | 2 +- src/lib/provable/merkle-tree.ts | 2 +- src/lib/provable/string.ts | 2 +- src/lib/provable/test/field.unit-test.ts | 2 +- src/lib/provable/test/foreign-field.unit-test.ts | 2 +- src/lib/provable/test/group.unit-test.ts | 2 +- src/lib/provable/test/keccak.unit-test.ts | 2 +- src/lib/provable/test/merkle-tree.unit-test.ts | 2 +- src/lib/provable/test/nullifier.unit-test.ts | 2 +- src/lib/provable/test/struct.unit-test.ts | 2 +- src/lib/provable/types/circuit-value.ts | 2 +- src/lib/provable/types/provable-derivers.ts | 2 +- src/lib/provable/types/struct.ts | 2 +- src/lib/provable/{provable-types.ts => wrapped-classes.ts} | 0 src/lib/provable/{core.ts => wrapped.ts} | 0 src/lib/testing/equivalent.ts | 2 +- src/mina-signer/tests/verify-in-snark.unit-test.ts | 2 +- 56 files changed, 56 insertions(+), 56 deletions(-) rename src/lib/provable/{provable-types.ts => wrapped-classes.ts} (100%) rename src/lib/provable/{core.ts => wrapped.ts} (100%) diff --git a/src/bindings b/src/bindings index 6e9cf7da3f..046fc002db 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 6e9cf7da3f82b6c1ac9b6e6c718cd267a5db5970 +Subproject commit 046fc002db7c35f14c8f9b819da81485f072fb52 diff --git a/src/index.ts b/src/index.ts index 86ccf13e46..681f78e452 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ export type { ProvablePure } from './lib/provable/types/provable-intf.js'; export { Ledger } from './snarky.js'; -export { Field, Bool, Group, Scalar } from './lib/provable/core.js'; +export { Field, Bool, Group, Scalar } from './lib/provable/wrapped.js'; export { createForeignField, ForeignField, @@ -42,7 +42,7 @@ export { circuitMain, } from './lib/proof-system/circuit.js'; export { UInt32, UInt64, Int64, Sign, UInt8 } from './lib/provable/int.js'; -export { Bytes } from './lib/provable/provable-types.js'; +export { Bytes } from './lib/provable/wrapped-classes.js'; export { Packed, Hashed } from './lib/provable/packed.js'; export { Gadgets } from './lib/provable/gadgets/gadgets.js'; export { Types } from './bindings/mina-transaction/types.js'; diff --git a/src/lib/mina/account-update.ts b/src/lib/mina/account-update.ts index 7f6fb46284..faf9ef4e53 100644 --- a/src/lib/mina/account-update.ts +++ b/src/lib/mina/account-update.ts @@ -10,7 +10,7 @@ import { memoizeWitness, Provable, } from '../provable/provable.js'; -import { Field, Bool } from '../provable/core.js'; +import { Field, Bool } from '../provable/wrapped.js'; import { Pickles, Test } from '../../snarky.js'; import { jsLayout } from '../../bindings/mina-transaction/gen/js-layout.js'; import { diff --git a/src/lib/mina/account.ts b/src/lib/mina/account.ts index f1f38eabe2..e741412c93 100644 --- a/src/lib/mina/account.ts +++ b/src/lib/mina/account.ts @@ -1,5 +1,5 @@ import { Types } from '../../bindings/mina-transaction/types.js'; -import { Bool, Field } from '../provable/core.js'; +import { Bool, Field } from '../provable/wrapped.js'; import { Permissions } from './account-update.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { PublicKey } from '../provable/crypto/signature.js'; diff --git a/src/lib/mina/base58-encodings.ts b/src/lib/mina/base58-encodings.ts index 142f882c9b..f09786f38c 100644 --- a/src/lib/mina/base58-encodings.ts +++ b/src/lib/mina/base58-encodings.ts @@ -1,5 +1,5 @@ import { fieldEncodings } from '../util/base58.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; export { TokenId, ReceiptChainHash, LedgerHash, EpochSeed, StateHash }; diff --git a/src/lib/mina/fetch.ts b/src/lib/mina/fetch.ts index b03439d619..a3f8c730f1 100644 --- a/src/lib/mina/fetch.ts +++ b/src/lib/mina/fetch.ts @@ -1,5 +1,5 @@ import 'isomorphic-fetch'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { Actions, TokenId } from './account-update.js'; import { PublicKey, PrivateKey } from '../provable/crypto/signature.js'; diff --git a/src/lib/mina/local-blockchain.ts b/src/lib/mina/local-blockchain.ts index 5833d7cc6a..9cbb2d9c57 100644 --- a/src/lib/mina/local-blockchain.ts +++ b/src/lib/mina/local-blockchain.ts @@ -2,7 +2,7 @@ import { SimpleLedger } from './transaction-logic/ledger.js'; import { Ml } from '../ml/conversion.js'; import { transactionCommitments } from '../../mina-signer/src/sign-zkapp-command.js'; import { Ledger, Test } from '../../snarky.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { Account } from './account.js'; diff --git a/src/lib/mina/mina-instance.ts b/src/lib/mina/mina-instance.ts index 0a657c79a9..87db6f24b0 100644 --- a/src/lib/mina/mina-instance.ts +++ b/src/lib/mina/mina-instance.ts @@ -1,7 +1,7 @@ /** * This module holds the global Mina instance and its interface. */ -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { UInt64, UInt32 } from '../provable/int.js'; import { PublicKey } from '../provable/crypto/signature.js'; import type { EventActionFilterOptions } from '././../mina/graphql.js'; diff --git a/src/lib/mina/mina.ts b/src/lib/mina/mina.ts index 7745c8a8b7..0f843c76a0 100644 --- a/src/lib/mina/mina.ts +++ b/src/lib/mina/mina.ts @@ -1,5 +1,5 @@ import { Test } from '../../snarky.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { UInt64 } from '../provable/int.js'; import { PublicKey } from '../provable/crypto/signature.js'; import { ZkappCommand, TokenId, Authorization } from './account-update.js'; diff --git a/src/lib/mina/precondition.ts b/src/lib/mina/precondition.ts index 96d55588c9..3d3942b66f 100644 --- a/src/lib/mina/precondition.ts +++ b/src/lib/mina/precondition.ts @@ -1,4 +1,4 @@ -import { Bool, Field } from '../provable/core.js'; +import { Bool, Field } from '../provable/wrapped.js'; import { circuitValueEquals, cloneCircuitValue, diff --git a/src/lib/mina/state.ts b/src/lib/mina/state.ts index 61a82e3855..3f16428782 100644 --- a/src/lib/mina/state.ts +++ b/src/lib/mina/state.ts @@ -6,7 +6,7 @@ import { fetchAccount, networkConfig } from './fetch.js'; import { SmartContract } from './zkapp.js'; import { Account } from './account.js'; import { Provable } from '../provable/provable.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { ProvablePure } from '../provable/types/provable-intf.js'; // external API diff --git a/src/lib/mina/token/forest-iterator.ts b/src/lib/mina/token/forest-iterator.ts index 67cdaf6f35..bab2a07ccb 100644 --- a/src/lib/mina/token/forest-iterator.ts +++ b/src/lib/mina/token/forest-iterator.ts @@ -4,7 +4,7 @@ import { AccountUpdateTreeBase, TokenId, } from '../account-update.js'; -import { Field } from '../../provable/core.js'; +import { Field } from '../../provable/wrapped.js'; import { Provable } from '../../provable/provable.js'; import { Struct } from '../../provable/types/struct.js'; import { assert } from '../../provable/gadgets/common.js'; diff --git a/src/lib/mina/token/forest-iterator.unit-test.ts b/src/lib/mina/token/forest-iterator.unit-test.ts index 7072dc5756..20d4c38af4 100644 --- a/src/lib/mina/token/forest-iterator.unit-test.ts +++ b/src/lib/mina/token/forest-iterator.unit-test.ts @@ -14,7 +14,7 @@ import { callForestHash, } from '../../../mina-signer/src/sign-zkapp-command.js'; import assert from 'assert'; -import { Field, Bool } from '../../provable/core.js'; +import { Field, Bool } from '../../provable/wrapped.js'; import { PublicKey } from '../../provable/crypto/signature.js'; // RANDOM NUMBER GENERATORS for account updates diff --git a/src/lib/mina/token/token-contract.ts b/src/lib/mina/token/token-contract.ts index b62b2ad75b..1a9845d51a 100644 --- a/src/lib/mina/token/token-contract.ts +++ b/src/lib/mina/token/token-contract.ts @@ -1,4 +1,4 @@ -import { Bool } from '../../provable/core.js'; +import { Bool } from '../../provable/wrapped.js'; import { UInt64, Int64 } from '../../provable/int.js'; import { Provable } from '../../provable/provable.js'; import { PublicKey } from '../../provable/crypto/signature.js'; diff --git a/src/lib/mina/token/token-methods.ts b/src/lib/mina/token/token-methods.ts index 7e54acfa4e..df7357197a 100644 --- a/src/lib/mina/token/token-methods.ts +++ b/src/lib/mina/token/token-methods.ts @@ -3,7 +3,7 @@ import { isSmartContract } from '../smart-contract-base.js'; import { PublicKey } from '../../provable/crypto/signature.js'; import type { SmartContract } from '../zkapp.js'; import { UInt64 } from '../../provable/int.js'; -import { Bool, Field } from '../../provable/core.js'; +import { Bool, Field } from '../../provable/wrapped.js'; export { tokenMethods }; diff --git a/src/lib/mina/transaction-validation.ts b/src/lib/mina/transaction-validation.ts index 9df24d90e5..ddc6a23893 100644 --- a/src/lib/mina/transaction-validation.ts +++ b/src/lib/mina/transaction-validation.ts @@ -9,7 +9,7 @@ import { AccountUpdate, dummySignature, } from './account-update.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { UInt64, UInt32 } from '../provable/int.js'; import { PublicKey } from '../provable/crypto/signature.js'; import { JsonProof, verify } from '../proof-system/zkprogram.js'; diff --git a/src/lib/mina/transaction.ts b/src/lib/mina/transaction.ts index 4a028026ae..0a5c2bc6c0 100644 --- a/src/lib/mina/transaction.ts +++ b/src/lib/mina/transaction.ts @@ -8,7 +8,7 @@ import { TokenId, addMissingProofs, } from './account-update.js'; -import { Field } from '../provable/core.js'; +import { Field } from '../provable/wrapped.js'; import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { UInt32, UInt64 } from '../provable/int.js'; import { Empty, Proof } from '../proof-system/zkprogram.js'; diff --git a/src/lib/mina/zkapp.ts b/src/lib/mina/zkapp.ts index f81f778caa..3a03d83dd5 100644 --- a/src/lib/mina/zkapp.ts +++ b/src/lib/mina/zkapp.ts @@ -1,6 +1,6 @@ import 'reflect-metadata'; import { Gate, Pickles } from '../../snarky.js'; -import { Field, Bool } from '../provable/core.js'; +import { Field, Bool } from '../provable/wrapped.js'; import { AccountUpdate, Authorization, diff --git a/src/lib/ml/consistency.unit-test.ts b/src/lib/ml/consistency.unit-test.ts index 93647d16b7..84a30f691e 100644 --- a/src/lib/ml/consistency.unit-test.ts +++ b/src/lib/ml/consistency.unit-test.ts @@ -1,6 +1,6 @@ import { Test } from '../../snarky.js'; import { Random, test } from '../testing/property.js'; -import { Field, Bool } from '../provable/core.js'; +import { Field, Bool } from '../provable/wrapped.js'; import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; import { TokenId, dummySignature } from '../mina/account-update.js'; import { Ml } from './conversion.js'; diff --git a/src/lib/ml/conversion.ts b/src/lib/ml/conversion.ts index 4068fef636..91b938d105 100644 --- a/src/lib/ml/conversion.ts +++ b/src/lib/ml/conversion.ts @@ -4,7 +4,7 @@ import type { MlPublicKey, MlPublicKeyVar } from '../../snarky.js'; import { HashInput } from '../provable/types/struct.js'; -import { Bool, Field } from '../provable/core.js'; +import { Bool, Field } from '../provable/wrapped.js'; import { FieldVar, FieldConst } from '../provable/core/fieldvar.js'; import { Scalar, ScalarConst } from '../provable/scalar.js'; import { PrivateKey, PublicKey } from '../provable/crypto/signature.js'; diff --git a/src/lib/proof-system/proof-system.unit-test.ts b/src/lib/proof-system/proof-system.unit-test.ts index f6787b1e7f..b2e7501f94 100644 --- a/src/lib/proof-system/proof-system.unit-test.ts +++ b/src/lib/proof-system/proof-system.unit-test.ts @@ -1,4 +1,4 @@ -import { Field, Bool } from '../provable/core.js'; +import { Field, Bool } from '../provable/wrapped.js'; import { Struct } from '../provable/types/struct.js'; import { UInt64 } from '../provable/int.js'; import { diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index e09d23edfa..246d3573cd 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -11,7 +11,7 @@ import { Gate, GateType, } from '../../snarky.js'; -import { Field, Bool } from '../provable/core.js'; +import { Field, Bool } from '../provable/wrapped.js'; import { FlexibleProvable, FlexibleProvablePure, diff --git a/src/lib/provable/crypto/encryption.ts b/src/lib/provable/crypto/encryption.ts index 14dee36bf1..8c025886ab 100644 --- a/src/lib/provable/crypto/encryption.ts +++ b/src/lib/provable/crypto/encryption.ts @@ -1,4 +1,4 @@ -import { Field, Scalar, Group } from '../core.js'; +import { Field, Scalar, Group } from '../wrapped.js'; import { Poseidon } from './poseidon.js'; import { Provable } from '../provable.js'; import { PrivateKey, PublicKey } from './signature.js'; diff --git a/src/lib/provable/crypto/foreign-ecdsa.ts b/src/lib/provable/crypto/foreign-ecdsa.ts index 56998a421b..b601928b93 100644 --- a/src/lib/provable/crypto/foreign-ecdsa.ts +++ b/src/lib/provable/crypto/foreign-ecdsa.ts @@ -13,7 +13,7 @@ import { Field3 } from '../gadgets/foreign-field.js'; import { Ecdsa } from '../gadgets/elliptic-curve.js'; import { l } from '../gadgets/range-check.js'; import { Keccak } from './keccak.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; import { UInt8 } from '../int.js'; // external API diff --git a/src/lib/provable/crypto/hash.ts b/src/lib/provable/crypto/hash.ts index 3f1cd87efa..3c7edaf813 100644 --- a/src/lib/provable/crypto/hash.ts +++ b/src/lib/provable/crypto/hash.ts @@ -1,7 +1,7 @@ import { Gadgets } from '../gadgets/gadgets.js'; import { Poseidon } from './poseidon.js'; import { Keccak } from './keccak.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; export { Hash }; diff --git a/src/lib/provable/crypto/keccak.ts b/src/lib/provable/crypto/keccak.ts index d1560c5a3c..23c95f8a2f 100644 --- a/src/lib/provable/crypto/keccak.ts +++ b/src/lib/provable/crypto/keccak.ts @@ -3,7 +3,7 @@ import { Gadgets } from '../gadgets/gadgets.js'; import { assert } from '../../util/errors.js'; import { FlexibleBytes } from '../bytes.js'; import { UInt8 } from '../int.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; import { bytesToWords, wordsToBytes } from '../gadgets/bit-slices.js'; export { Keccak }; diff --git a/src/lib/provable/crypto/nullifier.ts b/src/lib/provable/crypto/nullifier.ts index 7f29948369..f0ce72a65b 100644 --- a/src/lib/provable/crypto/nullifier.ts +++ b/src/lib/provable/crypto/nullifier.ts @@ -1,6 +1,6 @@ import type { Nullifier as JsonNullifier } from '../../../mina-signer/src/types.js'; import { Struct } from '../types/struct.js'; -import { Field, Group, Scalar } from '../core.js'; +import { Field, Group, Scalar } from '../wrapped.js'; import { Poseidon } from './poseidon.js'; import { MerkleMapWitness } from '../merkle-map.js'; import { PrivateKey, PublicKey, scaleShifted } from './signature.js'; diff --git a/src/lib/provable/crypto/poseidon.ts b/src/lib/provable/crypto/poseidon.ts index e7d4124f50..33be685443 100644 --- a/src/lib/provable/crypto/poseidon.ts +++ b/src/lib/provable/crypto/poseidon.ts @@ -1,6 +1,6 @@ import { HashInput, ProvableExtended, Struct } from '../types/struct.js'; import { Snarky } from '../../../snarky.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { createHashHelpers } from './hash-generic.js'; import { Provable } from '../provable.js'; import { MlFieldArray } from '../../ml/fields.js'; diff --git a/src/lib/provable/crypto/signature.ts b/src/lib/provable/crypto/signature.ts index 8eb0c849b5..5dd1f5929d 100644 --- a/src/lib/provable/crypto/signature.ts +++ b/src/lib/provable/crypto/signature.ts @@ -1,4 +1,4 @@ -import { Field, Bool, Group, Scalar } from '../core.js'; +import { Field, Bool, Group, Scalar } from '../wrapped.js'; import { AnyConstructor } from '../types/struct.js'; import { hashWithPrefix } from './poseidon.js'; import { Fq } from '../../../bindings/crypto/finite-field.js'; diff --git a/src/lib/provable/gadgets/arithmetic.ts b/src/lib/provable/gadgets/arithmetic.ts index ea0922ff4e..c5d1bc75f3 100644 --- a/src/lib/provable/gadgets/arithmetic.ts +++ b/src/lib/provable/gadgets/arithmetic.ts @@ -1,5 +1,5 @@ import { provableTuple } from '../types/struct.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { assert } from '../../util/errors.js'; import { Provable } from '../provable.js'; import { rangeCheck32, rangeCheckN } from './range-check.js'; diff --git a/src/lib/provable/gadgets/arithmetic.unit-test.ts b/src/lib/provable/gadgets/arithmetic.unit-test.ts index 5b2be3b562..13009759cd 100644 --- a/src/lib/provable/gadgets/arithmetic.unit-test.ts +++ b/src/lib/provable/gadgets/arithmetic.unit-test.ts @@ -5,7 +5,7 @@ import { field, record, } from '../../testing/equivalent.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { Gadgets } from './gadgets.js'; import { provable } from '../types/struct.js'; import { assert } from './common.js'; diff --git a/src/lib/provable/gadgets/bitwise.unit-test.ts b/src/lib/provable/gadgets/bitwise.unit-test.ts index 1c4e1efbed..a938b84ab8 100644 --- a/src/lib/provable/gadgets/bitwise.unit-test.ts +++ b/src/lib/provable/gadgets/bitwise.unit-test.ts @@ -6,7 +6,7 @@ import { fieldWithRng, } from '../../testing/equivalent.js'; import { Fp, mod } from '../../../bindings/crypto/finite-field.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { Gadgets } from './gadgets.js'; import { Random } from '../../testing/property.js'; import { diff --git a/src/lib/provable/gadgets/gadgets.ts b/src/lib/provable/gadgets/gadgets.ts index 4da3b4d68f..fa56fb47e9 100644 --- a/src/lib/provable/gadgets/gadgets.ts +++ b/src/lib/provable/gadgets/gadgets.ts @@ -21,7 +21,7 @@ import { rightShift64, leftShift32, } from './bitwise.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { ForeignField, Field3, diff --git a/src/lib/provable/gadgets/range-check.unit-test.ts b/src/lib/provable/gadgets/range-check.unit-test.ts index a9b5dce44d..ba2ab8b087 100644 --- a/src/lib/provable/gadgets/range-check.unit-test.ts +++ b/src/lib/provable/gadgets/range-check.unit-test.ts @@ -1,5 +1,5 @@ import { mod } from '../../../bindings/crypto/finite-field.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Spec, diff --git a/src/lib/provable/gadgets/sha256.ts b/src/lib/provable/gadgets/sha256.ts index 27d7983bb5..38a5c82b14 100644 --- a/src/lib/provable/gadgets/sha256.ts +++ b/src/lib/provable/gadgets/sha256.ts @@ -1,10 +1,10 @@ // https://csrc.nist.gov/pubs/fips/180-4/upd1/final import { mod } from '../../../bindings/crypto/finite-field.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { UInt32, UInt8 } from '../int.js'; import { exists } from '../core/exists.js'; import { FlexibleBytes } from '../bytes.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; import { chunk } from '../../util/arrays.js'; import { TupleN } from '../../util/types.js'; import { divMod32 } from './arithmetic.js'; diff --git a/src/lib/provable/gadgets/sha256.unit-test.ts b/src/lib/provable/gadgets/sha256.unit-test.ts index 6238576405..bf8f5cb27c 100644 --- a/src/lib/provable/gadgets/sha256.unit-test.ts +++ b/src/lib/provable/gadgets/sha256.unit-test.ts @@ -1,5 +1,5 @@ import { ZkProgram } from '../../proof-system/zkprogram.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; import { Gadgets } from './gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; import { bytes } from './test-utils.js'; diff --git a/src/lib/provable/gadgets/test-utils.ts b/src/lib/provable/gadgets/test-utils.ts index efd4d177d8..4b420aa632 100644 --- a/src/lib/provable/gadgets/test-utils.ts +++ b/src/lib/provable/gadgets/test-utils.ts @@ -3,7 +3,7 @@ import { ProvableSpec, spec } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; import { Field3 } from './gadgets.js'; import { assert } from './common.js'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; export { foreignField, diff --git a/src/lib/provable/int.ts b/src/lib/provable/int.ts index f7312a4ad6..8a3f791278 100644 --- a/src/lib/provable/int.ts +++ b/src/lib/provable/int.ts @@ -1,4 +1,4 @@ -import { Field, Bool } from './core.js'; +import { Field, Bool } from './wrapped.js'; import { AnyConstructor, Struct } from './types/struct.js'; import { Types } from '../../bindings/mina-transaction/types.js'; import { HashInput } from './crypto/poseidon.js'; diff --git a/src/lib/provable/merkle-list.ts b/src/lib/provable/merkle-list.ts index 3d55cadbb4..2286caee40 100644 --- a/src/lib/provable/merkle-list.ts +++ b/src/lib/provable/merkle-list.ts @@ -1,4 +1,4 @@ -import { Bool, Field } from './core.js'; +import { Bool, Field } from './wrapped.js'; import { Provable } from './provable.js'; import { Struct } from './types/struct.js'; import { assert } from './gadgets/common.js'; diff --git a/src/lib/provable/merkle-map.ts b/src/lib/provable/merkle-map.ts index 54b9e23cbe..9436ed0340 100644 --- a/src/lib/provable/merkle-map.ts +++ b/src/lib/provable/merkle-map.ts @@ -1,5 +1,5 @@ import { arrayProp, CircuitValue } from './types/circuit-value.js'; -import { Field, Bool } from './core.js'; +import { Field, Bool } from './wrapped.js'; import { Poseidon } from './crypto/poseidon.js'; import { MerkleTree, MerkleWitness } from './merkle-tree.js'; import { Provable } from './provable.js'; diff --git a/src/lib/provable/merkle-tree.ts b/src/lib/provable/merkle-tree.ts index 98d2264236..69236a3fda 100644 --- a/src/lib/provable/merkle-tree.ts +++ b/src/lib/provable/merkle-tree.ts @@ -4,7 +4,7 @@ import { CircuitValue, arrayProp } from './types/circuit-value.js'; import { Poseidon } from './crypto/poseidon.js'; -import { Bool, Field } from './core.js'; +import { Bool, Field } from './wrapped.js'; import { Provable } from './provable.js'; // external API diff --git a/src/lib/provable/string.ts b/src/lib/provable/string.ts index f6b9d57afe..b5a85878a8 100644 --- a/src/lib/provable/string.ts +++ b/src/lib/provable/string.ts @@ -1,4 +1,4 @@ -import { Bool, Field } from './core.js'; +import { Bool, Field } from './wrapped.js'; import { Provable } from './provable.js'; import { Poseidon } from './crypto/poseidon.js'; import { Gadgets } from './gadgets/gadgets.js'; diff --git a/src/lib/provable/test/field.unit-test.ts b/src/lib/provable/test/field.unit-test.ts index c65aacad4d..2465df3adb 100644 --- a/src/lib/provable/test/field.unit-test.ts +++ b/src/lib/provable/test/field.unit-test.ts @@ -1,4 +1,4 @@ -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { Fp } from '../../../bindings/crypto/finite-field.js'; import { BinableFp } from '../../../mina-signer/src/field-bigint.js'; import { test, Random } from '../../testing/property.js'; diff --git a/src/lib/provable/test/foreign-field.unit-test.ts b/src/lib/provable/test/foreign-field.unit-test.ts index cca08c78ba..64f5fb65c3 100644 --- a/src/lib/provable/test/foreign-field.unit-test.ts +++ b/src/lib/provable/test/foreign-field.unit-test.ts @@ -1,4 +1,4 @@ -import { Field, Group } from '../core.js'; +import { Field, Group } from '../wrapped.js'; import { ForeignField, createForeignField } from '../foreign-field.js'; import { Fq } from '../../../bindings/crypto/finite-field.js'; import { Pallas } from '../../../bindings/crypto/elliptic-curve.js'; diff --git a/src/lib/provable/test/group.unit-test.ts b/src/lib/provable/test/group.unit-test.ts index 7fae17625a..a6d3205b5d 100644 --- a/src/lib/provable/test/group.unit-test.ts +++ b/src/lib/provable/test/group.unit-test.ts @@ -1,4 +1,4 @@ -import { Group } from '../core.js'; +import { Group } from '../wrapped.js'; import { test, Random } from '../../testing/property.js'; import { Provable } from '../provable.js'; import { Poseidon } from '../../../mina-signer/src/poseidon-bigint.js'; diff --git a/src/lib/provable/test/keccak.unit-test.ts b/src/lib/provable/test/keccak.unit-test.ts index 6a61c35bf2..b70f704748 100644 --- a/src/lib/provable/test/keccak.unit-test.ts +++ b/src/lib/provable/test/keccak.unit-test.ts @@ -15,7 +15,7 @@ import { sha3_384, sha3_512, } from '@noble/hashes/sha3'; -import { Bytes } from '../provable-types.js'; +import { Bytes } from '../wrapped-classes.js'; import { bytes } from '../gadgets/test-utils.js'; import { UInt8 } from '../int.js'; import { test, Random, sample } from '../../testing/property.js'; diff --git a/src/lib/provable/test/merkle-tree.unit-test.ts b/src/lib/provable/test/merkle-tree.unit-test.ts index 8c1e7b8a25..7eb7e7415d 100644 --- a/src/lib/provable/test/merkle-tree.unit-test.ts +++ b/src/lib/provable/test/merkle-tree.unit-test.ts @@ -1,4 +1,4 @@ -import { Bool, Field } from '../core.js'; +import { Bool, Field } from '../wrapped.js'; import { maybeSwap } from '../merkle-tree.js'; import { Random, test } from '../../testing/property.js'; import { expect } from 'expect'; diff --git a/src/lib/provable/test/nullifier.unit-test.ts b/src/lib/provable/test/nullifier.unit-test.ts index 77fe49ce4c..fda3a33836 100644 --- a/src/lib/provable/test/nullifier.unit-test.ts +++ b/src/lib/provable/test/nullifier.unit-test.ts @@ -1,5 +1,5 @@ import { createNullifier } from '../../../mina-signer/src/nullifier.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { Nullifier } from '../crypto/nullifier.js'; import { PrivateKey } from '../crypto/signature.js'; diff --git a/src/lib/provable/test/struct.unit-test.ts b/src/lib/provable/test/struct.unit-test.ts index 7a19ab86d3..7218d99bf8 100644 --- a/src/lib/provable/test/struct.unit-test.ts +++ b/src/lib/provable/test/struct.unit-test.ts @@ -12,7 +12,7 @@ import { import { State, state } from '../../mina/state.js'; import { AccountUpdate } from '../../mina/account-update.js'; import { Provable } from '../provable.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; let type = provable({ nested: { a: Number, b: Boolean }, diff --git a/src/lib/provable/types/circuit-value.ts b/src/lib/provable/types/circuit-value.ts index 3b54f501b8..828a0b0776 100644 --- a/src/lib/provable/types/circuit-value.ts +++ b/src/lib/provable/types/circuit-value.ts @@ -1,5 +1,5 @@ import 'reflect-metadata'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { HashInput, NonMethods } from './provable-derivers.js'; import { Provable } from '../provable.js'; import { AnyConstructor, FlexibleProvable } from './struct.js'; diff --git a/src/lib/provable/types/provable-derivers.ts b/src/lib/provable/types/provable-derivers.ts index a1871b3c7c..552e11b3b2 100644 --- a/src/lib/provable/types/provable-derivers.ts +++ b/src/lib/provable/types/provable-derivers.ts @@ -1,5 +1,5 @@ import { Provable, ProvablePure } from './provable-intf.js'; -import { Field } from '../core.js'; +import { Field } from '../wrapped.js'; import { createDerivers, NonMethods, diff --git a/src/lib/provable/types/struct.ts b/src/lib/provable/types/struct.ts index f20dbda0c4..250f05b7d3 100644 --- a/src/lib/provable/types/struct.ts +++ b/src/lib/provable/types/struct.ts @@ -1,4 +1,4 @@ -import { Field, Bool, Scalar, Group } from '../core.js'; +import { Field, Bool, Scalar, Group } from '../wrapped.js'; import { provable, provablePure, diff --git a/src/lib/provable/provable-types.ts b/src/lib/provable/wrapped-classes.ts similarity index 100% rename from src/lib/provable/provable-types.ts rename to src/lib/provable/wrapped-classes.ts diff --git a/src/lib/provable/core.ts b/src/lib/provable/wrapped.ts similarity index 100% rename from src/lib/provable/core.ts rename to src/lib/provable/wrapped.ts diff --git a/src/lib/testing/equivalent.ts b/src/lib/testing/equivalent.ts index 84e28c27bc..c15b162639 100644 --- a/src/lib/testing/equivalent.ts +++ b/src/lib/testing/equivalent.ts @@ -4,7 +4,7 @@ import { test, Random } from '../testing/property.js'; import { Provable } from '../provable/provable.js'; import { deepEqual } from 'node:assert/strict'; -import { Bool, Field } from '../provable/core.js'; +import { Bool, Field } from '../provable/wrapped.js'; import { AnyFunction, Tuple } from '../util/types.js'; import { provable } from '../provable/types/struct.js'; import { assert } from '../provable/gadgets/common.js'; diff --git a/src/mina-signer/tests/verify-in-snark.unit-test.ts b/src/mina-signer/tests/verify-in-snark.unit-test.ts index 04cd42d01b..5ae1559006 100644 --- a/src/mina-signer/tests/verify-in-snark.unit-test.ts +++ b/src/mina-signer/tests/verify-in-snark.unit-test.ts @@ -1,4 +1,4 @@ -import { Field } from '../../lib/provable/core.js'; +import { Field } from '../../lib/provable/wrapped.js'; import { ZkProgram } from '../../lib/proof-system/zkprogram.js'; import Client from '../mina-signer.js'; import { PrivateKey, Signature } from '../../lib/provable/crypto/signature.js'; From 393123a61fcb5e421dcbd91e8a11b991ffb4165c Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 14:37:26 +0100 Subject: [PATCH 7/7] tests into tests --- src/lib/provable/gadgets/foreign-field.ts | 2 +- src/lib/provable/packed.ts | 2 +- .../provable/{gadgets => test}/arithmetic.unit-test.ts | 4 ++-- src/lib/provable/{gadgets => test}/bitwise.unit-test.ts | 2 +- src/lib/provable/{gadgets => test}/ecdsa.unit-test.ts | 8 ++++---- .../{gadgets => test}/elliptic-curve.unit-test.ts | 8 ++++++-- .../foreign-field-gadgets.unit-test.ts} | 6 +++--- src/lib/provable/test/keccak.unit-test.ts | 2 +- .../provable/{gadgets => test}/range-check.unit-test.ts | 6 +++--- src/lib/provable/{gadgets => test}/sha256.unit-test.ts | 2 +- src/lib/provable/{gadgets => test}/test-utils.ts | 4 ++-- src/lib/provable/{ => types}/fields.ts | 4 ++-- 12 files changed, 27 insertions(+), 23 deletions(-) rename src/lib/provable/{gadgets => test}/arithmetic.unit-test.ts (93%) rename src/lib/provable/{gadgets => test}/bitwise.unit-test.ts (99%) rename src/lib/provable/{gadgets => test}/ecdsa.unit-test.ts (97%) rename src/lib/provable/{gadgets => test}/elliptic-curve.unit-test.ts (94%) rename src/lib/provable/{gadgets/foreign-field.unit-test.ts => test/foreign-field-gadgets.unit-test.ts} (98%) rename src/lib/provable/{gadgets => test}/range-check.unit-test.ts (96%) rename src/lib/provable/{gadgets => test}/sha256.unit-test.ts (97%) rename src/lib/provable/{gadgets => test}/test-utils.ts (94%) rename src/lib/provable/{ => types}/fields.ts (91%) diff --git a/src/lib/provable/gadgets/foreign-field.ts b/src/lib/provable/gadgets/foreign-field.ts index b955521024..71744eb4b3 100644 --- a/src/lib/provable/gadgets/foreign-field.ts +++ b/src/lib/provable/gadgets/foreign-field.ts @@ -11,7 +11,7 @@ import { Unconstrained } from '../types/unconstrained.js'; import { Field } from '../field.js'; import { Gates, foreignFieldAdd } from '../gates.js'; import { exists } from '../core/exists.js'; -import { modifiedField } from '../fields.js'; +import { modifiedField } from '../types/fields.js'; import { Tuple, TupleN } from '../../util/types.js'; import { assertOneOf } from './basic.js'; import { assert, bitSlice, toVar, toVars } from './common.js'; diff --git a/src/lib/provable/packed.ts b/src/lib/provable/packed.ts index 966e8baf70..6bf7d86908 100644 --- a/src/lib/provable/packed.ts +++ b/src/lib/provable/packed.ts @@ -5,7 +5,7 @@ import { Field } from './field.js'; import { assert } from './gadgets/common.js'; import { Poseidon, ProvableHashable, packToFields } from './crypto/poseidon.js'; import { Provable } from './provable.js'; -import { fields, modifiedField } from './fields.js'; +import { fields, modifiedField } from './types/fields.js'; export { Packed, Hashed }; diff --git a/src/lib/provable/gadgets/arithmetic.unit-test.ts b/src/lib/provable/test/arithmetic.unit-test.ts similarity index 93% rename from src/lib/provable/gadgets/arithmetic.unit-test.ts rename to src/lib/provable/test/arithmetic.unit-test.ts index 13009759cd..579dce8236 100644 --- a/src/lib/provable/gadgets/arithmetic.unit-test.ts +++ b/src/lib/provable/test/arithmetic.unit-test.ts @@ -6,9 +6,9 @@ import { record, } from '../../testing/equivalent.js'; import { Field } from '../wrapped.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { provable } from '../types/struct.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; let Arithmetic = ZkProgram({ name: 'arithmetic', diff --git a/src/lib/provable/gadgets/bitwise.unit-test.ts b/src/lib/provable/test/bitwise.unit-test.ts similarity index 99% rename from src/lib/provable/gadgets/bitwise.unit-test.ts rename to src/lib/provable/test/bitwise.unit-test.ts index a938b84ab8..1c3bbc8240 100644 --- a/src/lib/provable/gadgets/bitwise.unit-test.ts +++ b/src/lib/provable/test/bitwise.unit-test.ts @@ -7,7 +7,7 @@ import { } from '../../testing/equivalent.js'; import { Fp, mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../wrapped.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { Random } from '../../testing/property.js'; import { constraintSystem, diff --git a/src/lib/provable/gadgets/ecdsa.unit-test.ts b/src/lib/provable/test/ecdsa.unit-test.ts similarity index 97% rename from src/lib/provable/gadgets/ecdsa.unit-test.ts rename to src/lib/provable/test/ecdsa.unit-test.ts index 0cfab362e3..97e9b93f30 100644 --- a/src/lib/provable/gadgets/ecdsa.unit-test.ts +++ b/src/lib/provable/test/ecdsa.unit-test.ts @@ -5,12 +5,12 @@ import { Point, initialAggregator, verifyEcdsaConstant, -} from './elliptic-curve.js'; -import { Field3 } from './foreign-field.js'; +} from '../gadgets/elliptic-curve.js'; +import { Field3 } from '../gadgets/foreign-field.js'; import { CurveParams } from '../../../bindings/crypto/elliptic-curve-examples.js'; import { Provable } from '../provable.js'; import { ZkProgram } from '../../proof-system/zkprogram.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; import { foreignField, uniformForeignField } from './test-utils.js'; import { First, @@ -22,7 +22,7 @@ import { oneOf, record, } from '../../testing/equivalent.js'; -import { Bool } from '../../provable/bool.js'; +import { Bool } from '../bool.js'; import { Random } from '../../testing/random.js'; // quick tests diff --git a/src/lib/provable/gadgets/elliptic-curve.unit-test.ts b/src/lib/provable/test/elliptic-curve.unit-test.ts similarity index 94% rename from src/lib/provable/gadgets/elliptic-curve.unit-test.ts rename to src/lib/provable/test/elliptic-curve.unit-test.ts index 2dfa76d0fb..2db23ecd9d 100644 --- a/src/lib/provable/gadgets/elliptic-curve.unit-test.ts +++ b/src/lib/provable/test/elliptic-curve.unit-test.ts @@ -9,8 +9,12 @@ import { unit, } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { assert } from './common.js'; -import { EllipticCurve, Point, simpleMapToCurve } from './elliptic-curve.js'; +import { assert } from '../gadgets/common.js'; +import { + EllipticCurve, + Point, + simpleMapToCurve, +} from '../gadgets/elliptic-curve.js'; import { foreignField, throwError } from './test-utils.js'; // provable equivalence tests diff --git a/src/lib/provable/gadgets/foreign-field.unit-test.ts b/src/lib/provable/test/foreign-field-gadgets.unit-test.ts similarity index 98% rename from src/lib/provable/gadgets/foreign-field.unit-test.ts rename to src/lib/provable/test/foreign-field-gadgets.unit-test.ts index e5213da894..3f0fdaaca5 100644 --- a/src/lib/provable/gadgets/foreign-field.unit-test.ts +++ b/src/lib/provable/test/foreign-field-gadgets.unit-test.ts @@ -10,10 +10,10 @@ import { unit, } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { Field3, Gadgets } from './gadgets.js'; +import { Field3, Gadgets } from '../gadgets/gadgets.js'; import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Provable } from '../provable.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; import { allConstant, and, @@ -33,7 +33,7 @@ import { throwError, unreducedForeignField, } from './test-utils.js'; -import { l2 } from './range-check.js'; +import { l2 } from '../gadgets/range-check.js'; const { ForeignField } = Gadgets; diff --git a/src/lib/provable/test/keccak.unit-test.ts b/src/lib/provable/test/keccak.unit-test.ts index b70f704748..1678b0a231 100644 --- a/src/lib/provable/test/keccak.unit-test.ts +++ b/src/lib/provable/test/keccak.unit-test.ts @@ -16,7 +16,7 @@ import { sha3_512, } from '@noble/hashes/sha3'; import { Bytes } from '../wrapped-classes.js'; -import { bytes } from '../gadgets/test-utils.js'; +import { bytes } from './test-utils.js'; import { UInt8 } from '../int.js'; import { test, Random, sample } from '../../testing/property.js'; import { expect } from 'expect'; diff --git a/src/lib/provable/gadgets/range-check.unit-test.ts b/src/lib/provable/test/range-check.unit-test.ts similarity index 96% rename from src/lib/provable/gadgets/range-check.unit-test.ts rename to src/lib/provable/test/range-check.unit-test.ts index ba2ab8b087..fbb65befb7 100644 --- a/src/lib/provable/gadgets/range-check.unit-test.ts +++ b/src/lib/provable/test/range-check.unit-test.ts @@ -8,9 +8,9 @@ import { fieldWithRng, } from '../../testing/equivalent.js'; import { Random } from '../../testing/property.js'; -import { assert } from './common.js'; -import { Gadgets } from './gadgets.js'; -import { l } from './range-check.js'; +import { assert } from '../gadgets/common.js'; +import { Gadgets } from '../gadgets/gadgets.js'; +import { l } from '../gadgets/range-check.js'; import { constraintSystem, contains, diff --git a/src/lib/provable/gadgets/sha256.unit-test.ts b/src/lib/provable/test/sha256.unit-test.ts similarity index 97% rename from src/lib/provable/gadgets/sha256.unit-test.ts rename to src/lib/provable/test/sha256.unit-test.ts index bf8f5cb27c..c18d661752 100644 --- a/src/lib/provable/gadgets/sha256.unit-test.ts +++ b/src/lib/provable/test/sha256.unit-test.ts @@ -1,6 +1,6 @@ import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Bytes } from '../wrapped-classes.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; import { bytes } from './test-utils.js'; import { diff --git a/src/lib/provable/gadgets/test-utils.ts b/src/lib/provable/test/test-utils.ts similarity index 94% rename from src/lib/provable/gadgets/test-utils.ts rename to src/lib/provable/test/test-utils.ts index 4b420aa632..0406cc0d2a 100644 --- a/src/lib/provable/gadgets/test-utils.ts +++ b/src/lib/provable/test/test-utils.ts @@ -1,8 +1,8 @@ import type { FiniteField } from '../../../bindings/crypto/finite-field.js'; import { ProvableSpec, spec } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { Field3 } from './gadgets.js'; -import { assert } from './common.js'; +import { Field3 } from '../gadgets/gadgets.js'; +import { assert } from '../gadgets/common.js'; import { Bytes } from '../wrapped-classes.js'; export { diff --git a/src/lib/provable/fields.ts b/src/lib/provable/types/fields.ts similarity index 91% rename from src/lib/provable/fields.ts rename to src/lib/provable/types/fields.ts index 419ba9d203..e92cd0d51e 100644 --- a/src/lib/provable/fields.ts +++ b/src/lib/provable/types/fields.ts @@ -1,5 +1,5 @@ -import { ProvablePureExtended } from './types/struct.js'; -import { Field } from './field.js'; +import { ProvablePureExtended } from './struct.js'; +import { Field } from '../field.js'; export { modifiedField, fields };