Skip to content

Commit e394899

Browse files
authored
Merge pull request #1053 from ProvableHQ/rr/fix-docstrings-for-encryption-module
Reformat docstrings to include input and return fields
2 parents a1a12b7 + 87dffd3 commit e394899

File tree

10 files changed

+158
-46
lines changed

10 files changed

+158
-46
lines changed

docs/api_reference/sdk-src_account.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,23 @@ const viewKey = account.viewKey();
504504

505505
---
506506

507-
### `computeKey() ► Field`
507+
### `computeKey() ► ComputeKey`
508508

509509
![modifier: public](images/badges/modifier-public.svg)
510510

511-
Returns the Transition View Key associated with the transition public key.
511+
Returns the ComputeKey associated with the account.
512512

513513
Parameters | Type | Description
514514
--- | --- | ---
515-
__*return*__ | [Field](sdk-src_wasm.md) | *The transition view key*
515+
__*return*__ | `ComputeKey` | *The compute key of the account*
516516

517517
#### Examples
518518

519519
```javascript
520520
import { Account } from "@provablehq/sdk/testnet.js";
521-
const account =
521+
522+
const account = new Account();
523+
const computeKey = account.computeKey();
522524
```
523525

524526
---

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

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,

wasm/src/programs/data/plaintext.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,22 @@ impl Plaintext {
7373
}
7474

7575
/// Encrypt a plaintext with an address and randomizer.
76+
///
77+
/// @param {Address} address The address to encrypt the plaintext for.
78+
/// @param {Scalar} randomizer The randomizer to use for encryption.
79+
///
80+
/// @returns {Ciphertext} The encrypted ciphertext.
81+
#[wasm_bindgen(js_name = encrypt)]
7682
pub fn encrypt(&self, address: &Address, randomizer: &Scalar) -> Result<Ciphertext, String> {
7783
self.0.encrypt(address, **randomizer).map_err(|e| e.to_string()).map(Ciphertext::from)
7884
}
7985

8086
/// Encrypt a plaintext with a transition view key.
87+
///
88+
/// @param {Field} transition_view_key The transition view key of the transition
89+
/// associated with the plaintext.
90+
///
91+
/// @returns {Ciphertext} The encrypted ciphertext.
8192
#[wasm_bindgen(js_name = encryptSymmetric)]
8293
pub fn encrypt_symmetric(&self, transition_view_key: &Field) -> Result<Ciphertext, String> {
8394
self.0.encrypt_symmetric(**transition_view_key).map_err(|e| e.to_string()).map(Ciphertext::from)
@@ -106,6 +117,8 @@ impl Plaintext {
106117
}
107118

108119
/// Get the left endian byte array representation of the plaintext.
120+
///
121+
/// @returns {Uint8Array} The left endian byte array representation of the plaintext.
109122
#[wasm_bindgen(js_name = "toBytesLe")]
110123
pub fn to_bytes_le(&self) -> Result<Uint8Array, String> {
111124
let rust_bytes = self.0.to_bytes_le().map_err(|e| e.to_string())?;
@@ -125,6 +138,8 @@ impl Plaintext {
125138
}
126139

127140
/// Get the left endian boolean array representation of the bits of the plaintext.
141+
///
142+
/// @returns {Array} The left endian boolean array representation of the bits of the plaintext.
128143
#[wasm_bindgen(js_name = "toBitsLe")]
129144
pub fn to_bits_le(&self) -> Array {
130145
to_bits_array_le!(self)
@@ -143,6 +158,8 @@ impl Plaintext {
143158
}
144159

145160
/// Get the field array representation of the plaintext.
161+
///
162+
/// @returns {Array} The field array representation of the plaintext.
146163
#[wasm_bindgen(js_name = "toFields")]
147164
pub fn to_fields(&self) -> Result<Array, String> {
148165
let native = self.0.clone();

0 commit comments

Comments
 (0)