@aztec/foundation 0.0.0-test.0 → 0.0.1-fake-c83136db25
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 +14 -3
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +45 -0
- 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/bn254/index.d.ts +54 -0
- package/dest/crypto/bn254/index.d.ts.map +1 -0
- package/dest/crypto/bn254/index.js +140 -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 +1 -0
- package/dest/crypto/index.d.ts.map +1 -1
- package/dest/crypto/index.js +1 -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 +15 -2
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +21 -3
- 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 +3 -2
- package/dest/string/index.d.ts.map +1 -1
- package/dest/string/index.js +26 -0
- 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 +32 -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 +51 -1
- 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/bn254/index.ts +167 -0
- package/src/crypto/ecdsa/index.ts +41 -23
- package/src/crypto/grumpkin/index.ts +35 -45
- package/src/crypto/index.ts +1 -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 +25 -4
- 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 +33 -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,140 @@
|
|
|
1
|
+
import { BN254_G1_GENERATOR, BN254_G2_GENERATOR, BarretenbergSync } from '@aztec/bb.js';
|
|
2
|
+
import { Fq } from '../../fields/fields.js';
|
|
3
|
+
/**
|
|
4
|
+
* BN254 G1 point using foundation field classes.
|
|
5
|
+
* Represents a point on the BN254 elliptic curve in affine coordinates.
|
|
6
|
+
*/ export class Bn254G1Point {
|
|
7
|
+
x;
|
|
8
|
+
y;
|
|
9
|
+
constructor(x, y){
|
|
10
|
+
this.x = x;
|
|
11
|
+
this.y = y;
|
|
12
|
+
}
|
|
13
|
+
toBbApiPoint() {
|
|
14
|
+
return {
|
|
15
|
+
x: this.x.toBuffer(),
|
|
16
|
+
y: this.y.toBuffer()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static fromBbApiPoint(point) {
|
|
20
|
+
return new Bn254G1Point(Fq.fromBuffer(Buffer.from(point.x)), Fq.fromBuffer(Buffer.from(point.y)));
|
|
21
|
+
}
|
|
22
|
+
async isOnCurve() {
|
|
23
|
+
await BarretenbergSync.initSingleton();
|
|
24
|
+
const api = BarretenbergSync.getSingleton();
|
|
25
|
+
const apiPoint = this.toBbApiPoint();
|
|
26
|
+
const response = api.bn254G1IsOnCurve({
|
|
27
|
+
point: apiPoint
|
|
28
|
+
});
|
|
29
|
+
return response.isOnCurve;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the generator point for BN254 G1, or perform scalar multiplication.
|
|
33
|
+
* When called without arguments, returns the base generator point.
|
|
34
|
+
* When called with a scalar, returns scalar * generator (useful for public key derivation).
|
|
35
|
+
*/ static async generator(scalar) {
|
|
36
|
+
if (!scalar) {
|
|
37
|
+
return new Bn254G1Point(Fq.fromBuffer(Buffer.from(BN254_G1_GENERATOR.x)), Fq.fromBuffer(Buffer.from(BN254_G1_GENERATOR.y)));
|
|
38
|
+
}
|
|
39
|
+
await BarretenbergSync.initSingleton();
|
|
40
|
+
const api = BarretenbergSync.getSingleton();
|
|
41
|
+
const response = api.bn254G1Mul({
|
|
42
|
+
point: BN254_G1_GENERATOR,
|
|
43
|
+
scalar: scalar.toBuffer()
|
|
44
|
+
});
|
|
45
|
+
return Bn254G1Point.fromBbApiPoint(response.point);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Decompress a BN254 G1 point from compressed form (32 bytes).
|
|
49
|
+
* The compressed format encodes the x-coordinate and the sign bit of the y-coordinate
|
|
50
|
+
* in the most significant bit.
|
|
51
|
+
*/ static async fromCompressed(compressed) {
|
|
52
|
+
await BarretenbergSync.initSingleton();
|
|
53
|
+
const api = BarretenbergSync.getSingleton();
|
|
54
|
+
const response = api.bn254G1FromCompressed({
|
|
55
|
+
compressed: new Uint8Array(compressed)
|
|
56
|
+
});
|
|
57
|
+
return Bn254G1Point.fromBbApiPoint(response.point);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Compress this BN254 G1 point to 32 bytes.
|
|
61
|
+
* The compressed format encodes the x-coordinate and the sign bit of the y-coordinate
|
|
62
|
+
* in the most significant bit (bit 255).
|
|
63
|
+
*/ compress() {
|
|
64
|
+
const xBytes = this.x.toBuffer();
|
|
65
|
+
// Get the least significant bit of y to determine the sign
|
|
66
|
+
const yLsb = this.y.toBigInt() & 1n;
|
|
67
|
+
// If y is odd, set the most significant bit (bit 255) of the output
|
|
68
|
+
if (yLsb === 1n) {
|
|
69
|
+
xBytes[0] |= 0x80;
|
|
70
|
+
}
|
|
71
|
+
return xBytes;
|
|
72
|
+
}
|
|
73
|
+
equals(other) {
|
|
74
|
+
return this.x.equals(other.x) && this.y.equals(other.y);
|
|
75
|
+
}
|
|
76
|
+
toString() {
|
|
77
|
+
return `Bn254G1Point(x: ${this.x.toString()}, y: ${this.y.toString()})`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* BN254 G2 point using foundation field classes.
|
|
82
|
+
* Represents a point on the BN254 G2 curve (twist curve) in affine coordinates.
|
|
83
|
+
* G2 points use extension field coordinates (Fq2).
|
|
84
|
+
*/ export class Bn254G2Point {
|
|
85
|
+
x;
|
|
86
|
+
y;
|
|
87
|
+
constructor(x, y){
|
|
88
|
+
this.x = x;
|
|
89
|
+
this.y = y;
|
|
90
|
+
}
|
|
91
|
+
toBbApiPoint() {
|
|
92
|
+
return {
|
|
93
|
+
x: [
|
|
94
|
+
this.x[0].toBuffer(),
|
|
95
|
+
this.x[1].toBuffer()
|
|
96
|
+
],
|
|
97
|
+
y: [
|
|
98
|
+
this.y[0].toBuffer(),
|
|
99
|
+
this.y[1].toBuffer()
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static fromBbApiPoint(point) {
|
|
104
|
+
return new Bn254G2Point([
|
|
105
|
+
Fq.fromBuffer(Buffer.from(point.x[0])),
|
|
106
|
+
Fq.fromBuffer(Buffer.from(point.x[1]))
|
|
107
|
+
], [
|
|
108
|
+
Fq.fromBuffer(Buffer.from(point.y[0])),
|
|
109
|
+
Fq.fromBuffer(Buffer.from(point.y[1]))
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the generator point for BN254 G2, or perform scalar multiplication.
|
|
114
|
+
* When called without arguments, returns the base generator point.
|
|
115
|
+
* When called with a scalar, returns scalar * generator.
|
|
116
|
+
*/ static async generator(scalar) {
|
|
117
|
+
if (!scalar) {
|
|
118
|
+
return new Bn254G2Point([
|
|
119
|
+
Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.x[0])),
|
|
120
|
+
Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.x[1]))
|
|
121
|
+
], [
|
|
122
|
+
Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.y[0])),
|
|
123
|
+
Fq.fromBuffer(Buffer.from(BN254_G2_GENERATOR.y[1]))
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
await BarretenbergSync.initSingleton();
|
|
127
|
+
const api = BarretenbergSync.getSingleton();
|
|
128
|
+
const response = api.bn254G2Mul({
|
|
129
|
+
point: BN254_G2_GENERATOR,
|
|
130
|
+
scalar: scalar.toBuffer()
|
|
131
|
+
});
|
|
132
|
+
return Bn254G2Point.fromBbApiPoint(response.point);
|
|
133
|
+
}
|
|
134
|
+
equals(other) {
|
|
135
|
+
return this.x[0].equals(other.x[0]) && this.x[1].equals(other.x[1]) && this.y[0].equals(other.y[0]) && this.y[1].equals(other.y[1]);
|
|
136
|
+
}
|
|
137
|
+
toString() {
|
|
138
|
+
return `Bn254G2Point(x: (${this.x[0].toString()}, ${this.x[1].toString()}), y: (${this.y[0].toString()}, ${this.y[1].toString()}))`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { EcdsaSignature } from './signature.js';
|
|
4
2
|
export * from './signature.js';
|
|
5
3
|
/**
|
|
@@ -7,6 +5,8 @@ export * from './signature.js';
|
|
|
7
5
|
* TODO: Replace with codegen api on bb.js.
|
|
8
6
|
*/
|
|
9
7
|
export declare class Ecdsa {
|
|
8
|
+
private curve;
|
|
9
|
+
constructor(curve?: 'secp256k1' | 'secp256r1');
|
|
10
10
|
/**
|
|
11
11
|
* Computes a secp256k1 public key from a private key.
|
|
12
12
|
* @param privateKey - Secp256k1 private key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/ecdsa/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/ecdsa/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,cAAc,gBAAgB,CAAC;AAE/B;;;GAGG;AACH,qBAAa,KAAK;IACJ,OAAO,CAAC,KAAK;gBAAL,KAAK,GAAE,WAAW,GAAG,WAAyB;IAClE;;;;OAIG;IACU,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlE;;;;;OAKG;IACU,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM;IAUnE;;;;;OAKG;IACU,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAUpF;;;;;;OAMG;IACU,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc;CAqBlF"}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
|
-
import { numToInt32BE } from '@aztec/foundation/serialize';
|
|
3
|
-
import { concatenateUint8Arrays } from '../serialize.js';
|
|
4
2
|
import { EcdsaSignature } from './signature.js';
|
|
5
3
|
export * from './signature.js';
|
|
6
4
|
/**
|
|
7
5
|
* ECDSA signature construction and helper operations.
|
|
8
6
|
* TODO: Replace with codegen api on bb.js.
|
|
9
7
|
*/ export class Ecdsa {
|
|
8
|
+
curve;
|
|
9
|
+
constructor(curve = 'secp256k1'){
|
|
10
|
+
this.curve = curve;
|
|
11
|
+
}
|
|
10
12
|
/**
|
|
11
13
|
* Computes a secp256k1 public key from a private key.
|
|
12
14
|
* @param privateKey - Secp256k1 private key.
|
|
13
15
|
* @returns A secp256k1 public key.
|
|
14
16
|
*/ async computePublicKey(privateKey) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
await BarretenbergSync.initSingleton({
|
|
18
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
19
|
+
});
|
|
20
|
+
const api = BarretenbergSync.getSingleton();
|
|
21
|
+
const response = this.curve === 'secp256r1' ? api.ecdsaSecp256r1ComputePublicKey({
|
|
22
|
+
privateKey
|
|
23
|
+
}) : api.ecdsaSecp256k1ComputePublicKey({
|
|
17
24
|
privateKey
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
});
|
|
26
|
+
return Buffer.concat([
|
|
27
|
+
Buffer.from(response.publicKey.x),
|
|
28
|
+
Buffer.from(response.publicKey.y)
|
|
20
29
|
]);
|
|
21
|
-
return Buffer.from(result);
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Constructs an ECDSA signature given a msg and a private key.
|
|
@@ -26,20 +34,20 @@ export * from './signature.js';
|
|
|
26
34
|
* @param privateKey - The secp256k1 private key of the signer.
|
|
27
35
|
* @returns An ECDSA signature of the form (r, s, v).
|
|
28
36
|
*/ async constructSignature(msg, privateKey) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
messageArray,
|
|
37
|
+
await BarretenbergSync.initSingleton({
|
|
38
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
39
|
+
});
|
|
40
|
+
const api = BarretenbergSync.getSingleton();
|
|
41
|
+
const response = this.curve === 'secp256r1' ? api.ecdsaSecp256r1ConstructSignature({
|
|
42
|
+
message: msg,
|
|
36
43
|
privateKey
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
}) : api.ecdsaSecp256k1ConstructSignature({
|
|
45
|
+
message: msg,
|
|
46
|
+
privateKey
|
|
47
|
+
});
|
|
48
|
+
return new EcdsaSignature(Buffer.from(response.r), Buffer.from(response.s), Buffer.from([
|
|
49
|
+
response.v
|
|
50
|
+
]));
|
|
43
51
|
}
|
|
44
52
|
/**
|
|
45
53
|
* Recovers a secp256k1 public key from an ECDSA signature (similar to ecrecover).
|
|
@@ -47,20 +55,25 @@ export * from './signature.js';
|
|
|
47
55
|
* @param sig - The ECDSA signature.
|
|
48
56
|
* @returns The secp256k1 public key of the signer.
|
|
49
57
|
*/ async recoverPublicKey(msg, sig) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
sig.
|
|
58
|
-
sig.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
await BarretenbergSync.initSingleton({
|
|
59
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
60
|
+
});
|
|
61
|
+
const api = BarretenbergSync.getSingleton();
|
|
62
|
+
const response = this.curve === 'secp256r1' ? api.ecdsaSecp256r1RecoverPublicKey({
|
|
63
|
+
message: msg,
|
|
64
|
+
r: sig.r,
|
|
65
|
+
s: sig.s,
|
|
66
|
+
v: sig.v[0]
|
|
67
|
+
}) : api.ecdsaSecp256k1RecoverPublicKey({
|
|
68
|
+
message: msg,
|
|
69
|
+
r: sig.r,
|
|
70
|
+
s: sig.s,
|
|
71
|
+
v: sig.v[0]
|
|
72
|
+
});
|
|
73
|
+
return Buffer.concat([
|
|
74
|
+
Buffer.from(response.publicKey.x),
|
|
75
|
+
Buffer.from(response.publicKey.y)
|
|
62
76
|
]);
|
|
63
|
-
return Buffer.from(result);
|
|
64
77
|
}
|
|
65
78
|
/**
|
|
66
79
|
* Verifies and ECDSA signature given a secp256k1 public key.
|
|
@@ -69,20 +82,29 @@ export * from './signature.js';
|
|
|
69
82
|
* @param sig - The ECDSA signature.
|
|
70
83
|
* @returns True or false.
|
|
71
84
|
*/ async verifySignature(msg, pubKey, sig) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
sig.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
await BarretenbergSync.initSingleton({
|
|
86
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
87
|
+
});
|
|
88
|
+
const api = BarretenbergSync.getSingleton();
|
|
89
|
+
const response = this.curve === 'secp256r1' ? api.ecdsaSecp256r1VerifySignature({
|
|
90
|
+
message: msg,
|
|
91
|
+
publicKey: {
|
|
92
|
+
x: pubKey.subarray(0, 32),
|
|
93
|
+
y: pubKey.subarray(32, 64)
|
|
94
|
+
},
|
|
95
|
+
r: sig.r,
|
|
96
|
+
s: sig.s,
|
|
97
|
+
v: sig.v[0]
|
|
98
|
+
}) : api.ecdsaSecp256k1VerifySignature({
|
|
99
|
+
message: msg,
|
|
100
|
+
publicKey: {
|
|
101
|
+
x: pubKey.subarray(0, 32),
|
|
102
|
+
y: pubKey.subarray(32, 64)
|
|
103
|
+
},
|
|
104
|
+
r: sig.r,
|
|
105
|
+
s: sig.s,
|
|
106
|
+
v: sig.v[0]
|
|
107
|
+
});
|
|
108
|
+
return response.verified;
|
|
87
109
|
}
|
|
88
110
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
2
|
import type { Signature } from '../signature/index.js';
|
|
5
3
|
/**
|
|
@@ -36,7 +34,7 @@ export declare class EcdsaSignature implements Signature {
|
|
|
36
34
|
* Converts an ECDSA signature to a buffer.
|
|
37
35
|
* @returns A buffer.
|
|
38
36
|
*/
|
|
39
|
-
toBuffer(): Buffer
|
|
37
|
+
toBuffer(): Buffer<ArrayBuffer>;
|
|
40
38
|
/**
|
|
41
39
|
* Deserializes the signature from a buffer.
|
|
42
40
|
* @param buffer - The buffer from which to deserialize the signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/ecdsa/signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/ecdsa/signature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,cAAe,YAAW,SAAS;IAE5C;;OAEG;IACI,CAAC,EAAE,MAAM;IAChB;;OAEG;IACI,CAAC,EAAE,MAAM;IAChB;;OAEG;IACI,CAAC,EAAE,MAAM;;IAXhB;;OAEG;IACI,CAAC,EAAE,MAAM;IAChB;;OAEG;IACI,CAAC,EAAE,MAAM;IAChB;;OAEG;IACI,CAAC,EAAE,MAAM;IAalB;;;OAGG;IACH,QAAQ;IAIR;;;;OAIG;WACW,UAAU,CAAC,MAAM,EAAE,MAAM;IAIvC;;;;;;OAMG;WACW,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAIzD;;;OAGG;WACW,MAAM;IAIpB;;;OAGG;IACH,QAAQ;IAIR;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,UAAQ,GAAG,EAAE,EAAE;CAajC"}
|
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr, type GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
4
2
|
/**
|
|
5
3
|
* Grumpkin elliptic curve operations.
|
|
6
4
|
*/
|
|
7
5
|
export declare class Grumpkin {
|
|
8
|
-
static generator: Point;
|
|
9
|
-
/**
|
|
10
|
-
* Point generator
|
|
11
|
-
* @returns The generator for the curve.
|
|
12
|
-
*/
|
|
13
|
-
generator(): Point;
|
|
6
|
+
static readonly generator: Point;
|
|
14
7
|
/**
|
|
15
8
|
* Multiplies a point by a scalar (adds the point `scalar` amount of times).
|
|
16
9
|
* @param point - Point to multiply.
|
|
17
10
|
* @param scalar - Scalar to multiply by.
|
|
18
11
|
* @returns Result of the multiplication.
|
|
19
12
|
*/
|
|
20
|
-
mul(point: Point, scalar: GrumpkinScalar): Promise<Point>;
|
|
13
|
+
static mul(point: Point, scalar: GrumpkinScalar): Promise<Point>;
|
|
21
14
|
/**
|
|
22
15
|
* Add two points.
|
|
23
16
|
* @param a - Point a in the addition
|
|
24
17
|
* @param b - Point b to add to a
|
|
25
18
|
* @returns Result of the addition.
|
|
26
19
|
*/
|
|
27
|
-
add(a: Point, b: Point): Promise<Point>;
|
|
20
|
+
static add(a: Point, b: Point): Promise<Point>;
|
|
28
21
|
/**
|
|
29
22
|
* Multiplies a set of points by a scalar.
|
|
30
23
|
* @param points - Points to multiply.
|
|
31
24
|
* @param scalar - Scalar to multiply by.
|
|
32
25
|
* @returns Points multiplied by the scalar.
|
|
33
26
|
*/
|
|
34
|
-
batchMul(points: Point[], scalar: GrumpkinScalar): Promise<Point[]>;
|
|
27
|
+
static batchMul(points: Point[], scalar: GrumpkinScalar): Promise<Point[]>;
|
|
35
28
|
/**
|
|
36
29
|
* Gets a random field element.
|
|
37
30
|
* @returns Random field element.
|
|
38
31
|
*/
|
|
39
|
-
getRandomFr(): Promise<Fr>;
|
|
32
|
+
static getRandomFr(): Promise<Fr>;
|
|
40
33
|
/**
|
|
41
34
|
* Converts a 512 bits long buffer to a field.
|
|
42
35
|
* @param uint512Buf - The buffer to convert.
|
|
43
36
|
* @returns Buffer representation of the field element.
|
|
44
37
|
*/
|
|
45
|
-
reduce512BufferToFr(uint512Buf: Buffer): Promise<Fr>;
|
|
38
|
+
static reduce512BufferToFr(uint512Buf: Buffer): Promise<Fr>;
|
|
46
39
|
}
|
|
47
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/grumpkin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/grumpkin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;GAEG;AACH,qBAAa,QAAQ;IAEnB,MAAM,CAAC,QAAQ,CAAC,SAAS,QAKrB;IAEJ;;;;;OAKG;WACiB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IAU7E;;;;;OAKG;WACiB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAU3D;;;;;OAKG;WACiB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc;IAWpE;;;OAGG;WACiB,WAAW,IAAI,OAAO,CAAC,EAAE,CAAC;IAO9C;;;;OAIG;WACiB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CAMzE"}
|
|
@@ -71,84 +71,99 @@ import { Fr, Point } from '@aztec/foundation/fields';
|
|
|
71
71
|
0x2c
|
|
72
72
|
]));
|
|
73
73
|
/**
|
|
74
|
-
* Point generator
|
|
75
|
-
* @returns The generator for the curve.
|
|
76
|
-
*/ generator() {
|
|
77
|
-
return Grumpkin.generator;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
74
|
* Multiplies a point by a scalar (adds the point `scalar` amount of times).
|
|
81
75
|
* @param point - Point to multiply.
|
|
82
76
|
* @param scalar - Scalar to multiply by.
|
|
83
77
|
* @returns Result of the multiplication.
|
|
84
|
-
*/ async mul(point, scalar) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
*/ static async mul(point, scalar) {
|
|
79
|
+
await BarretenbergSync.initSingleton({
|
|
80
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
81
|
+
});
|
|
82
|
+
const api = BarretenbergSync.getSingleton();
|
|
83
|
+
const response = api.grumpkinMul({
|
|
84
|
+
point: {
|
|
85
|
+
x: point.x.toBuffer(),
|
|
86
|
+
y: point.y.toBuffer()
|
|
87
|
+
},
|
|
88
|
+
scalar: scalar.toBuffer()
|
|
89
|
+
});
|
|
90
|
+
return Point.fromBuffer(Buffer.concat([
|
|
91
|
+
Buffer.from(response.point.x),
|
|
92
|
+
Buffer.from(response.point.y)
|
|
93
|
+
]));
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
96
|
* Add two points.
|
|
96
97
|
* @param a - Point a in the addition
|
|
97
98
|
* @param b - Point b to add to a
|
|
98
99
|
* @returns Result of the addition.
|
|
99
|
-
*/ async add(a, b) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
*/ static async add(a, b) {
|
|
101
|
+
await BarretenbergSync.initSingleton({
|
|
102
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
103
|
+
});
|
|
104
|
+
const api = BarretenbergSync.getSingleton();
|
|
105
|
+
const response = api.grumpkinAdd({
|
|
106
|
+
pointA: {
|
|
107
|
+
x: a.x.toBuffer(),
|
|
108
|
+
y: a.y.toBuffer()
|
|
109
|
+
},
|
|
110
|
+
pointB: {
|
|
111
|
+
x: b.x.toBuffer(),
|
|
112
|
+
y: b.y.toBuffer()
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return Point.fromBuffer(Buffer.concat([
|
|
116
|
+
Buffer.from(response.point.x),
|
|
117
|
+
Buffer.from(response.point.y)
|
|
118
|
+
]));
|
|
108
119
|
}
|
|
109
120
|
/**
|
|
110
121
|
* Multiplies a set of points by a scalar.
|
|
111
122
|
* @param points - Points to multiply.
|
|
112
123
|
* @param scalar - Scalar to multiply by.
|
|
113
124
|
* @returns Points multiplied by the scalar.
|
|
114
|
-
*/ async batchMul(points, scalar) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
*/ static async batchMul(points, scalar) {
|
|
126
|
+
await BarretenbergSync.initSingleton({
|
|
127
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
128
|
+
});
|
|
129
|
+
const api = BarretenbergSync.getSingleton();
|
|
130
|
+
const response = api.grumpkinBatchMul({
|
|
131
|
+
points: points.map((p)=>({
|
|
132
|
+
x: p.x.toBuffer(),
|
|
133
|
+
y: p.y.toBuffer()
|
|
134
|
+
})),
|
|
135
|
+
scalar: scalar.toBuffer()
|
|
136
|
+
});
|
|
137
|
+
return response.points.map((p)=>Point.fromBuffer(Buffer.concat([
|
|
138
|
+
Buffer.from(p.x),
|
|
139
|
+
Buffer.from(p.y)
|
|
140
|
+
])));
|
|
130
141
|
}
|
|
131
142
|
/**
|
|
132
143
|
* Gets a random field element.
|
|
133
144
|
* @returns Random field element.
|
|
134
|
-
*/ async getRandomFr() {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
*/ static async getRandomFr() {
|
|
146
|
+
await BarretenbergSync.initSingleton({
|
|
147
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
148
|
+
});
|
|
149
|
+
const api = BarretenbergSync.getSingleton();
|
|
150
|
+
const response = api.grumpkinGetRandomFr({
|
|
151
|
+
dummy: 0
|
|
152
|
+
});
|
|
153
|
+
return Fr.fromBuffer(Buffer.from(response.value));
|
|
140
154
|
}
|
|
141
155
|
/**
|
|
142
156
|
* Converts a 512 bits long buffer to a field.
|
|
143
157
|
* @param uint512Buf - The buffer to convert.
|
|
144
158
|
* @returns Buffer representation of the field element.
|
|
145
|
-
*/ async reduce512BufferToFr(uint512Buf) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
*/ static async reduce512BufferToFr(uint512Buf) {
|
|
160
|
+
await BarretenbergSync.initSingleton({
|
|
161
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
162
|
+
});
|
|
163
|
+
const api = BarretenbergSync.getSingleton();
|
|
164
|
+
const response = api.grumpkinReduce512({
|
|
165
|
+
input: uint512Buf
|
|
166
|
+
});
|
|
167
|
+
return Fr.fromBuffer(Buffer.from(response.value));
|
|
153
168
|
}
|
|
154
169
|
}
|
package/dest/crypto/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './poseidon/index.js';
|
|
|
7
7
|
export * from './secp256k1-signer/index.js';
|
|
8
8
|
export * from './keys/index.js';
|
|
9
9
|
export * from './aes128/index.js';
|
|
10
|
+
export * from './bn254/index.js';
|
|
10
11
|
export * from './grumpkin/index.js';
|
|
11
12
|
export * from './ecdsa/index.js';
|
|
12
13
|
export * from './secp256k1/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
package/dest/crypto/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './poseidon/index.js';
|
|
|
7
7
|
export * from './secp256k1-signer/index.js';
|
|
8
8
|
export * from './keys/index.js';
|
|
9
9
|
export * from './aes128/index.js';
|
|
10
|
+
export * from './bn254/index.js';
|
|
10
11
|
export * from './grumpkin/index.js';
|
|
11
12
|
export * from './ecdsa/index.js';
|
|
12
13
|
export * from './secp256k1/index.js';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Buffer32 } from '../../buffer/buffer32.js';
|
|
4
2
|
/**
|
|
5
3
|
* Computes the Keccak-256 hash of the given input buffer.
|
|
@@ -7,7 +5,7 @@ import { Buffer32 } from '../../buffer/buffer32.js';
|
|
|
7
5
|
* @param input - The input buffer to be hashed.
|
|
8
6
|
* @returns The computed Keccak-256 hash as a Buffer.
|
|
9
7
|
*/
|
|
10
|
-
export declare function keccak256(input: Buffer | Buffer32): Buffer
|
|
8
|
+
export declare function keccak256(input: Buffer | Buffer32): Buffer<ArrayBufferLike>;
|
|
11
9
|
/**
|
|
12
10
|
* Computes the keccak-256 hash of a given input string and returns the result as a hexadecimal string.
|
|
13
11
|
*/
|
|
@@ -18,7 +16,7 @@ export declare function keccak256String(input: string): string;
|
|
|
18
16
|
* @param input - The input buffer to be hashed.
|
|
19
17
|
* @returns The computed Keccak-224 hash as a Buffer.
|
|
20
18
|
*/
|
|
21
|
-
export declare function keccak224(input: Buffer): Buffer
|
|
19
|
+
export declare function keccak224(input: Buffer): Buffer<ArrayBufferLike>;
|
|
22
20
|
/**
|
|
23
21
|
* Computes the Keccak-f1600 permutation of the input.
|
|
24
22
|
* @param state 25 64-bit words.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/keccak/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/keccak/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,2BAMjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,UAK5C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,2BAGtC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA+MrD"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr } from '../../fields/fields.js';
|
|
4
2
|
export declare function vkAsFieldsMegaHonk(input: Buffer): Promise<Fr[]>;
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/keys/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/keys/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAE5C,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAKrE"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Fr } from '../../fields/fields.js';
|
|
3
3
|
export async function vkAsFieldsMegaHonk(input) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
await BarretenbergSync.initSingleton({
|
|
5
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
6
|
+
});
|
|
7
|
+
const api = BarretenbergSync.getSingleton();
|
|
8
|
+
const response = api.megaVkAsFields({
|
|
9
|
+
verificationKey: input
|
|
10
|
+
});
|
|
11
|
+
return response.fields.map((field)=>Fr.fromBuffer(Buffer.from(field)));
|
|
7
12
|
}
|