@aztec/foundation 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec7ac5448
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/dest/array/sorted_array.d.ts +6 -1
- package/dest/array/sorted_array.d.ts.map +1 -1
- package/dest/array/sorted_array.js +18 -15
- package/dest/branded-types/slot.d.ts +4 -1
- package/dest/branded-types/slot.d.ts.map +1 -1
- package/dest/branded-types/slot.js +3 -0
- package/dest/buffer/buffer16.d.ts +3 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer32.d.ts +3 -1
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/index.d.ts +2 -1
- package/dest/buffer/index.d.ts.map +1 -1
- package/dest/buffer/index.js +1 -0
- package/dest/buffer/utils.d.ts +3 -0
- package/dest/buffer/utils.d.ts.map +1 -0
- package/dest/buffer/utils.js +7 -0
- package/dest/collection/array.d.ts +9 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +39 -0
- package/dest/collection/index.d.ts +2 -1
- package/dest/collection/index.d.ts.map +1 -1
- package/dest/collection/index.js +1 -0
- package/dest/collection/lru_set.d.ts +35 -0
- package/dest/collection/lru_set.d.ts.map +1 -0
- package/dest/collection/lru_set.js +95 -0
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +1 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +15 -0
- package/dest/config/network_config.d.ts +19 -1
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +4 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +2 -0
- package/dest/crypto/aes128/index.d.ts +2 -1
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +11 -2
- package/dest/crypto/bls/bn254_keystore.d.ts +1 -10
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +0 -17
- package/dest/crypto/poseidon/index.d.ts +1 -1
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +40 -33
- package/dest/crypto/random/randomness_singleton.d.ts +4 -3
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/random/randomness_singleton.js +4 -4
- package/dest/crypto/secp256k1-signer/utils.d.ts +12 -1
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +26 -0
- package/dest/curves/bn254/field.d.ts +2 -1
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +5 -2
- package/dest/curves/grumpkin/point.d.ts +4 -4
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/curves/grumpkin/point.js +7 -4
- package/dest/eth-signature/eth_signature.d.ts +2 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +7 -2
- package/dest/fifo/fifo_frame_reader.d.ts +41 -0
- package/dest/fifo/fifo_frame_reader.d.ts.map +1 -0
- package/dest/fifo/fifo_frame_reader.js +74 -0
- package/dest/fifo/index.d.ts +2 -0
- package/dest/fifo/index.d.ts.map +1 -0
- package/dest/fifo/index.js +1 -0
- package/dest/jest/setup.js +28 -1
- package/dest/json-rpc/client/fetch.d.ts +1 -1
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +4 -3
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +2 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +1 -1
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +5 -3
- package/dest/json-rpc/server/api_key_auth.d.ts +19 -0
- package/dest/json-rpc/server/api_key_auth.d.ts.map +1 -0
- package/dest/json-rpc/server/api_key_auth.js +57 -0
- package/dest/json-rpc/server/index.d.ts +2 -1
- package/dest/json-rpc/server/index.d.ts.map +1 -1
- package/dest/json-rpc/server/index.js +1 -0
- package/dest/log/bigint-utils.d.ts +5 -0
- package/dest/log/bigint-utils.d.ts.map +1 -0
- package/dest/log/bigint-utils.js +21 -0
- package/dest/log/gcloud-logger-config.d.ts +1 -1
- package/dest/log/gcloud-logger-config.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.js +3 -0
- package/dest/log/libp2p_logger.d.ts +5 -2
- package/dest/log/libp2p_logger.d.ts.map +1 -1
- package/dest/log/libp2p_logger.js +14 -4
- package/dest/log/log-filters.d.ts +17 -4
- package/dest/log/log-filters.d.ts.map +1 -1
- package/dest/log/log-filters.js +26 -12
- package/dest/log/pino-logger-server.d.ts +9 -0
- package/dest/log/pino-logger-server.d.ts.map +1 -0
- package/dest/log/pino-logger-server.js +18 -0
- package/dest/log/pino-logger.d.ts +37 -8
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +137 -29
- package/dest/queue/base_memory_queue.d.ts +2 -2
- package/dest/queue/base_memory_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.js +1 -0
- package/dest/queue/semaphore.d.ts +5 -1
- package/dest/queue/semaphore.d.ts.map +1 -1
- package/dest/retry/index.d.ts +12 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +21 -0
- package/dest/schemas/api.d.ts +2 -2
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.d.ts +8 -1
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +13 -0
- package/dest/serialize/serialize.d.ts +19 -1
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +31 -0
- package/dest/sleep/index.d.ts +2 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +10 -1
- package/dest/string/index.js +1 -1
- package/dest/timer/date.d.ts +25 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +33 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/index.d.ts +1 -2
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/transport/transport_client.js +2 -2
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.js +5 -1
- package/dest/types/index.d.ts +3 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +3 -0
- package/package.json +24 -2
- package/src/array/sorted_array.ts +22 -17
- package/src/branded-types/slot.ts +5 -0
- package/src/buffer/buffer16.ts +3 -0
- package/src/buffer/buffer32.ts +3 -0
- package/src/buffer/index.ts +1 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +35 -0
- package/src/collection/index.ts +1 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/config/env_var.ts +61 -12
- package/src/config/index.ts +15 -0
- package/src/config/network_config.ts +3 -0
- package/src/config/network_name.ts +4 -1
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +0 -23
- package/src/crypto/poseidon/index.ts +42 -34
- package/src/crypto/random/randomness_singleton.ts +9 -5
- package/src/crypto/secp256k1-signer/utils.ts +32 -0
- package/src/curves/bn254/field.ts +6 -2
- package/src/curves/grumpkin/point.ts +6 -3
- package/src/eth-signature/eth_signature.ts +7 -1
- package/src/fifo/fifo_frame_reader.ts +98 -0
- package/src/fifo/index.ts +1 -0
- package/src/jest/setup.mjs +31 -1
- package/src/json-rpc/client/fetch.ts +4 -3
- package/src/json-rpc/client/safe_json_rpc_client.ts +2 -0
- package/src/json-rpc/client/undici.ts +5 -3
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/log/bigint-utils.ts +25 -0
- package/src/log/gcloud-logger-config.ts +5 -0
- package/src/log/libp2p_logger.ts +12 -5
- package/src/log/log-filters.ts +29 -11
- package/src/log/pino-logger-server.ts +25 -0
- package/src/log/pino-logger.ts +160 -39
- package/src/queue/base_memory_queue.ts +1 -1
- package/src/queue/batch_queue.ts +1 -0
- package/src/queue/semaphore.ts +5 -0
- package/src/retry/index.ts +30 -0
- package/src/schemas/api.ts +4 -1
- package/src/serialize/buffer_reader.ts +15 -0
- package/src/serialize/serialize.ts +32 -0
- package/src/sleep/index.ts +10 -1
- package/src/string/index.ts +1 -1
- package/src/timer/date.ts +48 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
- package/src/transport/index.ts +0 -1
- package/src/transport/transport_client.ts +2 -2
- package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
- package/src/types/index.ts +5 -0
- package/dest/crypto/serialize.d.ts +0 -51
- package/dest/crypto/serialize.d.ts.map +0 -1
- package/dest/crypto/serialize.js +0 -68
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
- package/src/crypto/serialize.ts +0 -85
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
|
@@ -21,34 +21,39 @@ export function dedupeSortedArray<T>(arr: T[], cmp: Cmp<T>): void {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function insertIntoSortedArray<T>(arr: T[], item: T, cmp: Cmp<T>, allowDuplicates = true): boolean {
|
|
24
|
+
const index = findInsertionIndexInSortedArray(arr, item, cmp);
|
|
25
|
+
|
|
26
|
+
if (!allowDuplicates) {
|
|
27
|
+
// Check element before insertion point (upper bound returns index after equal elements)
|
|
28
|
+
if (index > 0 && cmp(arr[index - 1], item) === 0) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
arr.splice(index, 0, item);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Finds the index where needle would be inserted to maintain sorted order.
|
|
39
|
+
* Returns the count of elements less than or equal to needle.
|
|
40
|
+
*/
|
|
41
|
+
export function findInsertionIndexInSortedArray<T, N>(values: T[], needle: N, cmp: (a: T, b: N) => number): number {
|
|
24
42
|
let start = 0;
|
|
25
|
-
let end =
|
|
43
|
+
let end = values.length;
|
|
26
44
|
|
|
27
45
|
while (start < end) {
|
|
28
46
|
const mid = start + (((end - start) / 2) | 0);
|
|
29
|
-
const comparison = cmp(
|
|
47
|
+
const comparison = cmp(values[mid], needle);
|
|
30
48
|
|
|
31
|
-
if (comparison
|
|
49
|
+
if (comparison <= 0) {
|
|
32
50
|
start = mid + 1;
|
|
33
51
|
} else {
|
|
34
52
|
end = mid;
|
|
35
53
|
}
|
|
36
54
|
}
|
|
37
55
|
|
|
38
|
-
|
|
39
|
-
// Check element at insertion point
|
|
40
|
-
if (start < arr.length && cmp(arr[start], item) === 0) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Check element before insertion point (in case we landed after duplicates)
|
|
45
|
-
if (start > 0 && cmp(arr[start - 1], item) === 0) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
arr.splice(start, 0, item);
|
|
51
|
-
return true;
|
|
56
|
+
return start;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
export function findIndexInSortedArray<T, N>(values: T[], needle: N, cmp: (a: T, b: N) => number): number {
|
|
@@ -73,6 +73,11 @@ SlotNumber.isValid = function (value: unknown): value is SlotNumber {
|
|
|
73
73
|
return typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/** Increments a SlotNumber by a given value. */
|
|
77
|
+
SlotNumber.add = function (sn: SlotNumber, increment: number): SlotNumber {
|
|
78
|
+
return SlotNumber(sn + increment);
|
|
79
|
+
};
|
|
80
|
+
|
|
76
81
|
/**
|
|
77
82
|
* The zero slot value.
|
|
78
83
|
*/
|
package/src/buffer/buffer16.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { bufferToHex } from '../string/index.js';
|
|
|
10
10
|
* A class representing a 16 byte Buffer.
|
|
11
11
|
*/
|
|
12
12
|
export class Buffer16 {
|
|
13
|
+
/** Branding to prevent structural compatibility with Buffer32. */
|
|
14
|
+
declare readonly __brand: 'Buffer16';
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* The size of the hash in bytes.
|
|
15
18
|
*/
|
package/src/buffer/buffer32.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { bufferToHex } from '../string/index.js';
|
|
|
10
10
|
* A class representing a 32 byte Buffer.
|
|
11
11
|
*/
|
|
12
12
|
export class Buffer32 {
|
|
13
|
+
/** Branding to prevent structural compatibility with Buffer16. */
|
|
14
|
+
declare readonly __brand: 'Buffer32';
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* The size of the hash in bytes.
|
|
15
18
|
*/
|
package/src/buffer/index.ts
CHANGED
package/src/collection/array.ts
CHANGED
|
@@ -250,6 +250,27 @@ export function chunk<T>(items: T[], chunkSize: number): T[][] {
|
|
|
250
250
|
return chunks;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Splits the given array into chunks of the given size, wrapping around to the beginning
|
|
255
|
+
* if the last chunk would be smaller than the requested size.
|
|
256
|
+
* Returns empty array for empty input. Returns single chunk with all items if chunkSize <= 0.
|
|
257
|
+
*/
|
|
258
|
+
export function chunkWrapAround<T>(items: T[], chunkSize: number): T[][] {
|
|
259
|
+
if (items.length === 0) {
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
if (chunkSize <= 0 || items.length <= chunkSize) {
|
|
263
|
+
return [items];
|
|
264
|
+
}
|
|
265
|
+
const remainder = items.length % chunkSize;
|
|
266
|
+
if (remainder === 0) {
|
|
267
|
+
return chunk(items, chunkSize);
|
|
268
|
+
}
|
|
269
|
+
const wrapAroundCount = chunkSize - remainder;
|
|
270
|
+
const wrappedItems = [...items, ...items.slice(0, wrapAroundCount)];
|
|
271
|
+
return chunk(wrappedItems, chunkSize);
|
|
272
|
+
}
|
|
273
|
+
|
|
253
274
|
const UNINITIALIZED = Symbol('uninitialized');
|
|
254
275
|
|
|
255
276
|
/**
|
|
@@ -294,3 +315,17 @@ export function partition<T>(items: T[], predicate: (item: T) => boolean): [T[],
|
|
|
294
315
|
}
|
|
295
316
|
return [pass, fail];
|
|
296
317
|
}
|
|
318
|
+
|
|
319
|
+
/** Partitions the given iterable into two arrays based on the predicate. */
|
|
320
|
+
export async function partitionAsync<T>(items: T[], predicate: (item: T) => Promise<boolean>): Promise<[T[], T[]]> {
|
|
321
|
+
const pass: T[] = [];
|
|
322
|
+
const fail: T[] = [];
|
|
323
|
+
for (const item of items) {
|
|
324
|
+
if (await predicate(item)) {
|
|
325
|
+
pass.push(item);
|
|
326
|
+
} else {
|
|
327
|
+
fail.push(item);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return [pass, fail];
|
|
331
|
+
}
|
package/src/collection/index.ts
CHANGED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** Node in a doubly-linked list used by {@link LruSet}. */
|
|
2
|
+
type LruNode<T> = {
|
|
3
|
+
value: T;
|
|
4
|
+
prev: LruNode<T> | undefined;
|
|
5
|
+
next: LruNode<T> | undefined;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A bounded set with Least Recently Used (LRU) eviction.
|
|
10
|
+
* Both {@link has} and {@link add} count as an access and refresh the entry's
|
|
11
|
+
* recency, so items that are actively checked stay in the set longest.
|
|
12
|
+
*
|
|
13
|
+
* Uses a doubly-linked list for O(1) ordering and a Map for O(1) lookup.
|
|
14
|
+
* Head = least recent, tail = most recent.
|
|
15
|
+
*/
|
|
16
|
+
export class LruSet<T> {
|
|
17
|
+
/** Map from value to its linked-list node for O(1) lookup. */
|
|
18
|
+
private readonly map = new Map<T, LruNode<T>>();
|
|
19
|
+
private head: LruNode<T> | undefined;
|
|
20
|
+
private tail: LruNode<T> | undefined;
|
|
21
|
+
|
|
22
|
+
constructor(private readonly maxSize: number) {
|
|
23
|
+
if (maxSize < 1) {
|
|
24
|
+
throw new Error('LruSet maxSize must be at least 1');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Number of entries in the set. */
|
|
29
|
+
get size(): number {
|
|
30
|
+
return this.map.size;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the item is in the set.
|
|
35
|
+
* Refreshes the item's recency so it becomes the most recently used.
|
|
36
|
+
*/
|
|
37
|
+
has(item: T): boolean {
|
|
38
|
+
const node = this.map.get(item);
|
|
39
|
+
if (!node) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
this.moveToTail(node);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Adds an item to the set. If the item already exists, refreshes its recency.
|
|
48
|
+
* If the set is at capacity, evicts the least recently used item.
|
|
49
|
+
*/
|
|
50
|
+
add(item: T): void {
|
|
51
|
+
const existing = this.map.get(item);
|
|
52
|
+
if (existing) {
|
|
53
|
+
this.moveToTail(existing);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.map.size >= this.maxSize) {
|
|
58
|
+
this.evictHead();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const node: LruNode<T> = { value: item, prev: this.tail, next: undefined };
|
|
62
|
+
if (this.tail) {
|
|
63
|
+
this.tail.next = node;
|
|
64
|
+
} else {
|
|
65
|
+
this.head = node;
|
|
66
|
+
}
|
|
67
|
+
this.tail = node;
|
|
68
|
+
this.map.set(item, node);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Removes all entries from the set. */
|
|
72
|
+
clear(): void {
|
|
73
|
+
this.map.clear();
|
|
74
|
+
this.head = undefined;
|
|
75
|
+
this.tail = undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Unlinks a node from its current position and relinks it at the tail. */
|
|
79
|
+
private moveToTail(node: LruNode<T>): void {
|
|
80
|
+
if (node === this.tail) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Unlink
|
|
85
|
+
if (node.prev) {
|
|
86
|
+
node.prev.next = node.next;
|
|
87
|
+
} else {
|
|
88
|
+
this.head = node.next;
|
|
89
|
+
}
|
|
90
|
+
if (node.next) {
|
|
91
|
+
node.next.prev = node.prev;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Relink at tail
|
|
95
|
+
node.prev = this.tail;
|
|
96
|
+
node.next = undefined;
|
|
97
|
+
if (this.tail) {
|
|
98
|
+
this.tail.next = node;
|
|
99
|
+
}
|
|
100
|
+
this.tail = node;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Evicts the head (least recently used) node. */
|
|
104
|
+
private evictHead(): void {
|
|
105
|
+
const oldHead = this.head!;
|
|
106
|
+
this.map.delete(oldHead.value);
|
|
107
|
+
|
|
108
|
+
this.head = oldHead.next;
|
|
109
|
+
if (this.head) {
|
|
110
|
+
this.head.prev = undefined;
|
|
111
|
+
} else {
|
|
112
|
+
this.tail = undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
package/src/config/env_var.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type EnvVar =
|
|
2
2
|
| 'REGISTRY_CONTRACT_ADDRESS'
|
|
3
3
|
| 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS'
|
|
4
|
-
| 'SLASH_FACTORY_CONTRACT_ADDRESS'
|
|
5
4
|
| 'ACVM_BINARY_PATH'
|
|
6
5
|
| 'ACVM_WORKING_DIRECTORY'
|
|
7
6
|
| 'API_KEY'
|
|
@@ -12,6 +11,10 @@ export type EnvVar =
|
|
|
12
11
|
| 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
|
|
13
12
|
| 'ARCHIVER_BATCH_SIZE'
|
|
14
13
|
| 'AZTEC_ADMIN_PORT'
|
|
14
|
+
| 'AZTEC_NODE_DEBUG'
|
|
15
|
+
| 'AZTEC_ADMIN_API_KEY_HASH'
|
|
16
|
+
| 'AZTEC_DISABLE_ADMIN_API_KEY'
|
|
17
|
+
| 'AZTEC_RESET_ADMIN_API_KEY'
|
|
15
18
|
| 'AZTEC_NODE_ADMIN_URL'
|
|
16
19
|
| 'AZTEC_NODE_URL'
|
|
17
20
|
| 'AZTEC_PORT'
|
|
@@ -20,6 +23,8 @@ export type EnvVar =
|
|
|
20
23
|
| 'BB_WORKING_DIRECTORY'
|
|
21
24
|
| 'BB_NUM_IVC_VERIFIERS'
|
|
22
25
|
| 'BB_IVC_CONCURRENCY'
|
|
26
|
+
| 'BB_CHONK_VERIFY_MAX_BATCH'
|
|
27
|
+
| 'BB_CHONK_VERIFY_BATCH_CONCURRENCY'
|
|
23
28
|
| 'BOOTSTRAP_NODES'
|
|
24
29
|
| 'BLOB_ARCHIVE_API_URL'
|
|
25
30
|
| 'BLOB_FILE_STORE_URLS'
|
|
@@ -47,7 +52,10 @@ export type EnvVar =
|
|
|
47
52
|
| 'BOT_TX_MINED_WAIT_SECONDS'
|
|
48
53
|
| 'BOT_MAX_CONSECUTIVE_ERRORS'
|
|
49
54
|
| 'BOT_STOP_WHEN_UNHEALTHY'
|
|
50
|
-
| '
|
|
55
|
+
| 'BOT_MODE'
|
|
56
|
+
| 'BOT_L2_TO_L1_MESSAGES_PER_TX'
|
|
57
|
+
| 'BOT_L1_TO_L2_SEED_COUNT'
|
|
58
|
+
| 'BOT_L1_TO_L2_SEED_INTERVAL'
|
|
51
59
|
| 'COINBASE'
|
|
52
60
|
| 'CRS_PATH'
|
|
53
61
|
| 'DATA_DIRECTORY'
|
|
@@ -56,6 +64,7 @@ export type EnvVar =
|
|
|
56
64
|
| 'BLOB_SINK_MAP_SIZE_KB'
|
|
57
65
|
| 'P2P_STORE_MAP_SIZE_KB'
|
|
58
66
|
| 'PROVER_BROKER_STORE_MAP_SIZE_KB'
|
|
67
|
+
| 'SIGNING_PROTECTION_MAP_SIZE_KB'
|
|
59
68
|
| 'WS_DB_MAP_SIZE_KB'
|
|
60
69
|
| 'ARCHIVE_TREE_MAP_SIZE_KB'
|
|
61
70
|
| 'NULLIFIER_TREE_MAP_SIZE_KB'
|
|
@@ -64,6 +73,7 @@ export type EnvVar =
|
|
|
64
73
|
| 'PUBLIC_DATA_TREE_MAP_SIZE_KB'
|
|
65
74
|
| 'DEBUG'
|
|
66
75
|
| 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY'
|
|
76
|
+
| 'ENABLE_PROVER_NODE'
|
|
67
77
|
| 'ETHEREUM_HOSTS'
|
|
68
78
|
| 'ETHEREUM_DEBUG_HOSTS'
|
|
69
79
|
| 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS'
|
|
@@ -73,15 +83,17 @@ export type EnvVar =
|
|
|
73
83
|
| 'KEY_STORE_DIRECTORY'
|
|
74
84
|
| 'L1_CHAIN_ID'
|
|
75
85
|
| 'L1_CONSENSUS_HOST_URLS'
|
|
86
|
+
| 'ETHEREUM_HTTP_TIMEOUT_MS'
|
|
76
87
|
| 'L1_CONSENSUS_HOST_API_KEYS'
|
|
77
88
|
| 'L1_CONSENSUS_HOST_API_KEY_HEADERS'
|
|
89
|
+
| 'L1_TX_FAILED_STORE'
|
|
78
90
|
| 'LOG_JSON'
|
|
79
91
|
| 'LOG_MULTILINE'
|
|
92
|
+
| 'LOG_NO_COLOR_PER_ACTOR'
|
|
80
93
|
| 'LOG_LEVEL'
|
|
81
94
|
| 'MNEMONIC'
|
|
82
95
|
| 'NETWORK'
|
|
83
96
|
| 'NETWORK_CONFIG_LOCATION'
|
|
84
|
-
| 'NO_PXE'
|
|
85
97
|
| 'USE_GCLOUD_LOGGING'
|
|
86
98
|
| 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
|
|
87
99
|
| 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
|
|
@@ -94,7 +106,12 @@ export type EnvVar =
|
|
|
94
106
|
| 'PUBLIC_OTEL_INCLUDE_METRICS'
|
|
95
107
|
| 'PUBLIC_OTEL_COLLECT_FROM'
|
|
96
108
|
| 'PUBLIC_OTEL_OPT_OUT'
|
|
109
|
+
| 'P2P_BATCH_TX_REQUESTER_SMART_PARALLEL_WORKER_COUNT'
|
|
110
|
+
| 'P2P_BATCH_TX_REQUESTER_DUMB_PARALLEL_WORKER_COUNT'
|
|
111
|
+
| 'P2P_BATCH_TX_REQUESTER_TX_BATCH_SIZE'
|
|
112
|
+
| 'P2P_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD'
|
|
97
113
|
| 'P2P_BLOCK_CHECK_INTERVAL_MS'
|
|
114
|
+
| 'P2P_SLOT_CHECK_INTERVAL_MS'
|
|
98
115
|
| 'P2P_BLOCK_REQUEST_BATCH_SIZE'
|
|
99
116
|
| 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
|
|
100
117
|
| 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS'
|
|
@@ -115,6 +132,7 @@ export type EnvVar =
|
|
|
115
132
|
| 'P2P_L2_QUEUE_SIZE'
|
|
116
133
|
| 'P2P_MAX_PEERS'
|
|
117
134
|
| 'P2P_PEER_CHECK_INTERVAL_MS'
|
|
135
|
+
| 'P2P_PEER_FAILED_BAN_TIME_MS'
|
|
118
136
|
| 'P2P_PEER_PENALTY_VALUES'
|
|
119
137
|
| 'P2P_QUERY_FOR_IP'
|
|
120
138
|
| 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS'
|
|
@@ -135,9 +153,10 @@ export type EnvVar =
|
|
|
135
153
|
| 'P2P_PREFERRED_PEERS'
|
|
136
154
|
| 'P2P_MAX_PENDING_TX_COUNT'
|
|
137
155
|
| 'P2P_SEEN_MSG_CACHE_SIZE'
|
|
138
|
-
| 'P2P_DROP_TX'
|
|
139
156
|
| 'P2P_DROP_TX_CHANCE'
|
|
140
157
|
| 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
|
|
158
|
+
| 'P2P_MIN_TX_POOL_AGE_MS'
|
|
159
|
+
| 'P2P_RPC_PRICE_BUMP_PERCENTAGE'
|
|
141
160
|
| 'DEBUG_P2P_INSTRUMENT_MESSAGES'
|
|
142
161
|
| 'PEER_ID_PRIVATE_KEY'
|
|
143
162
|
| 'PEER_ID_PRIVATE_KEY_PATH'
|
|
@@ -151,8 +170,11 @@ export type EnvVar =
|
|
|
151
170
|
| 'PROVER_BROKER_BATCH_INTERVAL_MS'
|
|
152
171
|
| 'PROVER_BROKER_BATCH_SIZE'
|
|
153
172
|
| 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR'
|
|
173
|
+
| 'PROVER_BROKER_DEBUG_REPLAY_ENABLED'
|
|
154
174
|
| 'PROVER_CANCEL_JOBS_ON_STOP'
|
|
175
|
+
| 'PROVER_ENQUEUE_CONCURRENCY'
|
|
155
176
|
| 'PROVER_COORDINATION_NODE_URLS'
|
|
177
|
+
| 'PROVER_PROOF_STORE'
|
|
156
178
|
| 'PROVER_FAILED_PROOF_STORE'
|
|
157
179
|
| 'PROVER_NODE_FAILED_EPOCH_STORE'
|
|
158
180
|
| 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
|
|
@@ -184,27 +206,32 @@ export type EnvVar =
|
|
|
184
206
|
| 'SENTINEL_ENABLED'
|
|
185
207
|
| 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
|
|
186
208
|
| 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
|
|
187
|
-
| '
|
|
209
|
+
| 'SEQ_ENABLE_PROPOSER_PIPELINING'
|
|
188
210
|
| 'SEQ_MAX_TX_PER_BLOCK'
|
|
211
|
+
| 'SEQ_MAX_TX_PER_CHECKPOINT'
|
|
189
212
|
| 'SEQ_MIN_TX_PER_BLOCK'
|
|
190
213
|
| 'SEQ_PUBLISH_TXS_WITH_PROPOSALS'
|
|
191
214
|
| 'SEQ_MAX_DA_BLOCK_GAS'
|
|
192
215
|
| 'SEQ_MAX_L2_BLOCK_GAS'
|
|
216
|
+
| 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER'
|
|
217
|
+
| 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET'
|
|
193
218
|
| 'SEQ_PUBLISHER_PRIVATE_KEY'
|
|
194
219
|
| 'SEQ_PUBLISHER_PRIVATE_KEYS'
|
|
195
220
|
| 'SEQ_PUBLISHER_ADDRESSES'
|
|
196
221
|
| 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
|
|
197
222
|
| 'SEQ_PUBLISHER_FORWARDER_ADDRESS'
|
|
223
|
+
| 'PUBLISHER_FUNDING_THRESHOLD'
|
|
224
|
+
| 'PUBLISHER_FUNDING_AMOUNT'
|
|
198
225
|
| 'SEQ_POLLING_INTERVAL_MS'
|
|
199
226
|
| 'SEQ_ENFORCE_TIME_TABLE'
|
|
200
227
|
| 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
|
|
201
228
|
| 'SEQ_ATTESTATION_PROPAGATION_TIME'
|
|
202
229
|
| 'SEQ_BLOCK_DURATION_MS'
|
|
230
|
+
| 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
|
|
203
231
|
| 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
|
|
204
232
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
|
|
205
233
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
|
|
206
|
-
| '
|
|
207
|
-
| 'SLASH_MAX_PENALTY_PERCENTAGE'
|
|
234
|
+
| 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
|
|
208
235
|
| 'SLASH_VALIDATORS_ALWAYS'
|
|
209
236
|
| 'SLASH_VALIDATORS_NEVER'
|
|
210
237
|
| 'SLASH_PRUNE_PENALTY'
|
|
@@ -213,6 +240,8 @@ export type EnvVar =
|
|
|
213
240
|
| 'SLASH_INACTIVITY_TARGET_PERCENTAGE'
|
|
214
241
|
| 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD'
|
|
215
242
|
| 'SLASH_INVALID_BLOCK_PENALTY'
|
|
243
|
+
| 'SLASH_DUPLICATE_PROPOSAL_PENALTY'
|
|
244
|
+
| 'SLASH_DUPLICATE_ATTESTATION_PENALTY'
|
|
216
245
|
| 'SLASH_OVERRIDE_PAYLOAD'
|
|
217
246
|
| 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY'
|
|
218
247
|
| 'SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY'
|
|
@@ -227,6 +256,7 @@ export type EnvVar =
|
|
|
227
256
|
| 'TELEMETRY'
|
|
228
257
|
| 'TEST_ACCOUNTS'
|
|
229
258
|
| 'SPONSORED_FPC'
|
|
259
|
+
| 'PREFUND_ADDRESSES'
|
|
230
260
|
| 'TX_COLLECTION_FAST_NODES_TIMEOUT_BEFORE_REQ_RESP_MS'
|
|
231
261
|
| 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS'
|
|
232
262
|
| 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS'
|
|
@@ -237,20 +267,38 @@ export type EnvVar =
|
|
|
237
267
|
| 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE'
|
|
238
268
|
| 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE'
|
|
239
269
|
| 'TX_COLLECTION_NODE_RPC_URLS'
|
|
270
|
+
| 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE'
|
|
271
|
+
| 'TX_COLLECTION_FILE_STORE_URLS'
|
|
272
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS'
|
|
273
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS'
|
|
274
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT'
|
|
275
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT'
|
|
276
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS'
|
|
277
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS'
|
|
278
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS'
|
|
279
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS'
|
|
280
|
+
| 'TX_FILE_STORE_URL'
|
|
281
|
+
| 'TX_FILE_STORE_UPLOAD_CONCURRENCY'
|
|
282
|
+
| 'TX_FILE_STORE_MAX_QUEUE_SIZE'
|
|
283
|
+
| 'TX_FILE_STORE_ENABLED'
|
|
240
284
|
| 'TX_PUBLIC_SETUP_ALLOWLIST'
|
|
241
285
|
| 'TXE_PORT'
|
|
242
286
|
| 'TRANSACTIONS_DISABLED'
|
|
243
287
|
| 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS'
|
|
244
288
|
| 'VALIDATOR_DISABLED'
|
|
289
|
+
| 'VALIDATOR_MAX_DA_BLOCK_GAS'
|
|
290
|
+
| 'VALIDATOR_MAX_L2_BLOCK_GAS'
|
|
291
|
+
| 'VALIDATOR_MAX_TX_PER_BLOCK'
|
|
292
|
+
| 'VALIDATOR_MAX_TX_PER_CHECKPOINT'
|
|
245
293
|
| 'VALIDATOR_PRIVATE_KEYS'
|
|
246
294
|
| 'VALIDATOR_PRIVATE_KEY'
|
|
247
|
-
| 'VALIDATOR_REEXECUTE'
|
|
248
295
|
| 'VALIDATOR_ADDRESSES'
|
|
249
296
|
| 'ROLLUP_VERSION'
|
|
250
297
|
| 'WS_BLOCK_CHECK_INTERVAL_MS'
|
|
251
298
|
| 'WS_BLOCK_REQUEST_BATCH_SIZE'
|
|
252
299
|
| 'L1_READER_VIEM_POLLING_INTERVAL_MS'
|
|
253
300
|
| 'WS_DATA_DIRECTORY'
|
|
301
|
+
| 'WS_NUM_HISTORIC_CHECKPOINTS'
|
|
254
302
|
| 'WS_NUM_HISTORIC_BLOCKS'
|
|
255
303
|
| 'ETHEREUM_SLOT_DURATION'
|
|
256
304
|
| 'AZTEC_SLOT_DURATION'
|
|
@@ -276,7 +324,7 @@ export type EnvVar =
|
|
|
276
324
|
| 'AZTEC_SLASH_AMOUNT_SMALL'
|
|
277
325
|
| 'AZTEC_SLASH_AMOUNT_MEDIUM'
|
|
278
326
|
| 'AZTEC_SLASH_AMOUNT_LARGE'
|
|
279
|
-
| '
|
|
327
|
+
| 'AZTEC_SLASHER_ENABLED'
|
|
280
328
|
| 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
|
|
281
329
|
| 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
|
|
282
330
|
| 'AZTEC_GOVERNANCE_VOTING_DURATION'
|
|
@@ -305,12 +353,12 @@ export type EnvVar =
|
|
|
305
353
|
| 'K8S_POD_NAME'
|
|
306
354
|
| 'K8S_POD_UID'
|
|
307
355
|
| 'K8S_NAMESPACE_NAME'
|
|
308
|
-
| '
|
|
309
|
-
| 'AUTO_UPDATE'
|
|
310
|
-
| 'AUTO_UPDATE_URL'
|
|
356
|
+
| 'ENABLE_VERSION_CHECK'
|
|
311
357
|
| 'WEB3_SIGNER_URL'
|
|
312
358
|
| 'SKIP_ARCHIVER_INITIAL_SYNC'
|
|
313
359
|
| 'BLOB_ALLOW_EMPTY_SOURCES'
|
|
360
|
+
| 'BLOB_PREFER_FILESTORES'
|
|
361
|
+
| 'BLOB_FILE_STORE_TIMEOUT_MS'
|
|
314
362
|
| 'FISHERMAN_MODE'
|
|
315
363
|
| 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
|
|
316
364
|
| 'LEGACY_BLS_CLI'
|
|
@@ -320,6 +368,7 @@ export type EnvVar =
|
|
|
320
368
|
| 'VALIDATOR_HA_POLLING_INTERVAL_MS'
|
|
321
369
|
| 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
|
|
322
370
|
| 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
|
|
371
|
+
| 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H'
|
|
323
372
|
| 'VALIDATOR_HA_DATABASE_URL'
|
|
324
373
|
| 'VALIDATOR_HA_RUN_MIGRATIONS'
|
|
325
374
|
| 'VALIDATOR_HA_POOL_MAX'
|
package/src/config/index.ts
CHANGED
|
@@ -177,6 +177,21 @@ export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'pa
|
|
|
177
177
|
if (val === '') {
|
|
178
178
|
return defaultVal;
|
|
179
179
|
}
|
|
180
|
+
// Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
|
|
181
|
+
// We parse it losslessly using bigint arithmetic instead of going through float64.
|
|
182
|
+
if (/[eE]/.test(val)) {
|
|
183
|
+
const match = val.match(/^(-?\d+(?:\.(\d+))?)[eE]([+-]?\d+)$/);
|
|
184
|
+
if (!match) {
|
|
185
|
+
throw new Error(`Cannot convert '${val}' to a BigInt`);
|
|
186
|
+
}
|
|
187
|
+
const digits = match[1].replace('.', '');
|
|
188
|
+
const decimalPlaces = match[2]?.length ?? 0;
|
|
189
|
+
const exponent = parseInt(match[3], 10) - decimalPlaces;
|
|
190
|
+
if (exponent < 0) {
|
|
191
|
+
throw new Error(`Cannot convert '${val}' to a BigInt: result is not an integer`);
|
|
192
|
+
}
|
|
193
|
+
return BigInt(digits) * 10n ** BigInt(exponent);
|
|
194
|
+
}
|
|
180
195
|
return BigInt(val);
|
|
181
196
|
},
|
|
182
197
|
defaultValue: defaultVal,
|
|
@@ -5,10 +5,13 @@ export const NetworkConfigSchema = z
|
|
|
5
5
|
bootnodes: z.array(z.string()),
|
|
6
6
|
snapshots: z.array(z.string()),
|
|
7
7
|
blobFileStoreUrls: z.array(z.string()).optional(),
|
|
8
|
+
txCollectionFileStoreUrls: z.array(z.string()).optional(),
|
|
8
9
|
registryAddress: z.string(),
|
|
9
10
|
feeAssetHandlerAddress: z.string().optional(),
|
|
10
11
|
l1ChainId: z.number(),
|
|
11
12
|
blockDurationMs: z.number().positive().optional(),
|
|
13
|
+
txPublicSetupAllowListExtend: z.string().optional(),
|
|
14
|
+
nodeVersion: z.string().optional(),
|
|
12
15
|
})
|
|
13
16
|
.passthrough(); // Allow additional unknown fields to pass through
|
|
14
17
|
|
|
@@ -5,7 +5,8 @@ export type NetworkNames =
|
|
|
5
5
|
| 'testnet'
|
|
6
6
|
| 'mainnet'
|
|
7
7
|
| 'next-net'
|
|
8
|
-
| 'devnet'
|
|
8
|
+
| 'devnet'
|
|
9
|
+
| `v${number}-devnet-${number}`;
|
|
9
10
|
|
|
10
11
|
export function getActiveNetworkName(name?: string): NetworkNames {
|
|
11
12
|
const network = name || process.env.NETWORK;
|
|
@@ -23,6 +24,8 @@ export function getActiveNetworkName(name?: string): NetworkNames {
|
|
|
23
24
|
return 'next-net';
|
|
24
25
|
} else if (network === 'devnet') {
|
|
25
26
|
return 'devnet';
|
|
27
|
+
} else if (/^v\d+-devnet-\d+$/.test(network)) {
|
|
28
|
+
return network as `v${number}-devnet-${number}`;
|
|
26
29
|
}
|
|
27
30
|
throw new Error(`Unknown network: ${network}`);
|
|
28
31
|
}
|
|
@@ -59,10 +59,19 @@ export class Aes128 {
|
|
|
59
59
|
* @param iv - AES initialization vector.
|
|
60
60
|
* @param key - Key to decrypt with.
|
|
61
61
|
* @returns Decrypted data.
|
|
62
|
+
* @throws If the decrypted buffer has invalid PKCS#7 padding.
|
|
62
63
|
*/
|
|
63
64
|
public async decryptBufferCBC(data: Uint8Array, iv: Uint8Array, key: Uint8Array) {
|
|
64
65
|
const paddedBuffer = await this.decryptBufferCBCKeepPadding(data, iv, key);
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const paddingLen = paddedBuffer[paddedBuffer.length - 1];
|
|
67
|
+
if (paddingLen === 0 || paddingLen > 16) {
|
|
68
|
+
throw new Error(`Invalid PKCS#7 padding length: ${paddingLen}`);
|
|
69
|
+
}
|
|
70
|
+
for (let i = paddedBuffer.length - paddingLen; i < paddedBuffer.length; i++) {
|
|
71
|
+
if (paddedBuffer[i] !== paddingLen) {
|
|
72
|
+
throw new Error('Invalid PKCS#7 padding');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return paddedBuffer.subarray(0, paddedBuffer.length - paddingLen);
|
|
67
76
|
}
|
|
68
77
|
}
|
|
@@ -262,26 +262,3 @@ export function decryptBn254KeystoreFromObject(keystore: Bn254Keystore, password
|
|
|
262
262
|
throw new Bn254KeystoreError(`Failed to decrypt keystore: ${String(error)}`, error as Error);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Validates that a decrypted private key matches the public key in the keystore.
|
|
268
|
-
*
|
|
269
|
-
* @param privateKeyHex - Decrypted private key (0x-prefixed)
|
|
270
|
-
* @param expectedPubkey - Expected public key from keystore
|
|
271
|
-
* @param computePublicKey - Function to compute public key from private key
|
|
272
|
-
* @returns true if keys match, false otherwise
|
|
273
|
-
*/
|
|
274
|
-
export function verifyBn254Keypair(
|
|
275
|
-
privateKeyHex: string,
|
|
276
|
-
expectedPubkey: string,
|
|
277
|
-
computePublicKey: (privateKey: string) => string,
|
|
278
|
-
): boolean {
|
|
279
|
-
try {
|
|
280
|
-
const computedPubkey = computePublicKey(privateKeyHex);
|
|
281
|
-
const normalizedExpected = expectedPubkey.toLowerCase().replace(/^0x/i, '');
|
|
282
|
-
const normalizedComputed = computedPubkey.toLowerCase().replace(/^0x/i, '');
|
|
283
|
-
return normalizedExpected === normalizedComputed;
|
|
284
|
-
} catch {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|