@zerc20/wallet-sdk 0.3.0 → 0.5.0

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.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/dist/accountId.d.ts +5 -0
  3. package/dist/accountId.js +19 -0
  4. package/dist/accountId.js.map +1 -0
  5. package/dist/chain.d.ts +85 -9
  6. package/dist/chain.js +60 -33
  7. package/dist/chain.js.map +1 -1
  8. package/dist/context.d.ts +14 -6
  9. package/dist/context.js +17 -3
  10. package/dist/context.js.map +1 -1
  11. package/dist/core.d.ts +35 -5
  12. package/dist/core.js +95 -23
  13. package/dist/core.js.map +1 -1
  14. package/dist/errors.d.ts +2 -0
  15. package/dist/errors.js.map +1 -1
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.js +6 -2
  18. package/dist/index.js.map +1 -1
  19. package/dist/pos.d.ts +7 -1
  20. package/dist/pos.js +213 -55
  21. package/dist/pos.js.map +1 -1
  22. package/dist/rageExit.d.ts +27 -4
  23. package/dist/rageExit.js +160 -49
  24. package/dist/rageExit.js.map +1 -1
  25. package/dist/seed.d.ts +4 -0
  26. package/dist/seed.js +13 -1
  27. package/dist/seed.js.map +1 -1
  28. package/dist/servers.d.ts +2 -0
  29. package/dist/servers.js +1 -0
  30. package/dist/servers.js.map +1 -1
  31. package/dist/services.d.ts +11 -4
  32. package/dist/services.js +26 -7
  33. package/dist/services.js.map +1 -1
  34. package/dist/spend.d.ts +30 -9
  35. package/dist/spend.js +46 -17
  36. package/dist/spend.js.map +1 -1
  37. package/dist/state.d.ts +21 -0
  38. package/dist/state.js.map +1 -1
  39. package/dist/sync.d.ts +10 -5
  40. package/dist/sync.js +53 -19
  41. package/dist/sync.js.map +1 -1
  42. package/dist/viewKey.d.ts +14 -0
  43. package/dist/viewKey.js +45 -0
  44. package/dist/viewKey.js.map +1 -0
  45. package/dist/wallet.d.ts +109 -16
  46. package/dist/wallet.js +291 -85
  47. package/dist/wallet.js.map +1 -1
  48. package/package.json +3 -2
  49. package/src/accountId.ts +22 -0
  50. package/src/chain.ts +95 -49
  51. package/src/context.ts +35 -8
  52. package/src/core.ts +109 -24
  53. package/src/errors.ts +2 -0
  54. package/src/index.ts +18 -2
  55. package/src/pos.ts +240 -61
  56. package/src/rageExit.ts +237 -61
  57. package/src/seed.ts +24 -1
  58. package/src/servers.ts +4 -1
  59. package/src/services.ts +28 -15
  60. package/src/spend.ts +58 -23
  61. package/src/state.ts +25 -1
  62. package/src/sync.ts +57 -20
  63. package/src/viewKey.ts +49 -0
  64. package/src/wallet.ts +387 -106
  65. package/wasm/zerc20_wallet_core.d.ts +8 -1
  66. package/wasm/zerc20_wallet_core.js +31 -1
  67. package/wasm/zerc20_wallet_core_bg.wasm +0 -0
  68. package/wasm/zerc20_wallet_core_bg.wasm.d.ts +1 -0
@@ -73,6 +73,12 @@ export function path(i: bigint, n: bigint, chunk_leaves: Uint8Array, page_chunks
73
73
  */
74
74
  export function pathRoot(leaf: string, i: bigint, siblings: string[]): string;
75
75
 
76
+ /**
77
+ * The public key a signing key's hash and a nullifying key make: how a view key's holder checks that the nullifying
78
+ * key it was given is the one the account's notes commit to.
79
+ */
80
+ export function publicKey(auth_key_hash: string, nullifying_key: string): string;
81
+
76
82
  /**
77
83
  * Seals a merge witness (JSON) to the merge prover's key, padded with spaces to `pad_to` bytes. Take the key from
78
84
  * `verifyAttestation`, as for the attester's.
@@ -99,7 +105,7 @@ export function signMerge(statement: string, witness: string): string;
99
105
  * `tokenId`, `chainId`, `commitmentRoot` and `aspRoot`; the rest is ignored), and the attester's witness for it:
100
106
  * `{statement, witness}`. The statement is the public signals the proof and the attestation cover. The attester's
101
107
  * witness has each input's private key replaced by its signing and nullifying keys, and its owner's signature on the
102
- * statement. Fails with the attester's own reason when the attester would refuse the witness.
108
+ * statement. Fails, with the reason, where the attester would refuse the witness.
103
109
  */
104
110
  export function signTransact(statement: string, witness: string): string;
105
111
 
@@ -138,6 +144,7 @@ export interface InitOutput {
138
144
  readonly nullifier: (a: bigint, b: bigint, c: number, d: number) => [number, number, number, number];
139
145
  readonly path: (a: bigint, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
140
146
  readonly pathRoot: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
147
+ readonly publicKey: (a: number, b: number, c: number, d: number) => [number, number, number, number];
141
148
  readonly sealMergeWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
142
149
  readonly sealWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
143
150
  readonly signMerge: (a: number, b: number, c: number, d: number) => [number, number, number, number];
@@ -324,6 +324,36 @@ export function pathRoot(leaf, i, siblings) {
324
324
  }
325
325
  }
326
326
 
327
+ /**
328
+ * The public key a signing key's hash and a nullifying key make: how a view key's holder checks that the nullifying
329
+ * key it was given is the one the account's notes commit to.
330
+ * @param {string} auth_key_hash
331
+ * @param {string} nullifying_key
332
+ * @returns {string}
333
+ */
334
+ export function publicKey(auth_key_hash, nullifying_key) {
335
+ let deferred4_0;
336
+ let deferred4_1;
337
+ try {
338
+ const ptr0 = passStringToWasm0(auth_key_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ptr1 = passStringToWasm0(nullifying_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len1 = WASM_VECTOR_LEN;
342
+ const ret = wasm.publicKey(ptr0, len0, ptr1, len1);
343
+ var ptr3 = ret[0];
344
+ var len3 = ret[1];
345
+ if (ret[3]) {
346
+ ptr3 = 0; len3 = 0;
347
+ throw takeFromExternrefTable0(ret[2]);
348
+ }
349
+ deferred4_0 = ptr3;
350
+ deferred4_1 = len3;
351
+ return getStringFromWasm0(ptr3, len3);
352
+ } finally {
353
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
354
+ }
355
+ }
356
+
327
357
  /**
328
358
  * Seals a merge witness (JSON) to the merge prover's key, padded with spaces to `pad_to` bytes. Take the key from
329
359
  * `verifyAttestation`, as for the attester's.
@@ -406,7 +436,7 @@ export function signMerge(statement, witness) {
406
436
  * `tokenId`, `chainId`, `commitmentRoot` and `aspRoot`; the rest is ignored), and the attester's witness for it:
407
437
  * `{statement, witness}`. The statement is the public signals the proof and the attestation cover. The attester's
408
438
  * witness has each input's private key replaced by its signing and nullifying keys, and its owner's signature on the
409
- * statement. Fails with the attester's own reason when the attester would refuse the witness.
439
+ * statement. Fails, with the reason, where the attester would refuse the witness.
410
440
  * @param {string} statement
411
441
  * @param {string} witness
412
442
  * @returns {string}
Binary file
@@ -14,6 +14,7 @@ export const noteTag: (a: number, b: number, c: number) => [number, number, numb
14
14
  export const nullifier: (a: bigint, b: bigint, c: number, d: number) => [number, number, number, number];
15
15
  export const path: (a: bigint, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
16
16
  export const pathRoot: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
17
+ export const publicKey: (a: number, b: number, c: number, d: number) => [number, number, number, number];
17
18
  export const sealMergeWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
18
19
  export const sealWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
19
20
  export const signMerge: (a: number, b: number, c: number, d: number) => [number, number, number, number];