@typeberry/native 0.0.1-64ee5ed → 0.0.1-6e4ec82

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.
@@ -0,0 +1,15 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all) __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true
7
+ });
8
+ };
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
12
+ });
13
+
14
+ //#endregion
15
+ export { __export, __require };
package/index.d.ts ADDED
@@ -0,0 +1,167 @@
1
+ declare namespace bandersnatch_d_exports {
2
+ export { batch_verify_tickets, derive_public_key, ring_commitment, verify_seal };
3
+ }
4
+ /* tslint:disable */
5
+ /* eslint-disable */
6
+ /**
7
+ * @param {Uint8Array} keys
8
+ * @returns {Uint8Array}
9
+ */
10
+ declare function ring_commitment(keys: Uint8Array): Uint8Array;
11
+ /**
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
+ */
18
+ declare function derive_public_key(seed: Uint8Array): Uint8Array;
19
+ /**
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
+ */
31
+ declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
32
+ /**
33
+ * Verify multiple tickets at once as defined in:
34
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
35
+ *
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}
41
+ */
42
+ declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
43
+ declare namespace ed25519_wasm_d_exports {
44
+ export { InitInput, InitOutput, SyncInitInput, __wbg_init as default, initSync, verify_ed25519, verify_ed25519_batch };
45
+ }
46
+ /* tslint:disable */
47
+ /* eslint-disable */
48
+ /**
49
+ *
50
+ * * Verify Ed25519 signatures one by one using strict verification.
51
+ * *
52
+ * * This function is slower but does strict verification.
53
+ *
54
+ */
55
+ declare function verify_ed25519(data: Uint8Array): Uint8Array;
56
+ /**
57
+ *
58
+ * * Verify Ed25519 signatures using build-in batch verification.
59
+ * *
60
+ * * This function is faster but does not do strict verification.
61
+ * * See https://crates.io/crates/ed25519-dalek#batch-verification for more information.
62
+ *
63
+ */
64
+ declare function verify_ed25519_batch(data: Uint8Array): boolean;
65
+ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
66
+ interface InitOutput {
67
+ readonly memory: WebAssembly.Memory;
68
+ readonly verify_ed25519: (a: number, b: number) => [number, number];
69
+ readonly verify_ed25519_batch: (a: number, b: number) => number;
70
+ readonly __wbindgen_export_0: WebAssembly.Table;
71
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
72
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
73
+ readonly __wbindgen_start: () => void;
74
+ }
75
+ type SyncInitInput = BufferSource | WebAssembly.Module;
76
+ /**
77
+ * Instantiates the given `module`, which can either be bytes or
78
+ * a precompiled `WebAssembly.Module`.
79
+ *
80
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
81
+ *
82
+ * @returns {InitOutput}
83
+ */
84
+ declare function initSync(module: {
85
+ module: SyncInitInput;
86
+ } | SyncInitInput): InitOutput;
87
+
88
+ /**
89
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
90
+ * for everything else, calls `WebAssembly.instantiate` directly.
91
+ *
92
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
93
+ *
94
+ * @returns {Promise<InitOutput>}
95
+ */
96
+ declare function __wbg_init(module_or_path?: {
97
+ module_or_path: InitInput | Promise<InitInput>;
98
+ } | InitInput | Promise<InitInput>): Promise<InitOutput>;
99
+ declare namespace reed_solomon_wasm_d_exports {
100
+ export { ShardsCollection, decode, encode };
101
+ }
102
+ /* tslint:disable */
103
+ /* eslint-disable */
104
+ /**
105
+ * @param {number} recovery_count
106
+ * @param {ShardsCollection} shards
107
+ * @returns {ShardsCollection}
108
+ */
109
+ declare function encode(recovery_count: number, shards: ShardsCollection): ShardsCollection;
110
+ /**
111
+ * @param {number} original_count
112
+ * @param {number} recovery_count
113
+ * @param {ShardsCollection} shards
114
+ * @returns {ShardsCollection}
115
+ */
116
+ declare function decode(original_count: number, recovery_count: number, shards: ShardsCollection): ShardsCollection;
117
+ /**
118
+ * Collection of shards (either input or output).
119
+ *
120
+ * To efficiently pass data between JS and WASM all of the shards
121
+ * are passed as one big vector of bytes.
122
+ * It's assumed that every shard has the same length (`shard_len`).
123
+ * If the shards are NOT passed in the exact order they were created
124
+ * it's possible to pass `indices` array.
125
+ * A value of `indices` array at position `idx` is the shard index
126
+ * that resides at `[ idx * shard_len .. idx * shard_len + shard_len )`
127
+ * in `data` array.
128
+ *
129
+ * This collection is only used to get the data from JS or pass the data back.
130
+ * Internally we convert it to [`RsShardsCollection`], which copies
131
+ * the memory to/from WASM.
132
+ */
133
+ declare class ShardsCollection {
134
+ free(): void;
135
+ /**
136
+ * @param {number} shard_len
137
+ * @param {Uint8Array} data
138
+ * @param {Uint16Array | undefined} [indices]
139
+ */
140
+ constructor(shard_len: number, data: Uint8Array, indices?: Uint16Array);
141
+ /**
142
+ * Extract the `indices` from this shards container.
143
+ *
144
+ * Should be called on the JS side to avoid copying.
145
+ * NOTE that subsequent calls to that method will return `None`.
146
+ * @returns {Uint16Array | undefined}
147
+ */
148
+ take_indices(): Uint16Array | undefined;
149
+ /**
150
+ * Take the underlying `data` to the JS side.
151
+ *
152
+ * NOTE this object is destroyed after the data is consumed,
153
+ * so make sure to [`take_indices`] first.
154
+ * @returns {Uint8Array}
155
+ */
156
+ take_data(): Uint8Array;
157
+ /**
158
+ * Number of shards within the collection.
159
+ */
160
+ length: number;
161
+ /**
162
+ * The length of each shard.
163
+ */
164
+ shard_len: number;
165
+ }
166
+ //#endregion
167
+ export { bandersnatch_d_exports as bandersnatch, ed25519_wasm_d_exports as ed25519, reed_solomon_wasm_d_exports as reedSolomon };
package/index.js CHANGED
@@ -1,17 +1,5 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all) __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true
7
- });
8
- };
9
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
12
- });
1
+ import { __export, __require } from "./chunk-CPmnHcRE.js";
13
2
 
14
- //#endregion
15
3
  //#region \0wasmHelpers.js
16
4
  function _loadWasmModule(sync, filepath, src, imports) {
17
5
  function _instantiateOrCompile(source, imports$1, stream) {
@@ -56,7 +44,7 @@ function bandersnatch_bg_default(imports) {
56
44
  //#endregion
57
45
  //#region bandersnatch/pkg/bandersnatch_bg.js
58
46
  let wasm$2;
59
- function __wbg_set_wasm$2(val) {
47
+ function __wbg_set_wasm$1(val) {
60
48
  wasm$2 = val;
61
49
  }
62
50
  let cachedUint8Memory0 = null;
@@ -186,28 +174,24 @@ function batch_verify_tickets(keys, tickets_data, vrf_input_data_len) {
186
174
  //#region bandersnatch/pkg/bandersnatch.js
187
175
  var bandersnatch_exports = {};
188
176
  __export(bandersnatch_exports, {
189
- __wbg_set_wasm: () => __wbg_set_wasm$2,
177
+ __wbg_set_wasm: () => __wbg_set_wasm$1,
190
178
  batch_verify_tickets: () => batch_verify_tickets,
191
179
  derive_public_key: () => derive_public_key,
192
180
  ring_commitment: () => ring_commitment,
193
181
  verify_seal: () => verify_seal
194
182
  });
195
- __wbg_set_wasm$2(bandersnatch_bg_exports);
183
+ __wbg_set_wasm$1(bandersnatch_bg_exports);
196
184
 
197
185
  //#endregion
198
- //#region ed25519/pkg/ed25519_wasm_bg.wasm
199
- var ed25519_wasm_bg_exports = {};
200
- __export(ed25519_wasm_bg_exports, { default: () => ed25519_wasm_bg_default });
201
- function ed25519_wasm_bg_default(imports) {
202
- return _loadWasmModule(0, "5941c010ea533d2f.wasm", null, imports);
203
- }
204
-
205
- //#endregion
206
- //#region ed25519/pkg/ed25519_wasm_bg.js
186
+ //#region ed25519/pkg/ed25519_wasm.js
187
+ var ed25519_wasm_exports = {};
188
+ __export(ed25519_wasm_exports, {
189
+ default: () => ed25519_wasm_default,
190
+ initSync: () => initSync,
191
+ verify_ed25519: () => verify_ed25519,
192
+ verify_ed25519_batch: () => verify_ed25519_batch
193
+ });
207
194
  let wasm$1;
208
- function __wbg_set_wasm$1(val) {
209
- wasm$1 = val;
210
- }
211
195
  let cachedUint8ArrayMemory0$1 = null;
212
196
  function getUint8ArrayMemory0$1() {
213
197
  if (cachedUint8ArrayMemory0$1 === null || cachedUint8ArrayMemory0$1.byteLength === 0) cachedUint8ArrayMemory0$1 = new Uint8Array(wasm$1.memory.buffer);
@@ -256,27 +240,69 @@ function verify_ed25519_batch(data) {
256
240
  const len0 = WASM_VECTOR_LEN;
257
241
  return wasm$1.verify_ed25519_batch(ptr0, len0) !== 0;
258
242
  }
259
- function __wbindgen_init_externref_table() {
260
- const table = wasm$1.__wbindgen_export_0;
261
- const offset = table.grow(4);
262
- table.set(0, void 0);
263
- table.set(offset + 0, void 0);
264
- table.set(offset + 1, null);
265
- table.set(offset + 2, true);
266
- table.set(offset + 3, false);
243
+ async function __wbg_load(module$1, imports) {
244
+ if (typeof Response === "function" && module$1 instanceof Response) {
245
+ if (typeof WebAssembly.instantiateStreaming === "function") try {
246
+ return await WebAssembly.instantiateStreaming(module$1, imports);
247
+ } catch (e) {
248
+ if (module$1.headers.get("Content-Type") != "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
249
+ else throw e;
250
+ }
251
+ const bytes = await module$1.arrayBuffer();
252
+ return await WebAssembly.instantiate(bytes, imports);
253
+ } else {
254
+ const instance = await WebAssembly.instantiate(module$1, imports);
255
+ if (instance instanceof WebAssembly.Instance) return {
256
+ instance,
257
+ module: module$1
258
+ };
259
+ else return instance;
260
+ }
267
261
  }
268
-
269
- //#endregion
270
- //#region ed25519/pkg/ed25519_wasm.js
271
- var ed25519_wasm_exports = {};
272
- __export(ed25519_wasm_exports, {
273
- __wbg_set_wasm: () => __wbg_set_wasm$1,
274
- __wbindgen_init_externref_table: () => __wbindgen_init_externref_table,
275
- verify_ed25519: () => verify_ed25519,
276
- verify_ed25519_batch: () => verify_ed25519_batch
277
- });
278
- __wbg_set_wasm$1(ed25519_wasm_bg_exports);
279
- (void 0)();
262
+ function __wbg_get_imports() {
263
+ const imports = {};
264
+ imports.wbg = {};
265
+ imports.wbg.__wbindgen_init_externref_table = function() {
266
+ const table = wasm$1.__wbindgen_export_0;
267
+ const offset = table.grow(4);
268
+ table.set(0, void 0);
269
+ table.set(offset + 0, void 0);
270
+ table.set(offset + 1, null);
271
+ table.set(offset + 2, true);
272
+ table.set(offset + 3, false);
273
+ };
274
+ return imports;
275
+ }
276
+ function __wbg_init_memory(imports, memory) {}
277
+ function __wbg_finalize_init(instance, module$1) {
278
+ wasm$1 = instance.exports;
279
+ __wbg_init.__wbindgen_wasm_module = module$1;
280
+ cachedUint8ArrayMemory0$1 = null;
281
+ wasm$1.__wbindgen_start();
282
+ return wasm$1;
283
+ }
284
+ function initSync(module$1) {
285
+ if (wasm$1 !== void 0) return wasm$1;
286
+ if (typeof module$1 !== "undefined") if (Object.getPrototypeOf(module$1) === Object.prototype) ({module: module$1} = module$1);
287
+ else console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
288
+ const imports = __wbg_get_imports();
289
+ __wbg_init_memory(imports);
290
+ if (!(module$1 instanceof WebAssembly.Module)) module$1 = new WebAssembly.Module(module$1);
291
+ const instance = new WebAssembly.Instance(module$1, imports);
292
+ return __wbg_finalize_init(instance, module$1);
293
+ }
294
+ async function __wbg_init(module_or_path) {
295
+ if (wasm$1 !== void 0) return wasm$1;
296
+ if (typeof module_or_path !== "undefined") if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
297
+ else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
298
+ if (typeof module_or_path === "undefined") module_or_path = new URL("ed25519_wasm_bg.wasm", import.meta.url);
299
+ const imports = __wbg_get_imports();
300
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) module_or_path = fetch(module_or_path);
301
+ __wbg_init_memory(imports);
302
+ const { instance, module: module$1 } = await __wbg_load(await module_or_path, imports);
303
+ return __wbg_finalize_init(instance, module$1);
304
+ }
305
+ var ed25519_wasm_default = __wbg_init;
280
306
 
281
307
  //#endregion
282
308
  //#region reed-solomon/pkg/reed_solomon_wasm_bg.wasm
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeberry/native",
3
- "version": "0.0.1-64ee5ed",
3
+ "version": "0.0.1-6e4ec82",
4
4
  "main": "./index.js",
5
5
  "type": "module",
6
6
  "author": "Fluffy Labs",
Binary file