@provablehq/sdk 0.9.18 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/mainnet/browser.d.ts +6 -4
  2. package/dist/mainnet/browser.js +394 -16
  3. package/dist/mainnet/browser.js.map +1 -1
  4. package/dist/mainnet/external-signing.d.ts +76 -0
  5. package/dist/mainnet/keys/keystore/error.d.ts +5 -4
  6. package/dist/mainnet/keys/keystore/file.d.ts +64 -104
  7. package/dist/mainnet/keys/keystore/interface.d.ts +106 -30
  8. package/dist/mainnet/models/external-signing.d.ts +123 -0
  9. package/dist/mainnet/models/input/inputJSON.d.ts +1 -0
  10. package/dist/mainnet/models/input/inputObject.d.ts +1 -0
  11. package/dist/mainnet/models/output/outputJSON.d.ts +1 -0
  12. package/dist/mainnet/models/output/outputObject.d.ts +1 -0
  13. package/dist/mainnet/network-client.d.ts +1 -0
  14. package/dist/mainnet/node.js +112 -138
  15. package/dist/mainnet/node.js.map +1 -1
  16. package/dist/mainnet/program-manager.d.ts +100 -4
  17. package/dist/mainnet/record-scanner.d.ts +1 -0
  18. package/dist/mainnet/wasm.d.ts +1 -1
  19. package/dist/testnet/browser.d.ts +6 -4
  20. package/dist/testnet/browser.js +394 -16
  21. package/dist/testnet/browser.js.map +1 -1
  22. package/dist/testnet/external-signing.d.ts +76 -0
  23. package/dist/testnet/keys/keystore/error.d.ts +5 -4
  24. package/dist/testnet/keys/keystore/file.d.ts +64 -104
  25. package/dist/testnet/keys/keystore/interface.d.ts +106 -30
  26. package/dist/testnet/models/external-signing.d.ts +123 -0
  27. package/dist/testnet/models/input/inputJSON.d.ts +1 -0
  28. package/dist/testnet/models/input/inputObject.d.ts +1 -0
  29. package/dist/testnet/models/output/outputJSON.d.ts +1 -0
  30. package/dist/testnet/models/output/outputObject.d.ts +1 -0
  31. package/dist/testnet/network-client.d.ts +1 -0
  32. package/dist/testnet/node.js +112 -138
  33. package/dist/testnet/node.js.map +1 -1
  34. package/dist/testnet/program-manager.d.ts +100 -4
  35. package/dist/testnet/record-scanner.d.ts +1 -0
  36. package/dist/testnet/wasm.d.ts +1 -1
  37. package/package.json +2 -2
  38. package/dist/mainnet/models/keyHolder.d.ts +0 -2
  39. package/dist/testnet/models/keyHolder.d.ts +0 -2
@@ -5,7 +5,8 @@ import { RecordProvider } from "./record-provider.js";
5
5
  import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
6
6
  import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.js";
7
7
  import { FunctionKeyPair } from "./models/keyPair.js";
8
- import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
8
+ import { Authorization, ExecutionRequest, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
9
+ import { ExternalSigningOptions } from "./models/external-signing.js";
9
10
  /**
10
11
  * Represents the options for deploying and upgrading a transaction in the Aleo network.
11
12
  * This interface is used to specify the parameters required for building and submitting an deployment transaction.
@@ -147,7 +148,7 @@ interface ProvingRequestOptions {
147
148
  functionName: string;
148
149
  priorityFee: number;
149
150
  privateFee: boolean;
150
- inputs: string[];
151
+ inputs?: string[];
151
152
  baseFee?: number;
152
153
  recordSearchParams?: RecordSearchParams;
153
154
  feeRecord?: string | RecordPlaintext;
@@ -158,6 +159,7 @@ interface ProvingRequestOptions {
158
159
  unchecked?: boolean;
159
160
  edition?: number;
160
161
  useFeeMaster?: boolean;
162
+ executionRequest?: ExecutionRequest;
161
163
  }
162
164
  /**
163
165
  * Fee estimate options.
@@ -177,6 +179,30 @@ interface FeeEstimateOptions {
177
179
  edition?: number;
178
180
  authorization?: Authorization;
179
181
  }
182
+ /**
183
+ * Options for verifying a single Aleo zkSnark proof.
184
+ *
185
+ * @property {string} verifyingKey - The verifying key string for the circuit
186
+ * @property {string[]} inputs - Array of public input strings — either field elements (e.g. "1field") or Aleo types (e.g. "1u32", "{ x: 1u8 }")
187
+ * @property {string} proof - The proof string to verify
188
+ */
189
+ interface VerificationOptions {
190
+ verifyingKey: string;
191
+ inputs: string[];
192
+ proof: string;
193
+ }
194
+ /**
195
+ * Options for verifying a batch Aleo zkSnark proof.
196
+ *
197
+ * @property {string[]} verifyingKeys - Array of verifying key strings, one per circuit
198
+ * @property {string[][][]} inputs - 3D array of input strings [circuit_idx][instance_idx][input_idx]
199
+ * @property {string} proof - The batch proof string to verify
200
+ */
201
+ interface BatchVerificationOptions {
202
+ verifyingKeys: string[];
203
+ inputs: string[][][];
204
+ proof: string;
205
+ }
180
206
  /**
181
207
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
182
208
  */
@@ -549,7 +575,7 @@ declare class ProgramManager {
549
575
  */
550
576
  buildAuthorizationUnchecked(options: AuthorizationOptions): Promise<Authorization>;
551
577
  /**
552
- * Builds a `ProvingRequest` for submission to a prover for execution.
578
+ * Builds a `ProvingRequest` for submission to a prover for execution. If building a proving request with an ExecutionRequest, a private key must be explicitly provided.
553
579
  *
554
580
  * @param {ProvingRequestOptions} options - The options for building the proving request
555
581
  * @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.
@@ -1471,4 +1497,74 @@ declare class ProgramManager {
1471
1497
  */
1472
1498
  buildDevnodeUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
1473
1499
  }
1474
- export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };
1500
+ /**
1501
+ * Convert an array of Aleo type strings to field element strings.
1502
+ *
1503
+ * Inputs that are already field elements (e.g. "1field") are passed through directly.
1504
+ * Other Aleo values (e.g. "1u32", records, futures, dynamic records) are parsed via
1505
+ * Value and converted to their field representation.
1506
+ *
1507
+ * @param {string[]} inputs Array of Aleo value strings
1508
+ * @returns {string[]} Array of field element strings
1509
+ */
1510
+ declare function inputsToFields(inputs: string[]): string[];
1511
+ /**
1512
+ * Verify an Aleo zkSnark proof against a verifying key and public inputs.
1513
+ *
1514
+ * This verifies a proof produced by an Aleo program that may not be deployed on chain.
1515
+ * It directly invokes the Varuna proof verification from snarkVM.
1516
+ *
1517
+ * **Note:** The proof must have been generated with the Fiat-Shamir domain separator
1518
+ * "snark_verify". Proofs generated via snarkVM with a different function name will fail
1519
+ * verification even if the circuit and inputs are correct.
1520
+ *
1521
+ * Inputs can be raw field element strings (e.g. "1field") or Aleo type strings
1522
+ * (e.g. "1u32", "true", "{ x: 1u8, y: 2u8 }"). Non-field inputs are automatically
1523
+ * converted to their field representation via Value.toFields().
1524
+ *
1525
+ * @param {VerificationOptions} options The verification parameters
1526
+ * @returns {boolean} True if the proof is valid, false otherwise
1527
+ *
1528
+ * @example
1529
+ * import { verifyProof } from "@provablehq/sdk/mainnet.js";
1530
+ *
1531
+ * // Using raw field elements:
1532
+ * const isValid = verifyProof({
1533
+ * verifyingKey: "verifier1...",
1534
+ * inputs: ["1field", "2field"],
1535
+ * proof: "proof1...",
1536
+ * });
1537
+ *
1538
+ * // Using Aleo types (automatically converted to fields):
1539
+ * const isValid2 = verifyProof({
1540
+ * verifyingKey: "verifier1...",
1541
+ * inputs: ["1u32", "2u32"],
1542
+ * proof: "proof1...",
1543
+ * });
1544
+ */
1545
+ declare function verifyProof(options: VerificationOptions): boolean;
1546
+ /**
1547
+ * Verify a batch Aleo zkSnark proof against multiple verifying keys and their corresponding public inputs.
1548
+ *
1549
+ * Each verifying key is paired with one or more sets of public inputs (instances).
1550
+ * Inputs can be raw field element strings or Aleo type strings — non-field inputs
1551
+ * are automatically converted to their field representation.
1552
+ *
1553
+ * **Note:** The proof must have been generated with the Fiat-Shamir domain separator
1554
+ * "snark_verify_batch". Proofs generated with a different function name will fail
1555
+ * verification even if the circuits and inputs are correct.
1556
+ *
1557
+ * @param {BatchVerificationOptions} options The batch verification parameters
1558
+ * @returns {boolean} True if the batch proof is valid, false otherwise
1559
+ *
1560
+ * @example
1561
+ * import { verifyBatchProof } from "@provablehq/sdk/mainnet.js";
1562
+ *
1563
+ * const isValid = verifyBatchProof({
1564
+ * verifyingKeys: ["verifier1...", "verifier2..."],
1565
+ * inputs: [[["1field", "2field"]], [["3field"]]],
1566
+ * proof: "proof1...",
1567
+ * });
1568
+ */
1569
+ declare function verifyBatchProof(options: BatchVerificationOptions): boolean;
1570
+ export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions, ExternalSigningOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof };
@@ -96,6 +96,7 @@ export interface RecordScannerOptions {
96
96
  declare class RecordScanner implements RecordProvider {
97
97
  readonly cacheViewKeysOnRegister?: boolean;
98
98
  readonly url: string;
99
+ private readonly baseUrl;
99
100
  private apiKey?;
100
101
  private consumerId?;
101
102
  private jwtData?;
@@ -1 +1 @@
1
- export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
1
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, stringToField, Signature, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
@@ -54,17 +54,19 @@ import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.
54
54
  import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams } from "./keys/provider/memory.js";
55
55
  import { KeyFingerprint, KeyMetadata, KeyVerificationError, KeyVerifier, sha256Hex } from "./keys/verifier/interface.js";
56
56
  import { MemKeyVerifier } from "./keys/verifier/memory.js";
57
- import { InvalidLocatorError, InvalidLocatorReason, KeyLocator, KeyStore } from "./keys/keystore/interface.js";
57
+ import { BaseFunctionKeyLocator, InvalidLocatorError, InvalidLocatorReason, KeyLocator, KeyStore, KeyType, ProvingKeyLocator, TranslationKeyLocator, VerifyingKeyLocator, provingKeyLocator, verifyingKeyLocator, translationKeyLocator } from "./keys/keystore/interface.js";
58
58
  import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline.js";
59
59
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
60
60
  import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
61
61
  import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
62
62
  declare function initializeWasm(): Promise<void>;
63
- export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
63
+ export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof } from "./program-manager.js";
64
64
  export { logAndThrow } from "./utils.js";
65
- export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "./wasm.js";
65
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "./wasm.js";
66
66
  export { initializeWasm };
67
67
  export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
68
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, KeyFingerprint, KeyLocator, KeyMetadata, KeyStore, KeyVerificationError, KeyVerifier, MemKeyVerifier, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, DecryptionNotEnabledError, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationRequest, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
68
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationRequest, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
69
69
  export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
70
70
  export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";
71
+ export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
72
+ export type { FieldLike, GroupLike, ViewKeyLike, SignatureLike, AddressLike, InputID, ExecutionRequestParams, RecordViewKeyStrategy, ViewKeyStrategy, InputIdStrategy, InputStrategy, ExternalSigningInput, ExternalSigningOptions, RequestSignInput, OutputFormat, FieldOutput, } from "./external-signing.js";