Skip to content

Commit 893eec7

Browse files
Merge branch 'update/testnet-v4.0.0' into feat/proving-requests
2 parents fe14482 + a63418e commit 893eec7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1230
-486
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ version: 2.1
22

33

44
orbs:
5-
node: circleci/node@7.0.0
5+
node: circleci/node@7.1.0
66

77

88
executors:
99
rust-node:
1010
docker:
11-
- image: cimg/rust:1.80-node
11+
- image: cimg/rust:1.88-node
1212

1313

1414
commands:

create-leo-app/template-node-ts/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
5252
console.log("hello_hello/hello executed - result:", executionResponse.getOutputs());
5353

5454
// Verify the execution using the verifying key that was generated earlier.
55-
if (programManager.verifyExecution(executionResponse)) {
55+
if (programManager.verifyExecution(executionResponse, 9_000_000)) {
5656
console.log("hello_hello/hello execution verified!");
5757
} else {
5858
throw("Execution failed verification!");

create-leo-app/template-node/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
4646
console.log("hello_hello/hello executed - result:", executionResponse.getOutputs());
4747

4848
// Verify the execution using the verifying key that was generated earlier.
49-
if (programManager.verifyExecution(executionResponse)) {
49+
if (programManager.verifyExecution(executionResponse, 9_000_000)) {
5050
console.log("hello_hello/hello execution verified!");
5151
} else {
5252
throw("Execution failed verification!");

docs/api_reference/sdk-src_program-manager.md

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,44 @@ const authorization = await programManager.buildAuthorization({
311311

312312
---
313313

314+
### `buildAuthorizationUnchecked(options) ► Promise.<Authorization>`
315+
316+
![modifier: public](images/badges/modifier-public.svg)
317+
318+
Builds a SnarkVM &#x60;Authorization&#x60; for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.
319+
320+
Parameters | Type | Description
321+
--- | --- | ---
322+
__options__ | `AuthorizationOptions` | *The options for building the &#x60;Authorization&#x60;*
323+
__*return*__ | `Promise.<Authorization>` | *- A promise that resolves to an &#x60;Authorization&#x60; or throws an Error.*
324+
325+
#### Examples
326+
327+
```javascript
328+
/// Import the mainnet version of the sdk.
329+
import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
330+
331+
// Create a new NetworkClient, KeyProvider, and RecordProvider.
332+
const keyProvider = new AleoKeyProvider();
333+
const recordProvider = new NetworkRecordProvider(account, networkClient);
334+
keyProvider.useCache = true;
335+
336+
// Initialize a ProgramManager with the key and record providers.
337+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
338+
339+
// Build the unchecked `Authorization`.
340+
const authorization = await programManager.buildAuthorizationUnchecked({
341+
programName: "credits.aleo",
342+
functionName: "transfer_public",
343+
inputs: [
344+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
345+
"10000000u64",
346+
],
347+
});
348+
```
349+
350+
---
351+
314352
### `buildFeeAuthorization(options) ► Promise.<Authorization>`
315353

316354
![modifier: public](images/badges/modifier-public.svg)
@@ -1129,7 +1167,7 @@ setTimeout(async () => {
11291167

11301168
---
11311169

1132-
### `verifyExecution(executionResponse, imports, importedVerifyingKeys) ► boolean`
1170+
### `verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys) ► boolean`
11331171

11341172
![modifier: public](images/badges/modifier-public.svg)
11351173

@@ -1138,6 +1176,7 @@ Verify a proof from an offline execution. This is useful when it is desired to d
11381176
Parameters | Type | Description
11391177
--- | --- | ---
11401178
__executionResponse__ | `executionResponse` | *The response from an offline function execution (via the &#x60;programManager.run&#x60; method)*
1179+
__blockHeight__ | `blockHeight` | *The ledger height when the execution was generated.*
11411180
__imports__ | `ImportedPrograms` | *The imported programs used in the execution. Specified as { &quot;programName&quot;: &quot;programSourceCode&quot;, ... }*
11421181
__importedVerifyingKeys__ | `ImportedVerifyingKeys` | *The verifying keys in the execution. Specified as { &quot;programName&quot;: [[&quot;functionName&quot;, &quot;verifyingKey&quot;], ...], ... }*
11431182
__*return*__ | `boolean` | *True if the proof is valid, false otherwise*
@@ -1165,7 +1204,8 @@ const imports = { "add_it_up.aleo": program_import };
11651204
const importedVerifyingKeys = { "add_it_up.aleo": [["add_it", "verifyingKey1..."]] };
11661205

11671206
/// Verify the execution.
1168-
const isValid = programManager.verifyExecution(executionResponse, imports, importedVerifyingKeys);
1207+
const blockHeight = 9000000;
1208+
const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);
11691209
assert(isValid);
11701210
```
11711211

@@ -1497,6 +1537,44 @@ const authorization = await programManager.buildAuthorization({
14971537

14981538
---
14991539

1540+
### `buildAuthorizationUnchecked(options) ► Promise.<Authorization>`
1541+
1542+
![modifier: public](images/badges/modifier-public.svg)
1543+
1544+
Builds a SnarkVM &#x60;Authorization&#x60; for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.
1545+
1546+
Parameters | Type | Description
1547+
--- | --- | ---
1548+
__options__ | `AuthorizationOptions` | *The options for building the &#x60;Authorization&#x60;*
1549+
__*return*__ | `Promise.<Authorization>` | *- A promise that resolves to an &#x60;Authorization&#x60; or throws an Error.*
1550+
1551+
#### Examples
1552+
1553+
```javascript
1554+
/// Import the mainnet version of the sdk.
1555+
import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
1556+
1557+
// Create a new NetworkClient, KeyProvider, and RecordProvider.
1558+
const keyProvider = new AleoKeyProvider();
1559+
const recordProvider = new NetworkRecordProvider(account, networkClient);
1560+
keyProvider.useCache = true;
1561+
1562+
// Initialize a ProgramManager with the key and record providers.
1563+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
1564+
1565+
// Build the unchecked `Authorization`.
1566+
const authorization = await programManager.buildAuthorizationUnchecked({
1567+
programName: "credits.aleo",
1568+
functionName: "transfer_public",
1569+
inputs: [
1570+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
1571+
"10000000u64",
1572+
],
1573+
});
1574+
```
1575+
1576+
---
1577+
15001578
### `buildFeeAuthorization(options) ► Promise.<Authorization>`
15011579

15021580
![modifier: public](images/badges/modifier-public.svg)
@@ -2315,7 +2393,7 @@ setTimeout(async () => {
23152393

23162394
---
23172395

2318-
### `verifyExecution(executionResponse, imports, importedVerifyingKeys) ► boolean`
2396+
### `verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys) ► boolean`
23192397

23202398
![modifier: public](images/badges/modifier-public.svg)
23212399

@@ -2324,6 +2402,7 @@ Verify a proof from an offline execution. This is useful when it is desired to d
23242402
Parameters | Type | Description
23252403
--- | --- | ---
23262404
__executionResponse__ | `executionResponse` | *The response from an offline function execution (via the &#x60;programManager.run&#x60; method)*
2405+
__blockHeight__ | `blockHeight` | *The ledger height when the execution was generated.*
23272406
__imports__ | `ImportedPrograms` | *The imported programs used in the execution. Specified as { &quot;programName&quot;: &quot;programSourceCode&quot;, ... }*
23282407
__importedVerifyingKeys__ | `ImportedVerifyingKeys` | *The verifying keys in the execution. Specified as { &quot;programName&quot;: [[&quot;functionName&quot;, &quot;verifyingKey&quot;], ...], ... }*
23292408
__*return*__ | `boolean` | *True if the proof is valid, false otherwise*
@@ -2351,7 +2430,8 @@ const imports = { "add_it_up.aleo": program_import };
23512430
const importedVerifyingKeys = { "add_it_up.aleo": [["add_it", "verifyingKey1..."]] };
23522431

23532432
/// Verify the execution.
2354-
const isValid = programManager.verifyExecution(executionResponse, imports, importedVerifyingKeys);
2433+
const blockHeight = 9000000;
2434+
const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);
23552435
assert(isValid);
23562436
```
23572437

docs/api_reference/sdk-src_wasm.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ __*return*__ | `string` | *Nonce of the record*
27762776
27772777
---
27782778
2779-
### `serialNumberString(private_key, program_id, record_name) ► string`
2779+
### `serialNumberString(private_key, program_id, record_name, record_view_key) ► string`
27802780
27812781
![modifier: public](images/badges/modifier-public.svg)
27822782
@@ -2787,6 +2787,7 @@ Parameters | Type | Description
27872787
__private_key__ | [PrivateKey](sdk-src_wasm.md) | *Private key of the account that owns the record*
27882788
__program_id__ | `string` | *Program ID of the program that the record is associated with*
27892789
__record_name__ | `string` | *Name of the record*
2790+
__record_view_key__ | `string` | *The string representation of the record view key.*
27902791
__*return*__ | `string` | *Serial number of the record*
27912792
27922793
---
@@ -2805,6 +2806,20 @@ __*return*__ | [Field](sdk-src_wasm.md) | **
28052806
28062807
---
28072808
2809+
### `recordViewKey(view_key) ► Group`
2810+
2811+
![modifier: public](images/badges/modifier-public.svg)
2812+
2813+
Generate the record view key. The record view key can only decrypt record if the
2814+
supplied view key belongs to the record owner.
2815+
2816+
Parameters | Type | Description
2817+
--- | --- | ---
2818+
__view_key__ | `ViewKey` | *View key used to generate the record view key*
2819+
__*return*__ | [Group](sdk-src_wasm.md) | *record view key*
2820+
2821+
---
2822+
28082823
# Class `Scalar`
28092824
28102825
Scalar field element.

e2e/mainnet/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
4646
console.log("hello_hello/hello executed - result:", executionResponse.getOutputs());
4747

4848
// Verify the execution using the verifying key that was generated earlier.
49-
if (programManager.verifyExecution(executionResponse)) {
49+
const blockHeight = 9_000_000;
50+
if (programManager.verifyExecution(executionResponse, blockHeight)) {
5051
console.log("hello_hello/hello execution verified!");
5152
} else {
5253
throw("Execution failed verification!");

e2e/testnet/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
4646
console.log("hello_hello/hello executed - result:", executionResponse.getOutputs());
4747

4848
// Verify the execution using the verifying key that was generated earlier.
49-
if (programManager.verifyExecution(executionResponse)) {
49+
if (programManager.verifyExecution(executionResponse, 9_000_000)) {
5050
console.log("hello_hello/hello execution verified!");
5151
} else {
5252
throw("Execution failed verification!");

sdk/rollup.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export default networks.map((network) => {
1212
input: {
1313
"node-polyfill": "./src/node-polyfill.ts",
1414
"browser": "./src/browser.ts",
15-
"worker": "./src/worker.ts",
1615
"node": "./src/node.ts",
1716
},
1817
output: {

sdk/src/browser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ async function initializeWasm() {
5353
console.warn("initializeWasm is deprecated, you no longer need to use it");
5454
}
5555

56-
export { createAleoWorker } from "./managed-worker.js";
57-
5856
export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
5957

6058
export { logAndThrow } from "./utils.js";

sdk/src/managed-worker.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)