@typeberry/native 0.0.4-68ac75d → 0.0.4-92ff682

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 +89 -27
  2. package/index.js +222 -72
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,18 +1,82 @@
1
1
  declare namespace bandersnatch_d_exports {
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 };
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, generate_seal, initSync$2 as initSync, ring_commitment, verify_header_seals, verify_seal, vrf_output_hash };
3
3
  }
4
4
  /* tslint:disable */
5
5
  /* eslint-disable */
6
+ /**
7
+ * Generate seal that is verifiable using `verify_seal` function.
8
+ *
9
+ * # Arguments
10
+ * * `secret_seed` - Seed used to derive the secret key
11
+ * * `input` - VRF input data
12
+ * * `aux_data` - Auxiliary data for the VRF proof
13
+ *
14
+ * # Returns
15
+ * A byte vector with the following format:
16
+ * - On success (97 bytes):
17
+ * - Byte 0: Status code `0` (RESULT_OK)
18
+ * - Bytes 1-32: Serialized VRF output (32 bytes, compressed) NOTE: not output hash!
19
+ * - Bytes 33-96: Serialized IETF VRF proof (64 bytes, compressed)
20
+ * - On error (1 byte):
21
+ * - Byte 0: Status code `1` (RESULT_ERR)
22
+ *
23
+ * Returns an error if the input cannot be converted to a valid VRF input point
24
+ * or if serialization of the output or proof fails.
25
+ */
26
+ declare function generate_seal(secret_seed: Uint8Array, input: Uint8Array, aux_data: Uint8Array): Uint8Array;
27
+ /**
28
+ * Verify multiple tickets at once as defined in:
29
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
30
+ *
31
+ * NOTE: the aux_data of VRF function is empty!
32
+ */
33
+ declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
34
+ /**
35
+ * Compute VRF output hash from a secret seed and input data.
36
+ *
37
+ * This function derives a deterministic VRF output hash without generating a proof.
38
+ * Unlike `generate_seal`, this produces only the output hash, not a verifiable signature.
39
+ *
40
+ * # Arguments
41
+ * * `secret_seed` - Seed used to derive the secret key
42
+ * * `input` - VRF input data to be hashed
43
+ *
44
+ * # Returns
45
+ * A byte vector with the following format:
46
+ * - On success (33 bytes):
47
+ * - Byte 0: Status code `0` (RESULT_OK)
48
+ * - Bytes 1-32: VRF output hash (32 bytes)
49
+ * - On error (1 byte):
50
+ * - Byte 0: Status code `1` (RESULT_ERR)
51
+ *
52
+ * Returns an error if the input cannot be converted to a valid VRF input point.
53
+ */
54
+ declare function vrf_output_hash(secret_seed: Uint8Array, input: Uint8Array): Uint8Array;
6
55
  /**
7
56
  * Generate ring commitment given concatenation of ring keys.
8
57
  */
9
58
  declare function ring_commitment(keys: Uint8Array): Uint8Array;
10
59
  /**
11
- * Derive Private and Public Key from Seed
60
+ * Verifies both header seal and entropy source in a single call.
12
61
  *
13
- * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
62
+ * This combines seal verification (block author's VRF proof) with entropy
63
+ * verification (randomness derivation) as required by the JAM protocol.
64
+ *
65
+ * # Arguments
66
+ * * `signer_key` - Signer's public key (32 bytes, compressed)
67
+ * * `seal_data` - VRF signature for the seal (96 bytes)
68
+ * * `seal_payload` - VRF input data for seal verification
69
+ * * `unsealed_header` - Auxiliary data (unsealed header bytes)
70
+ * * `entropy_data` - VRF signature for entropy (96 bytes)
71
+ * * `entropy_prefix` - Prefix bytes for entropy payload construction
72
+ *
73
+ * # Returns
74
+ * A 65-byte vector:
75
+ * - Byte 0: Status code (`0` = success, `1` = error)
76
+ * - Bytes 1-32: Seal VRF output hash (zeros on error)
77
+ * - Bytes 33-64: Entropy VRF output hash (zeros on error)
14
78
  */
15
- declare function derive_public_key(seed: Uint8Array): Uint8Array;
79
+ declare function verify_header_seals(signer_key: Uint8Array, seal_data: Uint8Array, seal_payload: Uint8Array, unsealed_header: Uint8Array, entropy_data: Uint8Array, entropy_prefix: Uint8Array): Uint8Array;
16
80
  /**
17
81
  * Seal verification as defined in:
18
82
  * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
@@ -21,19 +85,21 @@ declare function derive_public_key(seed: Uint8Array): Uint8Array;
21
85
  */
22
86
  declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
23
87
  /**
24
- * Verify multiple tickets at once as defined in:
25
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
88
+ * Derive Private and Public Key from Seed
26
89
  *
27
- * NOTE: the aux_data of VRF function is empty!
90
+ * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
28
91
  */
29
- declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
92
+ declare function derive_public_key(seed: Uint8Array): Uint8Array;
30
93
  type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
31
94
  interface InitOutput$2 {
32
95
  readonly memory: WebAssembly.Memory;
33
- readonly ring_commitment: (a: number, b: number) => [number, number];
96
+ readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
34
97
  readonly derive_public_key: (a: number, b: number) => [number, number];
98
+ readonly generate_seal: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
99
+ readonly ring_commitment: (a: number, b: number) => [number, number];
100
+ readonly verify_header_seals: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
35
101
  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];
102
+ readonly vrf_output_hash: (a: number, b: number, c: number, d: number) => [number, number];
37
103
  readonly __wbindgen_export_0: WebAssembly.Table;
38
104
  readonly __wbindgen_malloc: (a: number, b: number) => number;
39
105
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -70,18 +136,14 @@ declare namespace ed25519_wasm_d_exports {
70
136
  /* eslint-disable */
71
137
  /**
72
138
  *
73
- * * Verify Ed25519 signatures one by one using strict verification.
139
+ * * Verify Ed25519 signatures one by one.
74
140
  * *
75
- * * This function is slower but does strict verification.
76
- *
141
+ * * ed25519-consensus always does strict verification (ZIP-215 compatible).
77
142
  */
78
143
  declare function verify_ed25519(data: Uint8Array): Uint8Array;
79
144
  /**
80
145
  *
81
- * * Verify Ed25519 signatures using build-in batch verification.
82
- * *
83
- * * This function is faster but does not do strict verification.
84
- * * See https://crates.io/crates/ed25519-dalek#batch-verification for more information.
146
+ * * ed25519-consensus doesn't have built-in batch verification.
85
147
  *
86
148
  */
87
149
  declare function verify_ed25519_batch(data: Uint8Array): boolean;
@@ -124,8 +186,8 @@ declare namespace reed_solomon_wasm_d_exports {
124
186
  }
125
187
  /* tslint:disable */
126
188
  /* eslint-disable */
127
- declare function encode(recovery_count: number, shards: ShardsCollection): ShardsCollection;
128
189
  declare function decode(original_count: number, recovery_count: number, shards: ShardsCollection): ShardsCollection;
190
+ declare function encode(recovery_count: number, shards: ShardsCollection): ShardsCollection;
129
191
  /**
130
192
  * Collection of shards (either input or output).
131
193
  *
@@ -144,7 +206,6 @@ declare function decode(original_count: number, recovery_count: number, shards:
144
206
  */
145
207
  declare class ShardsCollection {
146
208
  free(): void;
147
- constructor(shard_len: number, data: Uint8Array, indices?: Uint16Array | null);
148
209
  /**
149
210
  * Extract the `indices` from this shards container.
150
211
  *
@@ -152,6 +213,7 @@ declare class ShardsCollection {
152
213
  * NOTE that subsequent calls to that method will return `None`.
153
214
  */
154
215
  take_indices(): Uint16Array | undefined;
216
+ constructor(shard_len: number, data: Uint8Array, indices?: Uint16Array | null);
155
217
  /**
156
218
  * Take the underlying `data` to the JS side.
157
219
  *
@@ -171,16 +233,16 @@ declare class ShardsCollection {
171
233
  type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
172
234
  interface InitOutput {
173
235
  readonly memory: WebAssembly.Memory;
174
- readonly __wbg_shardscollection_free: (a: number, b: number) => void;
175
236
  readonly __wbg_get_shardscollection_length: (a: number) => number;
176
- readonly __wbg_set_shardscollection_length: (a: number, b: number) => void;
177
237
  readonly __wbg_get_shardscollection_shard_len: (a: number) => number;
238
+ readonly __wbg_set_shardscollection_length: (a: number, b: number) => void;
178
239
  readonly __wbg_set_shardscollection_shard_len: (a: number, b: number) => void;
240
+ readonly __wbg_shardscollection_free: (a: number, b: number) => void;
241
+ readonly decode: (a: number, b: number, c: number) => [number, number, number];
242
+ readonly encode: (a: number, b: number) => [number, number, number];
179
243
  readonly shardscollection_new: (a: number, b: any, c: number) => number;
180
- readonly shardscollection_take_indices: (a: number) => any;
181
244
  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];
245
+ readonly shardscollection_take_indices: (a: number) => any;
184
246
  readonly __wbindgen_export_0: WebAssembly.Table;
185
247
  readonly __externref_table_alloc: () => number;
186
248
  readonly __externref_table_dealloc: (a: number) => void;
@@ -214,9 +276,9 @@ declare function __wbg_init(module_or_path?: {
214
276
  //#region native/index.d.ts
215
277
  declare function initAll(): Promise<void>;
216
278
  declare const init: {
217
- bandersnatch: () => Promise<InitOutput$2>;
218
- ed25519: () => Promise<InitOutput$1>;
219
- reedSolomon: () => Promise<InitOutput>;
279
+ bandersnatch: any;
280
+ ed25519: any;
281
+ reedSolomon: any;
220
282
  };
221
283
  //#endregion
222
284
  export { bandersnatch_d_exports as bandersnatch, ed25519_wasm_d_exports as ed25519, init, initAll, reed_solomon_wasm_d_exports as reedSolomon };