@zerc20/wallet-sdk 0.0.0-stage → 0.1.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 (84) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +26 -2
  3. package/dist/burnWorker.d.ts +1 -0
  4. package/dist/burnWorker.js +21 -0
  5. package/dist/burnWorker.js.map +1 -0
  6. package/dist/chain.d.ts +345 -0
  7. package/dist/chain.js +149 -0
  8. package/dist/chain.js.map +1 -0
  9. package/dist/context.d.ts +48 -0
  10. package/dist/context.js +40 -0
  11. package/dist/context.js.map +1 -0
  12. package/dist/core.d.ts +43 -0
  13. package/dist/core.js +106 -0
  14. package/dist/core.js.map +1 -0
  15. package/dist/errors.d.ts +36 -0
  16. package/dist/errors.js +26 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/index.d.ts +6 -0
  19. package/dist/index.js +19 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/network.d.ts +66 -0
  22. package/dist/network.js +55 -0
  23. package/dist/network.js.map +1 -0
  24. package/dist/pos.d.ts +93 -0
  25. package/dist/pos.js +302 -0
  26. package/dist/pos.js.map +1 -0
  27. package/dist/prove.d.ts +13 -0
  28. package/dist/prove.js +53 -0
  29. package/dist/prove.js.map +1 -0
  30. package/dist/rageExit.d.ts +5 -0
  31. package/dist/rageExit.js +146 -0
  32. package/dist/rageExit.js.map +1 -0
  33. package/dist/scan.d.ts +17 -0
  34. package/dist/scan.js +47 -0
  35. package/dist/scan.js.map +1 -0
  36. package/dist/seed.d.ts +8 -0
  37. package/dist/seed.js +35 -0
  38. package/dist/seed.js.map +1 -0
  39. package/dist/servers.d.ts +60 -0
  40. package/dist/servers.js +117 -0
  41. package/dist/servers.js.map +1 -0
  42. package/dist/services.d.ts +62 -0
  43. package/dist/services.js +128 -0
  44. package/dist/services.js.map +1 -0
  45. package/dist/spend.d.ts +151 -0
  46. package/dist/spend.js +745 -0
  47. package/dist/spend.js.map +1 -0
  48. package/dist/state.d.ts +174 -0
  49. package/dist/state.js +45 -0
  50. package/dist/state.js.map +1 -0
  51. package/dist/sync.d.ts +84 -0
  52. package/dist/sync.js +615 -0
  53. package/dist/sync.js.map +1 -0
  54. package/dist/tree.d.ts +19 -0
  55. package/dist/tree.js +63 -0
  56. package/dist/tree.js.map +1 -0
  57. package/dist/wallet.d.ts +301 -0
  58. package/dist/wallet.js +992 -0
  59. package/dist/wallet.js.map +1 -0
  60. package/package.json +60 -4
  61. package/src/burnWorker.ts +25 -0
  62. package/src/chain.ts +205 -0
  63. package/src/context.ts +84 -0
  64. package/src/core.ts +147 -0
  65. package/src/errors.ts +61 -0
  66. package/src/index.ts +41 -0
  67. package/src/network.ts +94 -0
  68. package/src/pos.ts +415 -0
  69. package/src/prove.ts +67 -0
  70. package/src/rageExit.ts +168 -0
  71. package/src/scan.ts +62 -0
  72. package/src/seed.ts +46 -0
  73. package/src/servers.ts +172 -0
  74. package/src/services.ts +184 -0
  75. package/src/snarkjs.d.ts +11 -0
  76. package/src/spend.ts +912 -0
  77. package/src/state.ts +211 -0
  78. package/src/sync.ts +698 -0
  79. package/src/tree.ts +108 -0
  80. package/src/wallet.ts +1297 -0
  81. package/wasm/zerc20_wallet_core.d.ts +176 -0
  82. package/wasm/zerc20_wallet_core.js +783 -0
  83. package/wasm/zerc20_wallet_core_bg.wasm +0 -0
  84. package/wasm/zerc20_wallet_core_bg.wasm.d.ts +32 -0
@@ -0,0 +1,176 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The ASP tree's leaves for `count` positions from `first`, from an ASP `/bitmap/{c}` page (position `first + j` is
6
+ * bit `j % 8`, least significant first, of byte `j / 8`): `asp_leaf(position)` where approved, 0 elsewhere.
7
+ */
8
+ export function aspLeaves(bitmap: Uint8Array, first: bigint, count: number): Uint8Array;
9
+
10
+ /**
11
+ * A seed's `index`-th burn address for one chain and token, with its salt: `{salt, address}`. About 2^16 hashes.
12
+ */
13
+ export function burnAddress(seed: Uint8Array, chain_id: bigint, token_id: number, index: number): any;
14
+
15
+ export function burnAddressOf(chain_id: bigint, public_key: string, salt: string): string | undefined;
16
+
17
+ /**
18
+ * The key that owns the notes paid to a seed's `index`-th receive code for one chain and token, shaped like
19
+ * `spendKey`.
20
+ */
21
+ export function codeKey(seed: Uint8Array, chain_id: bigint, token_id: number, index: number): any;
22
+
23
+ /**
24
+ * `CommitmentLedger`'s hash chain after appending a commitment with `fields` to `prev`.
25
+ */
26
+ export function hashChain(prev: string, fields: string[]): string;
27
+
28
+ /**
29
+ * One commitment's leaf, from its 4 fields.
30
+ */
31
+ export function leaf(fields: string[]): string;
32
+
33
+ /**
34
+ * The leaves of commitments in the indexer's layout (4 fields of 32 bytes each, as after a `/commitments/{p}` page's
35
+ * 32-byte header), 32 bytes each.
36
+ */
37
+ export function leaves(entries: Uint8Array): Uint8Array;
38
+
39
+ /**
40
+ * The note hash a note's opening commits to.
41
+ */
42
+ export function noteHash(chain_id: bigint, public_key: string, value: string, token_id: number, salt: string): string;
43
+
44
+ /**
45
+ * The tag of a note commitment.
46
+ */
47
+ export function noteTag(token_id: number, note_hash: string): number;
48
+
49
+ /**
50
+ * The nullifier that spending the note or deposit at `commitment_index` publishes.
51
+ */
52
+ export function nullifier(chain_id: bigint, commitment_index: bigint, nullifying_key: string): string;
53
+
54
+ /**
55
+ * The sibling path (32 hex values) of position `i` in the tree at `n` leaves, from what a wallet downloads: the leaves
56
+ * of `i`'s chunk, the chunk roots of `i`'s page, the page roots, and the root entry's partial chunk and page roots
57
+ * (zero or absent where there is none). Lists may run past `n`. Check the path with `pathRoot` against a root the chain
58
+ * accepts.
59
+ */
60
+ export function path(i: bigint, n: bigint, chunk_leaves: Uint8Array, page_chunks: Uint8Array, page_roots: Uint8Array, partial_chunk?: string | null, partial_page?: string | null): string[];
61
+
62
+ /**
63
+ * The root of the tree holding `leaf` at position `i` with path `siblings`.
64
+ */
65
+ export function pathRoot(leaf: string, i: bigint, siblings: string[]): string;
66
+
67
+ /**
68
+ * The `k`-th burn address a point of sale holding `lane_key` makes for `public_key` on one chain and token, with its
69
+ * salt: `{salt, address}`. About 2^16 hashes.
70
+ */
71
+ export function posBurnAddress(lane_key: Uint8Array, chain_id: bigint, token_id: number, k: number, public_key: string): any;
72
+
73
+ /**
74
+ * Seals a merge witness (JSON) to the merge prover's key, padded with spaces to `pad_to` bytes. Take the key from
75
+ * `verifyAttestation`, as for the attester's.
76
+ */
77
+ export function sealMergeWitness(public_key: Uint8Array, witness: string, pad_to: number): Uint8Array;
78
+
79
+ /**
80
+ * Seals a witness (JSON) to an attester's key, padded with spaces to `pad_to` bytes so its length is the same for
81
+ * every amount. Take the key from `verifyAttestation`; only a development attester, which has no document, is taken
82
+ * at its word.
83
+ */
84
+ export function sealWitness(public_key: Uint8Array, witness: string, pad_to: number): Uint8Array;
85
+
86
+ /**
87
+ * The statement a merge witness proves and the witness the attester and the merge prover take, as [`sign_transact`]
88
+ * for a JoinSplit: `{statement, witness}`. `statement` holds the public inputs and the fee (JSON with `tokenId`,
89
+ * `chainId`, `commitmentRoot`, `aspRoot`, `fee` and `feeRecipient`), and `witness` is the attester's merge witness
90
+ * JSON with each input's `private_key` in place of its keys. The statement gains the nullifiers and the note.
91
+ */
92
+ export function signMerge(statement: string, witness: string): string;
93
+
94
+ /**
95
+ * The statement a JoinSplit witness (snarkjs's input JSON) proves, given the public inputs in `statement` (JSON with
96
+ * `tokenId`, `chainId`, `commitmentRoot` and `aspRoot`; the rest is ignored), and the attester's witness for it:
97
+ * `{statement, witness}`. The statement is the public signals the proof and the attestation cover. The attester's
98
+ * witness has each input's private key replaced by its signing and nullifying keys, and its owner's signature on the
99
+ * statement. Fails with the attester's own reason when the attester would refuse the witness.
100
+ */
101
+ export function signTransact(statement: string, witness: string): string;
102
+
103
+ /**
104
+ * The key that owns a seed's notes and deposits on every chain and token: `{secret, authKeyHash, publicKey,
105
+ * nullifyingKey}`.
106
+ */
107
+ export function spendKey(seed: Uint8Array): any;
108
+
109
+ /**
110
+ * The tag of a transfer to `to` (`0x` address), such as a deposit to a burn address.
111
+ */
112
+ export function transferTag(token_id: number, to: string): number;
113
+
114
+ /**
115
+ * The key an attester's enclave opens witnesses with, once its `/attestation` document (`attestation`, decoded from
116
+ * base64) checks out: signed by a certificate chain up to the root whose DER has SHA-256 `root_sha256` (hex), valid
117
+ * at `now` (Unix seconds), and measuring `pcr0` (hex).
118
+ */
119
+ export function verifyAttestation(attestation: Uint8Array, root_sha256: string, pcr0: string, now: bigint): Uint8Array;
120
+
121
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
122
+
123
+ export interface InitOutput {
124
+ readonly memory: WebAssembly.Memory;
125
+ readonly aspLeaves: (a: number, b: number, c: bigint, d: number) => [number, number, number, number];
126
+ readonly burnAddress: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number];
127
+ readonly burnAddressOf: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number];
128
+ readonly codeKey: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number];
129
+ readonly hashChain: (a: number, b: number, c: number, d: number) => [number, number, number, number];
130
+ readonly leaf: (a: number, b: number) => [number, number, number, number];
131
+ readonly leaves: (a: number, b: number) => [number, number, number, number];
132
+ readonly noteHash: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
133
+ readonly noteTag: (a: number, b: number, c: number) => [number, number, number];
134
+ readonly nullifier: (a: bigint, b: bigint, c: number, d: number) => [number, number, number, number];
135
+ 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];
136
+ readonly pathRoot: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
137
+ readonly posBurnAddress: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => [number, number, number];
138
+ readonly sealMergeWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
139
+ readonly sealWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
140
+ readonly signMerge: (a: number, b: number, c: number, d: number) => [number, number, number, number];
141
+ readonly signTransact: (a: number, b: number, c: number, d: number) => [number, number, number, number];
142
+ readonly spendKey: (a: number, b: number) => [number, number, number];
143
+ readonly transferTag: (a: number, b: number, c: number) => [number, number, number];
144
+ readonly verifyAttestation: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => [number, number, number, number];
145
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
146
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
147
+ readonly __wbindgen_exn_store: (a: number) => void;
148
+ readonly __externref_table_alloc: () => number;
149
+ readonly __wbindgen_externrefs: WebAssembly.Table;
150
+ readonly __externref_table_dealloc: (a: number) => void;
151
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
152
+ readonly __externref_drop_slice: (a: number, b: number) => void;
153
+ readonly __wbindgen_start: () => void;
154
+ }
155
+
156
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
157
+
158
+ /**
159
+ * Instantiates the given `module`, which can either be bytes or
160
+ * a precompiled `WebAssembly.Module`.
161
+ *
162
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
163
+ *
164
+ * @returns {InitOutput}
165
+ */
166
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
167
+
168
+ /**
169
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
170
+ * for everything else, calls `WebAssembly.instantiate` directly.
171
+ *
172
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
173
+ *
174
+ * @returns {Promise<InitOutput>}
175
+ */
176
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;