@aptos-labs/confidential-assets-bindings 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -10,60 +10,43 @@ npm install @aptos-labs/confidential-assets-bindings
10
10
 
11
11
  ## Usage
12
12
 
13
- ```typescript
14
- import init, {
15
- DiscreteLogSolver,
16
- range_proof,
17
- batch_range_proof,
18
- verify_proof,
19
- batch_verify_proof,
20
- initializeWasm,
21
- } from "@aptos-labs/confidential-assets-bindings";
22
-
23
- // Initialize WASM module before calling any functions
24
- await init();
25
- ```
26
-
27
- Node.js consumers do not need to call `initializeWasm()`; the runtime is loaded automatically.
13
+ No initialization required — WASM is loaded automatically on first use, from local `node_modules` in Node.js or from the versioned unpkg CDN in browsers.
28
14
 
29
15
  ### Discrete Log
30
16
 
31
17
  Solves discrete logarithms on the Ristretto255 curve for 16-bit and 32-bit secrets. Used to decrypt confidential asset balances.
32
18
 
33
19
  ```typescript
34
- const solver = new DiscreteLogSolver();
20
+ import { solveDiscreteLog } from "@aptos-labs/confidential-assets-bindings";
35
21
 
36
22
  // y is a compressed Ristretto point (32 bytes): y = g^x
37
- // max_num_bits must be 16 or 32
38
- const x: bigint = solver.solve(y, 32);
39
-
40
- console.log(solver.algorithm()); // e.g. "NaiveTruncatedDoubledLookup (16-bit) + TBSGS-k32 (32-bit)"
41
- console.log(solver.max_num_bits()); // [16, 32]
23
+ // maxNumBits must be 16 or 32
24
+ const x: bigint = await solveDiscreteLog(y, 32);
42
25
  ```
43
26
 
44
27
  ### Range Proofs
45
28
 
46
- Zero-knowledge range proofs using Bulletproofs. Proves a value lies in `[0, 2^num_bits)` without revealing it.
29
+ Zero-knowledge range proofs using Bulletproofs. Proves a value lies in `[0, 2^numBits)` without revealing it.
47
30
 
48
31
  ```typescript
49
- // Generate a single range proof
32
+ import {
33
+ rangeProof,
34
+ batchRangeProof,
35
+ verifyProof,
36
+ batchVerifyProof,
37
+ } from "@aptos-labs/confidential-assets-bindings";
38
+
50
39
  // r is a 32-byte blinding scalar
51
- // val_base and rand_base are 32-byte compressed Ristretto points (Pedersen bases)
52
- // num_bits must be 8, 16, 32, or 64
53
- const result = range_proof(value, r, val_base, rand_base, num_bits);
54
- const proofBytes: Uint8Array = result.proof();
55
- const commitment: Uint8Array = result.comm(); // 32 bytes
56
-
57
- // Verify a single range proof
58
- const valid: boolean = verify_proof(proofBytes, commitment, val_base, rand_base, num_bits);
59
-
60
- // Generate a batch range proof
61
- const batchResult = batch_range_proof(values, blindings, val_base, rand_base, num_bits);
62
- const batchProof: Uint8Array = batchResult.proof();
63
- const commitments: Uint8Array[] = batchResult.comms(); // one per value
64
-
65
- // Verify a batch range proof
66
- const batchValid: boolean = batch_verify_proof(batchProof, commitments, val_base, rand_base, num_bits);
40
+ // valBase and randBase are 32-byte compressed Ristretto points (Pedersen bases)
41
+ // numBits must be 8, 16, 32, or 64 (default: 32)
42
+ const { proof, commitment } = await rangeProof({ v, r, valBase, randBase, numBits });
43
+
44
+ const valid = await verifyProof({ proof, comm: commitment, valBase, randBase, numBits });
45
+
46
+ // Batch variants
47
+ const { proof: batchProof, commitments } = await batchRangeProof({ v: values, rs: blindings, valBase, randBase, numBits });
48
+
49
+ const batchValid = await batchVerifyProof({ proof: batchProof, comms: commitments, valBase, randBase, numBits });
67
50
  ```
68
51
 
69
52
  ## Cross-Version Compatibility
package/dist/index.cjs CHANGED
@@ -522,7 +522,7 @@ async function __wbg_init(module_or_path) {
522
522
  }
523
523
  //#endregion
524
524
  //#region src/index.ts
525
- const CDN_WASM_URL = `https://unpkg.com/@aptos-labs/confidential-assets-bindings@0.0.5/dist/aptos_confidential_asset_wasm_bg.wasm`;
525
+ const CDN_WASM_URL = `https://unpkg.com/@aptos-labs/confidential-assets-bindings@0.0.7/dist/aptos_confidential_asset_wasm_bg.wasm`;
526
526
  async function getNodeModulesWASM() {
527
527
  try {
528
528
  const fs = await import("fs");
package/dist/index.mjs CHANGED
@@ -521,7 +521,7 @@ async function __wbg_init(module_or_path) {
521
521
  }
522
522
  //#endregion
523
523
  //#region src/index.ts
524
- const CDN_WASM_URL = `https://unpkg.com/@aptos-labs/confidential-assets-bindings@0.0.5/dist/aptos_confidential_asset_wasm_bg.wasm`;
524
+ const CDN_WASM_URL = `https://unpkg.com/@aptos-labs/confidential-assets-bindings@0.0.7/dist/aptos_confidential_asset_wasm_bg.wasm`;
525
525
  async function getNodeModulesWASM() {
526
526
  try {
527
527
  const fs = await import("fs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/confidential-assets-bindings",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Bindings for Aptos confidential assets (discrete log + range proofs)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {