@typeberry/native 0.0.1-b29cbf6 → 0.0.4-22d630b

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