@typeberry/native 0.0.1-0330ab3 → 0.0.1-43eee4f

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 (3) hide show
  1. package/index.d.ts +167 -81
  2. package/index.js +402 -298
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,47 +1,67 @@
1
1
  declare namespace bandersnatch_d_exports {
2
- export { batch_verify_tickets, derive_public_key, ring_commitment, verify_seal };
2
+ export { InitInput$2 as InitInput, InitOutput$2 as InitOutput, SyncInitInput$2 as SyncInitInput, batch_verify_tickets, __wbg_init$2 as default, derive_public_key, initSync$2 as initSync, ring_commitment, verify_seal };
3
3
  }
4
4
  /* tslint:disable */
5
5
  /* eslint-disable */
6
- /**
7
- * @param {Uint8Array} keys
8
- * @returns {Uint8Array}
9
- */
10
6
  declare function ring_commitment(keys: Uint8Array): Uint8Array;
11
7
  /**
12
- * Derive Private and Public Key from Seed
13
- *
14
- * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
15
- * @param {Uint8Array} seed
16
- * @returns {Uint8Array}
17
- */
8
+ * Derive Private and Public Key from Seed
9
+ *
10
+ * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
11
+ */
18
12
  declare function derive_public_key(seed: Uint8Array): Uint8Array;
19
13
  /**
20
- * Seal verification as defined in:
21
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
22
- * or
23
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
24
- * @param {Uint8Array} keys
25
- * @param {number} signer_key_index
26
- * @param {Uint8Array} seal_data
27
- * @param {Uint8Array} payload
28
- * @param {Uint8Array} aux_data
29
- * @returns {Uint8Array}
30
- */
14
+ * Seal verification as defined in:
15
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
16
+ * or
17
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
18
+ */
31
19
  declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
32
20
  /**
33
- * Verify multiple tickets at once as defined in:
34
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
21
+ * Verify multiple tickets at once as defined in:
22
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
23
+ *
24
+ * NOTE: the aux_data of VRF function is empty!
25
+ */
26
+ declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
27
+ type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
28
+ interface InitOutput$2 {
29
+ readonly memory: WebAssembly.Memory;
30
+ readonly ring_commitment: (a: number, b: number) => [number, number];
31
+ readonly derive_public_key: (a: number, b: number) => [number, number];
32
+ readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
33
+ readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number) => [number, number];
34
+ readonly __wbindgen_export_0: WebAssembly.Table;
35
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
36
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
37
+ readonly __wbindgen_start: () => void;
38
+ }
39
+ type SyncInitInput$2 = BufferSource | WebAssembly.Module;
40
+ /**
41
+ * Instantiates the given `module`, which can either be bytes or
42
+ * a precompiled `WebAssembly.Module`.
35
43
  *
36
- * NOTE: the aux_data of VRF function is empty!
37
- * @param {Uint8Array} keys
38
- * @param {Uint8Array} tickets_data
39
- * @param {number} vrf_input_data_len
40
- * @returns {Uint8Array}
44
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
45
+ *
46
+ * @returns {InitOutput}
41
47
  */
42
- declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
48
+ declare function initSync$2(module: {
49
+ module: SyncInitInput$2;
50
+ } | SyncInitInput$2): InitOutput$2;
51
+
52
+ /**
53
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
54
+ * for everything else, calls `WebAssembly.instantiate` directly.
55
+ *
56
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
57
+ *
58
+ * @returns {Promise<InitOutput>}
59
+ */
60
+ declare function __wbg_init$2(module_or_path?: {
61
+ module_or_path: InitInput$2 | Promise<InitInput$2>;
62
+ } | InitInput$2 | Promise<InitInput$2>): Promise<InitOutput$2>;
43
63
  declare namespace ed25519_wasm_d_exports {
44
- export { verify_ed25519, verify_ed25519_batch };
64
+ export { InitInput$1 as InitInput, InitOutput$1 as InitOutput, SyncInitInput$1 as SyncInitInput, __wbg_init$1 as default, initSync$1 as initSync, verify_ed25519, verify_ed25519_batch };
45
65
  }
46
66
  /* tslint:disable */
47
67
  /* eslint-disable */
@@ -62,72 +82,138 @@ declare function verify_ed25519(data: Uint8Array): Uint8Array;
62
82
  *
63
83
  */
64
84
  declare function verify_ed25519_batch(data: Uint8Array): boolean;
65
- declare namespace reed_solomon_wasm_d_exports {
66
- export { ShardsCollection, decode, encode };
85
+ type InitInput$1 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
86
+ interface InitOutput$1 {
87
+ readonly memory: WebAssembly.Memory;
88
+ readonly verify_ed25519: (a: number, b: number) => [number, number];
89
+ readonly verify_ed25519_batch: (a: number, b: number) => number;
90
+ readonly __wbindgen_export_0: WebAssembly.Table;
91
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
92
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
93
+ readonly __wbindgen_start: () => void;
67
94
  }
68
- /* tslint:disable */
69
- /* eslint-disable */
70
- /**
71
- * @param {number} recovery_count
72
- * @param {ShardsCollection} shards
73
- * @returns {ShardsCollection}
74
- */
75
- declare function encode(recovery_count: number, shards: ShardsCollection): ShardsCollection;
95
+ type SyncInitInput$1 = BufferSource | WebAssembly.Module;
76
96
  /**
77
- * @param {number} original_count
78
- * @param {number} recovery_count
79
- * @param {ShardsCollection} shards
80
- * @returns {ShardsCollection}
97
+ * Instantiates the given `module`, which can either be bytes or
98
+ * a precompiled `WebAssembly.Module`.
99
+ *
100
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
101
+ *
102
+ * @returns {InitOutput}
81
103
  */
82
- declare function decode(original_count: number, recovery_count: number, shards: ShardsCollection): ShardsCollection;
104
+ declare function initSync$1(module: {
105
+ module: SyncInitInput$1;
106
+ } | SyncInitInput$1): InitOutput$1;
107
+
83
108
  /**
84
- * Collection of shards (either input or output).
109
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
110
+ * for everything else, calls `WebAssembly.instantiate` directly.
85
111
  *
86
- * To efficiently pass data between JS and WASM all of the shards
87
- * are passed as one big vector of bytes.
88
- * It's assumed that every shard has the same length (`shard_len`).
89
- * If the shards are NOT passed in the exact order they were created
90
- * it's possible to pass `indices` array.
91
- * A value of `indices` array at position `idx` is the shard index
92
- * that resides at `[ idx * shard_len .. idx * shard_len + shard_len )`
93
- * in `data` array.
112
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
94
113
  *
95
- * This collection is only used to get the data from JS or pass the data back.
96
- * Internally we convert it to [`RsShardsCollection`], which copies
97
- * the memory to/from WASM.
114
+ * @returns {Promise<InitOutput>}
98
115
  */
116
+ declare function __wbg_init$1(module_or_path?: {
117
+ module_or_path: InitInput$1 | Promise<InitInput$1>;
118
+ } | InitInput$1 | Promise<InitInput$1>): Promise<InitOutput$1>;
119
+ declare namespace reed_solomon_wasm_d_exports {
120
+ export { InitInput, InitOutput, ShardsCollection, SyncInitInput, decode, __wbg_init as default, encode, initSync };
121
+ }
122
+ /* tslint:disable */
123
+ /* eslint-disable */
124
+ declare function encode(recovery_count: number, shards: ShardsCollection): ShardsCollection;
125
+ declare function decode(original_count: number, recovery_count: number, shards: ShardsCollection): ShardsCollection;
126
+ /**
127
+ * Collection of shards (either input or output).
128
+ *
129
+ * To efficiently pass data between JS and WASM all of the shards
130
+ * are passed as one big vector of bytes.
131
+ * It's assumed that every shard has the same length (`shard_len`).
132
+ * If the shards are NOT passed in the exact order they were created
133
+ * it's possible to pass `indices` array.
134
+ * A value of `indices` array at position `idx` is the shard index
135
+ * that resides at `[ idx * shard_len .. idx * shard_len + shard_len )`
136
+ * in `data` array.
137
+ *
138
+ * This collection is only used to get the data from JS or pass the data back.
139
+ * Internally we convert it to [`RsShardsCollection`], which copies
140
+ * the memory to/from WASM.
141
+ */
99
142
  declare class ShardsCollection {
100
143
  free(): void;
144
+ constructor(shard_len: number, data: Uint8Array, indices?: Uint16Array | null);
101
145
  /**
102
- * @param {number} shard_len
103
- * @param {Uint8Array} data
104
- * @param {Uint16Array | undefined} [indices]
105
- */
106
- constructor(shard_len: number, data: Uint8Array, indices?: Uint16Array);
107
- /**
108
- * Extract the `indices` from this shards container.
109
- *
110
- * Should be called on the JS side to avoid copying.
111
- * NOTE that subsequent calls to that method will return `None`.
112
- * @returns {Uint16Array | undefined}
113
- */
146
+ * Extract the `indices` from this shards container.
147
+ *
148
+ * Should be called on the JS side to avoid copying.
149
+ * NOTE that subsequent calls to that method will return `None`.
150
+ */
114
151
  take_indices(): Uint16Array | undefined;
115
152
  /**
116
- * Take the underlying `data` to the JS side.
117
- *
118
- * NOTE this object is destroyed after the data is consumed,
119
- * so make sure to [`take_indices`] first.
120
- * @returns {Uint8Array}
121
- */
153
+ * Take the underlying `data` to the JS side.
154
+ *
155
+ * NOTE this object is destroyed after the data is consumed,
156
+ * so make sure to [`take_indices`] first.
157
+ */
122
158
  take_data(): Uint8Array;
123
159
  /**
124
- * Number of shards within the collection.
125
- */
160
+ * Number of shards within the collection.
161
+ */
126
162
  length: number;
127
163
  /**
128
- * The length of each shard.
129
- */
164
+ * The length of each shard.
165
+ */
130
166
  shard_len: number;
131
167
  }
168
+ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
169
+ interface InitOutput {
170
+ readonly memory: WebAssembly.Memory;
171
+ readonly __wbg_shardscollection_free: (a: number, b: number) => void;
172
+ readonly __wbg_get_shardscollection_length: (a: number) => number;
173
+ readonly __wbg_set_shardscollection_length: (a: number, b: number) => void;
174
+ readonly __wbg_get_shardscollection_shard_len: (a: number) => number;
175
+ readonly __wbg_set_shardscollection_shard_len: (a: number, b: number) => void;
176
+ readonly shardscollection_new: (a: number, b: any, c: number) => number;
177
+ readonly shardscollection_take_indices: (a: number) => any;
178
+ readonly shardscollection_take_data: (a: number) => any;
179
+ readonly encode: (a: number, b: number) => [number, number, number];
180
+ readonly decode: (a: number, b: number, c: number) => [number, number, number];
181
+ readonly __wbindgen_export_0: WebAssembly.Table;
182
+ readonly __externref_table_alloc: () => number;
183
+ readonly __externref_table_dealloc: (a: number) => void;
184
+ readonly __wbindgen_start: () => void;
185
+ }
186
+ type SyncInitInput = BufferSource | WebAssembly.Module;
187
+ /**
188
+ * Instantiates the given `module`, which can either be bytes or
189
+ * a precompiled `WebAssembly.Module`.
190
+ *
191
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
192
+ *
193
+ * @returns {InitOutput}
194
+ */
195
+ declare function initSync(module: {
196
+ module: SyncInitInput;
197
+ } | SyncInitInput): InitOutput;
198
+
199
+ /**
200
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
201
+ * for everything else, calls `WebAssembly.instantiate` directly.
202
+ *
203
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
204
+ *
205
+ * @returns {Promise<InitOutput>}
206
+ */
207
+ declare function __wbg_init(module_or_path?: {
208
+ module_or_path: InitInput | Promise<InitInput>;
209
+ } | InitInput | Promise<InitInput>): Promise<InitOutput>;
210
+ //#endregion
211
+ //#region native/index.d.ts
212
+ declare function initAll(): Promise<void>;
213
+ declare const init: {
214
+ bandersnatch: () => Promise<InitOutput$2>;
215
+ ed25519: () => Promise<InitOutput$1>;
216
+ reedSolomon: () => Promise<InitOutput>;
217
+ };
132
218
  //#endregion
133
- export { bandersnatch_d_exports as bandersnatch, ed25519_wasm_d_exports as ed25519, reed_solomon_wasm_d_exports as reedSolomon };
219
+ export { bandersnatch_d_exports as bandersnatch, ed25519_wasm_d_exports as ed25519, init, initAll, reed_solomon_wasm_d_exports as reedSolomon };