Skip to content

Commit 36df1dd

Browse files
Merge branch 'mainnet' into update/testnet-v4.0.0
Signed-off-by: Mike Turner <[email protected]>
2 parents 5efcf0f + e394899 commit 36df1dd

File tree

15 files changed

+394
-44
lines changed

15 files changed

+394
-44
lines changed

docs/api_reference/sdk-src_wasm.md

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,12 @@ Decrypt a ciphertext using the view key of the transition signer, transition pub
424424

425425
Parameters | Type | Description
426426
--- | --- | ---
427-
__view_key__ | `ViewKey` | **
428-
__transition_public_key__ | [Group](sdk-src_wasm.md) | **
429-
__program__ | `string` | **
430-
__function_name__ | `string` | **
431-
__index__ | `number` | **
432-
__*return*__ | [Plaintext](sdk-src_wasm.md) | **
427+
__view_key__ | `ViewKey` | *The view key of the transition signer.*
428+
__transition_public_key__ | [Group](sdk-src_wasm.md) | *The transition public key used to encrypt the ciphertext.*
429+
__program__ | `string` | *The program ID associated with the ciphertext.*
430+
__function_name__ | `string` | *The name of the function associated with the encrypted inputs and outputs.*
431+
__index__ | `u16` | *The index of the input or output parameter that was encrypted.*
432+
__*return*__ | [Plaintext](sdk-src_wasm.md) | *The decrypted plaintext.*
433433

434434
---
435435

@@ -441,11 +441,11 @@ Decrypt a ciphertext using the transition view key and a (program, function, ind
441441

442442
Parameters | Type | Description
443443
--- | --- | ---
444-
__transition_view_key__ | [Field](sdk-src_wasm.md) | **
445-
__program__ | `string` | **
446-
__function_name__ | `string` | **
447-
__index__ | `number` | **
448-
__*return*__ | [Plaintext](sdk-src_wasm.md) | **
444+
__transition_view_key__ | [Field](sdk-src_wasm.md) | *The transition view key that was used to encrypt the ciphertext.*
445+
__program__ | `string` | *The program ID associated with the ciphertext.*
446+
__function_name__ | `string` | *The name of the function associated with the encrypted inputs and outputs.*
447+
__index__ | `u16` | *The index of the input or output parameter that was encrypted.*
448+
__*return*__ | [Plaintext](sdk-src_wasm.md) | *The decrypted plaintext.*
449449

450450
---
451451

@@ -1280,8 +1280,9 @@ Creates a new offline query object. The state root is required to be passed in a
12801280

12811281
Parameters | Type | Description
12821282
--- | --- | ---
1283-
__block_height__ | `number` | **
1284-
__state_root__ | `string` | **
1283+
__block_height__ | `u32` | *The block height.*
1284+
__state_root__ | `string` | *The state root of the current network.*
1285+
__*return*__ | [OfflineQuery](sdk-src_wasm.md) | *The newly created offline query object.*
12851286

12861287
---
12871288

@@ -1295,7 +1296,7 @@ Add a new block height to the offline query object.
12951296

12961297
Parameters | Type | Description
12971298
--- | --- | ---
1298-
__block_height__ | `number` | **
1299+
__block_height__ | `u32` | *The block height to add.*
12991300
__*return*__ | `void` | **
13001301

13011302
---
@@ -1308,8 +1309,8 @@ Add a new state path to the offline query object.
13081309

13091310
Parameters | Type | Description
13101311
--- | --- | ---
1311-
__commitment:__ | `string` | *The commitment corresponding to a record inpout*
1312-
__state_path:__ | `string` | *The state path corresponding to the commitment*
1312+
__commitment:__ | `string` | *The commitment corresponding to a record input.*
1313+
__state_path:__ | `string` | *The state path corresponding to the commitment.*
13131314
__*return*__ | `void` | **
13141315

13151316
---
@@ -1318,23 +1319,23 @@ __*return*__ | `void` | **
13181319

13191320
![modifier: public](images/badges/modifier-public.svg)
13201321

1321-
Get a json string representation of the offline query object
1322+
Get a json string representation of the offline query object.
13221323

13231324
Parameters | Type | Description
13241325
--- | --- | ---
1325-
__*return*__ | `string` | **
1326+
__*return*__ | `string` | *JSON string representation of the offline query object.*
13261327

13271328
---
13281329

1329-
### `fromString(s) ► OfflineQuery`
1330+
### `fromString(JSON) ► OfflineQuery`
13301331

13311332
![modifier: public](images/badges/modifier-public.svg) ![modifier: static](images/badges/modifier-static.svg)
13321333

1333-
Create an offline query object from a json string representation
1334+
Create an offline query object from a json string representation.
13341335

13351336
Parameters | Type | Description
13361337
--- | --- | ---
1337-
__s__ | `string` | **
1338+
__JSON__ | `string` | *string representation of the offline query object.*
13381339
__*return*__ | [OfflineQuery](sdk-src_wasm.md) | **
13391340

13401341
---
@@ -1387,9 +1388,9 @@ Encrypt a plaintext with an address and randomizer.
13871388
13881389
Parameters | Type | Description
13891390
--- | --- | ---
1390-
__address__ | [Address](sdk-src_wasm.md) | **
1391-
__randomizer__ | [Scalar](sdk-src_wasm.md) | **
1392-
__*return*__ | [Ciphertext](sdk-src_wasm.md) | **
1391+
__address__ | [Address](sdk-src_wasm.md) | *The address to encrypt the plaintext for.*
1392+
__randomizer__ | [Scalar](sdk-src_wasm.md) | *The randomizer to use for encryption.*
1393+
__*return*__ | [Ciphertext](sdk-src_wasm.md) | *The encrypted ciphertext.*
13931394
13941395
---
13951396
@@ -1401,8 +1402,9 @@ Encrypt a plaintext with a transition view key.
14011402
14021403
Parameters | Type | Description
14031404
--- | --- | ---
1404-
__transition_view_key__ | [Field](sdk-src_wasm.md) | **
1405-
__*return*__ | [Ciphertext](sdk-src_wasm.md) | **
1405+
__transition_view_key__ | [Field](sdk-src_wasm.md) | *The transition view key of the transition
1406+
associated with the plaintext.*
1407+
__*return*__ | [Ciphertext](sdk-src_wasm.md) | *The encrypted ciphertext.*
14061408
14071409
---
14081410
@@ -1440,7 +1442,7 @@ Get the left endian byte array representation of the plaintext.
14401442
14411443
Parameters | Type | Description
14421444
--- | --- | ---
1443-
__*return*__ | `Uint8Array` | **
1445+
__*return*__ | `Uint8Array` | *The left endian byte array representation of the plaintext.*
14441446
14451447
---
14461448
@@ -1457,15 +1459,15 @@ __*return*__ | [Plaintext](sdk-src_wasm.md) | *The plaintext object.*
14571459
14581460
---
14591461
1460-
### `toBitsLe() ► Array.<any>`
1462+
### `toBitsLe() ► Array`
14611463
14621464
![modifier: public](images/badges/modifier-public.svg)
14631465
14641466
Get the left endian boolean array representation of the bits of the plaintext.
14651467
14661468
Parameters | Type | Description
14671469
--- | --- | ---
1468-
__*return*__ | `Array.<any>` | **
1470+
__*return*__ | `Array` | *The left endian boolean array representation of the bits of the plaintext.*
14691471
14701472
---
14711473
@@ -1482,15 +1484,15 @@ __*return*__ | [Plaintext](sdk-src_wasm.md) | *The plaintext object.*
14821484
14831485
---
14841486
1485-
### `toFields() ► Array.<any>`
1487+
### `toFields() ► Array`
14861488
14871489
![modifier: public](images/badges/modifier-public.svg)
14881490
14891491
Get the field array representation of the plaintext.
14901492
14911493
Parameters | Type | Description
14921494
--- | --- | ---
1493-
__*return*__ | `Array.<any>` | **
1495+
__*return*__ | `Array` | *The field array representation of the plaintext.*
14941496
14951497
---
14961498
@@ -2529,7 +2531,7 @@ Get the left endian byte array representation of the record ciphertext.
25292531
25302532
Parameters | Type | Description
25312533
--- | --- | ---
2532-
__*return*__ | `Uint8Array` | **
2534+
__*return*__ | `Uint8Array` | *Left endian byte array representation of the record ciphertext.*
25332535
25342536
---
25352537
@@ -2539,21 +2541,23 @@ __*return*__ | `Uint8Array` | **
25392541
25402542
Get the left endian boolean array representation of the record ciphertext bits.
25412543
2544+
returns {Array} Left endian boolean array representation of the bits of the record ciphertext.
2545+
25422546
Parameters | Type | Description
25432547
--- | --- | ---
25442548
__*return*__ | `Array.<any>` | **
25452549
25462550
---
25472551
2548-
### `toFields() ► Array.<any>`
2552+
### `toFields() ► Array`
25492553
25502554
![modifier: public](images/badges/modifier-public.svg)
25512555
25522556
Get the field array representation of the record ciphertext.
25532557
25542558
Parameters | Type | Description
25552559
--- | --- | ---
2556-
__*return*__ | `Array.<any>` | **
2560+
__*return*__ | `Array` | *Field array representation of the record ciphertext.*
25572561
25582562
---
25592563
@@ -2578,7 +2582,7 @@ Get the record nonce.
25782582
25792583
Parameters | Type | Description
25802584
--- | --- | ---
2581-
__*return*__ | [Group](sdk-src_wasm.md) | **
2585+
__*return*__ | [Group](sdk-src_wasm.md) | *The record nonce.*
25822586
25832587
---
25842588
@@ -2596,11 +2600,24 @@ Return a record plaintext from a string.
25962600
25972601
Parameters | Type | Description
25982602
--- | --- | ---
2599-
__record__ | `string` | *String representation of a plaintext representation of an Aleo record*
2603+
__record__ | `string` | *String representation of a plaintext representation of an Aleo record.*
26002604
__*return*__ | [RecordPlaintext](sdk-src_wasm.md) | *Record plaintext*
26012605
26022606
---
26032607
2608+
### `getMember(input) ► Plaintext`
2609+
2610+
![modifier: public](images/badges/modifier-public.svg)
2611+
2612+
Get the record entry matching a key.
2613+
2614+
Parameters | Type | Description
2615+
--- | --- | ---
2616+
__input__ | `string` | *The key to retrieve the value in the record data field.*
2617+
__*return*__ | [Plaintext](sdk-src_wasm.md) | *The plaintext value corresponding to the key.*
2618+
2619+
---
2620+
26042621
### `owner() ► Address`
26052622
26062623
![modifier: public](images/badges/modifier-public.svg)
@@ -2609,7 +2626,7 @@ Get the owner of the record.
26092626
26102627
Parameters | Type | Description
26112628
--- | --- | ---
2612-
__*return*__ | [Address](sdk-src_wasm.md) | **
2629+
__*return*__ | [Address](sdk-src_wasm.md) | *Address of the owner of the record.*
26132630
26142631
---
26152632

sdk/src/browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export { logAndThrow } from "./utils.js";
5858
export {
5959
Address,
6060
Authorization,
61+
Boolean,
6162
BHP256,
6263
BHP512,
6364
BHP768,

sdk/src/wasm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export {
22
Address,
33
Authorization,
4+
Boolean,
45
BHP256,
56
BHP512,
67
BHP768,

sdk/tests/arithmetic.test.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sinon from "sinon";
22
import { expect } from "chai";
3-
import { Field, Scalar, Group} from "../src/node.js";
3+
import { Field, Scalar, Group, Boolean} from "../src/node.js";
44
import { FieldGenerator, GroupGenerator, ScalarGenerator } from "./data/algebra.js";
55

66
describe('Field and Group Arithmetic Tests', () => {
@@ -44,6 +44,58 @@ describe('Field and Group Arithmetic Tests', () => {
4444
expect(two_power_four.equals(two_times_eight)).equal(true);
4545
});
4646

47+
it('Check boolean creation and serialization', () => {
48+
const t = Boolean.fromString("true");
49+
const f = Boolean.fromString("false");
50+
51+
expect(t.toString()).equals("true");
52+
expect(f.toString()).equals("false");
53+
54+
const tBytes = t.toBytesLe();
55+
const fBytes = f.toBytesLe();
56+
57+
const tFromBytes = Boolean.fromBytesLe(tBytes);
58+
const fFromBytes = Boolean.fromBytesLe(fBytes);
59+
60+
expect(t.equals(tFromBytes)).equals(true);
61+
expect(f.equals(fFromBytes)).equals(true);
62+
63+
const tBits = t.toBitsLe();
64+
const fBits = f.toBitsLe();
65+
66+
const tFromBits = Boolean.fromBitsLe(tBits);
67+
const fFromBits = Boolean.fromBitsLe(fBits);
68+
69+
expect(t.equals(tFromBits)).equals(true);
70+
expect(f.equals(fFromBits)).equals(true);
71+
});
72+
73+
it('Check boolean logical operations', () => {
74+
const t = new Boolean(true);
75+
const f = new Boolean(false);
76+
77+
expect(t.not().toString()).equals("false");
78+
expect(f.not().toString()).equals("true");
79+
80+
expect(t.and(t).toString()).equals("true");
81+
expect(t.and(f).toString()).equals("false");
82+
expect(f.and(f).toString()).equals("false");
83+
84+
expect(t.or(t).toString()).equals("true");
85+
expect(t.or(f).toString()).equals("true");
86+
expect(f.or(f).toString()).equals("false");
87+
88+
expect(t.xor(t).toString()).equals("false");
89+
expect(t.xor(f).toString()).equals("true");
90+
expect(f.xor(f).toString()).equals("false");
91+
92+
expect(t.nand(t).toString()).equals("false");
93+
expect(t.nand(f).toString()).equals("true");
94+
95+
expect(f.nor(f).toString()).equals("true");
96+
expect(t.nor(f).toString()).equals("false");
97+
});
98+
4799
it('Check scalar field arithmetic', () => {
48100
// Create the 2 scalar element.
49101
const a = Scalar.fromString("2scalar");

wasm/src/ledger/transition.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,32 @@ impl Transition {
176176
}
177177

178178
/// Get the transition public key of the transition.
179+
///
180+
/// @returns {Group} Transition public key
179181
pub fn tpk(&self) -> Group {
180182
Group::from(self.0.tpk())
181183
}
182184

183185
/// Get the transition view key of the transition.
186+
///
187+
/// @param {ViewKey} view_key The view key of the transition signer.
188+
///
189+
/// @returns {Field} Transition view key
184190
pub fn tvk(&self, view_key: &ViewKey) -> Field {
185191
let tpk = self.tpk();
186192
tpk.scalar_multiply(&view_key.to_scalar()).to_x_coordinate()
187193
}
188194

189195
/// Get the transition commitment of the transition.
196+
///
197+
/// @returns {Field} Transition commitment
190198
pub fn tcm(&self) -> Field {
191199
Field::from(self.0.tcm())
192200
}
193201

194202
/// Get the transition signer commitment of the transition.
203+
///
204+
/// @returns {Field} Transition signer commitment
195205
pub fn scm(&self) -> Field {
196206
Field::from(self.0.scm())
197207
}

wasm/src/programs/data/ciphertext.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ impl Ciphertext {
5757

5858
/// Decrypt a ciphertext using the view key of the transition signer, transition public key, and
5959
/// (program, function, index) tuple.
60+
///
61+
/// @param {ViewKey} view_key The view key of the transition signer.
62+
/// @param {Group} transition_public_key The transition public key used to encrypt the ciphertext.
63+
/// @param {string} program The program ID associated with the ciphertext.
64+
/// @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
65+
/// @param {u16} index The index of the input or output parameter that was encrypted.
66+
///
67+
/// @returns {Plaintext} The decrypted plaintext.
6068
#[wasm_bindgen(js_name = decryptWithTransitionInfo)]
6169
pub fn decrypt_with_transition_info(
6270
&self,
@@ -82,6 +90,13 @@ impl Ciphertext {
8290
}
8391

8492
/// Decrypt a ciphertext using the transition view key and a (program, function, index) tuple.
93+
///
94+
/// @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
95+
/// @param {string} program The program ID associated with the ciphertext.
96+
/// @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
97+
/// @param {u16} index The index of the input or output parameter that was encrypted.
98+
///
99+
/// @returns {Plaintext} The decrypted plaintext.
85100
#[wasm_bindgen(js_name = decryptWithTransitionViewKey)]
86101
pub fn decrypt_with_transition_view_key(
87102
&self,

0 commit comments

Comments
 (0)