@provablehq/sdk 0.9.14 → 0.9.16-rc
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 +6 -3
- package/dist/mainnet/browser.js +79 -15
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/keys/keystore/file.d.ts +23 -0
- package/dist/mainnet/keys/keystore/keystore.d.ts +81 -0
- package/dist/mainnet/keys/keystore/memory.d.ts +8 -0
- package/dist/mainnet/{function-key-provider.d.ts → keys/provider/function-key-provider.d.ts} +13 -5
- package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline-key-provider.d.ts} +5 -2
- package/dist/mainnet/models/keyPair.d.ts +4 -0
- package/dist/mainnet/node-polyfill.js +2 -49
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.d.ts +1 -0
- package/dist/mainnet/node.js +129 -2
- package/dist/mainnet/node.js.map +1 -1
- package/dist/mainnet/program-manager.d.ts +2 -1
- package/dist/testnet/browser.d.ts +6 -3
- package/dist/testnet/browser.js +79 -15
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/keys/keystore/file.d.ts +23 -0
- package/dist/testnet/keys/keystore/keystore.d.ts +81 -0
- package/dist/testnet/keys/keystore/memory.d.ts +8 -0
- package/dist/testnet/{function-key-provider.d.ts → keys/provider/function-key-provider.d.ts} +13 -5
- package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline-key-provider.d.ts} +5 -2
- package/dist/testnet/models/keyPair.d.ts +4 -0
- package/dist/testnet/node-polyfill.js +2 -49
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.d.ts +1 -0
- package/dist/testnet/node.js +129 -2
- package/dist/testnet/node.js.map +1 -1
- package/dist/testnet/program-manager.d.ts +2 -1
- package/package.json +3 -4
|
@@ -2,6 +2,7 @@ import "./polyfill/shared.js";
|
|
|
2
2
|
import { Account } from "./account.js";
|
|
3
3
|
import { AleoNetworkClient, ProgramImports } from "./network-client.js";
|
|
4
4
|
import { BlockJSON, Header, Metadata } from "./models/blockJSON.js";
|
|
5
|
+
import { CachedKeyPair, FunctionKeyPair } from "./models/keyPair.js";
|
|
5
6
|
import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
|
|
6
7
|
import { DeploymentJSON, VerifyingKeys } from "./models/deployment/deploymentJSON.js";
|
|
7
8
|
import { DeploymentObject } from "./models/deployment/deploymentObject.js";
|
|
@@ -34,8 +35,10 @@ import { TransactionJSON } from "./models/transaction/transactionJSON.js";
|
|
|
34
35
|
import { TransactionObject } from "./models/transaction/transactionObject.js";
|
|
35
36
|
import { TransitionJSON } from "./models/transition/transitionJSON.js";
|
|
36
37
|
import { TransitionObject } from "./models/transition/transitionObject.js";
|
|
37
|
-
import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams,
|
|
38
|
-
import {
|
|
38
|
+
import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, FunctionKeyProvider, KeySearchParams } from "./keys/provider/function-key-provider";
|
|
39
|
+
import { KeyStore } from "./keys/keystore/keystore";
|
|
40
|
+
import { promoteMapToKeyStore } from "./keys/keystore/memory";
|
|
41
|
+
import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline-key-provider";
|
|
39
42
|
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
|
|
40
43
|
import { RecordScanner } from "./record-scanner.js";
|
|
41
44
|
import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
|
|
@@ -45,4 +48,4 @@ export { logAndThrow } from "./utils.js";
|
|
|
45
48
|
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";
|
|
46
49
|
export { initializeWasm };
|
|
47
50
|
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";
|
|
48
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordSearchParams, SealanceMerkleTree, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
|
|
51
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeyStore, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, promoteMapToKeyStore, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordSearchParams, SealanceMerkleTree, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
|
package/dist/mainnet/browser.js
CHANGED
|
@@ -602,7 +602,7 @@ class AleoNetworkClient {
|
|
|
602
602
|
else {
|
|
603
603
|
this.headers = {
|
|
604
604
|
// This is replaced by the actual version by a Rollup plugin
|
|
605
|
-
"X-Aleo-SDK-Version": "0.9.
|
|
605
|
+
"X-Aleo-SDK-Version": "0.9.16-rc",
|
|
606
606
|
"X-Aleo-environment": environment(),
|
|
607
607
|
};
|
|
608
608
|
}
|
|
@@ -2102,6 +2102,48 @@ class AleoNetworkClient {
|
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
|
+
/**
|
|
2106
|
+
* @param {Map<string, CachedKeyPair>} map Any interface which returns a string as cached keypair bytes.
|
|
2107
|
+
*
|
|
2108
|
+
* @returns {KeyStore} The map decorated as a keystore.
|
|
2109
|
+
*/
|
|
2110
|
+
function promoteMapToKeyStore(map) {
|
|
2111
|
+
const ks = map;
|
|
2112
|
+
ks.getKeys = async (locator) => {
|
|
2113
|
+
const raw = map.get(locator);
|
|
2114
|
+
if (!raw)
|
|
2115
|
+
return null;
|
|
2116
|
+
const [p, v] = raw;
|
|
2117
|
+
return [
|
|
2118
|
+
ProvingKey.fromBytes(p),
|
|
2119
|
+
VerifyingKey.fromBytes(v),
|
|
2120
|
+
];
|
|
2121
|
+
};
|
|
2122
|
+
ks.getKeyBytes = async (locator) => map.get(locator) ?? null;
|
|
2123
|
+
ks.getProvingKey = async (locator) => {
|
|
2124
|
+
const raw = map.get(locator);
|
|
2125
|
+
return raw ? ProvingKey.fromBytes(raw[0]) : null;
|
|
2126
|
+
};
|
|
2127
|
+
ks.getProvingKeyBytes = async (locator) => map.get(locator)?.[0] ?? null;
|
|
2128
|
+
ks.getVerifyingKey = async (locator) => {
|
|
2129
|
+
const raw = map.get(locator);
|
|
2130
|
+
return raw ? VerifyingKey.fromBytes(raw[1]) : null;
|
|
2131
|
+
};
|
|
2132
|
+
ks.getVerifyingKeyBytes = async (locator) => map.get(locator)?.[1] ?? null;
|
|
2133
|
+
ks.setKeys = async (locator, [pk, vk]) => {
|
|
2134
|
+
map.set(locator, [pk.toBytes(), vk.toBytes()]);
|
|
2135
|
+
};
|
|
2136
|
+
ks.setKeyBytes = async (locator, raw) => {
|
|
2137
|
+
map.set(locator, raw);
|
|
2138
|
+
};
|
|
2139
|
+
ks.has = async (locator) => Map.prototype.has.call(map, locator);
|
|
2140
|
+
ks.delete = async (locator) => {
|
|
2141
|
+
Map.prototype.delete.call(map, locator);
|
|
2142
|
+
};
|
|
2143
|
+
ks.clear = async () => Map.prototype.clear.call(map);
|
|
2144
|
+
return ks;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2105
2147
|
/**
|
|
2106
2148
|
* AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and
|
|
2107
2149
|
* verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
|
|
@@ -2150,6 +2192,11 @@ class AleoKeyProvider {
|
|
|
2150
2192
|
this.cache = new Map();
|
|
2151
2193
|
this.cacheOption = false;
|
|
2152
2194
|
}
|
|
2195
|
+
keyStore() {
|
|
2196
|
+
if (!this.cacheOption)
|
|
2197
|
+
return Promise.resolve(undefined);
|
|
2198
|
+
return Promise.resolve(promoteMapToKeyStore(this.cache));
|
|
2199
|
+
}
|
|
2153
2200
|
/**
|
|
2154
2201
|
* Use local memory to store keys
|
|
2155
2202
|
*
|
|
@@ -2202,8 +2249,11 @@ class AleoKeyProvider {
|
|
|
2202
2249
|
getKeys(keyId) {
|
|
2203
2250
|
console.debug(`Checking if key exists in cache. KeyId: ${keyId}`);
|
|
2204
2251
|
if (this.cache.has(keyId)) {
|
|
2205
|
-
const [provingKeyBytes, verifyingKeyBytes] = this.cache.get(keyId);
|
|
2206
|
-
return [
|
|
2252
|
+
const [provingKeyBytes, verifyingKeyBytes] = (this.cache.get(keyId));
|
|
2253
|
+
return [
|
|
2254
|
+
ProvingKey.fromBytes(provingKeyBytes),
|
|
2255
|
+
VerifyingKey.fromBytes(verifyingKeyBytes),
|
|
2256
|
+
];
|
|
2207
2257
|
}
|
|
2208
2258
|
else {
|
|
2209
2259
|
throw new Error("Key not found in cache.");
|
|
@@ -2238,10 +2288,12 @@ class AleoKeyProvider {
|
|
|
2238
2288
|
let key = CREDITS_PROGRAM_KEYS.getKey(params["name"]);
|
|
2239
2289
|
return this.fetchCreditsKeys(key);
|
|
2240
2290
|
}
|
|
2241
|
-
if ("proverUri" in params &&
|
|
2291
|
+
if ("proverUri" in params &&
|
|
2292
|
+
typeof params["proverUri"] == "string") {
|
|
2242
2293
|
proverUrl = params["proverUri"];
|
|
2243
2294
|
}
|
|
2244
|
-
if ("verifierUri" in params &&
|
|
2295
|
+
if ("verifierUri" in params &&
|
|
2296
|
+
typeof params["verifierUri"] == "string") {
|
|
2245
2297
|
verifierUrl = params["verifierUri"];
|
|
2246
2298
|
}
|
|
2247
2299
|
if ("cacheKey" in params && typeof params["cacheKey"] == "string") {
|
|
@@ -2290,20 +2342,26 @@ class AleoKeyProvider {
|
|
|
2290
2342
|
}
|
|
2291
2343
|
const value = this.cache.get(cacheKey);
|
|
2292
2344
|
if (typeof value !== "undefined") {
|
|
2293
|
-
return [
|
|
2345
|
+
return [
|
|
2346
|
+
ProvingKey.fromBytes(value[0]),
|
|
2347
|
+
VerifyingKey.fromBytes(value[1]),
|
|
2348
|
+
];
|
|
2294
2349
|
}
|
|
2295
2350
|
else {
|
|
2296
2351
|
console.debug("Fetching proving keys from url " + proverUrl);
|
|
2297
|
-
const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
|
|
2352
|
+
const provingKey = (ProvingKey.fromBytes(await this.fetchBytes(proverUrl)));
|
|
2298
2353
|
console.debug("Fetching verifying keys " + verifierUrl);
|
|
2299
2354
|
const verifyingKey = (await this.getVerifyingKey(verifierUrl));
|
|
2300
|
-
this.cache.set(cacheKey, [
|
|
2355
|
+
this.cache.set(cacheKey, [
|
|
2356
|
+
provingKey.toBytes(),
|
|
2357
|
+
verifyingKey.toBytes(),
|
|
2358
|
+
]);
|
|
2301
2359
|
return [provingKey, verifyingKey];
|
|
2302
2360
|
}
|
|
2303
2361
|
}
|
|
2304
2362
|
else {
|
|
2305
2363
|
// If cache is disabled, fetch the keys and return them
|
|
2306
|
-
const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
|
|
2364
|
+
const provingKey = (ProvingKey.fromBytes(await this.fetchBytes(proverUrl)));
|
|
2307
2365
|
const verifyingKey = (await this.getVerifyingKey(verifierUrl));
|
|
2308
2366
|
return [provingKey, verifyingKey];
|
|
2309
2367
|
}
|
|
@@ -2333,12 +2391,12 @@ class AleoKeyProvider {
|
|
|
2333
2391
|
}
|
|
2334
2392
|
else {
|
|
2335
2393
|
console.debug("Fetching proving keys from url " + proverUrl);
|
|
2336
|
-
const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
|
|
2394
|
+
const provingKey = (ProvingKey.fromBytes(await this.fetchBytes(proverUrl)));
|
|
2337
2395
|
return provingKey;
|
|
2338
2396
|
}
|
|
2339
2397
|
}
|
|
2340
2398
|
else {
|
|
2341
|
-
const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
|
|
2399
|
+
const provingKey = (ProvingKey.fromBytes(await this.fetchBytes(proverUrl)));
|
|
2342
2400
|
return provingKey;
|
|
2343
2401
|
}
|
|
2344
2402
|
}
|
|
@@ -2350,7 +2408,7 @@ class AleoKeyProvider {
|
|
|
2350
2408
|
try {
|
|
2351
2409
|
if (!this.cache.has(key.locator) || !this.cacheOption) {
|
|
2352
2410
|
const verifying_key = key.verifyingKey();
|
|
2353
|
-
const proving_key = await this.fetchProvingKey(key.prover, key.locator);
|
|
2411
|
+
const proving_key = (await this.fetchProvingKey(key.prover, key.locator));
|
|
2354
2412
|
if (this.cacheOption) {
|
|
2355
2413
|
this.cache.set(CREDITS_PROGRAM_KEYS.getKey(key.name).locator, [proving_key.toBytes(), verifying_key.toBytes()]);
|
|
2356
2414
|
}
|
|
@@ -2358,7 +2416,10 @@ class AleoKeyProvider {
|
|
|
2358
2416
|
}
|
|
2359
2417
|
else {
|
|
2360
2418
|
const keyPair = this.cache.get(key.locator);
|
|
2361
|
-
return [
|
|
2419
|
+
return [
|
|
2420
|
+
ProvingKey.fromBytes(keyPair[0]),
|
|
2421
|
+
VerifyingKey.fromBytes(keyPair[1]),
|
|
2422
|
+
];
|
|
2362
2423
|
}
|
|
2363
2424
|
}
|
|
2364
2425
|
catch (error) {
|
|
@@ -2508,7 +2569,7 @@ class AleoKeyProvider {
|
|
|
2508
2569
|
catch (e) {
|
|
2509
2570
|
/// If that fails, try to fetch the verifying key from the network as bytes
|
|
2510
2571
|
try {
|
|
2511
|
-
return VerifyingKey.fromBytes(await this.fetchBytes(verifierUri));
|
|
2572
|
+
return (VerifyingKey.fromBytes(await this.fetchBytes(verifierUri)));
|
|
2512
2573
|
}
|
|
2513
2574
|
catch (inner) {
|
|
2514
2575
|
throw new Error("Invalid verifying key. Error: " + inner.message);
|
|
@@ -2694,6 +2755,9 @@ class OfflineKeyProvider {
|
|
|
2694
2755
|
constructor() {
|
|
2695
2756
|
this.cache = new Map();
|
|
2696
2757
|
}
|
|
2758
|
+
keyStore() {
|
|
2759
|
+
return Promise.resolve(promoteMapToKeyStore(this.cache));
|
|
2760
|
+
}
|
|
2697
2761
|
/**
|
|
2698
2762
|
* Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
|
|
2699
2763
|
* method for it to work.
|
|
@@ -6623,5 +6687,5 @@ async function initializeWasm() {
|
|
|
6623
6687
|
console.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
6624
6688
|
}
|
|
6625
6689
|
|
|
6626
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, 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, RecordScanner, SealanceMerkleTree, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow };
|
|
6690
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, 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, RecordScanner, SealanceMerkleTree, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow, promoteMapToKeyStore };
|
|
6627
6691
|
//# sourceMappingURL=browser.js.map
|