@aztec/foundation 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/index.d.ts +2 -1
- package/dest/array/index.d.ts.map +1 -1
- package/dest/array/index.js +1 -0
- package/dest/array/sorted_array.d.ts +15 -0
- package/dest/array/sorted_array.d.ts.map +1 -0
- package/dest/array/sorted_array.js +109 -0
- package/dest/bigint-buffer/index.d.ts +1 -1
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/bigint-buffer/index.js +6 -1
- package/dest/branded-types/block_number.d.ts +6 -3
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +18 -4
- package/dest/branded-types/buffer32_hash.d.ts +27 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +12 -0
- package/dest/branded-types/checkpoint_number.d.ts +17 -3
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +28 -8
- package/dest/branded-types/epoch.d.ts +2 -2
- package/dest/branded-types/epoch.d.ts.map +1 -1
- package/dest/branded-types/index.d.ts +4 -2
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +3 -1
- package/dest/branded-types/index_within_checkpoint.d.ts +42 -0
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -0
- package/dest/branded-types/index_within_checkpoint.js +59 -0
- package/dest/branded-types/slot.d.ts +5 -2
- package/dest/branded-types/slot.d.ts.map +1 -1
- package/dest/branded-types/slot.js +3 -0
- package/dest/buffer/buffer16.d.ts +7 -2
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer16.js +4 -2
- package/dest/buffer/buffer32.d.ts +29 -59
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +33 -65
- 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 +22 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +84 -0
- package/dest/collection/index.d.ts +3 -1
- package/dest/collection/index.d.ts.map +1 -1
- package/dest/collection/index.js +2 -0
- package/dest/collection/lru_map.d.ts +41 -0
- package/dest/collection/lru_map.d.ts.map +1 -0
- package/dest/collection/lru_map.js +119 -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/committable/committable.js +1 -1
- 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 +79 -38
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +103 -64
- package/dest/config/network_config.d.ts +17 -31
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +6 -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 +3 -3
- package/dest/config/parse-env.d.ts +3 -0
- package/dest/config/parse-env.d.ts.map +1 -0
- package/dest/config/parse-env.js +7 -0
- package/dest/config/secret_value.d.ts +2 -2
- package/dest/config/secret_value.d.ts.map +1 -1
- package/dest/config/secret_value.js +3 -1
- 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 +10 -177
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +23 -35
- package/dest/crypto/bls/index.js +1 -1
- package/dest/crypto/bn254/index.d.ts +35 -51
- package/dest/crypto/bn254/index.d.ts.map +1 -1
- package/dest/crypto/bn254/index.js +51 -140
- package/dest/crypto/ecdsa/signature.d.ts +11 -2
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
- package/dest/crypto/ecdsa/signature.js +2 -2
- package/dest/crypto/grumpkin/index.d.ts +4 -2
- package/dest/crypto/grumpkin/index.d.ts.map +1 -1
- package/dest/crypto/grumpkin/index.js +2 -1
- package/dest/crypto/keys/index.d.ts +4 -3
- package/dest/crypto/keys/index.d.ts.map +1 -1
- package/dest/crypto/keys/index.js +31 -7
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -2
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.js +1 -1
- package/dest/crypto/poseidon/index.d.ts +2 -3
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +41 -43
- 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 +5 -5
- package/dest/crypto/schnorr/index.d.ts +10 -8
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +7 -7
- package/dest/crypto/schnorr/signature.d.ts +10 -30
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/schnorr/signature.js +21 -37
- 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/crypto/sha256/index.d.ts +2 -2
- package/dest/crypto/sha256/index.d.ts.map +1 -1
- package/dest/crypto/sha256/index.js +1 -1
- package/dest/crypto/sha512/index.d.ts +2 -2
- package/dest/crypto/sha512/index.d.ts.map +1 -1
- package/dest/crypto/sha512/index.js +1 -1
- package/dest/crypto/signature/index.d.ts +2 -2
- package/dest/crypto/signature/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.d.ts +2 -2
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.js +1 -1
- package/dest/crypto/sync/poseidon/index.d.ts +2 -3
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +1 -9
- package/dest/{fields/bls12_fields.d.ts → curves/bls12/field.d.ts} +5 -5
- package/dest/curves/bls12/field.d.ts.map +1 -0
- package/dest/{fields/bls12_fields.js → curves/bls12/field.js} +11 -13
- package/dest/curves/bls12/index.d.ts +3 -0
- package/dest/curves/bls12/index.d.ts.map +1 -0
- package/dest/curves/bls12/index.js +2 -0
- package/dest/{fields/bls12_point.d.ts → curves/bls12/point.d.ts} +14 -5
- package/dest/curves/bls12/point.d.ts.map +1 -0
- package/dest/{fields/bls12_point.js → curves/bls12/point.js} +10 -8
- package/dest/curves/bn254/field.d.ts +185 -0
- package/dest/curves/bn254/field.d.ts.map +1 -0
- package/dest/{fields/fields.js → curves/bn254/field.js} +57 -62
- package/dest/curves/bn254/index.d.ts +3 -0
- package/dest/curves/bn254/index.d.ts.map +1 -0
- package/dest/curves/bn254/index.js +2 -0
- package/dest/curves/bn254/point.d.ts +54 -0
- package/dest/curves/bn254/point.d.ts.map +1 -0
- package/dest/curves/bn254/point.js +143 -0
- package/dest/curves/grumpkin/index.d.ts +10 -0
- package/dest/curves/grumpkin/index.d.ts.map +1 -0
- package/dest/curves/grumpkin/index.js +3 -0
- package/dest/{fields → curves/grumpkin}/point.d.ts +23 -28
- package/dest/curves/grumpkin/point.d.ts.map +1 -0
- package/dest/{fields → curves/grumpkin}/point.js +35 -49
- package/dest/error/index.d.ts +4 -4
- package/dest/error/index.d.ts.map +1 -1
- package/dest/eth-address/index.d.ts +4 -3
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +10 -6
- package/dest/eth-signature/eth_signature.d.ts +6 -2
- 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 +91 -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/fifo_set/fifo_set.d.ts +15 -0
- package/dest/fifo_set/fifo_set.d.ts.map +1 -0
- package/dest/fifo_set/fifo_set.js +39 -0
- package/dest/fifo_set/index.d.ts +2 -0
- package/dest/fifo_set/index.d.ts.map +1 -0
- package/dest/fifo_set/index.js +1 -0
- package/dest/iterator/filter.d.ts +3 -0
- package/dest/iterator/filter.d.ts.map +1 -0
- package/dest/iterator/filter.js +7 -0
- package/dest/iterator/index.d.ts +2 -0
- package/dest/iterator/index.d.ts.map +1 -0
- package/dest/iterator/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 +3 -3
- 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 +23 -4
- package/dest/json-rpc/fixtures/class_a.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/class_b.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/test_state.js +57 -17
- 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/json-rpc/server/safe_json_rpc_server.d.ts +8 -3
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +28 -14
- 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 +138 -30
- package/dest/noir/noir_package_config.d.ts +19 -104
- package/dest/noir/noir_package_config.d.ts.map +1 -1
- package/dest/noir/noir_package_config.js +1 -1
- package/dest/promise/running-promise.d.ts +5 -4
- package/dest/promise/running-promise.d.ts.map +1 -1
- package/dest/promise/running-promise.js +7 -3
- 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 +41 -3
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +55 -2
- package/dest/schemas/api.d.ts +12 -10
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/schemas/api.js +7 -1
- package/dest/schemas/parse.d.ts +4 -4
- package/dest/schemas/parse.d.ts.map +1 -1
- package/dest/schemas/parse.js +6 -5
- package/dest/schemas/schemas.d.ts +20 -16
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +9 -3
- package/dest/schemas/types.d.ts +32 -2
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/types.js +25 -1
- package/dest/schemas/utils.d.ts +7 -11
- package/dest/schemas/utils.d.ts.map +1 -1
- package/dest/schemas/utils.js +2 -18
- package/dest/serialize/buffer_reader.d.ts +14 -4
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +26 -4
- package/dest/serialize/buffer_sink.d.ts +134 -0
- package/dest/serialize/buffer_sink.d.ts.map +1 -0
- package/dest/serialize/buffer_sink.js +297 -0
- package/dest/serialize/field_reader.d.ts +2 -2
- package/dest/serialize/field_reader.d.ts.map +1 -1
- package/dest/serialize/field_reader.js +1 -1
- package/dest/serialize/free_funcs.d.ts +2 -2
- package/dest/serialize/free_funcs.d.ts.map +1 -1
- package/dest/serialize/free_funcs.js +1 -1
- package/dest/serialize/index.d.ts +2 -1
- package/dest/serialize/index.d.ts.map +1 -1
- package/dest/serialize/index.js +1 -0
- package/dest/serialize/serialize.d.ts +20 -2
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +32 -1
- package/dest/sleep/index.d.ts +4 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +14 -1
- package/dest/string/index.js +1 -1
- package/dest/testing/files/index.d.ts +2 -3
- package/dest/testing/files/index.d.ts.map +1 -1
- package/dest/testing/files/index.js +1 -2
- package/dest/timer/date.d.ts +26 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +36 -0
- package/dest/timer/index.d.ts +2 -2
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +3 -1
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +26 -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/balanced_merkle_tree_root.d.ts +16 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{balanced_merkle_tree.js → balanced_merkle_tree_root.js} +3 -17
- package/dest/trees/hasher.d.ts +4 -1
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +10 -5
- package/dest/trees/index.d.ts +4 -4
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +3 -3
- package/dest/trees/indexed_merkle_tree.js +1 -1
- 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/trees/membership_witness.d.ts +9 -3
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts +4 -2
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +1 -5
- package/dest/trees/sibling_path.d.ts +7 -5
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +11 -9
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +1 -5
- package/dest/trees/{unbalanced_merkle_tree.d.ts → unbalanced_merkle_tree_root.d.ts} +4 -7
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{unbalanced_merkle_tree.js → unbalanced_merkle_tree_root.js} +12 -51
- package/dest/trees/unbalanced_tree_store.d.ts +5 -1
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +49 -1
- package/dest/types/index.d.ts +28 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +21 -0
- package/package.json +50 -9
- package/src/array/index.ts +1 -0
- package/src/array/sorted_array.ts +138 -0
- package/src/bigint-buffer/index.ts +6 -1
- package/src/branded-types/block_number.ts +25 -2
- package/src/branded-types/buffer32_hash.ts +38 -0
- package/src/branded-types/checkpoint_number.ts +37 -7
- package/src/branded-types/epoch.ts +1 -1
- package/src/branded-types/index.ts +3 -1
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/branded-types/slot.ts +6 -1
- package/src/buffer/buffer16.ts +5 -2
- package/src/buffer/buffer32.ts +41 -70
- package/src/buffer/index.ts +1 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +86 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/lru_map.ts +143 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/committable/committable.ts +1 -1
- package/src/config/env_var.ts +127 -34
- package/src/config/index.ts +183 -114
- package/src/config/network_config.ts +5 -0
- package/src/config/network_name.ts +6 -6
- package/src/config/parse-env.ts +4 -0
- package/src/config/secret_value.ts +1 -1
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +34 -44
- package/src/crypto/bls/index.ts +1 -1
- package/src/crypto/bn254/index.ts +50 -159
- package/src/crypto/ecdsa/signature.ts +2 -2
- package/src/crypto/grumpkin/index.ts +3 -1
- package/src/crypto/keys/index.ts +21 -5
- package/src/crypto/pedersen/pedersen.wasm.ts +1 -1
- package/src/crypto/poseidon/index.ts +43 -45
- package/src/crypto/random/randomness_singleton.ts +6 -4
- package/src/crypto/schnorr/index.ts +11 -9
- package/src/crypto/schnorr/signature.ts +18 -47
- package/src/crypto/secp256k1-signer/utils.ts +32 -0
- package/src/crypto/sha256/index.ts +1 -1
- package/src/crypto/sha512/index.ts +1 -1
- package/src/crypto/signature/index.ts +1 -1
- package/src/crypto/sync/pedersen/index.ts +1 -1
- package/src/crypto/sync/poseidon/index.ts +1 -10
- package/src/{fields/bls12_fields.ts → curves/bls12/field.ts} +5 -12
- package/src/curves/bls12/index.ts +2 -0
- package/src/{fields/bls12_point.ts → curves/bls12/point.ts} +7 -7
- package/src/{fields/fields.ts → curves/bn254/field.ts} +68 -86
- package/src/curves/bn254/index.ts +2 -0
- package/src/curves/bn254/point.ts +170 -0
- package/src/curves/grumpkin/index.ts +11 -0
- package/src/{fields → curves/grumpkin}/point.ts +29 -46
- package/src/eth-address/index.ts +8 -6
- package/src/eth-signature/eth_signature.ts +7 -1
- package/src/fifo/fifo_frame_reader.ts +113 -0
- package/src/fifo/index.ts +1 -0
- package/src/fifo_set/fifo_set.ts +52 -0
- package/src/fifo_set/index.ts +1 -0
- package/src/iterator/filter.ts +11 -0
- package/src/iterator/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 +4 -2
- package/src/json-rpc/client/undici.ts +23 -3
- package/src/json-rpc/fixtures/test_state.ts +10 -10
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +32 -14
- 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 +162 -40
- package/src/noir/noir_package_config.ts +32 -20
- package/src/promise/running-promise.ts +8 -5
- 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 +84 -4
- package/src/schemas/api.ts +25 -25
- package/src/schemas/parse.ts +9 -6
- package/src/schemas/schemas.ts +17 -6
- package/src/schemas/types.ts +34 -1
- package/src/schemas/utils.ts +4 -38
- package/src/serialize/buffer_reader.ts +36 -9
- package/src/serialize/buffer_sink.ts +350 -0
- package/src/serialize/field_reader.ts +1 -1
- package/src/serialize/free_funcs.ts +1 -1
- package/src/serialize/index.ts +1 -0
- package/src/serialize/serialize.ts +33 -1
- package/src/sleep/index.ts +16 -1
- package/src/string/index.ts +1 -1
- package/src/testing/files/index.ts +1 -2
- package/src/timer/date.ts +52 -0
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +31 -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/{balanced_merkle_tree.ts → balanced_merkle_tree_root.ts} +3 -20
- package/src/trees/hasher.ts +12 -0
- package/src/trees/index.ts +3 -3
- package/src/trees/indexed_merkle_tree.ts +1 -1
- package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
- package/src/trees/membership_witness.ts +1 -1
- package/src/trees/merkle_tree_calculator.ts +4 -10
- package/src/trees/sibling_path.ts +12 -7
- package/src/trees/unbalanced_merkle_tree_calculator.ts +1 -12
- package/src/trees/{unbalanced_merkle_tree.ts → unbalanced_merkle_tree_root.ts} +17 -64
- package/src/trees/unbalanced_tree_store.ts +57 -2
- package/src/types/index.ts +58 -1
- package/dest/crypto/bn254/bn254_utils.d.ts +0 -39
- package/dest/crypto/bn254/bn254_utils.d.ts.map +0 -1
- package/dest/crypto/bn254/bn254_utils.js +0 -56
- package/dest/crypto/index.d.ts +0 -17
- package/dest/crypto/index.d.ts.map +0 -1
- package/dest/crypto/index.js +0 -16
- 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/fields/bls12_fields.d.ts.map +0 -1
- package/dest/fields/bls12_point.d.ts.map +0 -1
- package/dest/fields/coordinate.d.ts +0 -63
- package/dest/fields/coordinate.d.ts.map +0 -1
- package/dest/fields/coordinate.js +0 -96
- package/dest/fields/fields.d.ts +0 -188
- package/dest/fields/fields.d.ts.map +0 -1
- package/dest/fields/index.d.ts +0 -6
- package/dest/fields/index.d.ts.map +0 -1
- package/dest/fields/index.js +0 -5
- package/dest/fields/point.d.ts.map +0 -1
- package/dest/index.d.ts +0 -31
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -31
- package/dest/json-rpc/server/telemetry.d.ts +0 -2
- package/dest/json-rpc/server/telemetry.d.ts.map +0 -1
- package/dest/json-rpc/server/telemetry.js +0 -0
- 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/dest/trees/balanced_merkle_tree.d.ts +0 -22
- package/dest/trees/balanced_merkle_tree.d.ts.map +0 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +0 -1
- package/src/crypto/bn254/bn254_utils.ts +0 -64
- package/src/crypto/index.ts +0 -16
- package/src/crypto/serialize.ts +0 -85
- package/src/fields/coordinate.ts +0 -104
- package/src/fields/index.ts +0 -5
- package/src/index.ts +0 -31
- package/src/json-rpc/server/telemetry.ts +0 -0
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
package/src/config/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Fq, Fr } from '../
|
|
1
|
+
import { Fq, Fr } from '../curves/bn254/field.js';
|
|
2
|
+
import { createConsoleLogger } from '../log/console.js';
|
|
2
3
|
import type { EnvVar } from './env_var.js';
|
|
3
4
|
import { type NetworkNames, getActiveNetworkName } from './network_name.js';
|
|
5
|
+
import { parseBooleanEnv } from './parse-env.js';
|
|
4
6
|
import { SecretValue } from './secret_value.js';
|
|
5
7
|
|
|
6
8
|
export { SecretValue, getActiveNetworkName };
|
|
@@ -8,22 +10,29 @@ export type { EnvVar, NetworkNames };
|
|
|
8
10
|
export type { NetworkConfig, NetworkConfigMap } from './network_config.js';
|
|
9
11
|
export { NetworkConfigMapSchema, NetworkConfigSchema } from './network_config.js';
|
|
10
12
|
|
|
11
|
-
export interface ConfigMapping {
|
|
13
|
+
export interface ConfigMapping<T> {
|
|
12
14
|
env?: EnvVar;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/** Parse an env-var string into `T`. Throws on invalid input. */
|
|
16
|
+
parseEnv?: (val: string) => T;
|
|
17
|
+
defaultValue?: T;
|
|
15
18
|
printDefault?: (val: any) => string;
|
|
16
19
|
description: string;
|
|
17
20
|
isBoolean?: boolean;
|
|
18
|
-
nested?: Record<string, ConfigMapping>;
|
|
19
21
|
fallback?: EnvVar[];
|
|
22
|
+
/**
|
|
23
|
+
* List of deprecated env vars that are still supported but will log a warning.
|
|
24
|
+
* These should also be included in the fallback array for parsing.
|
|
25
|
+
*/
|
|
26
|
+
deprecatedFallback?: { env: EnvVar; message?: string }[];
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
export function isBooleanConfigValue<T>(obj: T, key: keyof T): boolean {
|
|
23
30
|
return typeof obj[key] === 'boolean';
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
export type ConfigMappingsType<T> =
|
|
33
|
+
export type ConfigMappingsType<T> = {
|
|
34
|
+
[K in keyof T]-?: ConfigMapping<Required<T>[K]>;
|
|
35
|
+
};
|
|
27
36
|
|
|
28
37
|
/**
|
|
29
38
|
* Shared utility function to get a value from environment variables with fallback support.
|
|
@@ -59,8 +68,8 @@ export function getValueFromEnvWithFallback<T>(
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
// Parse the value if needed
|
|
63
|
-
if (value !== undefined) {
|
|
71
|
+
// Parse the value if needed. Empty strings are treated as "not set".
|
|
72
|
+
if (value !== undefined && value !== '') {
|
|
64
73
|
return parseFunc ? parseFunc(value) : (value as unknown as T);
|
|
65
74
|
}
|
|
66
75
|
|
|
@@ -72,12 +81,22 @@ export function getConfigFromMappings<T>(configMappings: ConfigMappingsType<T>):
|
|
|
72
81
|
const config = {} as T;
|
|
73
82
|
|
|
74
83
|
for (const key in configMappings) {
|
|
75
|
-
const { env, parseEnv, defaultValue,
|
|
76
|
-
|
|
77
|
-
(config as any)[key] = getConfigFromMappings(nested);
|
|
78
|
-
} else {
|
|
79
|
-
// Use the shared utility function
|
|
84
|
+
const { env, parseEnv, defaultValue, fallback, deprecatedFallback } = configMappings[key];
|
|
85
|
+
try {
|
|
80
86
|
(config as any)[key] = getValueFromEnvWithFallback(env, parseEnv, defaultValue, fallback);
|
|
87
|
+
} catch (e: any) {
|
|
88
|
+
throw new Error(`Failed to parse config '${key}' (env: ${env ?? 'none'}): ${e.message}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (deprecatedFallback?.length) {
|
|
92
|
+
const userLog = createConsoleLogger('[DEPRECATED]');
|
|
93
|
+
for (const { env: deprecatedEnv, message } of deprecatedFallback) {
|
|
94
|
+
if (process.env[deprecatedEnv]) {
|
|
95
|
+
const warningMessage =
|
|
96
|
+
message ?? `Environment variable ${deprecatedEnv} is deprecated. Please use ${env} instead.`;
|
|
97
|
+
userLog(warningMessage, { deprecatedEnvVar: deprecatedEnv, newEnvVar: env });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
81
100
|
}
|
|
82
101
|
}
|
|
83
102
|
|
|
@@ -100,29 +119,37 @@ export function omitConfigMappings<T, K extends keyof T>(
|
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
/**
|
|
103
|
-
* Generates parseEnv and default values for
|
|
104
|
-
*
|
|
105
|
-
*
|
|
122
|
+
* Generates parseEnv and default values for an integer config value.
|
|
123
|
+
*
|
|
124
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
125
|
+
* value (non-numeric, fractional, or outside the safe-integer range) throws rather than silently
|
|
126
|
+
* falling back to the default.
|
|
127
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
128
|
+
* @returns Object with parseEnv and default values for an integer config value
|
|
106
129
|
*/
|
|
107
|
-
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping
|
|
130
|
+
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
108
131
|
return {
|
|
109
|
-
parseEnv: (val: string) =>
|
|
132
|
+
parseEnv: (val: string) => parseSafeInteger(val),
|
|
110
133
|
defaultValue: defaultVal,
|
|
111
134
|
};
|
|
112
135
|
}
|
|
113
136
|
|
|
114
137
|
/**
|
|
115
|
-
* Generates parseEnv and default values for a
|
|
116
|
-
*
|
|
117
|
-
*
|
|
138
|
+
* Generates parseEnv and default values for a floating-point config value.
|
|
139
|
+
*
|
|
140
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
141
|
+
* value (not a finite number) throws rather than silently falling back to the default.
|
|
142
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
143
|
+
* @param validationFn - Optional extra validation applied to the parsed value; should throw on invalid input
|
|
144
|
+
* @returns Object with parseEnv and default values for a floating-point config value
|
|
118
145
|
*/
|
|
119
146
|
export function floatConfigHelper(
|
|
120
147
|
defaultVal: number,
|
|
121
148
|
validationFn?: (val: number) => void,
|
|
122
|
-
): Pick<ConfigMapping
|
|
149
|
+
): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
123
150
|
return {
|
|
124
151
|
parseEnv: (val: string): number => {
|
|
125
|
-
const parsed =
|
|
152
|
+
const parsed = parseFiniteNumber(val);
|
|
126
153
|
validationFn?.(parsed);
|
|
127
154
|
return parsed;
|
|
128
155
|
},
|
|
@@ -130,16 +157,54 @@ export function floatConfigHelper(
|
|
|
130
157
|
};
|
|
131
158
|
}
|
|
132
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Generates parseEnv and default values for a 0-1 percentage config value.
|
|
162
|
+
*
|
|
163
|
+
* The default is used only when the environment variable is unset or empty. A set-but-invalid
|
|
164
|
+
* value (not a finite number, or outside the 0-1 range) throws rather than silently falling back
|
|
165
|
+
* to the default.
|
|
166
|
+
* @param defaultVal - The default value to use when the environment variable is unset
|
|
167
|
+
*/
|
|
168
|
+
export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
|
|
169
|
+
return {
|
|
170
|
+
parseEnv: (val: string): number => {
|
|
171
|
+
const parsed = parseFiniteNumber(val);
|
|
172
|
+
if (parsed < 0 || parsed > 1) {
|
|
173
|
+
throw new TypeError(`Invalid percentage value: ${parsed} should be between 0 and 1`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return parsed;
|
|
177
|
+
},
|
|
178
|
+
defaultValue: defaultVal,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
133
182
|
/**
|
|
134
183
|
* Generates parseEnv and default values for a numerical config value.
|
|
135
184
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
136
185
|
* @returns Object with parseEnv and default values for a numerical config value
|
|
137
186
|
*/
|
|
138
|
-
export function bigintConfigHelper(defaultVal
|
|
187
|
+
export function bigintConfigHelper(defaultVal: bigint): Pick<ConfigMapping<bigint>, 'parseEnv' | 'defaultValue'>;
|
|
188
|
+
export function bigintConfigHelper(): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'>;
|
|
189
|
+
export function bigintConfigHelper(
|
|
190
|
+
defaultVal?: bigint,
|
|
191
|
+
): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'> {
|
|
139
192
|
return {
|
|
140
193
|
parseEnv: (val: string) => {
|
|
141
|
-
|
|
142
|
-
|
|
194
|
+
// Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
|
|
195
|
+
// We parse it losslessly using bigint arithmetic instead of going through float64.
|
|
196
|
+
if (/[eE]/.test(val)) {
|
|
197
|
+
const match = val.match(/^(-?\d+(?:\.(\d+))?)[eE]([+-]?\d+)$/);
|
|
198
|
+
if (!match) {
|
|
199
|
+
throw new Error(`Cannot convert '${val}' to a BigInt`);
|
|
200
|
+
}
|
|
201
|
+
const digits = match[1].replace('.', '');
|
|
202
|
+
const decimalPlaces = match[2]?.length ?? 0;
|
|
203
|
+
const exponent = parseInt(match[3], 10) - decimalPlaces;
|
|
204
|
+
if (exponent < 0) {
|
|
205
|
+
throw new Error(`Cannot convert '${val}' to a BigInt: result is not an integer`);
|
|
206
|
+
}
|
|
207
|
+
return BigInt(digits) * 10n ** BigInt(exponent);
|
|
143
208
|
}
|
|
144
209
|
return BigInt(val);
|
|
145
210
|
},
|
|
@@ -149,32 +214,31 @@ export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'pa
|
|
|
149
214
|
|
|
150
215
|
/**
|
|
151
216
|
* Generates parseEnv for an optional numerical config value.
|
|
217
|
+
* Empty strings are already handled by getValueFromEnvWithFallback.
|
|
152
218
|
*/
|
|
153
|
-
export function optionalNumberConfigHelper(): Pick<ConfigMapping
|
|
219
|
+
export function optionalNumberConfigHelper(): Pick<ConfigMapping<number>, 'parseEnv'> {
|
|
154
220
|
return {
|
|
155
|
-
parseEnv: (val: string
|
|
156
|
-
if (val !== undefined && val.length > 0) {
|
|
157
|
-
const parsedValue = parseInt(val);
|
|
158
|
-
return Number.isSafeInteger(parsedValue) ? parsedValue : undefined;
|
|
159
|
-
}
|
|
160
|
-
return undefined;
|
|
161
|
-
},
|
|
221
|
+
parseEnv: (val: string) => parseSafeInteger(val),
|
|
162
222
|
};
|
|
163
223
|
}
|
|
164
224
|
|
|
165
225
|
/** Generates parseEnv for an enum-like config value. */
|
|
226
|
+
export function enumConfigHelper<T extends string>(
|
|
227
|
+
values: T[],
|
|
228
|
+
defaultValue: NoInfer<T>,
|
|
229
|
+
): Pick<ConfigMapping<T>, 'parseEnv' | 'defaultValue'>;
|
|
230
|
+
export function enumConfigHelper<T extends string>(
|
|
231
|
+
values: T[],
|
|
232
|
+
): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'>;
|
|
166
233
|
export function enumConfigHelper<T extends string>(
|
|
167
234
|
values: T[],
|
|
168
235
|
defaultValue?: NoInfer<T>,
|
|
169
|
-
): Pick<ConfigMapping
|
|
236
|
+
): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'> {
|
|
170
237
|
return {
|
|
171
238
|
parseEnv: (val: string) => {
|
|
172
|
-
const sanitizedVal =
|
|
173
|
-
if (values.
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
if (!val && defaultValue) {
|
|
177
|
-
return defaultValue;
|
|
239
|
+
const sanitizedVal = val.trim().toLowerCase();
|
|
240
|
+
if (values.some(v => v.toLowerCase() === sanitizedVal)) {
|
|
241
|
+
return values.find(v => v.toLowerCase() === sanitizedVal)!;
|
|
178
242
|
}
|
|
179
243
|
throw new Error(`Invalid config value '${val}' (must be one of ${values.join(', ')})`);
|
|
180
244
|
},
|
|
@@ -189,7 +253,9 @@ export function enumConfigHelper<T extends string>(
|
|
|
189
253
|
*/
|
|
190
254
|
export function booleanConfigHelper(
|
|
191
255
|
defaultVal = false,
|
|
192
|
-
): Required<
|
|
256
|
+
): Required<
|
|
257
|
+
Pick<ConfigMapping<boolean>, 'parseEnv' | 'defaultValue' | 'isBoolean'> & { parseVal: (val: string) => boolean }
|
|
258
|
+
> {
|
|
193
259
|
const parse = (val: string | boolean) => (typeof val === 'boolean' ? val : parseBooleanEnv(val));
|
|
194
260
|
return {
|
|
195
261
|
parseEnv: parse,
|
|
@@ -199,119 +265,122 @@ export function booleanConfigHelper(
|
|
|
199
265
|
};
|
|
200
266
|
}
|
|
201
267
|
|
|
202
|
-
export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T):
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
268
|
+
export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T): Pick<
|
|
269
|
+
ConfigMapping<SecretValue<T>>,
|
|
270
|
+
'parseEnv' | 'defaultValue'
|
|
271
|
+
> & {
|
|
272
|
+
parseVal: (val: string) => SecretValue<T>;
|
|
273
|
+
} {
|
|
207
274
|
const wrap = (val: string) => new SecretValue(parse(val));
|
|
208
275
|
return {
|
|
209
276
|
parseEnv: wrap,
|
|
210
277
|
parseVal: wrap,
|
|
211
278
|
defaultValue: new SecretValue(parse(undefined)),
|
|
212
|
-
isBoolean: true,
|
|
213
279
|
};
|
|
214
280
|
}
|
|
215
281
|
|
|
216
|
-
|
|
217
|
-
export function parseBooleanEnv(val: string | undefined): boolean {
|
|
218
|
-
return val !== undefined && ['1', 'true', 'TRUE'].includes(val);
|
|
219
|
-
}
|
|
282
|
+
export { parseBooleanEnv } from './parse-env.js';
|
|
220
283
|
|
|
221
|
-
export function secretStringConfigHelper():
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
export function secretStringConfigHelper(defaultValue: string):
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
export function secretStringConfigHelper(defaultValue?: string):
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
284
|
+
export function secretStringConfigHelper(): {
|
|
285
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
286
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
287
|
+
defaultValue: undefined;
|
|
288
|
+
};
|
|
289
|
+
export function secretStringConfigHelper(defaultValue: string): {
|
|
290
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
291
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
292
|
+
defaultValue: SecretValue<string>;
|
|
293
|
+
};
|
|
294
|
+
export function secretStringConfigHelper(defaultValue?: string): {
|
|
295
|
+
parseEnv: (val: string) => SecretValue<string>;
|
|
296
|
+
parseVal: (val: string) => SecretValue<string>;
|
|
297
|
+
defaultValue: SecretValue<string> | undefined;
|
|
298
|
+
} {
|
|
236
299
|
const parse = (val: string) => new SecretValue(val);
|
|
237
300
|
return {
|
|
238
301
|
parseEnv: parse,
|
|
239
302
|
parseVal: parse,
|
|
240
303
|
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
241
|
-
isBoolean: true,
|
|
242
304
|
};
|
|
243
305
|
}
|
|
244
306
|
|
|
245
|
-
export function secretFrConfigHelper():
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
export function secretFrConfigHelper(defaultValue: Fr):
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
export function secretFrConfigHelper(defaultValue?: Fr):
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
307
|
+
export function secretFrConfigHelper(): {
|
|
308
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
309
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
310
|
+
defaultValue: undefined;
|
|
311
|
+
};
|
|
312
|
+
export function secretFrConfigHelper(defaultValue: Fr): {
|
|
313
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
314
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
315
|
+
defaultValue: SecretValue<Fr>;
|
|
316
|
+
};
|
|
317
|
+
export function secretFrConfigHelper(defaultValue?: Fr): {
|
|
318
|
+
parseEnv: (val: string) => SecretValue<Fr>;
|
|
319
|
+
parseVal: (val: string) => SecretValue<Fr>;
|
|
320
|
+
defaultValue: SecretValue<Fr> | undefined;
|
|
321
|
+
} {
|
|
260
322
|
const parse = (val: string) => new SecretValue(Fr.fromHexString(val));
|
|
261
323
|
return {
|
|
262
324
|
parseEnv: parse,
|
|
263
325
|
parseVal: parse,
|
|
264
326
|
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
265
|
-
isBoolean: true,
|
|
266
327
|
};
|
|
267
328
|
}
|
|
268
329
|
|
|
269
|
-
export function secretFqConfigHelper(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
export function secretFqConfigHelper():
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export function secretFqConfigHelper(defaultValue?: Fq):
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
330
|
+
export function secretFqConfigHelper(): {
|
|
331
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
332
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
333
|
+
defaultValue: undefined;
|
|
334
|
+
};
|
|
335
|
+
export function secretFqConfigHelper(defaultValue: Fq): {
|
|
336
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
337
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
338
|
+
defaultValue: SecretValue<Fq>;
|
|
339
|
+
};
|
|
340
|
+
export function secretFqConfigHelper(defaultValue?: Fq): {
|
|
341
|
+
parseEnv: (val: string) => SecretValue<Fq>;
|
|
342
|
+
parseVal: (val: string) => SecretValue<Fq>;
|
|
343
|
+
defaultValue: SecretValue<Fq> | undefined;
|
|
344
|
+
} {
|
|
284
345
|
const parse = (val: string) => new SecretValue(Fq.fromHexString(val));
|
|
285
346
|
return {
|
|
286
347
|
parseEnv: parse,
|
|
287
348
|
parseVal: parse,
|
|
288
|
-
defaultValue:
|
|
289
|
-
isBoolean: true,
|
|
349
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
290
350
|
};
|
|
291
351
|
}
|
|
292
352
|
|
|
293
353
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
354
|
+
* Parses a string into a safe integer, throwing if the value is numeric but not an integer.
|
|
355
|
+
*
|
|
356
|
+
* Unlike `parseInt`, this does not silently truncate decimals: `'0.8'` throws rather than
|
|
357
|
+
* becoming `0`. A fractional value indicates the caller intended a non-integer where only
|
|
358
|
+
* integers are supported (use `floatConfigHelper`/`percentageConfigHelper` for those).
|
|
296
359
|
* @param value - The string value to parse
|
|
297
|
-
* @
|
|
298
|
-
* @returns Either parsed value or default value
|
|
360
|
+
* @returns The parsed integer value
|
|
299
361
|
*/
|
|
300
|
-
function
|
|
301
|
-
const parsedValue =
|
|
302
|
-
|
|
362
|
+
function parseSafeInteger(value: string): number {
|
|
363
|
+
const parsedValue = parseFloat(value);
|
|
364
|
+
if (!Number.isSafeInteger(parsedValue)) {
|
|
365
|
+
throw new Error(`Invalid integer config value '${value}'; expected a whole number`);
|
|
366
|
+
}
|
|
367
|
+
return parsedValue;
|
|
303
368
|
}
|
|
304
369
|
|
|
305
370
|
/**
|
|
306
|
-
*
|
|
307
|
-
*
|
|
371
|
+
* Parses a string into a finite floating-point number, throwing if the value is not a finite number.
|
|
372
|
+
*
|
|
373
|
+
* Invalid input (e.g. `'abc'`, or an overflow to `Infinity`) throws rather than being silently
|
|
374
|
+
* swallowed, so a misconfigured value fails loudly instead of falling back to the config default.
|
|
308
375
|
* @param value - The string value to parse
|
|
309
|
-
* @
|
|
310
|
-
* @returns Either parsed value or default value
|
|
376
|
+
* @returns The parsed number
|
|
311
377
|
*/
|
|
312
|
-
function
|
|
378
|
+
function parseFiniteNumber(value: string): number {
|
|
313
379
|
const parsedValue = parseFloat(value);
|
|
314
|
-
|
|
380
|
+
if (!Number.isFinite(parsedValue)) {
|
|
381
|
+
throw new Error(`Invalid number config value '${value}'`);
|
|
382
|
+
}
|
|
383
|
+
return parsedValue;
|
|
315
384
|
}
|
|
316
385
|
|
|
317
386
|
/**
|
|
@@ -4,9 +4,14 @@ export const NetworkConfigSchema = z
|
|
|
4
4
|
.object({
|
|
5
5
|
bootnodes: z.array(z.string()),
|
|
6
6
|
snapshots: z.array(z.string()),
|
|
7
|
+
blobFileStoreUrls: z.array(z.string()).optional(),
|
|
8
|
+
txCollectionFileStoreUrls: z.array(z.string()).optional(),
|
|
7
9
|
registryAddress: z.string(),
|
|
8
10
|
feeAssetHandlerAddress: z.string().optional(),
|
|
9
11
|
l1ChainId: z.number(),
|
|
12
|
+
blockDurationMs: z.number().positive().optional(),
|
|
13
|
+
txPublicSetupAllowListExtend: z.string().optional(),
|
|
14
|
+
nodeVersion: z.string().optional(),
|
|
10
15
|
})
|
|
11
16
|
.passthrough(); // Allow additional unknown fields to pass through
|
|
12
17
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
export type NetworkNames =
|
|
2
2
|
| 'local'
|
|
3
|
-
| 'staging
|
|
4
|
-
| 'staging-public'
|
|
3
|
+
| 'staging'
|
|
5
4
|
| 'testnet'
|
|
6
5
|
| 'mainnet'
|
|
7
6
|
| 'next-net'
|
|
8
|
-
| 'devnet'
|
|
7
|
+
| 'devnet'
|
|
8
|
+
| `v${number}-devnet-${number}`;
|
|
9
9
|
|
|
10
10
|
export function getActiveNetworkName(name?: string): NetworkNames {
|
|
11
11
|
const network = name || process.env.NETWORK;
|
|
12
12
|
if (!network || network === '' || network === 'local') {
|
|
13
13
|
return 'local';
|
|
14
|
-
} else if (network === 'staging
|
|
15
|
-
return network;
|
|
16
|
-
} else if (network === 'staging-public') {
|
|
14
|
+
} else if (network === 'staging') {
|
|
17
15
|
return network;
|
|
18
16
|
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
19
17
|
return 'testnet';
|
|
@@ -23,6 +21,8 @@ export function getActiveNetworkName(name?: string): NetworkNames {
|
|
|
23
21
|
return 'next-net';
|
|
24
22
|
} else if (network === 'devnet') {
|
|
25
23
|
return 'devnet';
|
|
24
|
+
} else if (/^v\d+-devnet-\d+$/.test(network)) {
|
|
25
|
+
return network as `v${number}-devnet-${number}`;
|
|
26
26
|
}
|
|
27
27
|
throw new Error(`Unknown network: ${network}`);
|
|
28
28
|
}
|
|
@@ -43,7 +43,7 @@ export class SecretValue<T> {
|
|
|
43
43
|
/**
|
|
44
44
|
* Returns a Zod schema
|
|
45
45
|
*/
|
|
46
|
-
static schema<O>(valueSchema: ZodType<O, any
|
|
46
|
+
static schema<O>(valueSchema: ZodType<O, any>): ZodType<SecretValue<O>, any> {
|
|
47
47
|
return valueSchema.transform(value => new SecretValue<O>(value));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
2
|
|
|
3
|
-
import { createCipheriv, createDecipheriv, createHash, pbkdf2Sync, randomUUID } from 'crypto';
|
|
3
|
+
import { createCipheriv, createDecipheriv, createHash, pbkdf2, pbkdf2Sync, randomUUID } from 'crypto';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
|
+
import { promisify } from 'util';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -100,24 +101,15 @@ export interface Bn254KeystoreInterface {
|
|
|
100
101
|
version: number;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* Uses PBKDF2 with SHA-256 for key derivation and AES-128-CTR for encryption,
|
|
107
|
-
* following the EIP-2335 specification format.
|
|
108
|
-
*
|
|
109
|
-
* @param password - Password for encrypting the private key
|
|
110
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
111
|
-
* @param pubkeyHex - Public key as hex string (compressed or uncompressed)
|
|
112
|
-
* @param derivationPath - BIP-44 style derivation path (e.g., "m/12381/3600/0/0/0")
|
|
113
|
-
* @returns BN254 keystore object ready to be serialized to JSON
|
|
114
|
-
* @throws Error if private key is not 32-byte hex
|
|
115
|
-
*/
|
|
116
|
-
export function createBn254Keystore(
|
|
117
|
-
password: string,
|
|
104
|
+
const pbkdf2Async = promisify(pbkdf2);
|
|
105
|
+
|
|
106
|
+
function createBn254KeystoreFromDerivedKey(
|
|
118
107
|
privateKeyHex: string,
|
|
119
108
|
pubkeyHex: string,
|
|
120
109
|
derivationPath: string,
|
|
110
|
+
salt: Buffer,
|
|
111
|
+
iv: Buffer,
|
|
112
|
+
dk: Buffer,
|
|
121
113
|
): Bn254Keystore {
|
|
122
114
|
const ensureHex = (hex: string) => hex.replace(/^0x/i, '');
|
|
123
115
|
const privHex = ensureHex(privateKeyHex);
|
|
@@ -125,11 +117,7 @@ export function createBn254Keystore(
|
|
|
125
117
|
throw new Error('BLS private key must be 32-byte hex');
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
const salt = randomBytes(32);
|
|
129
|
-
const iv = randomBytes(16);
|
|
130
|
-
const dk = pbkdf2Sync(Buffer.from(password.normalize('NFKD'), 'utf8'), salt, 262144, 32, 'sha256');
|
|
131
120
|
const cipherKey = dk.subarray(0, 16);
|
|
132
|
-
|
|
133
121
|
const cipher = createCipheriv('aes-128-ctr', cipherKey, iv);
|
|
134
122
|
const plaintext = Buffer.from(privHex, 'hex');
|
|
135
123
|
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
@@ -166,6 +154,31 @@ export function createBn254Keystore(
|
|
|
166
154
|
};
|
|
167
155
|
}
|
|
168
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Creates a BN254 keystore object for a BN254 BLS private key.
|
|
159
|
+
*
|
|
160
|
+
* Uses PBKDF2 with SHA-256 for key derivation and AES-128-CTR for encryption,
|
|
161
|
+
* following the EIP-2335 specification format.
|
|
162
|
+
*
|
|
163
|
+
* @param password - Password for encrypting the private key
|
|
164
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
165
|
+
* @param pubkeyHex - Public key as hex string (compressed or uncompressed)
|
|
166
|
+
* @param derivationPath - BIP-44 style derivation path (e.g., "m/12381/3600/0/0/0")
|
|
167
|
+
* @returns BN254 keystore object ready to be serialized to JSON
|
|
168
|
+
* @throws Error if private key is not 32-byte hex
|
|
169
|
+
*/
|
|
170
|
+
export async function createBn254Keystore(
|
|
171
|
+
password: string,
|
|
172
|
+
privateKeyHex: string,
|
|
173
|
+
pubkeyHex: string,
|
|
174
|
+
derivationPath: string,
|
|
175
|
+
): Promise<Bn254Keystore> {
|
|
176
|
+
const salt = randomBytes(32);
|
|
177
|
+
const iv = randomBytes(16);
|
|
178
|
+
const dk = await pbkdf2Async(Buffer.from(password.normalize('NFKD'), 'utf8'), salt, 262144, 32, 'sha256');
|
|
179
|
+
return createBn254KeystoreFromDerivedKey(privateKeyHex, pubkeyHex, derivationPath, salt, iv, dk);
|
|
180
|
+
}
|
|
181
|
+
|
|
169
182
|
/**
|
|
170
183
|
* Loads and validates a BN254 keystore file.
|
|
171
184
|
*
|
|
@@ -262,26 +275,3 @@ export function decryptBn254KeystoreFromObject(keystore: Bn254Keystore, password
|
|
|
262
275
|
throw new Bn254KeystoreError(`Failed to decrypt keystore: ${String(error)}`, error as Error);
|
|
263
276
|
}
|
|
264
277
|
}
|
|
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
|
-
}
|
package/src/crypto/bls/index.ts
CHANGED