@aztec/foundation 0.0.0-test.1 → 0.0.1-commit.b655e406
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/array.d.ts +5 -0
- package/dest/array/array.d.ts.map +1 -1
- package/dest/array/array.js +11 -0
- package/dest/async-pool/index.d.ts.map +1 -1
- package/dest/async-pool/index.js +1 -0
- package/dest/bigint/index.d.ts +7 -0
- package/dest/bigint/index.d.ts.map +1 -0
- package/dest/bigint/index.js +15 -0
- package/dest/bigint-buffer/index.d.ts +0 -2
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/buffer/buffer16.d.ts +80 -0
- package/dest/buffer/buffer16.d.ts.map +1 -0
- package/dest/buffer/buffer16.js +100 -0
- package/dest/buffer/buffer32.d.ts +3 -7
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +6 -6
- package/dest/buffer/index.d.ts +1 -0
- package/dest/buffer/index.d.ts.map +1 -1
- package/dest/buffer/index.js +1 -0
- package/dest/collection/array.d.ts +16 -3
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +57 -3
- package/dest/collection/object.d.ts +16 -0
- package/dest/collection/object.d.ts.map +1 -1
- package/dest/collection/object.js +25 -0
- package/dest/config/env_var.d.ts +1 -1
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +48 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +115 -7
- package/dest/config/network_config.d.ts +42 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +9 -0
- package/dest/config/network_name.d.ts +3 -0
- package/dest/config/network_name.d.ts.map +1 -0
- package/dest/config/network_name.js +19 -0
- package/dest/config/secret_value.d.ts +28 -0
- package/dest/config/secret_value.d.ts.map +1 -0
- package/dest/config/secret_value.js +34 -0
- package/dest/crypto/aes128/index.d.ts +2 -4
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +23 -6
- package/dest/crypto/bls/bn254_keystore.d.ts +296 -0
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -0
- package/dest/crypto/bls/bn254_keystore.js +218 -0
- package/dest/crypto/bls/index.d.ts +13 -0
- package/dest/crypto/bls/index.d.ts.map +1 -0
- package/dest/crypto/bls/index.js +87 -0
- package/dest/crypto/bn254/bn254_utils.d.ts +39 -0
- package/dest/crypto/bn254/bn254_utils.d.ts.map +1 -0
- package/dest/crypto/bn254/bn254_utils.js +56 -0
- package/dest/crypto/bn254/index.d.ts +55 -0
- package/dest/crypto/bn254/index.d.ts.map +1 -0
- package/dest/crypto/bn254/index.js +142 -0
- package/dest/crypto/ecdsa/index.d.ts +2 -2
- package/dest/crypto/ecdsa/index.d.ts.map +1 -1
- package/dest/crypto/ecdsa/index.js +70 -48
- package/dest/crypto/ecdsa/signature.d.ts +1 -3
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
- package/dest/crypto/grumpkin/index.d.ts +6 -13
- package/dest/crypto/grumpkin/index.d.ts.map +1 -1
- package/dest/crypto/grumpkin/index.js +69 -54
- package/dest/crypto/index.d.ts +2 -0
- package/dest/crypto/index.d.ts.map +1 -1
- package/dest/crypto/index.js +2 -0
- package/dest/crypto/keccak/index.d.ts +2 -4
- package/dest/crypto/keccak/index.d.ts.map +1 -1
- package/dest/crypto/keys/index.d.ts +0 -2
- package/dest/crypto/keys/index.d.ts.map +1 -1
- package/dest/crypto/keys/index.js +9 -4
- package/dest/crypto/pedersen/pedersen.noble.d.ts +2 -4
- package/dest/crypto/pedersen/pedersen.noble.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -4
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.js +29 -13
- package/dest/crypto/poseidon/index.d.ts +0 -2
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +42 -17
- package/dest/crypto/random/index.d.ts +1 -3
- package/dest/crypto/random/index.d.ts.map +1 -1
- package/dest/crypto/random/index.js +2 -34
- package/dest/crypto/random/randomness_singleton.d.ts +0 -2
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +35 -37
- package/dest/crypto/schnorr/signature.d.ts +3 -5
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/secp256k1/index.d.ts +4 -6
- package/dest/crypto/secp256k1/index.d.ts.map +1 -1
- package/dest/crypto/secp256k1/index.js +29 -18
- package/dest/crypto/secp256k1-signer/utils.d.ts +55 -4
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +92 -6
- package/dest/crypto/serialize.d.ts +4 -6
- package/dest/crypto/serialize.d.ts.map +1 -1
- package/dest/crypto/sha256/index.d.ts +21 -4
- package/dest/crypto/sha256/index.d.ts.map +1 -1
- package/dest/crypto/sha256/index.js +42 -0
- package/dest/crypto/sha512/index.d.ts +1 -3
- package/dest/crypto/sha512/index.d.ts.map +1 -1
- package/dest/crypto/signature/index.d.ts +0 -2
- package/dest/crypto/signature/index.d.ts.map +1 -1
- package/dest/crypto/sync/index.js +3 -1
- package/dest/crypto/sync/pedersen/index.d.ts +2 -4
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.js +17 -10
- package/dest/crypto/sync/poseidon/index.d.ts +0 -2
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +27 -12
- package/dest/decorators/memoize.d.ts.map +1 -1
- package/dest/eth-address/index.d.ts +6 -7
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +5 -0
- package/dest/eth-signature/eth_signature.d.ts +16 -14
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +31 -17
- package/dest/fields/bls12_fields.d.ts +148 -0
- package/dest/fields/bls12_fields.d.ts.map +1 -0
- package/dest/fields/bls12_fields.js +359 -0
- package/dest/fields/bls12_point.d.ts +229 -0
- package/dest/fields/bls12_point.d.ts.map +1 -0
- package/dest/fields/bls12_point.js +398 -0
- package/dest/fields/coordinate.d.ts +0 -2
- package/dest/fields/coordinate.d.ts.map +1 -1
- package/dest/fields/fields.d.ts +6 -3
- package/dest/fields/fields.d.ts.map +1 -1
- package/dest/fields/fields.js +43 -15
- package/dest/fields/index.d.ts +2 -0
- package/dest/fields/index.d.ts.map +1 -1
- package/dest/fields/index.js +2 -0
- package/dest/fields/point.d.ts +2 -4
- package/dest/fields/point.d.ts.map +1 -1
- package/dest/fields/point.js +3 -3
- package/dest/fs/index.d.ts +1 -0
- package/dest/fs/index.d.ts.map +1 -1
- package/dest/fs/index.js +1 -0
- package/dest/fs/try_rm_dir.d.ts +3 -0
- package/dest/fs/try_rm_dir.d.ts.map +1 -0
- package/dest/fs/try_rm_dir.js +16 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/iterable/filter.js +1 -1
- package/dest/iterable/map.js +1 -1
- package/dest/jest/env.js +48 -0
- package/dest/jest/setupAfterEnv.js +3 -0
- package/dest/json-rpc/client/fetch.d.ts +2 -2
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +16 -30
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +9 -3
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +173 -13
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +6 -7
- package/dest/json-rpc/convert.d.ts +2 -9
- package/dest/json-rpc/convert.d.ts.map +1 -1
- package/dest/json-rpc/convert.js +1 -9
- package/dest/json-rpc/errors.d.ts +4 -0
- package/dest/json-rpc/errors.d.ts.map +1 -0
- package/dest/json-rpc/errors.js +6 -0
- package/dest/json-rpc/fixtures/class_a.d.ts +5 -3
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/class_b.d.ts +5 -3
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
- package/dest/json-rpc/index.d.ts +2 -1
- package/dest/json-rpc/index.d.ts.map +1 -1
- package/dest/json-rpc/index.js +2 -1
- package/dest/json-rpc/js_utils.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +21 -22
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +161 -56
- package/dest/json-rpc/test/integration.d.ts +1 -2
- package/dest/json-rpc/test/integration.d.ts.map +1 -1
- package/dest/log/console.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.d.ts +0 -1
- package/dest/log/gcloud-logger-config.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.js +1 -9
- package/dest/log/index.d.ts +4 -4
- package/dest/log/index.d.ts.map +1 -1
- package/dest/log/index.js +4 -4
- package/dest/log/libp2p_logger.js +13 -2
- package/dest/log/log_fn.d.ts +1 -1
- package/dest/log/log_fn.d.ts.map +1 -1
- package/dest/log/noir_debug_log_util.d.ts +14 -0
- package/dest/log/noir_debug_log_util.d.ts.map +1 -0
- package/dest/log/noir_debug_log_util.js +14 -0
- package/dest/log/pino-logger.d.ts +2 -2
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +28 -2
- package/dest/message/index.d.ts.map +1 -1
- package/dest/mutex/mutex_database.d.ts.map +1 -1
- package/dest/noir/noir_package_config.d.ts +4 -4
- package/dest/number/index.d.ts +3 -0
- package/dest/number/index.d.ts.map +1 -0
- package/dest/number/index.js +12 -0
- package/dest/profiler/index.d.ts +2 -0
- package/dest/profiler/index.d.ts.map +1 -0
- package/dest/profiler/index.js +1 -0
- package/dest/profiler/profiler.d.ts +8 -0
- package/dest/profiler/profiler.d.ts.map +1 -0
- package/dest/profiler/profiler.js +97 -0
- package/dest/promise/running-promise.d.ts +1 -1
- package/dest/promise/running-promise.d.ts.map +1 -1
- package/dest/promise/running-promise.js +2 -2
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.js +1 -1
- package/dest/queue/bounded_serial_queue.d.ts.map +1 -1
- package/dest/queue/serial_queue.d.ts +2 -2
- package/dest/queue/serial_queue.d.ts.map +1 -1
- package/dest/queue/serial_queue.js +7 -5
- package/dest/retry/index.d.ts +3 -2
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +2 -2
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/schemas/parse.js +1 -1
- package/dest/schemas/schemas.d.ts +9 -6
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +15 -1
- package/dest/schemas/utils.d.ts +1 -3
- package/dest/schemas/utils.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.d.ts +27 -2
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +44 -2
- package/dest/serialize/field_reader.d.ts +10 -1
- package/dest/serialize/field_reader.d.ts.map +1 -1
- package/dest/serialize/field_reader.js +18 -1
- package/dest/serialize/free_funcs.d.ts +23 -21
- package/dest/serialize/free_funcs.d.ts.map +1 -1
- package/dest/serialize/free_funcs.js +21 -27
- package/dest/serialize/serialize.d.ts +4 -5
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/string/index.d.ts +7 -2
- package/dest/string/index.d.ts.map +1 -1
- package/dest/string/index.js +27 -1
- package/dest/testing/files/index.d.ts +0 -2
- package/dest/testing/files/index.d.ts.map +1 -1
- package/dest/testing/files/index.js +2 -2
- package/dest/testing/formatting.d.ts +4 -0
- package/dest/testing/formatting.d.ts.map +1 -0
- package/dest/testing/formatting.js +3 -0
- package/dest/testing/index.d.ts +1 -0
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/dest/timer/date.d.ts +2 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +5 -3
- package/dest/timer/index.d.ts +1 -1
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +18 -5
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +43 -22
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +1 -1
- package/dest/transport/index.d.ts +0 -1
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/transport/interface/connector.d.ts.map +1 -1
- package/dest/transport/interface/listener.d.ts +0 -1
- package/dest/transport/interface/listener.d.ts.map +1 -1
- package/dest/transport/interface/socket.d.ts.map +1 -1
- package/dest/transport/node/node_connector.d.ts +0 -1
- package/dest/transport/node/node_connector.d.ts.map +1 -1
- package/dest/transport/node/node_connector_socket.d.ts +0 -1
- package/dest/transport/node/node_connector_socket.d.ts.map +1 -1
- package/dest/transport/node/node_listener.d.ts +0 -1
- package/dest/transport/node/node_listener.d.ts.map +1 -1
- package/dest/transport/node/node_listener_socket.d.ts +0 -1
- package/dest/transport/node/node_listener_socket.d.ts.map +1 -1
- package/dest/transport/transport_client.d.ts +0 -1
- package/dest/transport/transport_client.d.ts.map +1 -1
- package/dest/transport/transport_server.d.ts.map +1 -1
- package/dest/trees/hasher.d.ts +4 -6
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/index.d.ts +1 -0
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +1 -0
- package/dest/trees/indexed_merkle_tree.d.ts +0 -2
- package/dest/trees/indexed_merkle_tree.d.ts.map +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -3
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/indexed_tree_leaf.d.ts +0 -2
- package/dest/trees/indexed_tree_leaf.d.ts.map +1 -1
- package/dest/trees/membership_witness.d.ts +19 -3
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +13 -0
- package/dest/trees/merkle_tree.d.ts +0 -2
- package/dest/trees/merkle_tree.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts +11 -3
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +31 -1
- package/dest/trees/sibling_path.d.ts +6 -8
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts +19 -8
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree.js +49 -50
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +48 -0
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/unbalanced_merkle_tree_calculator.js +162 -0
- package/dest/trees/unbalanced_tree_store.d.ts +1 -0
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +6 -0
- package/dest/types/index.d.ts +25 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/url/index.d.ts.map +1 -1
- package/dest/url/index.js +1 -1
- package/package.json +35 -41
- package/src/array/array.ts +13 -0
- package/src/async-pool/index.ts +1 -0
- package/src/bigint/index.ts +20 -0
- package/src/buffer/buffer16.ts +133 -0
- package/src/buffer/buffer32.ts +8 -6
- package/src/buffer/index.ts +1 -0
- package/src/collection/array.ts +66 -4
- package/src/collection/object.ts +37 -0
- package/src/config/env_var.ts +142 -52
- package/src/config/index.ts +191 -8
- package/src/config/network_config.ts +16 -0
- package/src/config/network_name.ts +28 -0
- package/src/config/secret_value.ts +49 -0
- package/src/crypto/aes128/index.ts +19 -10
- package/src/crypto/bls/bn254_keystore.ts +287 -0
- package/src/crypto/bls/index.ts +77 -0
- package/src/crypto/bn254/bn254_utils.ts +64 -0
- package/src/crypto/bn254/index.ts +170 -0
- package/src/crypto/ecdsa/index.ts +41 -23
- package/src/crypto/grumpkin/index.ts +35 -45
- package/src/crypto/index.ts +2 -0
- package/src/crypto/keys/index.ts +5 -5
- package/src/crypto/pedersen/pedersen.wasm.ts +22 -18
- package/src/crypto/poseidon/index.ts +32 -24
- package/src/crypto/random/index.ts +2 -40
- package/src/crypto/schnorr/index.ts +20 -17
- package/src/crypto/secp256k1/index.ts +15 -11
- package/src/crypto/secp256k1-signer/utils.ts +120 -7
- package/src/crypto/sha256/index.ts +47 -0
- package/src/crypto/sync/index.ts +1 -1
- package/src/crypto/sync/pedersen/index.ts +16 -15
- package/src/crypto/sync/poseidon/index.ts +27 -22
- package/src/eth-address/index.ts +9 -2
- package/src/eth-signature/eth_signature.ts +44 -22
- package/src/fields/bls12_fields.ts +463 -0
- package/src/fields/bls12_point.ts +450 -0
- package/src/fields/fields.ts +37 -9
- package/src/fields/index.ts +2 -0
- package/src/fields/point.ts +1 -3
- package/src/fs/index.ts +1 -0
- package/src/fs/try_rm_dir.ts +15 -0
- package/src/index.ts +1 -2
- package/src/iterable/filter.ts +1 -1
- package/src/iterable/map.ts +1 -1
- package/src/jest/env.mjs +52 -0
- package/src/jest/setupAfterEnv.mjs +3 -0
- package/src/json-rpc/client/fetch.ts +14 -33
- package/src/json-rpc/client/safe_json_rpc_client.ts +226 -13
- package/src/json-rpc/client/undici.ts +8 -15
- package/src/json-rpc/convert.ts +3 -12
- package/src/json-rpc/errors.ts +6 -0
- package/src/json-rpc/fixtures/class_a.ts +4 -1
- package/src/json-rpc/fixtures/class_b.ts +4 -1
- package/src/json-rpc/index.ts +2 -1
- package/src/json-rpc/server/safe_json_rpc_server.ts +141 -48
- package/src/json-rpc/test/integration.ts +1 -1
- package/src/log/console.ts +4 -1
- package/src/log/gcloud-logger-config.ts +3 -7
- package/src/log/index.ts +4 -4
- package/src/log/libp2p_logger.ts +21 -2
- package/src/log/log_fn.ts +1 -1
- package/src/log/noir_debug_log_util.ts +21 -0
- package/src/log/pino-logger.ts +33 -2
- package/src/message/index.ts +5 -1
- package/src/mutex/mutex_database.ts +2 -3
- package/src/number/index.ts +14 -0
- package/src/profiler/index.ts +1 -0
- package/src/profiler/profiler.ts +125 -0
- package/src/promise/running-promise.ts +2 -2
- package/src/queue/batch_queue.ts +1 -1
- package/src/queue/bounded_serial_queue.ts +4 -1
- package/src/queue/serial_queue.ts +5 -5
- package/src/retry/index.ts +10 -5
- package/src/schemas/api.ts +4 -4
- package/src/schemas/parse.ts +1 -1
- package/src/schemas/schemas.ts +19 -1
- package/src/serialize/buffer_reader.ts +60 -3
- package/src/serialize/field_reader.ts +27 -3
- package/src/serialize/free_funcs.ts +25 -31
- package/src/serialize/serialize.ts +2 -0
- package/src/string/index.ts +36 -1
- package/src/testing/files/index.ts +6 -2
- package/src/testing/formatting.ts +3 -0
- package/src/testing/index.ts +1 -0
- package/src/timer/date.ts +9 -3
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +54 -19
- package/src/transport/index.ts +0 -1
- package/src/transport/interface/connector.ts +0 -1
- package/src/transport/interface/listener.ts +2 -3
- package/src/transport/interface/socket.ts +2 -3
- package/src/transport/transport_client.ts +3 -4
- package/src/transport/transport_server.ts +4 -1
- package/src/trees/hasher.ts +4 -4
- package/src/trees/index.ts +1 -0
- package/src/trees/indexed_merkle_tree.ts +5 -1
- package/src/trees/indexed_merkle_tree_calculator.ts +2 -2
- package/src/trees/membership_witness.ts +13 -0
- package/src/trees/merkle_tree.ts +4 -1
- package/src/trees/merkle_tree_calculator.ts +43 -5
- package/src/trees/unbalanced_merkle_tree.ts +50 -42
- package/src/trees/unbalanced_merkle_tree_calculator.ts +194 -0
- package/src/trees/unbalanced_tree_store.ts +5 -1
- package/src/types/index.ts +25 -4
- package/src/url/index.ts +0 -1
- package/dest/crypto/pedersen/pedersen.elliptic.d.ts +0 -13
- package/dest/crypto/pedersen/pedersen.elliptic.d.ts.map +0 -1
- package/dest/crypto/pedersen/pedersen.elliptic.js +0 -582
- package/dest/log/debug.d.ts +0 -56
- package/dest/log/debug.d.ts.map +0 -1
- package/dest/log/debug.js +0 -75
- package/dest/log/log_history.d.ts +0 -31
- package/dest/log/log_history.d.ts.map +0 -1
- package/dest/log/log_history.js +0 -38
- package/dest/transport/browser/index.d.ts +0 -5
- package/dest/transport/browser/index.d.ts.map +0 -1
- package/dest/transport/browser/index.js +0 -4
- package/dest/transport/browser/message_port_socket.d.ts +0 -37
- package/dest/transport/browser/message_port_socket.d.ts.map +0 -1
- package/dest/transport/browser/message_port_socket.js +0 -42
- package/dest/transport/browser/shared_worker_connector.d.ts +0 -19
- package/dest/transport/browser/shared_worker_connector.d.ts.map +0 -1
- package/dest/transport/browser/shared_worker_connector.js +0 -19
- package/dest/transport/browser/shared_worker_listener.d.ts +0 -38
- package/dest/transport/browser/shared_worker_listener.d.ts.map +0 -1
- package/dest/transport/browser/shared_worker_listener.js +0 -33
- package/dest/transport/browser/worker_connector.d.ts +0 -26
- package/dest/transport/browser/worker_connector.d.ts.map +0 -1
- package/dest/transport/browser/worker_connector.js +0 -30
- package/dest/transport/browser/worker_listener.d.ts +0 -39
- package/dest/transport/browser/worker_listener.d.ts.map +0 -1
- package/dest/transport/browser/worker_listener.js +0 -35
- package/dest/wasm/empty_wasi_sdk.d.ts +0 -130
- package/dest/wasm/empty_wasi_sdk.d.ts.map +0 -1
- package/dest/wasm/empty_wasi_sdk.js +0 -148
- package/dest/wasm/index.d.ts +0 -2
- package/dest/wasm/index.d.ts.map +0 -1
- package/dest/wasm/index.js +0 -1
- package/dest/wasm/wasm_module.d.ts +0 -136
- package/dest/wasm/wasm_module.d.ts.map +0 -1
- package/dest/wasm/wasm_module.js +0 -196
- package/dest/worker/browser/index.d.ts +0 -3
- package/dest/worker/browser/index.d.ts.map +0 -1
- package/dest/worker/browser/index.js +0 -2
- package/dest/worker/browser/start_web_module.d.ts +0 -7
- package/dest/worker/browser/start_web_module.d.ts.map +0 -1
- package/dest/worker/browser/start_web_module.js +0 -27
- package/dest/worker/browser/web_data_store.d.ts +0 -24
- package/dest/worker/browser/web_data_store.d.ts.map +0 -1
- package/dest/worker/browser/web_data_store.js +0 -29
- package/dest/worker/browser/web_worker.d.ts +0 -10
- package/dest/worker/browser/web_worker.d.ts.map +0 -1
- package/dest/worker/browser/web_worker.js +0 -25
- package/dest/worker/data_store.d.ts +0 -21
- package/dest/worker/data_store.d.ts.map +0 -1
- package/dest/worker/data_store.js +0 -3
- package/dest/worker/index.d.ts +0 -3
- package/dest/worker/index.d.ts.map +0 -1
- package/dest/worker/index.js +0 -1
- package/dest/worker/node/index.d.ts +0 -3
- package/dest/worker/node/index.d.ts.map +0 -1
- package/dest/worker/node/index.js +0 -2
- package/dest/worker/node/node_data_store.d.ts +0 -13
- package/dest/worker/node/node_data_store.d.ts.map +0 -1
- package/dest/worker/node/node_data_store.js +0 -20
- package/dest/worker/node/node_worker.d.ts +0 -6
- package/dest/worker/node/node_worker.d.ts.map +0 -1
- package/dest/worker/node/node_worker.js +0 -22
- package/dest/worker/node/start_node_module.d.ts +0 -7
- package/dest/worker/node/start_node_module.d.ts.map +0 -1
- package/dest/worker/node/start_node_module.js +0 -31
- package/dest/worker/wasm_worker.d.ts +0 -9
- package/dest/worker/wasm_worker.d.ts.map +0 -1
- package/dest/worker/wasm_worker.js +0 -3
- package/dest/worker/worker_pool.d.ts +0 -40
- package/dest/worker/worker_pool.d.ts.map +0 -1
- package/dest/worker/worker_pool.js +0 -51
- package/src/crypto/pedersen/pedersen.elliptic.ts +0 -584
- package/src/log/debug.ts +0 -104
- package/src/log/log_history.ts +0 -44
- package/src/transport/browser/index.ts +0 -4
- package/src/transport/browser/message_port_socket.ts +0 -48
- package/src/transport/browser/shared_worker_connector.ts +0 -21
- package/src/transport/browser/shared_worker_listener.ts +0 -53
- package/src/transport/browser/worker_connector.ts +0 -30
- package/src/transport/browser/worker_listener.ts +0 -54
- package/src/wasm/README.md +0 -6
- package/src/wasm/empty_wasi_sdk.ts +0 -166
- package/src/wasm/fixtures/gcd.wasm +0 -0
- package/src/wasm/fixtures/gcd.wat +0 -27
- package/src/wasm/index.ts +0 -1
- package/src/wasm/wasm_module.ts +0 -260
- package/src/worker/browser/index.ts +0 -2
- package/src/worker/browser/start_web_module.ts +0 -24
- package/src/worker/browser/web_data_store.ts +0 -38
- package/src/worker/browser/web_worker.ts +0 -25
- package/src/worker/data_store.ts +0 -19
- package/src/worker/index.ts +0 -2
- package/src/worker/node/index.ts +0 -2
- package/src/worker/node/node_data_store.ts +0 -27
- package/src/worker/node/node_worker.ts +0 -23
- package/src/worker/node/start_node_module.ts +0 -30
- package/src/worker/wasm_worker.ts +0 -7
- package/src/worker/worker_pool.ts +0 -73
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/* eslint-disable camelcase */ import { bls12_381 } from '@noble/curves/bls12-381';
|
|
2
|
+
import { inspect } from 'util';
|
|
3
|
+
import { toBufferBE } from '../bigint-buffer/index.js';
|
|
4
|
+
import { randomBoolean } from '../crypto/random/index.js';
|
|
5
|
+
import { hexSchemaFor } from '../schemas/utils.js';
|
|
6
|
+
import { BufferReader, serializeToBuffer } from '../serialize/index.js';
|
|
7
|
+
import { bufferToHex, hexToBuffer } from '../string/index.js';
|
|
8
|
+
import { BLS12Fq } from './bls12_fields.js';
|
|
9
|
+
import { Fr } from './fields.js';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a Point on an elliptic curve with x and y coordinates.
|
|
12
|
+
* The Point class provides methods for creating instances from different input types,
|
|
13
|
+
* converting instances to various output formats, and checking the equality of points.
|
|
14
|
+
* TODO(#7386): Clean up this class.
|
|
15
|
+
*/ export class BLS12Point {
|
|
16
|
+
x;
|
|
17
|
+
y;
|
|
18
|
+
isInfinite;
|
|
19
|
+
static ZERO = new BLS12Point(BLS12Fq.ZERO, BLS12Fq.ZERO, true);
|
|
20
|
+
static ONE = new BLS12Point(new BLS12Fq(bls12_381.G1.CURVE.Gx), new BLS12Fq(bls12_381.G1.CURVE.Gy), false);
|
|
21
|
+
static SIZE_IN_BYTES = BLS12Fq.SIZE_IN_BYTES * 2;
|
|
22
|
+
static COMPRESSED_SIZE_IN_BYTES = BLS12Fq.SIZE_IN_BYTES;
|
|
23
|
+
static COMPRESSED_ZERO = setMask(Buffer.alloc(BLS12Fq.SIZE_IN_BYTES), {
|
|
24
|
+
infinity: true,
|
|
25
|
+
compressed: true
|
|
26
|
+
});
|
|
27
|
+
constructor(/**
|
|
28
|
+
* The point's x coordinate
|
|
29
|
+
*/ x, /**
|
|
30
|
+
* The point's y coordinate
|
|
31
|
+
*/ y, /**
|
|
32
|
+
* Whether the point is at infinity
|
|
33
|
+
*/ isInfinite){
|
|
34
|
+
this.x = x;
|
|
35
|
+
this.y = y;
|
|
36
|
+
this.isInfinite = isInfinite;
|
|
37
|
+
if (!BLS12Point.isOnCurve(x, y)) {
|
|
38
|
+
throw new BLSPointNotOnCurveError(x, y);
|
|
39
|
+
}
|
|
40
|
+
if (isInfinite && !(x.equals(BLS12Fq.ZERO) && y.equals(BLS12Fq.ZERO))) {
|
|
41
|
+
throw new Error(`BLS12-381 G1 point ( ${x.toString()}, ${y.toString()} ) is not infinite.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
toJSON() {
|
|
45
|
+
return this.toString();
|
|
46
|
+
}
|
|
47
|
+
[inspect.custom]() {
|
|
48
|
+
return `BLS12Point {
|
|
49
|
+
x: ${inspect(this.x)},
|
|
50
|
+
y: ${inspect(this.y)},
|
|
51
|
+
isInfinite: ${inspect(this.isInfinite)},
|
|
52
|
+
}`;
|
|
53
|
+
}
|
|
54
|
+
static get schema() {
|
|
55
|
+
return hexSchemaFor(BLS12Point);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generate a random Point instance.
|
|
59
|
+
*
|
|
60
|
+
* @returns A randomly generated Point instance.
|
|
61
|
+
*/ static random() {
|
|
62
|
+
while(true){
|
|
63
|
+
try {
|
|
64
|
+
return BLS12Point.fromXAndSign(BLS12Fq.random(), randomBoolean());
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (!(e instanceof BLSPointNotOnCurveError)) {
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a Point instance from a given buffer or BufferReader.
|
|
75
|
+
* The input 'buffer' should have exactly 96 bytes representing the x and y coordinates.
|
|
76
|
+
*
|
|
77
|
+
* @param buffer - The buffer or BufferReader containing the x and y coordinates of the point.
|
|
78
|
+
* @returns A Point instance.
|
|
79
|
+
*/ static fromBuffer(buffer) {
|
|
80
|
+
const reader = BufferReader.asReader(buffer);
|
|
81
|
+
const [x, y] = [
|
|
82
|
+
BLS12Fq.fromBuffer(reader),
|
|
83
|
+
BLS12Fq.fromBuffer(reader)
|
|
84
|
+
];
|
|
85
|
+
return new this(x, y, x.isZero() && y.isZero());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a Point instance from a hex-encoded string.
|
|
89
|
+
* The input should be prefixed with '0x' or not, and have exactly 128 hex characters representing the x and y coordinates.
|
|
90
|
+
* Throws an error if the input length is invalid or coordinate values are out of range.
|
|
91
|
+
*
|
|
92
|
+
* @param str - The hex-encoded string representing the Point coordinates.
|
|
93
|
+
* @returns A Point instance.
|
|
94
|
+
*/ static fromString(str) {
|
|
95
|
+
return this.fromBuffer(hexToBuffer(str));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create a compressed buffer instance from a point.
|
|
99
|
+
* @dev NOTE: The compression standard for BLS12-381 differs from BN curves. Instead of
|
|
100
|
+
* one is_positive flag, we have three flags to prepend:
|
|
101
|
+
* - is_compressed: indicator that the point is compressed
|
|
102
|
+
* - is_infinity: whether the point the point at infinity
|
|
103
|
+
* - is_greater: only set if is_compressed && !is_infinity && y > (p - 1)/2
|
|
104
|
+
* See https://github.com/arkworks-rs/algebra/blob/master/curves/bls12_381/src/curves/g1.rs -> serialize_with_mode() -> encoding
|
|
105
|
+
* and noble-curves/src/bls12-381.ts -> setMask()
|
|
106
|
+
* @dev Most of the logic below is taken from noble-curves/src/bls12-381.ts -> toBytes()
|
|
107
|
+
* @param point A BLS12Point instance.
|
|
108
|
+
* @returns The buffer containing the x coordinate and the flags of the y coordinate.
|
|
109
|
+
*/ compress() {
|
|
110
|
+
if (this.isZero()) {
|
|
111
|
+
return BLS12Point.COMPRESSED_ZERO;
|
|
112
|
+
}
|
|
113
|
+
const isGreater = this.y.isNegative();
|
|
114
|
+
return setMask(toBufferBE(this.x.toBigInt(), BLS12Fq.SIZE_IN_BYTES), {
|
|
115
|
+
compressed: true,
|
|
116
|
+
sort: isGreater
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a Point instance from a compressed buffer.
|
|
121
|
+
* @dev See compress() above for compression encoding for BLS12-381.
|
|
122
|
+
* @dev Most of the logic below is taken from noble-curves/src/bls12-381.ts -> fromBytes()
|
|
123
|
+
* @param buffer - The buffer containing the x coordinate and the flags of the y coordinate.
|
|
124
|
+
* @returns A BLS12Point instance.
|
|
125
|
+
*/ static decompress(buffer) {
|
|
126
|
+
const { compressed, infinity, sort, value: decompressed } = parseMask(buffer);
|
|
127
|
+
if (decompressed.length === BLS12Fq.SIZE_IN_BYTES && compressed) {
|
|
128
|
+
const x = new BLS12Fq(decompressed);
|
|
129
|
+
if (infinity) {
|
|
130
|
+
if (!x.isZero()) {
|
|
131
|
+
throw new Error('Non-empty compressed G1 point at infinity');
|
|
132
|
+
}
|
|
133
|
+
return new BLS12Point(x, BLS12Fq.ZERO, true);
|
|
134
|
+
}
|
|
135
|
+
let y = this.YFromX(x);
|
|
136
|
+
if (!y) {
|
|
137
|
+
throw new BLSPointNotOnCurveError(x);
|
|
138
|
+
}
|
|
139
|
+
if (y.isNegative() !== sort) {
|
|
140
|
+
y = y.negate();
|
|
141
|
+
}
|
|
142
|
+
return new BLS12Point(x, y, infinity);
|
|
143
|
+
} else {
|
|
144
|
+
throw new Error('Invalid compressed G1 point of BLS12-381');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts a Point to two BN254 Fr elements by storing its compressed form (48 bytes) as:
|
|
149
|
+
* +-------------------+------------------------+
|
|
150
|
+
* | 31 bytes | 17 bytes |
|
|
151
|
+
* +-------------------+------------------------+
|
|
152
|
+
* | Field Element 1 | Field Element 2 |
|
|
153
|
+
* | [0][bytes 0-30] | [0...0][bytes 31-47] |
|
|
154
|
+
* +-------------------+------------------------+
|
|
155
|
+
* Used in the rollup circuits to store blob commitments in the native field type. See blob.ts.
|
|
156
|
+
* @param point - A BLS12Point instance.
|
|
157
|
+
* @returns The point fields.
|
|
158
|
+
*/ toBN254Fields() {
|
|
159
|
+
const compressed = this.compress();
|
|
160
|
+
return [
|
|
161
|
+
new Fr(compressed.subarray(0, 31)),
|
|
162
|
+
new Fr(compressed.subarray(31, 48))
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates a Point instance from 2 BN254 Fr fields as encoded in toBNFields() above.
|
|
167
|
+
* Used in the rollup circuits to store blob commitments in the native field type. See blob.ts.
|
|
168
|
+
* @param fields - The encoded BN254 fields.
|
|
169
|
+
* @returns The point fields.
|
|
170
|
+
*/ static fromBN254Fields(fields) {
|
|
171
|
+
return BLS12Point.decompress(Buffer.concat([
|
|
172
|
+
fields[0].toBuffer().subarray(1),
|
|
173
|
+
fields[1].toBuffer().subarray(-17)
|
|
174
|
+
]));
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates a point from an array of 2 fields.
|
|
178
|
+
* @returns The point
|
|
179
|
+
*/ static fromBLS12FqFields(fields) {
|
|
180
|
+
return new this(fields[0], fields[1], !fields[2].isEmpty());
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Creates a point from @noble/curves projective point definition.
|
|
184
|
+
* @returns The point
|
|
185
|
+
*/ static fromNobleProjectivePoint(point) {
|
|
186
|
+
const affine = point.toAffine();
|
|
187
|
+
return new BLS12Point(new BLS12Fq(affine.x), new BLS12Fq(affine.y), point.equals(bls12_381.G1.ProjectivePoint.ZERO));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Uses the x coordinate and isPositive flag (+/-) to reconstruct the point.
|
|
191
|
+
* @param x - The x coordinate of the point
|
|
192
|
+
* @param sign - The "sign" of the y coordinate - note that this is not a sign as is known in integer arithmetic.
|
|
193
|
+
* Instead it is a boolean flag that determines whether the y coordinate is <= (Fr.MODULUS - 1) / 2
|
|
194
|
+
* @returns The point as an array of 2 fields
|
|
195
|
+
*/ static fromXAndSign(x, sign) {
|
|
196
|
+
const y = BLS12Point.YFromX(x);
|
|
197
|
+
if (y == null) {
|
|
198
|
+
throw new BLSPointNotOnCurveError(x);
|
|
199
|
+
}
|
|
200
|
+
const yPositiveBigInt = y.isNegative() ? BLS12Fq.MODULUS - y.toBigInt() : y.toBigInt();
|
|
201
|
+
const yNegativeBigInt = BLS12Fq.MODULUS - yPositiveBigInt;
|
|
202
|
+
// Choose the positive or negative root based on isPositive
|
|
203
|
+
const finalY = sign ? new BLS12Fq(yPositiveBigInt) : new BLS12Fq(yNegativeBigInt);
|
|
204
|
+
// Create and return the new Point
|
|
205
|
+
return new this(x, finalY, false);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @param x - The x coordinate of the point
|
|
209
|
+
* @returns y^2 such that y^2 = x^3 + 4
|
|
210
|
+
*/ static YSquaredFromX(x) {
|
|
211
|
+
return new BLS12Fq(bls12_381.G1.weierstrassEquation(x.toBigInt()));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* @param x - The x coordinate of the point
|
|
215
|
+
* @returns The y coordinate of the point, if it exists on BLS12-381
|
|
216
|
+
*/ static YFromX(x) {
|
|
217
|
+
const ySquared = this.YSquaredFromX(x);
|
|
218
|
+
// y is then simply the square root. Note however that not all square roots exist in the field: if sqrt returns null
|
|
219
|
+
// then there is no point in the curve with this x coordinate.
|
|
220
|
+
return ySquared.sqrt();
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @param x - The x coordinate of the point
|
|
224
|
+
* @param y - The y coordinate of the point
|
|
225
|
+
* @returns Whether the point exists on BLS12-381
|
|
226
|
+
*/ static isOnCurve(x, y) {
|
|
227
|
+
if (x.isZero() && y.isZero()) {
|
|
228
|
+
// Representation of inf point
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
// The BLS12-381 equation is y^2 = x^3 + 4. We could use `YFromX` and then compare to `this.y`, but this would
|
|
232
|
+
// involve computing the square root of y, of which there are two possible valid values. This method is also faster.
|
|
233
|
+
const lhs = y.square();
|
|
234
|
+
const rhs = this.YSquaredFromX(x);
|
|
235
|
+
return lhs.equals(rhs);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Returns the contents of the point as an array of 2 fields.
|
|
239
|
+
* @returns The point as an array of 2 fields
|
|
240
|
+
*/ toBLS12FqFields() {
|
|
241
|
+
return [
|
|
242
|
+
this.x,
|
|
243
|
+
this.y,
|
|
244
|
+
new BLS12Fq(this.isInfinite ? 1 : 0)
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Returns the x coordinate and the sign of the y coordinate.
|
|
249
|
+
* @dev The y sign can be determined by checking if the y coordinate is greater than half of the modulus.
|
|
250
|
+
* @returns The x coordinate and the sign of the y coordinate.
|
|
251
|
+
*/ toXAndSign() {
|
|
252
|
+
return [
|
|
253
|
+
this.x,
|
|
254
|
+
!this.y.isNegative()
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns the contents of the point as BigInts.
|
|
259
|
+
* @returns The point as BigInts
|
|
260
|
+
*/ toBigInts() {
|
|
261
|
+
return {
|
|
262
|
+
x: this.x.toBigInt(),
|
|
263
|
+
y: this.y.toBigInt(),
|
|
264
|
+
isInfinite: this.isInfinite ? 1n : 0n
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Converts the Point instance to a Buffer representation of the coordinates.
|
|
269
|
+
* @returns A Buffer representation of the Point instance.
|
|
270
|
+
* @dev Note that toBuffer does not include the isInfinite flag and other serialization methods do (e.g. toBigInts).
|
|
271
|
+
*/ toBuffer() {
|
|
272
|
+
const buf = serializeToBuffer([
|
|
273
|
+
this.x,
|
|
274
|
+
this.y
|
|
275
|
+
]);
|
|
276
|
+
if (buf.length !== BLS12Point.SIZE_IN_BYTES) {
|
|
277
|
+
throw new Error(`Invalid buffer length for Point: ${buf.length}`);
|
|
278
|
+
}
|
|
279
|
+
return buf;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Convert the Point instance to a hexadecimal string representation.
|
|
283
|
+
* The output string is prefixed with '0x' and consists of exactly 128 hex characters,
|
|
284
|
+
* representing the concatenated x and y coordinates of the point.
|
|
285
|
+
*
|
|
286
|
+
* @returns A hex-encoded string representing the Point instance.
|
|
287
|
+
*/ toString() {
|
|
288
|
+
return bufferToHex(this.toBuffer());
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Check if two Point instances are equal by comparing their buffer values.
|
|
292
|
+
* Returns true if the buffer values are the same, and false otherwise.
|
|
293
|
+
*
|
|
294
|
+
* @param rhs - The Point instance to compare with the current instance.
|
|
295
|
+
* @returns A boolean indicating whether the two Point instances are equal.
|
|
296
|
+
*/ equals(rhs) {
|
|
297
|
+
return this.x.equals(rhs.x) && this.y.equals(rhs.y);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Check whether the point is zero.
|
|
301
|
+
*/ isZero() {
|
|
302
|
+
return this.x.isZero() && this.y.isZero();
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Check if this is point at infinity.
|
|
306
|
+
* Check this is consistent with how bb is encoding the point at infinity
|
|
307
|
+
*/ get inf() {
|
|
308
|
+
return this.isInfinite;
|
|
309
|
+
}
|
|
310
|
+
/** Arithmetic - wrapper around noble curves */ toNobleProjectivePoint() {
|
|
311
|
+
return bls12_381.G1.ProjectivePoint.fromAffine(this.toBigInts());
|
|
312
|
+
}
|
|
313
|
+
add(rhs) {
|
|
314
|
+
return BLS12Point.fromNobleProjectivePoint(this.toNobleProjectivePoint().add(rhs.toNobleProjectivePoint()));
|
|
315
|
+
}
|
|
316
|
+
negate() {
|
|
317
|
+
return new BLS12Point(this.x, this.y.negate(), this.isInfinite);
|
|
318
|
+
}
|
|
319
|
+
sub(rhs) {
|
|
320
|
+
return BLS12Point.fromNobleProjectivePoint(this.toNobleProjectivePoint().subtract(rhs.toNobleProjectivePoint()));
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @dev From noble curves package:
|
|
324
|
+
* Constant time multiplication. Uses wNAF method. Windowed method may be 10% faster,
|
|
325
|
+
* but takes 2x longer to generate and consumes 2x memory.
|
|
326
|
+
* Uses precomputes when available, uses endomorphism for Koblitz curves.
|
|
327
|
+
* @param scalar by which the point would be multiplied
|
|
328
|
+
* @returns New point
|
|
329
|
+
*/ mul(rhs) {
|
|
330
|
+
// Note: noble curves throws on 0
|
|
331
|
+
if (rhs.isZero()) {
|
|
332
|
+
return BLS12Point.ZERO;
|
|
333
|
+
}
|
|
334
|
+
return BLS12Point.fromNobleProjectivePoint(this.toNobleProjectivePoint().multiply(rhs.toBigInt()));
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* @dev From noble curves package:
|
|
338
|
+
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
339
|
+
* It's faster, but should only be used when you don't care about an exposed private key e.g. sig verification, which works over *public* keys.
|
|
340
|
+
* @param scalar by which the point would be multiplied
|
|
341
|
+
* @returns New point
|
|
342
|
+
*/ mulUnsafe(rhs) {
|
|
343
|
+
return BLS12Point.fromNobleProjectivePoint(this.toNobleProjectivePoint().multiplyUnsafe(rhs.toBigInt()));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @dev From noble curves package:
|
|
347
|
+
* Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
|
|
348
|
+
* Not using Strauss-Shamir trick: precomputation tables are faster. The trick could be useful if both P and Q are not G (not in our case).
|
|
349
|
+
* @returns affine point
|
|
350
|
+
*/ mulAndAddUnsafe(a, b, Q) {
|
|
351
|
+
const res = this.toNobleProjectivePoint().multiplyAndAddUnsafe(Q.toNobleProjectivePoint(), a.toBigInt(), b.toBigInt());
|
|
352
|
+
return res ? BLS12Point.fromNobleProjectivePoint(res) : BLS12Point.ZERO;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
export class BLSPointNotOnCurveError extends Error {
|
|
356
|
+
constructor(x, y){
|
|
357
|
+
super('The given G1 point is not on the BLS12-381 curve: (' + x.toString() + ', ' + (y ? y.toString() : '') + ')');
|
|
358
|
+
this.name = 'NotOnCurveError';
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Lifted from noble curves bls12_381 since it's not exposed. Sets the flags
|
|
363
|
+
* for BLS12-381 point compression.
|
|
364
|
+
* @dev 'sort' refers to 'is_greater' i.e. y > (p - 1)/2
|
|
365
|
+
*/ function setMask(bytes, mask) {
|
|
366
|
+
if (bytes[0] & 0b1110_0000) {
|
|
367
|
+
throw new Error('setMask: non-empty mask');
|
|
368
|
+
}
|
|
369
|
+
if (mask.compressed) {
|
|
370
|
+
bytes[0] |= 0b1000_0000;
|
|
371
|
+
}
|
|
372
|
+
if (mask.infinity) {
|
|
373
|
+
bytes[0] |= 0b0100_0000;
|
|
374
|
+
}
|
|
375
|
+
if (mask.sort) {
|
|
376
|
+
bytes[0] |= 0b0010_0000;
|
|
377
|
+
}
|
|
378
|
+
return bytes;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Lifted from noble curves bls12_381 since it's not exposed. Reads the flags
|
|
382
|
+
* for BLS12-381 point compression.
|
|
383
|
+
* @dev 'sort' refers to 'is_greater' i.e. y > (p - 1)/2
|
|
384
|
+
*/ function parseMask(bytes) {
|
|
385
|
+
// Copy, so we can remove mask data without affecting input bytes.
|
|
386
|
+
const value = Buffer.from(bytes);
|
|
387
|
+
const mask = value[0] & 0b1110_0000;
|
|
388
|
+
const compressed = !!(mask >> 7 & 1); // compression bit (0b1000_0000)
|
|
389
|
+
const infinity = !!(mask >> 6 & 1); // point at infinity bit (0b0100_0000)
|
|
390
|
+
const sort = !!(mask >> 5 & 1); // sort bit (0b0010_0000)
|
|
391
|
+
value[0] &= 0b0001_1111; // clear mask (zero first 3 bits)
|
|
392
|
+
return {
|
|
393
|
+
compressed,
|
|
394
|
+
infinity,
|
|
395
|
+
sort,
|
|
396
|
+
value
|
|
397
|
+
};
|
|
398
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate.d.ts","sourceRoot":"","sources":["../../src/fields/coordinate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coordinate.d.ts","sourceRoot":"","sources":["../../src/fields/coordinate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;;;GAOG;AACH,qBAAa,UAAU;IAInB;;OAEG;IACI,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAN7B,MAAM,CAAC,IAAI,aAAsC;;IAG/C;;OAEG;IACI,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAG7B;;;OAGG;IACH,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAIxB;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,UAAU;IAI3B;;;OAGG;IACH,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAOlB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAIlC;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM;IAYpC;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE;CAOhC"}
|
package/dest/fields/fields.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
1
|
import { inspect } from 'util';
|
|
5
2
|
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
6
3
|
/**
|
|
@@ -160,7 +157,13 @@ export declare class Fq extends BaseField {
|
|
|
160
157
|
static fromHexString(buf: string): Fq;
|
|
161
158
|
static fromHighLow(high: Fr, low: Fr): Fq;
|
|
162
159
|
add(rhs: Fq): Fq;
|
|
160
|
+
/**
|
|
161
|
+
* Computes a square root of the field element.
|
|
162
|
+
* @returns A square root of the field element (null if it does not exist).
|
|
163
|
+
*/
|
|
164
|
+
sqrt(): Promise<Fq | null>;
|
|
163
165
|
toJSON(): `0x${string}`;
|
|
166
|
+
toFields(): Fr[];
|
|
164
167
|
static get schema(): import("zod").ZodType<Fq, any, string>;
|
|
165
168
|
}
|
|
166
169
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":"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"}
|
package/dest/fields/fields.js
CHANGED
|
@@ -37,6 +37,8 @@ const ZERO_BUFFER = Buffer.alloc(32);
|
|
|
37
37
|
this.asBigInt = BigInt(value);
|
|
38
38
|
if (this.asBigInt >= this.modulus()) {
|
|
39
39
|
throw new Error(`Value 0x${this.asBigInt.toString(16)} is greater or equal to field modulus.`);
|
|
40
|
+
} else if (this.asBigInt < 0n) {
|
|
41
|
+
throw new Error(`Value 0x${this.asBigInt.toString(16)} is negative.`);
|
|
40
42
|
}
|
|
41
43
|
} else if (value instanceof BaseField) {
|
|
42
44
|
this.asBuffer = value.asBuffer;
|
|
@@ -233,19 +235,16 @@ const ZERO_BUFFER = Buffer.alloc(32);
|
|
|
233
235
|
* Computes a square root of the field element.
|
|
234
236
|
* @returns A square root of the field element (null if it does not exist).
|
|
235
237
|
*/ async sqrt() {
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
this.toBuffer()
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
]);
|
|
243
|
-
const isSqrt = buf[0] === 1;
|
|
244
|
-
if (!isSqrt) {
|
|
238
|
+
await BarretenbergSync.initSingleton();
|
|
239
|
+
const api = BarretenbergSync.getSingleton();
|
|
240
|
+
const response = api.bn254FrSqrt({
|
|
241
|
+
input: this.toBuffer()
|
|
242
|
+
});
|
|
243
|
+
if (!response.isSquareRoot) {
|
|
245
244
|
// Field element is not a quadratic residue mod p so it has no square root.
|
|
246
245
|
return null;
|
|
247
246
|
}
|
|
248
|
-
return
|
|
247
|
+
return Fr.fromBuffer(Buffer.from(response.value));
|
|
249
248
|
}
|
|
250
249
|
toJSON() {
|
|
251
250
|
return this.toString();
|
|
@@ -321,9 +320,33 @@ TypeRegistry.register('Fr', Fr);
|
|
|
321
320
|
add(rhs) {
|
|
322
321
|
return new Fq((this.toBigInt() + rhs.toBigInt()) % Fq.MODULUS);
|
|
323
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Computes a square root of the field element.
|
|
325
|
+
* @returns A square root of the field element (null if it does not exist).
|
|
326
|
+
*/ async sqrt() {
|
|
327
|
+
await BarretenbergSync.initSingleton();
|
|
328
|
+
const api = BarretenbergSync.getSingleton();
|
|
329
|
+
const response = api.bn254FqSqrt({
|
|
330
|
+
input: this.toBuffer()
|
|
331
|
+
});
|
|
332
|
+
if (!response.isSquareRoot) {
|
|
333
|
+
// Field element is not a quadratic residue mod p so it has no square root.
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
return Fq.fromBuffer(Buffer.from(response.value));
|
|
337
|
+
}
|
|
324
338
|
toJSON() {
|
|
325
339
|
return this.toString();
|
|
326
340
|
}
|
|
341
|
+
toFields() {
|
|
342
|
+
// The following has to match the order of the limbs in EmbeddedCurveScalar struct in noir::std. This is because
|
|
343
|
+
// this function is used when returning Scalar from the getAddressSecret oracle and in Noir the values get deserialized
|
|
344
|
+
// using the intrinsic serialization of Noir (which follows the order of the fields/members in the struct).
|
|
345
|
+
return [
|
|
346
|
+
this.lo,
|
|
347
|
+
this.hi
|
|
348
|
+
];
|
|
349
|
+
}
|
|
327
350
|
static get schema() {
|
|
328
351
|
return hexSchemaFor(Fq);
|
|
329
352
|
}
|
|
@@ -364,7 +387,7 @@ export const GrumpkinScalar = Fq;
|
|
|
364
387
|
/** Wraps a function that returns a buffer so that all results are reduced into a field of the given type. */ export function reduceFn(fn, field) {
|
|
365
388
|
return (input)=>fromBufferReduce(fn(input), field);
|
|
366
389
|
}
|
|
367
|
-
/** If we are in test mode, we register a special equality for fields. */ if (process.env.NODE_ENV === 'test'
|
|
390
|
+
/** If we are in test mode, we register a special equality for fields. */ if (process.env.NODE_ENV === 'test') {
|
|
368
391
|
const areFieldsEqual = (a, b)=>{
|
|
369
392
|
const isAField = a instanceof BaseField;
|
|
370
393
|
const isBField = b instanceof BaseField;
|
|
@@ -376,8 +399,13 @@ export const GrumpkinScalar = Fq;
|
|
|
376
399
|
return false;
|
|
377
400
|
}
|
|
378
401
|
};
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
402
|
+
if (typeof expect !== 'undefined') {
|
|
403
|
+
// `addEqualityTesters` doesn't seem to be in the types yet.
|
|
404
|
+
expect.addEqualityTesters([
|
|
405
|
+
areFieldsEqual
|
|
406
|
+
]);
|
|
407
|
+
} else {
|
|
408
|
+
globalThis.__extraEqualityTesters ??= [];
|
|
409
|
+
globalThis.__extraEqualityTesters.push(areFieldsEqual);
|
|
410
|
+
}
|
|
383
411
|
}
|
package/dest/fields/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/dest/fields/index.js
CHANGED
package/dest/fields/point.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { BufferReader, FieldReader } from '../serialize/index.js';
|
|
4
2
|
import { Fr } from './fields.js';
|
|
5
3
|
/**
|
|
@@ -117,12 +115,12 @@ export declare class Point {
|
|
|
117
115
|
* 2. we use toBuffer when serializing notes and events and there we only work with public keys and point at infinity
|
|
118
116
|
* is not considered a valid public key and the extra byte would raise DA cost.
|
|
119
117
|
*/
|
|
120
|
-
toBuffer(): Buffer
|
|
118
|
+
toBuffer(): Buffer<ArrayBufferLike>;
|
|
121
119
|
/**
|
|
122
120
|
* Converts the Point instance to a compressed Buffer representation of the coordinates.
|
|
123
121
|
* @returns A Buffer representation of the Point instance
|
|
124
122
|
*/
|
|
125
|
-
toCompressedBuffer(): Buffer
|
|
123
|
+
toCompressedBuffer(): Buffer<ArrayBufferLike>;
|
|
126
124
|
/**
|
|
127
125
|
* Convert the Point instance to a hexadecimal string representation.
|
|
128
126
|
* The output string is prefixed with '0x' and consists of exactly 128 hex characters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../src/fields/point.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../src/fields/point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AAErF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;GAKG;AACH,qBAAa,KAAK;IASd;;OAEG;aACa,CAAC,EAAE,EAAE;IACrB;;OAEG;aACa,CAAC,EAAE,EAAE;IACrB;;OAEG;aACa,UAAU,EAAE,OAAO;IAnBrC,MAAM,CAAC,IAAI,QAAsC;IACjD,MAAM,CAAC,aAAa,SAAwB;IAC5C,MAAM,CAAC,wBAAwB,SAAoB;IAEnD,yDAAyD;IACzD,SAAgB,IAAI,WAAW;;IAG7B;;OAEG;IACa,CAAC,EAAE,EAAE;IACrB;;OAEG;IACa,CAAC,EAAE,EAAE;IACrB;;OAEG;IACa,UAAU,EAAE,OAAO;IAKrC,MAAM;IAIN,MAAM,KAAK,MAAM,8CAEhB;IAED;;;;OAIG;WACU,MAAM;IAcnB;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;IAU1E;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM;IAI7B;;;OAGG;IACH,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C;;;;;;;;OAQG;WACU,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO;IAgB9C;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC;IASxC;;;;OAIG;IACH,UAAU,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC;IAI3B;;;OAGG;IACH,SAAS;;;;;IAQT;;;;;;;;;OASG;IACH,QAAQ;IAWR;;;OAGG;IACH,kBAAkB;IAalB;;;;;;OAMG;IACH,QAAQ;IAIR;;;;;;;OAOG;IACH,aAAa;IAKb,YAAY;;;;;IAOZ,mBAAmB;;;;;;;IAInB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,KAAK;IAIjB,MAAM;IAIN,IAAI;IAIJ;;;OAGG;IACH,IAAW,GAAG,YAEb;IAED,YAAY;CAYb;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,CAAC,EAAE,EAAE;CAIlB"}
|
package/dest/fields/point.js
CHANGED
|
@@ -160,7 +160,7 @@ import { Fr } from './fields.js';
|
|
|
160
160
|
* is not considered a valid public key and the extra byte would raise DA cost.
|
|
161
161
|
*/ toBuffer() {
|
|
162
162
|
if (this.isInfinite) {
|
|
163
|
-
throw new Error('Cannot serialize infinite point
|
|
163
|
+
throw new Error('Cannot serialize infinite point with isInfinite flag');
|
|
164
164
|
}
|
|
165
165
|
const buf = serializeToBuffer([
|
|
166
166
|
this.x,
|
|
@@ -215,10 +215,10 @@ import { Fr } from './fields.js';
|
|
|
215
215
|
/* eslint-enable camelcase */ }
|
|
216
216
|
// Used for IvpkM, OvpkM, NpkM and TpkM. TODO(#8124): Consider removing this method.
|
|
217
217
|
toWrappedNoirStruct() {
|
|
218
|
-
|
|
218
|
+
return {
|
|
219
219
|
inner: this.toNoirStruct()
|
|
220
220
|
};
|
|
221
|
-
|
|
221
|
+
}
|
|
222
222
|
/**
|
|
223
223
|
* Check if two Point instances are equal by comparing their buffer values.
|
|
224
224
|
* Returns true if the buffer values are the same, and false otherwise.
|
package/dest/fs/index.d.ts
CHANGED
package/dest/fs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dest/fs/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"try_rm_dir.d.ts","sourceRoot":"","sources":["../../src/fs/try_rm_dir.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUtF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rm } from 'fs/promises';
|
|
2
|
+
export async function tryRmDir(dir, logger) {
|
|
3
|
+
if (dir === undefined) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
logger?.debug(`Cleaning up directory at ${dir}`);
|
|
8
|
+
await rm(dir, {
|
|
9
|
+
recursive: true,
|
|
10
|
+
force: true,
|
|
11
|
+
maxRetries: 3
|
|
12
|
+
});
|
|
13
|
+
} catch (err) {
|
|
14
|
+
logger?.warn(`Failed to delete directory at ${dir}: ${err}`);
|
|
15
|
+
}
|
|
16
|
+
}
|