@provablehq/sdk 0.10.2-rc.1 → 0.10.2
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.
- package/dist/mainnet/browser.d.ts +2 -3
- package/dist/mainnet/browser.js +279 -826
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/network-client.d.ts +0 -16
- package/dist/mainnet/node.js +2 -2
- package/dist/mainnet/program-manager.d.ts +1 -62
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/testnet/browser.d.ts +2 -3
- package/dist/testnet/browser.js +279 -826
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/network-client.d.ts +0 -16
- package/dist/testnet/node.js +2 -2
- package/dist/testnet/program-manager.d.ts +1 -62
- package/dist/testnet/wasm.d.ts +1 -1
- package/package.json +3 -7
- package/dist/mainnet/keys/keystore/indexeddb.d.ts +0 -49
- package/dist/testnet/keys/keystore/indexeddb.d.ts +0 -49
|
@@ -478,22 +478,6 @@ declare class AleoNetworkClient {
|
|
|
478
478
|
* assert.equal(programVersion, 1);
|
|
479
479
|
*/
|
|
480
480
|
getLatestProgramEdition(programId: string): Promise<number>;
|
|
481
|
-
/**
|
|
482
|
-
* Returns the current edition and amendment count for a program.
|
|
483
|
-
*
|
|
484
|
-
* @param {string} programId - The program ID (e.g. "hello_hello.aleo")
|
|
485
|
-
* @returns {{ program_id: string, edition: number, amendment_count: number }}
|
|
486
|
-
*
|
|
487
|
-
* @example
|
|
488
|
-
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
489
|
-
* const info = await networkClient.getProgramAmendmentCount("hello_hello.aleo");
|
|
490
|
-
* console.log(info.edition, info.amendment_count);
|
|
491
|
-
*/
|
|
492
|
-
getProgramAmendmentCount(programId: string): Promise<{
|
|
493
|
-
program_id: string;
|
|
494
|
-
edition: number;
|
|
495
|
-
amendment_count: number;
|
|
496
|
-
}>;
|
|
497
481
|
/**
|
|
498
482
|
* Returns a program object from a program ID or program source code.
|
|
499
483
|
*
|
package/dist/testnet/node.js
CHANGED
|
@@ -3,9 +3,9 @@ import * as fs from 'node:fs/promises';
|
|
|
3
3
|
import * as $fs from 'node:fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { MemKeyVerifier, InvalidLocatorError } from './browser.js';
|
|
6
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, ChecksumMismatchError, DecryptionNotEnabledError,
|
|
6
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, ChecksumMismatchError, DecryptionNotEnabledError, KEY_STORE, ChecksumMismatchError as KeyVerificationError, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptViewKey, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, provingKeyLocator, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes } from './browser.js';
|
|
7
7
|
import { ProvingKey, VerifyingKey } from '@provablehq/wasm/testnet.js';
|
|
8
|
-
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program,
|
|
8
|
+
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initThreadPool, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
|
|
9
9
|
import 'core-js/proposals/json-parse-with-source.js';
|
|
10
10
|
import 'node:crypto';
|
|
11
11
|
import 'mime/lite';
|
|
@@ -4,7 +4,6 @@ import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
|
|
|
4
4
|
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
|
-
import { KeyStore } from "./keys/keystore/interface.js";
|
|
8
7
|
import { FunctionKeyPair } from "./models/keyPair.js";
|
|
9
8
|
import { Authorization, ExecutionRequest, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
|
|
10
9
|
import { ExternalSigningOptions } from "./models/external-signing.js";
|
|
@@ -121,7 +120,6 @@ interface ExecuteAuthorizationOptions {
|
|
|
121
120
|
offlineQuery?: OfflineQuery;
|
|
122
121
|
program?: string | Program;
|
|
123
122
|
imports?: ProgramImports;
|
|
124
|
-
edition?: number;
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* Represents the options for executing a transaction in the Aleo network.
|
|
@@ -215,14 +213,13 @@ declare class ProgramManager {
|
|
|
215
213
|
networkClient: AleoNetworkClient;
|
|
216
214
|
recordProvider: RecordProvider | undefined;
|
|
217
215
|
inclusionKeysLoaded: boolean;
|
|
218
|
-
private _keyStore;
|
|
219
216
|
/** Create a new instance of the ProgramManager
|
|
220
217
|
*
|
|
221
218
|
* @param { string | undefined } host A host uri running the official Aleo API
|
|
222
219
|
* @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface
|
|
223
220
|
* @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
|
|
224
221
|
*/
|
|
225
|
-
constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined, networkClientOptions?: AleoNetworkClientOptions | undefined
|
|
222
|
+
constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined, networkClientOptions?: AleoNetworkClientOptions | undefined);
|
|
226
223
|
/**
|
|
227
224
|
* Check if the fee is sufficient to pay for the transaction
|
|
228
225
|
*/
|
|
@@ -251,64 +248,6 @@ declare class ProgramManager {
|
|
|
251
248
|
* @param {RecordProvider} recordProvider
|
|
252
249
|
*/
|
|
253
250
|
setRecordProvider(recordProvider: RecordProvider): void;
|
|
254
|
-
/**
|
|
255
|
-
* Set the key store for automatic key caching across executions.
|
|
256
|
-
*
|
|
257
|
-
* @param {KeyStore} keyStore
|
|
258
|
-
*/
|
|
259
|
-
setKeyStore(keyStore: KeyStore): void;
|
|
260
|
-
/**
|
|
261
|
-
* Build a ProgramImportsBuilder from a program and its imports.
|
|
262
|
-
* Fetches imports from the network if not provided, resolves transitive
|
|
263
|
-
* dependencies, and optionally pre-loads cached keys from the KeyStore.
|
|
264
|
-
*
|
|
265
|
-
* @param loadKeys When true (default), loads cached proving/verifying keys
|
|
266
|
-
* from the KeyStore into the builder. Set to false for authorization and
|
|
267
|
-
* proving request paths where keys are not synthesized.
|
|
268
|
-
*/
|
|
269
|
-
private buildProgramImports;
|
|
270
|
-
/**
|
|
271
|
-
* Extract `import program_name.aleo;` names from program source via regex.
|
|
272
|
-
* Avoids a WASM round-trip compared to Program.fromString + getImports.
|
|
273
|
-
*/
|
|
274
|
-
private static getImportNames;
|
|
275
|
-
/**
|
|
276
|
-
* Parse `call program.aleo/function` instructions from program source
|
|
277
|
-
* to determine which functions of each import are actually in the call chain.
|
|
278
|
-
* Returns a map of program name -> set of called function names.
|
|
279
|
-
*/
|
|
280
|
-
private static getCalledFunctions;
|
|
281
|
-
/**
|
|
282
|
-
* Resolve the active KeyStore, preferring the directly-set _keyStore
|
|
283
|
-
* over the KeyProvider's keyStore().
|
|
284
|
-
*/
|
|
285
|
-
private resolveKeyStore;
|
|
286
|
-
/**
|
|
287
|
-
* Resolve the edition and amendment count for a program from the network.
|
|
288
|
-
* Returns `{ edition, amendment }` or falls back to `{ edition: 1, amendment: 0 }`.
|
|
289
|
-
*/
|
|
290
|
-
private resolveEditionAndAmendment;
|
|
291
|
-
/**
|
|
292
|
-
* Load cached proving/verifying keys from the KeyStore into a ProgramImportsBuilder.
|
|
293
|
-
* Only loads keys for the specified functions — returns immediately if
|
|
294
|
-
* functionNames is empty or undefined.
|
|
295
|
-
* Resolves edition and amendment from the network for accurate key locator
|
|
296
|
-
* construction when not explicitly provided.
|
|
297
|
-
*/
|
|
298
|
-
private loadKeysFromStore;
|
|
299
|
-
/**
|
|
300
|
-
* Persist newly synthesized keys from the returned ProgramImportsBuilder
|
|
301
|
-
* into the KeyStore. Only writes keys that are not already in the store,
|
|
302
|
-
* avoiding unnecessary writes of large proving keys.
|
|
303
|
-
* Fetches each program's current edition and amendment count from the network
|
|
304
|
-
* for accurate key locator construction.
|
|
305
|
-
*/
|
|
306
|
-
private persistExtractedKeys;
|
|
307
|
-
/**
|
|
308
|
-
* Resolve top-level function keys, checking the KeyStore first and
|
|
309
|
-
* falling back to the KeyProvider.
|
|
310
|
-
*/
|
|
311
|
-
private resolveTopLevelKeys;
|
|
312
251
|
/**
|
|
313
252
|
* Set a header in the `AleoNetworkClient`s header map
|
|
314
253
|
*
|
package/dist/testnet/wasm.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program,
|
|
1
|
+
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, 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, Signature, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provablehq/sdk",
|
|
3
|
-
"version": "0.10.2
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
|
|
5
5
|
"collaborators": [
|
|
6
6
|
"The Provable Team"
|
|
@@ -11,22 +11,18 @@
|
|
|
11
11
|
"browser": "./dist/testnet/browser.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./dist/testnet/node.d.ts",
|
|
15
14
|
"node": "./dist/testnet/node.js",
|
|
16
15
|
"default": "./dist/testnet/browser.js"
|
|
17
16
|
},
|
|
18
17
|
"./testnet.js": {
|
|
19
|
-
"types": "./dist/testnet/node.d.ts",
|
|
20
18
|
"node": "./dist/testnet/node.js",
|
|
21
19
|
"default": "./dist/testnet/browser.js"
|
|
22
20
|
},
|
|
23
21
|
"./mainnet.js": {
|
|
24
|
-
"types": "./dist/mainnet/node.d.ts",
|
|
25
22
|
"node": "./dist/mainnet/node.js",
|
|
26
23
|
"default": "./dist/mainnet/browser.js"
|
|
27
24
|
},
|
|
28
25
|
"./dynamic.js": {
|
|
29
|
-
"types": "./dist/dynamic/node.d.ts",
|
|
30
26
|
"node": "./dist/dynamic/node.js",
|
|
31
27
|
"default": "./dist/dynamic/browser.js"
|
|
32
28
|
}
|
|
@@ -55,12 +51,12 @@
|
|
|
55
51
|
},
|
|
56
52
|
"homepage": "https://github.com/ProvableHQ/sdk#readme",
|
|
57
53
|
"dependencies": {
|
|
58
|
-
"@provablehq/wasm": "^0.10.2
|
|
54
|
+
"@provablehq/wasm": "^0.10.2",
|
|
59
55
|
"@scure/base": "^2.0.0",
|
|
60
56
|
"comlink": "^4.4.2",
|
|
61
57
|
"core-js": "^3.40.0",
|
|
62
|
-
"mime": "^4.0.6",
|
|
63
58
|
"libsodium-wrappers": "^0.8.2",
|
|
59
|
+
"mime": "^4.0.6",
|
|
64
60
|
"xmlhttprequest-ssl": "^4.0.0"
|
|
65
61
|
},
|
|
66
62
|
"devDependencies": {
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { FunctionKeyPair } from "../../models/keyPair.js";
|
|
2
|
-
import { KeyFingerprint } from "../verifier/interface.js";
|
|
3
|
-
import { KeyLocator, KeyStore, ProvingKeyLocator, VerifyingKeyLocator } from "./interface.js";
|
|
4
|
-
import { ProvingKey, VerifyingKey } from "../../wasm.js";
|
|
5
|
-
/**
|
|
6
|
-
* Browser-compatible {@link KeyStore} backed by IndexedDB.
|
|
7
|
-
*
|
|
8
|
-
* This is the browser counterpart to {@link LocalFileKeyStore} (which requires Node.js `fs`).
|
|
9
|
-
* It persists proving and verifying keys across page reloads and browser sessions using the
|
|
10
|
-
* IndexedDB API available in all modern browsers and Web Workers.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { IndexedDBKeyStore, ProgramManager } from "@provablehq/sdk";
|
|
15
|
-
*
|
|
16
|
-
* const keyStore = new IndexedDBKeyStore();
|
|
17
|
-
* const pm = new ProgramManager();
|
|
18
|
-
* pm.setKeyStore(keyStore);
|
|
19
|
-
* // Keys synthesized during execution are now cached in IndexedDB
|
|
20
|
-
* // and reloaded automatically on subsequent runs.
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class IndexedDBKeyStore implements KeyStore {
|
|
24
|
-
private readonly dbName;
|
|
25
|
-
private readonly storeName;
|
|
26
|
-
private readonly keyVerifier;
|
|
27
|
-
private dbPromise;
|
|
28
|
-
/**
|
|
29
|
-
* @param dbName IndexedDB database name. Defaults to `"aleo-keystore"`.
|
|
30
|
-
*/
|
|
31
|
-
constructor(dbName?: string);
|
|
32
|
-
/** Opens (or creates) the database, returning a cached promise. */
|
|
33
|
-
private openDB;
|
|
34
|
-
/** Runs a single read-write transaction and returns the request result. */
|
|
35
|
-
private tx;
|
|
36
|
-
private validateComponent;
|
|
37
|
-
private validateNonNegative;
|
|
38
|
-
private serializeLocator;
|
|
39
|
-
private checksumToFingerprint;
|
|
40
|
-
getKeyBytes(locator: KeyLocator): Promise<Uint8Array | null>;
|
|
41
|
-
getProvingKey(locator: ProvingKeyLocator): Promise<ProvingKey | null>;
|
|
42
|
-
getVerifyingKey(locator: VerifyingKeyLocator): Promise<VerifyingKey | null>;
|
|
43
|
-
setKeys(proverLocator: ProvingKeyLocator, verifierLocator: VerifyingKeyLocator, keys: FunctionKeyPair): Promise<void>;
|
|
44
|
-
setKeyBytes(keyBytes: Uint8Array, locator: KeyLocator): Promise<void>;
|
|
45
|
-
getKeyMetadata(locator: KeyLocator): Promise<KeyFingerprint | null>;
|
|
46
|
-
has(locator: KeyLocator): Promise<boolean>;
|
|
47
|
-
delete(locator: KeyLocator): Promise<void>;
|
|
48
|
-
clear(): Promise<void>;
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { FunctionKeyPair } from "../../models/keyPair.js";
|
|
2
|
-
import { KeyFingerprint } from "../verifier/interface.js";
|
|
3
|
-
import { KeyLocator, KeyStore, ProvingKeyLocator, VerifyingKeyLocator } from "./interface.js";
|
|
4
|
-
import { ProvingKey, VerifyingKey } from "../../wasm.js";
|
|
5
|
-
/**
|
|
6
|
-
* Browser-compatible {@link KeyStore} backed by IndexedDB.
|
|
7
|
-
*
|
|
8
|
-
* This is the browser counterpart to {@link LocalFileKeyStore} (which requires Node.js `fs`).
|
|
9
|
-
* It persists proving and verifying keys across page reloads and browser sessions using the
|
|
10
|
-
* IndexedDB API available in all modern browsers and Web Workers.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { IndexedDBKeyStore, ProgramManager } from "@provablehq/sdk";
|
|
15
|
-
*
|
|
16
|
-
* const keyStore = new IndexedDBKeyStore();
|
|
17
|
-
* const pm = new ProgramManager();
|
|
18
|
-
* pm.setKeyStore(keyStore);
|
|
19
|
-
* // Keys synthesized during execution are now cached in IndexedDB
|
|
20
|
-
* // and reloaded automatically on subsequent runs.
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class IndexedDBKeyStore implements KeyStore {
|
|
24
|
-
private readonly dbName;
|
|
25
|
-
private readonly storeName;
|
|
26
|
-
private readonly keyVerifier;
|
|
27
|
-
private dbPromise;
|
|
28
|
-
/**
|
|
29
|
-
* @param dbName IndexedDB database name. Defaults to `"aleo-keystore"`.
|
|
30
|
-
*/
|
|
31
|
-
constructor(dbName?: string);
|
|
32
|
-
/** Opens (or creates) the database, returning a cached promise. */
|
|
33
|
-
private openDB;
|
|
34
|
-
/** Runs a single read-write transaction and returns the request result. */
|
|
35
|
-
private tx;
|
|
36
|
-
private validateComponent;
|
|
37
|
-
private validateNonNegative;
|
|
38
|
-
private serializeLocator;
|
|
39
|
-
private checksumToFingerprint;
|
|
40
|
-
getKeyBytes(locator: KeyLocator): Promise<Uint8Array | null>;
|
|
41
|
-
getProvingKey(locator: ProvingKeyLocator): Promise<ProvingKey | null>;
|
|
42
|
-
getVerifyingKey(locator: VerifyingKeyLocator): Promise<VerifyingKey | null>;
|
|
43
|
-
setKeys(proverLocator: ProvingKeyLocator, verifierLocator: VerifyingKeyLocator, keys: FunctionKeyPair): Promise<void>;
|
|
44
|
-
setKeyBytes(keyBytes: Uint8Array, locator: KeyLocator): Promise<void>;
|
|
45
|
-
getKeyMetadata(locator: KeyLocator): Promise<KeyFingerprint | null>;
|
|
46
|
-
has(locator: KeyLocator): Promise<boolean>;
|
|
47
|
-
delete(locator: KeyLocator): Promise<void>;
|
|
48
|
-
clear(): Promise<void>;
|
|
49
|
-
}
|