From 0497816694bef2b103494c8c61b7c8a06a72c7d3 Mon Sep 17 00:00:00 2001 From: Jay Geng Date: Wed, 18 Sep 2024 18:27:35 -0400 Subject: [PATCH] BLS12-381 host functions (#1456) ### What This PR adds support for BLS12-381 in Soroban, by adding host functions for the field and curve operations, new metering cost types, and their calibration. ### Why Please refer to the [CAP](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0059.md) for motivation and design rationale. ### Known limitations The unit tests currently covers the low-level operations: G1/G2 operations, hashing to curve, pairing. More test coverage will be added before the PR merged, at the integration level such as BLS signature and the Ethereum test vectors. --------- Co-authored-by: Plamen Hristov --- Cargo.lock | 226 ++- Cargo.toml | 2 +- cackle.toml | 36 + soroban-builtin-sdk-macros/Cargo.toml | 2 +- soroban-env-common/env.json | 286 +++ soroban-env-common/src/num.rs | 12 + soroban-env-host/Cargo.toml | 15 +- .../benches/common/cost_types/bls12_381.rs | 353 ++++ .../benches/common/cost_types/mod.rs | 2 + .../benches/common/experimental/bls12_381.rs | 86 + .../benches/common/experimental/mod.rs | 2 + soroban-env-host/benches/common/measure.rs | 33 +- soroban-env-host/benches/common/mod.rs | 40 + .../benches/variation_histograms.rs | 7 +- ...t__bls12_381__check_g1_is_in_subgroup.json | 78 + ...t__bls12_381__check_g2_is_in_subgroup.json | 78 + .../22/test__bls12_381__g1_add.json | 92 + .../22/test__bls12_381__g1_msm.json | 368 ++++ .../22/test__bls12_381__g1_mul.json | 28 + .../22/test__bls12_381__g2_add.json | 92 + .../22/test__bls12_381__g2_msm.json | 308 +++ .../22/test__bls12_381__g2_mul.json | 28 + .../22/test__bls12_381__hash_to_g1.json | 58 + .../22/test__bls12_381__hash_to_g2.json | 58 + .../22/test__bls12_381__map_fp2_to_g2.json | 96 + .../22/test__bls12_381__map_fp_to_g1.json | 96 + .../22/test__bls12_381__pairing.json | 180 ++ ...s12_381__test_serialization_roundtrip.json | 44 + ..._with_wrong_arg_type_bls12_381_fr_pow.json | 189 ++ ...s12_381_check_g1_is_in_subgroup_arg_0.json | 29 + ...s12_381_check_g2_is_in_subgroup_arg_0.json | 29 + ..._object_handle_bls12_381_g1_add_arg_0.json | 29 + ..._object_handle_bls12_381_g1_add_arg_1.json | 29 + ..._object_handle_bls12_381_g1_msm_arg_0.json | 29 + ..._object_handle_bls12_381_g1_msm_arg_1.json | 29 + ..._object_handle_bls12_381_g1_mul_arg_0.json | 29 + ..._object_handle_bls12_381_g2_add_arg_0.json | 29 + ..._object_handle_bls12_381_g2_add_arg_1.json | 29 + ..._object_handle_bls12_381_g2_msm_arg_0.json | 29 + ..._object_handle_bls12_381_g2_msm_arg_1.json | 29 + ..._object_handle_bls12_381_g2_mul_arg_0.json | 29 + ...ect_handle_bls12_381_hash_to_g1_arg_0.json | 29 + ...ect_handle_bls12_381_hash_to_g1_arg_1.json | 29 + ...ect_handle_bls12_381_hash_to_g2_arg_0.json | 29 + ...ect_handle_bls12_381_hash_to_g2_arg_1.json | 29 + ..._handle_bls12_381_map_fp2_to_g2_arg_0.json | 29 + ...t_handle_bls12_381_map_fp_to_g1_arg_0.json | 29 + ...e_bls12_381_multi_pairing_check_arg_0.json | 29 + ...e_bls12_381_multi_pairing_check_arg_1.json | 29 + soroban-env-host/src/budget.rs | 225 +++ .../src/cost_runner/cost_types/bls12_381.rs | 397 ++++ .../cost_types/compute_sha256_hash.rs | 2 +- .../src/cost_runner/cost_types/mod.rs | 2 + .../src/cost_runner/cost_types/prng.rs | 2 +- .../src/cost_runner/experimental/bls12_381.rs | 212 ++ .../experimental/decode_secp256r1_sig.rs | 2 +- .../experimental/ecdsa_secp256k1_verify.rs | 2 +- .../experimental/ecdsa_secp256r1_recover.rs | 2 +- .../experimental/ed25519_scalar_mut.rs | 2 +- .../src/cost_runner/experimental/mod.rs | 26 + .../src/cost_runner/experimental/read_xdr.rs | 2 +- .../sec1_decode_point_compressed.rs | 2 +- soroban-env-host/src/cost_runner/runner.rs | 2 +- soroban-env-host/src/cost_runner/util.rs | 99 + soroban-env-host/src/crypto/bls12_381.rs | 803 ++++++++ .../src/{host/crypto.rs => crypto/mod.rs} | 3 +- soroban-env-host/src/e2e_invoke.rs | 2 +- soroban-env-host/src/host.rs | 208 +- soroban-env-host/src/host/data_helper.rs | 2 +- soroban-env-host/src/host/lifecycle.rs | 3 +- soroban-env-host/src/host/metered_xdr.rs | 2 +- soroban-env-host/src/host/num.rs | 17 + soroban-env-host/src/host/prng.rs | 7 +- soroban-env-host/src/lib.rs | 4 +- soroban-env-host/src/test.rs | 1 + soroban-env-host/src/test/bls12_381.rs | 1750 +++++++++++++++++ soroban-env-host/src/test/budget_metering.rs | 165 +- .../data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json | 115 ++ .../data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json | 115 ++ soroban-env-host/src/test/hostile.rs | 25 + soroban-env-host/src/test/lifecycle.rs | 2 +- soroban-env-host/tests/bls.rs | 449 +++++ .../data/ethereum-bls/aggregate/README.md | 19 + ...0000000000000000000000000000000000000.json | 1 + ...6565656565656565656565656565656565656.json | 1 + ...babababababababababababababababababab.json | 1 + .../aggregate_infinity_signature.json | 1 + .../aggregate/aggregate_single_signature.json | 1 + .../ethereum-bls/aggregate_verify/README.md | 17 + .../aggregate_verify_valid.json | 1 + .../data/ethereum-bls/batch_verify/README.md | 17 + ...h_verify_invalid_forged_signature_set.json | 1 + ...h_verify_valid_multiple_signature_set.json | 1 + ...tch_verify_valid_simple_signature_set.json | 1 + .../fast_aggregate_verify/README.md | 17 + ..._verify_extra_pubkey_4f079f946446fabf.json | 1 + ..._verify_extra_pubkey_5a38e6b4017fe4dd.json | 1 + ..._verify_extra_pubkey_a698ea45b109f303.json | 1 + ...gregate_verify_valid_3d7576f3c0e3570a.json | 1 + ...gregate_verify_valid_5e745ad0c6199a6c.json | 1 + ...gregate_verify_valid_652ce62f09290811.json | 1 + .../tests/data/ethereum-bls/sign/README.md | 21 + .../sign/sign_case_11b8c7cad5238946.json | 1 + .../sign/sign_case_142f678a8d05fcd1.json | 1 + .../sign/sign_case_37286e1a6d1f6eb3.json | 1 + .../sign/sign_case_7055381f640f2c1d.json | 1 + .../sign/sign_case_84d45c9c7cca6b92.json | 1 + .../sign/sign_case_8cd3d4d0d9a5b265.json | 1 + .../sign/sign_case_c82df61aa3ee60fb.json | 1 + .../sign/sign_case_d0e28d7e76eb6e9c.json | 1 + .../sign/sign_case_f2ae1097e7d0e18b.json | 1 + .../tests/data/ethereum-bls/verify/README.md | 17 + .../verify_valid_case_195246ee3bd3b6ec.json | 1 + .../verify_valid_case_2ea479adf8c40300.json | 1 + .../verify_valid_case_2f09d443ab8a3ac2.json | 1 + .../verify_valid_case_3208262581c8fc09.json | 1 + .../verify_valid_case_6b3b17f6962a490c.json | 1 + .../verify_valid_case_6eeb7c52dfd9baf0.json | 1 + .../verify_valid_case_8761a0b7e920c323.json | 1 + .../verify_valid_case_d34885d766d5f705.json | 1 + .../verify_valid_case_e8a50c445c855360.json | 1 + ...fy_wrong_pubkey_case_195246ee3bd3b6ec.json | 1 + ...fy_wrong_pubkey_case_2ea479adf8c40300.json | 1 + ...fy_wrong_pubkey_case_2f09d443ab8a3ac2.json | 1 + ...fy_wrong_pubkey_case_3208262581c8fc09.json | 1 + ...fy_wrong_pubkey_case_6b3b17f6962a490c.json | 1 + ...fy_wrong_pubkey_case_6eeb7c52dfd9baf0.json | 1 + ...fy_wrong_pubkey_case_8761a0b7e920c323.json | 1 + ...fy_wrong_pubkey_case_d34885d766d5f705.json | 1 + ...fy_wrong_pubkey_case_e8a50c445c855360.json | 1 + ...rifycase_one_privkey_47117849458281be.json | 1 + soroban-env-macros/Cargo.toml | 2 +- 132 files changed, 8148 insertions(+), 132 deletions(-) create mode 100644 soroban-env-host/benches/common/cost_types/bls12_381.rs create mode 100644 soroban-env-host/benches/common/experimental/bls12_381.rs create mode 100644 soroban-env-host/observations/22/test__bls12_381__check_g1_is_in_subgroup.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__check_g2_is_in_subgroup.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g1_add.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g1_msm.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g1_mul.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g2_add.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g2_msm.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__g2_mul.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__hash_to_g1.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__hash_to_g2.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__pairing.json create mode 100644 soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json create mode 100644 soroban-env-host/observations/22/test__dispatch__dispatch_with_wrong_arg_type_bls12_381_fr_pow.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g1_is_in_subgroup_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g2_is_in_subgroup_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_mul_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_mul_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_1.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp2_to_g2_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp_to_g1_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_0.json create mode 100644 soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_1.json create mode 100644 soroban-env-host/src/cost_runner/cost_types/bls12_381.rs create mode 100644 soroban-env-host/src/cost_runner/experimental/bls12_381.rs create mode 100644 soroban-env-host/src/crypto/bls12_381.rs rename soroban-env-host/src/{host/crypto.rs => crypto/mod.rs} (99%) create mode 100644 soroban-env-host/src/test/bls12_381.rs create mode 100644 soroban-env-host/src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json create mode 100644 soroban-env-host/src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json create mode 100644 soroban-env-host/tests/bls.rs create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x0000000000000000000000000000000000000000000000000000000000000000.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x5656565656565656565656565656565656565656565656565656565656565656.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0xabababababababababababababababababababababababababababababababab.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_infinity_signature.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_single_signature.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate_verify/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/aggregate_verify/aggregate_verify_valid.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/batch_verify/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_invalid_forged_signature_set.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_multiple_signature_set.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_simple_signature_set.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_4f079f946446fabf.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_a698ea45b109f303.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_3d7576f3c0e3570a.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_5e745ad0c6199a6c.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_652ce62f09290811.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_11b8c7cad5238946.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_142f678a8d05fcd1.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_37286e1a6d1f6eb3.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_7055381f640f2c1d.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_84d45c9c7cca6b92.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_8cd3d4d0d9a5b265.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_c82df61aa3ee60fb.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_d0e28d7e76eb6e9c.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/sign/sign_case_f2ae1097e7d0e18b.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/README.md create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_195246ee3bd3b6ec.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2ea479adf8c40300.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2f09d443ab8a3ac2.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_3208262581c8fc09.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6b3b17f6962a490c.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6eeb7c52dfd9baf0.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_8761a0b7e920c323.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_d34885d766d5f705.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_e8a50c445c855360.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_195246ee3bd3b6ec.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2ea479adf8c40300.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2f09d443ab8a3ac2.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_3208262581c8fc09.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6b3b17f6962a490c.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6eeb7c52dfd9baf0.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_8761a0b7e920c323.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_d34885d766d5f705.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_e8a50c445c855360.json create mode 100644 soroban-env-host/tests/data/ethereum-bls/verify/verifycase_one_privkey_47117849458281be.json diff --git a/Cargo.lock b/Cargo.lock index 0874f69c1..5e6682f61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,6 +77,124 @@ dependencies = [ "derive_arbitrary", ] +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "arrayvec" version = "0.7.4" @@ -110,12 +228,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base32" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" - [[package]] name = "base64" version = "0.13.1" @@ -170,7 +282,7 @@ dependencies = [ "num-bigint", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -291,7 +403,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -315,7 +427,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.39", ] [[package]] @@ -326,9 +438,15 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.39", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "der" version = "0.7.6" @@ -349,6 +467,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_arbitrary" version = "1.3.2" @@ -357,7 +486,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -583,6 +712,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.1" @@ -692,9 +830,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] @@ -892,7 +1030,7 @@ checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -943,7 +1081,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1275,7 +1413,7 @@ checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1315,7 +1453,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1394,7 +1532,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1429,6 +1567,10 @@ name = "soroban-env-host" version = "22.0.0" dependencies = [ "arbitrary", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", "backtrace", "bytes-lit", "curve25519-dalek", @@ -1455,6 +1597,7 @@ dependencies = [ "rand_chacha", "rustversion", "sec1", + "serde", "serde_json", "sha2", "sha3", @@ -1488,7 +1631,7 @@ dependencies = [ "serde", "serde_json", "stellar-xdr", - "syn", + "syn 2.0.39", ] [[package]] @@ -1563,19 +1706,19 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" +checksum = "5e3aa3ed00e70082cb43febc1c2afa5056b9bb3e348bbb43d0cd0aa88a611144" dependencies = [ - "base32", "crate-git-revision", + "data-encoding", "thiserror", ] [[package]] name = "stellar-xdr" version = "22.0.0" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=39d7dbb0c12bd422ee43a6e2e3277789da4eaac8#39d7dbb0c12bd422ee43a6e2e3277789da4eaac8" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=b5516843b6379e4e29520bf2ba156484f62edc46#b5516843b6379e4e29520bf2ba156484f62edc46" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1610,6 +1753,17 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.39" @@ -1670,7 +1824,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1871,7 +2025,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -1893,7 +2047,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2035,7 +2189,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -2046,7 +2200,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -2242,7 +2396,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -2250,3 +2404,17 @@ name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/Cargo.toml b/Cargo.toml index 82ab4d2b1..cf6281186 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmparser = "=0.116.1" [workspace.dependencies.stellar-xdr] version = "=22.0.0" git = "https://github.com/stellar/rs-stellar-xdr" -rev = "39d7dbb0c12bd422ee43a6e2e3277789da4eaac8" +rev = "b5516843b6379e4e29520bf2ba156484f62edc46" default-features = false [workspace.dependencies.wasmi] diff --git a/cackle.toml b/cackle.toml index 6a4bb6214..44b49184e 100644 --- a/cackle.toml +++ b/cackle.toml @@ -17,6 +17,7 @@ include = [ [api.hash] include = [ "core::hash", + "derivative::hash", "std::collections::HashMap", "std::collections::hash", "std::sys::unix::rand::hashmap_random_keys", @@ -400,6 +401,10 @@ allow_apis = [ "hash", "thread", ] +build.allow_apis = [ + "env", + "process", +] [pkg.soroban-wasmi] allow_unsafe = true @@ -499,3 +504,34 @@ allow_unsafe = true [pkg.arrayvec] allow_unsafe = true + +[pkg.ark-serialize-derive] +allow_proc_macro = true + +[pkg.zeroize_derive] +allow_proc_macro = true + +[pkg.ark-ff-macros] +allow_proc_macro = true + +[pkg.derivative] +allow_proc_macro = true +allow_apis = [ + "hash", +] + +[pkg.ark-ff-asm] +allow_proc_macro = true + +[pkg.num-bigint] +build.allow_apis = [ + "env", + "fs", +] +allow_unsafe = true + +[pkg.data-encoding] +allow_unsafe = true + +[pkg.ark-ff] +allow_unsafe = true diff --git a/soroban-builtin-sdk-macros/Cargo.toml b/soroban-builtin-sdk-macros/Cargo.toml index 46c937b3c..b48b1add0 100644 --- a/soroban-builtin-sdk-macros/Cargo.toml +++ b/soroban-builtin-sdk-macros/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true syn = {version="2.0.39",features=["full"]} quote = "1.0.33" proc-macro2 = "1.0.69" -itertools = "0.11.0" +itertools = "0.10.5" [package.metadata.docs.rs] all-features = true diff --git a/soroban-env-common/env.json b/soroban-env-common/env.json index 9b720650c..d421dca2f 100644 --- a/soroban-env-common/env.json +++ b/soroban-env-common/env.json @@ -2047,6 +2047,292 @@ "return": "Void", "docs": "Verifies the `signature` using an ECDSA secp256r1 `public_key` on a 32-byte `msg_digest`. Warning: The `msg_digest` must be produced by a secure cryptographic hash function on the message, otherwise the attacker can potentially forge signatures. The `public_key` is expected to be 65 bytes in length, representing a SEC-1 encoded point in uncompressed format. The `signature` is the ECDSA signature `(r, s)` serialized as fixed-size big endian scalar values, both `r`, `s` must be non-zero and `s` must be in the lower range. ", "min_supported_protocol": 21 + }, + { + "export": "4", + "name": "bls12_381_check_g1_is_in_subgroup", + "args": [ + { + "name": "point", + "type": "BytesObject" + } + ], + "return": "Bool", + "docs": "Checks if the input G1 point is in the correct subgroup.", + "min_supported_protocol": 22 + }, + { + "export": "5", + "name": "bls12_381_g1_add", + "args": [ + { + "name": "point1", + "type": "BytesObject" + }, + { + "name": "point2", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Adds two BLS12-381 G1 points given in bytes format and returns the resulting G1 point in bytes format. G1 serialization format: `concat(be_bytes(X), be_bytes(Y))` and the most significant three bits of X encodes flags, i.e. bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.", + "min_supported_protocol": 22 + }, + { + "export": "6", + "name": "bls12_381_g1_mul", + "args": [ + { + "name": "point", + "type": "BytesObject" + }, + { + "name": "scalar", + "type": "U256Val" + } + ], + "return": "BytesObject", + "docs": "Multiplies a BLS12-381 G1 point by a scalar (Fr), and returns the resulting G1 point in bytes format.", + "min_supported_protocol": 22 + }, + { + "export": "7", + "name": "bls12_381_g1_msm", + "args": [ + { + "name": "vp", + "type": "VecObject" + }, + { + "name": "vs", + "type": "VecObject" + } + ], + "return": "BytesObject", + "docs": "Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G1 points (`Vec`) by a vector of scalars (`Vec`), and returns the resulting G1 point in bytes format.", + "min_supported_protocol": 22 + }, + { + "export": "8", + "name": "bls12_381_map_fp_to_g1", + "args": [ + { + "name": "fp", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Maps a BLS12-381 field element (Fp) to G1 point. The input is a BytesObject containing Fp serialized in big-endian order", + "min_supported_protocol": 22 + }, + { + "export": "9", + "name": "bls12_381_hash_to_g1", + "args": [ + { + "name": "msg", + "type": "BytesObject" + }, + { + "name": "dst", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Hashes a message to a BLS12-381 G1 point, with implementation following the specification in [Hashing to Elliptic Curves](https://datatracker.ietf.org/doc/html/rfc9380) (ciphersuite 'BLS12381G1_XMD:SHA-256_SSWU_RO_'). `dst` is the domain separation tag that will be concatenated with the `msg` during hashing, it is intended to keep hashing inputs of different applications separate. It is required `0 < len(dst_bytes) < 256`. DST **must** be chosen with care to avoid compromising the application's security properties. Refer to section 3.1 in the RFC on requirements of DST.", + "min_supported_protocol": 22 + }, + { + "export": "a", + "name": "bls12_381_check_g2_is_in_subgroup", + "args": [ + { + "name": "point", + "type": "BytesObject" + } + ], + "return": "Bool", + "docs": "Checks if the input G2 point is in the correct subgroup.", + "min_supported_protocol": 22 + }, + { + "export": "b", + "name": "bls12_381_g2_add", + "args": [ + { + "name": "point1", + "type": "BytesObject" + }, + { + "name": "point2", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Adds two BLS12-381 G2 points given in bytes format and returns the resulting G2 point in bytes format. G2 serialization format: concat(be_bytes(X_c1), be_bytes(X_c0), be_bytes(Y_c1), be_bytes(Y_c0)), and the most significant three bits of X_c1 are flags i.e. bits(X_c1) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.", + "min_supported_protocol": 22 + }, + { + "export": "c", + "name": "bls12_381_g2_mul", + "args": [ + { + "name": "point", + "type": "BytesObject" + }, + { + "name": "scalar", + "type": "U256Val" + } + ], + "return": "BytesObject", + "docs": "Multiplies a BLS12-381 G2 point by a scalar (Fr), and returns the resulting G2 point in bytes format.", + "min_supported_protocol": 22 + }, + { + "export": "d", + "name": "bls12_381_g2_msm", + "args": [ + { + "name": "vp", + "type": "VecObject" + }, + { + "name": "vs", + "type": "VecObject" + } + ], + "return": "BytesObject", + "docs": "Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G2 points (`Vec`) by a vector of scalars (`Vec`) , and returns the resulting G2 point in bytes format.", + "min_supported_protocol": 22 + }, + { + "export": "e", + "name": "bls12_381_map_fp2_to_g2", + "args": [ + { + "name": "fp2", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Maps a BLS12-381 quadratic extension field element (Fp2) to G2 point. Fp2 serialization format: concat(be_bytes(c1), be_bytes(c0))", + "min_supported_protocol": 22 + }, + { + "export": "f", + "name": "bls12_381_hash_to_g2", + "args": [ + { + "name": "msg", + "type": "BytesObject" + }, + { + "name": "dst", + "type": "BytesObject" + } + ], + "return": "BytesObject", + "docs": "Hashes a message to a BLS12-381 G2 point, with implementation following the specification in [Hashing to Elliptic Curves](https://datatracker.ietf.org/doc/html/rfc9380) (ciphersuite 'BLS12381G2_XMD:SHA-256_SSWU_RO_'). `dst` is the domain separation tag that will be concatenated with the `msg` during hashing, it is intended to keep hashing inputs of different applications separate. It is required `0 < len(dst_bytes) < 256`. DST **must** be chosen with care to avoid compromising the application's security properties. Refer to section 3.1 in the RFC on requirements of DST.", + "min_supported_protocol": 22 + }, + { + "export": "g", + "name": "bls12_381_multi_pairing_check", + "args": [ + { + "name": "vp1", + "type": "VecObject" + }, + { + "name": "vp2", + "type": "VecObject" + } + ], + "return": "Bool", + "docs": "performs pairing operation on a vector of `G1` (`Vec`) and a vector of `G2` points (`Vec`) , return true if the result equals `1_fp12`", + "min_supported_protocol": 22 + }, + { + "export": "h", + "name": "bls12_381_fr_add", + "args": [ + { + "name": "lhs", + "type": "U256Val" + }, + { + "name": "rhs", + "type": "U256Val" + } + ], + "return": "U256Val", + "docs": "performs addition `(lhs + rhs) mod r` between two BLS12-381 scalar elements (Fr), where r is the subgroup order", + "min_supported_protocol": 22 + }, + { + "export": "i", + "name": "bls12_381_fr_sub", + "args": [ + { + "name": "lhs", + "type": "U256Val" + }, + { + "name": "rhs", + "type": "U256Val" + } + ], + "return": "U256Val", + "docs": "performs subtraction `(lhs - rhs) mod r` between two BLS12-381 scalar elements (Fr), where r is the subgroup order", + "min_supported_protocol": 22 + }, + { + "export": "j", + "name": "bls12_381_fr_mul", + "args": [ + { + "name": "lhs", + "type": "U256Val" + }, + { + "name": "rhs", + "type": "U256Val" + } + ], + "return": "U256Val", + "docs": "performs multiplication `(lhs * rhs) mod r` between two BLS12-381 scalar elements (Fr), where r is the subgroup order", + "min_supported_protocol": 22 + }, + { + "export": "k", + "name": "bls12_381_fr_pow", + "args": [ + { + "name": "lhs", + "type": "U256Val" + }, + { + "name": "rhs", + "type": "U64Val" + } + ], + "return": "U256Val", + "docs": "performs exponentiation of a BLS12-381 scalar element (Fr) with a u64 exponent i.e. `lhs.exp(rhs) mod r`, where r is the subgroup order", + "min_supported_protocol": 22 + }, + { + "export": "l", + "name": "bls12_381_fr_inv", + "args": [ + { + "name": "lhs", + "type": "U256Val" + } + ], + "return": "U256Val", + "docs": "performs inversion of a BLS12-381 scalar element (Fr) modulo r (the subgroup order)", + "min_supported_protocol": 22 } ] }, diff --git a/soroban-env-common/src/num.rs b/soroban-env-common/src/num.rs index ffd9326d4..cd58a5127 100644 --- a/soroban-env-common/src/num.rs +++ b/soroban-env-common/src/num.rs @@ -230,6 +230,12 @@ impl TryFrom for I128Small { } } +impl From for u64 { + fn from(value: U256Small) -> Self { + value.0.get_body() + } +} + impl TryFrom for U256Small { type Error = ConversionError; fn try_from(value: U256) -> Result { @@ -243,6 +249,12 @@ impl TryFrom for U256Small { } } +impl From for i64 { + fn from(value: I256Small) -> Self { + value.0.get_signed_body() + } +} + impl TryFrom for I256Small { type Error = ConversionError; fn try_from(value: I256) -> Result { diff --git a/soroban-env-host/Cargo.toml b/soroban-env-host/Cargo.toml index c6275bcf1..d8a9b08e6 100644 --- a/soroban-env-host/Cargo.toml +++ b/soroban-env-host/Cargo.toml @@ -18,7 +18,7 @@ soroban-builtin-sdk-macros = { workspace = true } soroban-env-common = { workspace = true, features = ["std", "wasmi", "shallow-val-hash"] } wasmi = { workspace = true } wasmparser = { workspace = true } -stellar-strkey = "0.0.8" +stellar-strkey = "0.0.9" static_assertions = "1.1.0" sha2 = "0.10.8" hex-literal = "0.4.1" @@ -67,13 +67,17 @@ sha3 = "0.10.8" # which requires "4.1.3". We will need to pin to this version once Core is # updated to the new env version. curve25519-dalek = { version = ">=4.1.1", default-features = false, features = ["digest"]} +ark-bls12-381 = { version = "0.4.0"} +ark-serialize = { version = "0.4.2"} +ark-ff = { version = "0.4.2"} +ark-ec = { version = "0.4.2"} [target.'cfg(not(target_family = "wasm"))'.dependencies] tracy-client = { version = "0.17.0", features = ["enable", "timer-fallback"], default-features = false, optional = true } [dev-dependencies] hex = "0.4.3" -itertools = "0.11.0" +itertools = "0.10.5" tabwriter = "1.3.0" thousands = "0.2.0" soroban-env-macros = { workspace = true } @@ -88,6 +92,7 @@ more-asserts = "0.3.1" pretty_assertions = "1.4.0" backtrace = "0.3.69" serde_json = "1.0.108" +serde = "1.0.192" arbitrary = "1.3.2" lstsq = "0.5.0" nalgebra = { version = "0.32.3", default-features = false, features = ["std"]} @@ -100,7 +105,7 @@ p256 = {version = "0.13.2", default-features = false, features = ["alloc"]} [dev-dependencies.stellar-xdr] version = "=22.0.0" git = "https://github.com/stellar/rs-stellar-xdr" -rev = "39d7dbb0c12bd422ee43a6e2e3277789da4eaac8" +rev = "b5516843b6379e4e29520bf2ba156484f62edc46" default-features = false features = ["arbitrary"] @@ -141,6 +146,10 @@ name = "secp256r1_sig_ver" path = "tests/secp256r1_sig_ver.rs" required-features = ["testutils"] +[[test]] +name = "bls-signature" +path = "tests/bls.rs" +required-features = ["testutils"] [package.metadata.docs.rs] features = ["recording_mode", "tracy", "testutils"] diff --git a/soroban-env-host/benches/common/cost_types/bls12_381.rs b/soroban-env-host/benches/common/cost_types/bls12_381.rs new file mode 100644 index 000000000..918070cad --- /dev/null +++ b/soroban-env-host/benches/common/cost_types/bls12_381.rs @@ -0,0 +1,353 @@ +use crate::common::HostCostMeasurement; +use ark_bls12_381::{Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; +use ark_ff::UniformRand; +use ark_serialize::CanonicalSerialize; +use rand::{rngs::StdRng, Rng, RngCore}; +use soroban_env_host::{ + cost_runner::{ + Bls12381DecodeFpRun, Bls12381DecodeFpSample, Bls12381EncodeFpRun, Bls12381EncodeFpSample, + Bls12381FrAddRun, Bls12381FrAddSubMulSample, Bls12381FrFromU256Run, + Bls12381FrFromU256Sample, Bls12381FrInvRun, Bls12381FrInvSample, Bls12381FrMulRun, + Bls12381FrPowRun, Bls12381FrPowSample, Bls12381FrSubRun, Bls12381FrToU256Run, + Bls12381FrToU256Sample, Bls12381G1AddRun, Bls12381G1AddSample, + Bls12381G1CheckPointInSubgroupRun, Bls12381G1CheckPointInSubgroupSample, + Bls12381G1CheckPointOnCurveRun, Bls12381G1CheckPointOnCurveSample, Bls12381G1MsmRun, + Bls12381G1MsmSample, Bls12381G1MulRun, Bls12381G1MulSample, + Bls12381G1ProjectiveToAffineRun, Bls12381G1ProjectiveToAffineSample, Bls12381G2AddRun, + Bls12381G2AddSample, Bls12381G2CheckPointInSubgroupRun, + Bls12381G2CheckPointInSubgroupSample, Bls12381G2CheckPointOnCurveRun, + Bls12381G2CheckPointOnCurveSample, Bls12381G2MsmRun, Bls12381G2MsmSample, Bls12381G2MulRun, + Bls12381G2MulSample, Bls12381G2ProjectiveToAffineRun, Bls12381G2ProjectiveToAffineSample, + Bls12381HashToG1Run, Bls12381HashToG1Sample, Bls12381HashToG2Run, Bls12381HashToG2Sample, + Bls12381MapFp2ToG2Run, Bls12381MapFp2ToG2Sample, Bls12381MapFpToG1Run, + Bls12381MapFpToG1Sample, Bls12381PairingRun, Bls12381PairingSample, + }, + xdr::ContractCostType::*, + Host, TryIntoVal, U256Val, U256, +}; + +pub(crate) struct Bls12381EncodeFpMeasure; +impl HostCostMeasurement for Bls12381EncodeFpMeasure { + type Runner = Bls12381EncodeFpRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381EncodeFpSample { + let buf = vec![0; 1000]; + let fp = Fq::rand(rng); + Bls12381EncodeFpSample(buf, fp) + } +} +pub(crate) struct Bls12381DecodeFpMeasure; +impl HostCostMeasurement for Bls12381DecodeFpMeasure { + type Runner = Bls12381DecodeFpRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381DecodeFpSample { + let mut buf = vec![]; + let _ = Fq::rand(rng).serialize_uncompressed(&mut buf).unwrap(); + Bls12381DecodeFpSample(buf) + } +} +pub(crate) struct Bls12381G1CheckPointOnCurveMeasure; +impl HostCostMeasurement for Bls12381G1CheckPointOnCurveMeasure { + type Runner = Bls12381G1CheckPointOnCurveRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G1CheckPointOnCurveSample { + Bls12381G1CheckPointOnCurveSample( + G1Affine::new_unchecked(Fq::rand(rng), Fq::rand(rng)), + Bls12381G1CheckPointOnCurve, + ) + } +} +pub(crate) struct Bls12381G1CheckPointInSubgroupMeasure; +impl HostCostMeasurement for Bls12381G1CheckPointInSubgroupMeasure { + type Runner = Bls12381G1CheckPointInSubgroupRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G1CheckPointInSubgroupSample { + Bls12381G1CheckPointInSubgroupSample(G1Affine::rand(rng), Bls12381G1CheckPointInSubgroup) + } +} +pub(crate) struct Bls12381G2CheckPointOnCurveMeasure; +impl HostCostMeasurement for Bls12381G2CheckPointOnCurveMeasure { + type Runner = Bls12381G2CheckPointOnCurveRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G2CheckPointOnCurveSample { + Bls12381G2CheckPointOnCurveSample( + G2Affine::new_unchecked(Fq2::rand(rng), Fq2::rand(rng)), + Bls12381G2CheckPointOnCurve, + ) + } +} +pub(crate) struct Bls12381G2CheckPointInSubgroupMeasure; +impl HostCostMeasurement for Bls12381G2CheckPointInSubgroupMeasure { + type Runner = Bls12381G2CheckPointInSubgroupRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G2CheckPointInSubgroupSample { + Bls12381G2CheckPointInSubgroupSample(G2Affine::rand(rng), Bls12381G2CheckPointInSubgroup) + } +} +pub(crate) struct Bls12381FrFromU256Measure; +impl HostCostMeasurement for Bls12381FrFromU256Measure { + type Runner = Bls12381FrFromU256Run; + + fn new_random_case(host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrFromU256Sample { + let mut buf = [0; 32]; + rng.fill_bytes(&mut buf); + let u = U256::from_be_bytes(buf); + let val: U256Val = u.try_into_val(host).unwrap(); + Bls12381FrFromU256Sample(val) + } +} +pub(crate) struct Bls12381FrToU256Measure; +impl HostCostMeasurement for Bls12381FrToU256Measure { + type Runner = Bls12381FrToU256Run; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrToU256Sample { + Bls12381FrToU256Sample(Fr::rand(rng)) + } +} +pub(crate) struct Bls12381FrAddMeasure; +impl HostCostMeasurement for Bls12381FrAddMeasure { + type Runner = Bls12381FrAddRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrAddSubMulSample { + Bls12381FrAddSubMulSample(Fr::rand(rng), Fr::rand(rng)) + } +} +pub(crate) struct Bls12381FrSubMeasure; +impl HostCostMeasurement for Bls12381FrSubMeasure { + type Runner = Bls12381FrSubRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrAddSubMulSample { + Bls12381FrAddSubMulSample(Fr::rand(rng), Fr::rand(rng)) + } +} +pub(crate) struct Bls12381FrMulMeasure; +impl HostCostMeasurement for Bls12381FrMulMeasure { + type Runner = Bls12381FrMulRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrAddSubMulSample { + Bls12381FrAddSubMulSample(Fr::rand(rng), Fr::rand(rng)) + } +} +pub(crate) struct Bls12381FrPowMeasure; +impl HostCostMeasurement for Bls12381FrPowMeasure { + type Runner = Bls12381FrPowRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381FrPowSample { + assert!(input <= 64); + let rhs = if input == 64 { + u64::MAX + } else { + (1 << input) - 1 + }; + Bls12381FrPowSample(Fr::rand(rng), rhs) + } +} +pub(crate) struct Bls12381FrInvMeasure; +impl HostCostMeasurement for Bls12381FrInvMeasure { + type Runner = Bls12381FrInvRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381FrInvSample { + Bls12381FrInvSample(Fr::rand(rng)) + } +} + +pub(crate) struct Bls12381G1AddMeasure; + +impl HostCostMeasurement for Bls12381G1AddMeasure { + type Runner = Bls12381G1AddRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381G1AddSample { + let p0 = G1Affine::rand(rng); + let p1 = G1Affine::rand(rng); + Bls12381G1AddSample(p0, p1) + } +} + +pub(crate) struct Bls12381G1ProjectiveToAffineMeasure; + +impl HostCostMeasurement for Bls12381G1ProjectiveToAffineMeasure { + type Runner = Bls12381G1ProjectiveToAffineRun; + + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G1ProjectiveToAffineSample { + let p0 = G1Projective::rand(rng); + Bls12381G1ProjectiveToAffineSample(p0) + } +} + +pub(crate) struct Bls12381G1MulMeasure; + +impl HostCostMeasurement for Bls12381G1MulMeasure { + type Runner = Bls12381G1MulRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381G1MulSample { + let p = G1Affine::rand(rng); + let s = Fr::rand(rng); + Bls12381G1MulSample(p, s) + } +} + +pub(crate) struct Bls12381G1MsmMeasure; + +impl HostCostMeasurement for Bls12381G1MsmMeasure { + type Runner = Bls12381G1MsmRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381G1MsmSample { + Bls12381G1MsmSample( + (0..input) + .into_iter() + .map(|_| G1Affine::rand(rng)) + .collect(), + (0..input).into_iter().map(|_| Fr::rand(rng)).collect(), + Bls12381G1Msm, + "G1".to_string(), + ) + } +} + +pub(crate) struct Bls12381MapFpToG1Measure; + +impl HostCostMeasurement for Bls12381MapFpToG1Measure { + type Runner = Bls12381MapFpToG1Run; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381MapFpToG1Sample { + let fp = Fq::rand(rng); + Bls12381MapFpToG1Sample(fp, Bls12381MapFpToG1) + } +} + +pub(crate) struct Bls12381HashToG1Measure; + +impl HostCostMeasurement for Bls12381HashToG1Measure { + type Runner = Bls12381HashToG1Run; + const STEP_SIZE: u64 = 64; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381HashToG1Sample { + let len = Self::INPUT_BASE_SIZE + input * Self::STEP_SIZE; + let domain = "SOROBAN-V01-CS01-with-BLS12381G1_XMD:SHA-256_SSWU_RO_" + .as_bytes() + .to_vec(); + let mut msg = vec![0u8; len as usize]; + rng.fill(msg.as_mut_slice()); + Bls12381HashToG1Sample(domain, msg, Bls12381HashToG1) + } +} + +pub(crate) struct Bls12381G2ProjectiveToAffineMeasure; + +impl HostCostMeasurement for Bls12381G2ProjectiveToAffineMeasure { + type Runner = Bls12381G2ProjectiveToAffineRun; + + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> Bls12381G2ProjectiveToAffineSample { + let p0 = G2Projective::rand(rng); + Bls12381G2ProjectiveToAffineSample(p0) + } +} + +pub(crate) struct Bls12381G2AddMeasure; + +impl HostCostMeasurement for Bls12381G2AddMeasure { + type Runner = Bls12381G2AddRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381G2AddSample { + let p0 = G2Affine::rand(rng); + let p1 = G2Affine::rand(rng); + Bls12381G2AddSample(p0, p1) + } +} + +pub(crate) struct Bls12381G2MulMeasure; + +impl HostCostMeasurement for Bls12381G2MulMeasure { + type Runner = Bls12381G2MulRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381G2MulSample { + let p = G2Affine::rand(rng); + let s = Fr::rand(rng); + Bls12381G2MulSample(p, s) + } +} + +pub(crate) struct Bls12381G2MsmMeasure; + +impl HostCostMeasurement for Bls12381G2MsmMeasure { + type Runner = Bls12381G2MsmRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381G2MsmSample { + Bls12381G2MsmSample( + (0..input) + .into_iter() + .map(|_| G2Affine::rand(rng)) + .collect(), + (0..input).into_iter().map(|_| Fr::rand(rng)).collect(), + Bls12381G2Msm, + "G2".to_string(), + ) + } +} + +pub(crate) struct Bls12381MapFp2ToG2Measure; + +impl HostCostMeasurement for Bls12381MapFp2ToG2Measure { + type Runner = Bls12381MapFp2ToG2Run; + + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Bls12381MapFp2ToG2Sample { + let fp2 = Fq2::rand(rng); + Bls12381MapFp2ToG2Sample(fp2, Bls12381MapFp2ToG2) + } +} + +pub(crate) struct Bls12381HashToG2Measure; + +impl HostCostMeasurement for Bls12381HashToG2Measure { + type Runner = Bls12381HashToG2Run; + const STEP_SIZE: u64 = 64; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381HashToG2Sample { + let len = Self::INPUT_BASE_SIZE + input * Self::STEP_SIZE; + let domain = "SOROBAN-V01-CS01-with-BLS12381G2_XMD:SHA-256_SSWU_RO_" + .as_bytes() + .to_vec(); + let mut msg = vec![0u8; len as usize]; + rng.fill(msg.as_mut_slice()); + Bls12381HashToG2Sample(domain, msg, Bls12381HashToG2) + } +} + +pub(crate) struct Bls12381PairingMeasure; + +impl HostCostMeasurement for Bls12381PairingMeasure { + type Runner = Bls12381PairingRun; + + fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> Bls12381PairingSample { + Bls12381PairingSample( + (0..input) + .into_iter() + .map(|_| G1Affine::rand(rng)) + .collect(), + (0..input) + .into_iter() + .map(|_| G2Affine::rand(rng)) + .collect(), + ) + } +} diff --git a/soroban-env-host/benches/common/cost_types/mod.rs b/soroban-env-host/benches/common/cost_types/mod.rs index 651449342..c36092d88 100644 --- a/soroban-env-host/benches/common/cost_types/mod.rs +++ b/soroban-env-host/benches/common/cost_types/mod.rs @@ -1,3 +1,4 @@ +mod bls12_381; mod compute_ed25519_pubkey; mod compute_keccak256_hash; mod compute_sha256_hash; @@ -18,6 +19,7 @@ mod visit_object; mod vm_ops; mod wasm_insn_exec; +pub(crate) use bls12_381::*; pub(crate) use compute_ed25519_pubkey::*; pub(crate) use compute_keccak256_hash::*; pub(crate) use compute_sha256_hash::*; diff --git a/soroban-env-host/benches/common/experimental/bls12_381.rs b/soroban-env-host/benches/common/experimental/bls12_381.rs new file mode 100644 index 000000000..10ba9454f --- /dev/null +++ b/soroban-env-host/benches/common/experimental/bls12_381.rs @@ -0,0 +1,86 @@ +use crate::common::HostCostMeasurement; +use ark_bls12_381::{Fq2, G1Affine, G2Affine}; +use ark_ff::UniformRand; +use ark_serialize::CanonicalSerialize; +use rand::rngs::StdRng; +use soroban_env_host::{ + cost_runner::{ + Bls12381Fp2DeserializeUncompressedRun, Bls12381G1AffineDeserializeUncompressedRun, + Bls12381G1AffineSerializeUncompressedRun, Bls12381G1ComputeYFromXRun, + Bls12381G1ComputeYFromXSample, Bls12381G2AffineDeserializeUncompressedRun, + Bls12381G2AffineSerializeUncompressedRun, Bls12381G2ComputeYFromXRun, + Bls12381G2ComputeYFromXSample, CostRunner, + }, + Host, +}; + +pub(crate) struct Bls12381G1AffineSerializeUncompressedMeasure; +impl HostCostMeasurement for Bls12381G1AffineSerializeUncompressedMeasure { + type Runner = Bls12381G1AffineSerializeUncompressedRun; + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> G1Affine { + G1Affine::rand(rng) + } +} +pub(crate) struct Bls12381G2AffineSerializeUncompressedMeasure; +impl HostCostMeasurement for Bls12381G2AffineSerializeUncompressedMeasure { + type Runner = Bls12381G2AffineSerializeUncompressedRun; + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> G2Affine { + G2Affine::rand(rng) + } +} + +pub(crate) struct Bls12381G1AffineDeserializeUncompressedMeasure; +impl HostCostMeasurement for Bls12381G1AffineDeserializeUncompressedMeasure { + type Runner = Bls12381G1AffineDeserializeUncompressedRun; + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Vec { + let mut buf = vec![]; + let _ = G1Affine::rand(rng) + .serialize_uncompressed(&mut buf) + .unwrap(); + buf + } +} +pub(crate) struct Bls12381G2AffineDeserializeUncompressedMeasure; +impl HostCostMeasurement for Bls12381G2AffineDeserializeUncompressedMeasure { + type Runner = Bls12381G2AffineDeserializeUncompressedRun; + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Vec { + let mut buf = vec![]; + let _ = G2Affine::rand(rng) + .serialize_uncompressed(&mut buf) + .unwrap(); + buf + } +} + +pub(crate) struct Bls12381Fp2DeserializeUncompressedMeasure; +impl HostCostMeasurement for Bls12381Fp2DeserializeUncompressedMeasure { + type Runner = Bls12381Fp2DeserializeUncompressedRun; + fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Vec { + let mut buf = vec![]; + let _ = Fq2::rand(rng).serialize_uncompressed(&mut buf).unwrap(); + buf + } +} + +pub(crate) struct Bls12381G1ComputeYFromXMeasure; +impl HostCostMeasurement for Bls12381G1ComputeYFromXMeasure { + type Runner = Bls12381G1ComputeYFromXRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> ::SampleType { + Bls12381G1ComputeYFromXSample(G1Affine::rand(rng)) + } +} +pub(crate) struct Bls12381G2ComputeYFromXMeasure; +impl HostCostMeasurement for Bls12381G2ComputeYFromXMeasure { + type Runner = Bls12381G2ComputeYFromXRun; + fn new_random_case( + _host: &Host, + rng: &mut StdRng, + _input: u64, + ) -> ::SampleType { + Bls12381G2ComputeYFromXSample(G2Affine::rand(rng)) + } +} diff --git a/soroban-env-host/benches/common/experimental/mod.rs b/soroban-env-host/benches/common/experimental/mod.rs index d64b260e0..b011b3778 100644 --- a/soroban-env-host/benches/common/experimental/mod.rs +++ b/soroban-env-host/benches/common/experimental/mod.rs @@ -1,3 +1,4 @@ +mod bls12_381; mod decode_secp256r1_sig; mod ecdsa_secp256k1_verify; mod ecdsa_secp256r1_recover; @@ -5,6 +6,7 @@ mod ed25519_scalar_mul; mod read_xdr; mod sec1_decode_point_compressed; +pub(crate) use bls12_381::*; pub(crate) use decode_secp256r1_sig::*; pub(crate) use ecdsa_secp256k1_verify::*; pub(crate) use ecdsa_secp256r1_recover::*; diff --git a/soroban-env-host/benches/common/measure.rs b/soroban-env-host/benches/common/measure.rs index 3fde3a8db..1ec48598c 100644 --- a/soroban-env-host/benches/common/measure.rs +++ b/soroban-env-host/benches/common/measure.rs @@ -98,8 +98,15 @@ impl Measurements { let ymin = points.iter().map(|(_, y)| *y).reduce(f32::min).unwrap(); let ymax = points.iter().map(|(_, y)| *y).reduce(f32::max).unwrap(); let ymean = points.iter().map(|(_, y)| *y).sum::() / points.len().max(1) as f32; + let mut ystd = points + .iter() + .map(|(_, y)| (*y - ymean) * (*y - ymean)) + .sum::() + / points.len().max(1) as f32; + ystd = ystd.sqrt(); if ymin == ymax { + println!("{} output: min == max == {}", out_name, ymin); return; } let hist = textplots::utils::histogram(&points, ymin, ymax, 30); @@ -125,12 +132,13 @@ impl Measurements { in_max / in_min.max(1.0) ); println!( - "{} output: min {}; max {}; max/min = {}; mean = {}; count = {}", + "{} output: min {}; max {}; max/min = {}; mean = {}; std = {}, count = {}", out_name, ymin.separate_with_commas(), ymax.separate_with_commas(), ymax / ymin.max(1.0), ymean.separate_with_commas(), + ystd.separate_with_commas(), points.len() ); Chart::new(180, 60, ymin - 100.0, ymax + 100.0) @@ -316,8 +324,8 @@ pub trait HostCostMeasurement: Sized { ::run(host, samples, recycled_samples) } - fn get_tracker(host: &Host) -> CostTracker { - ::get_tracker(host) + fn get_tracker(host: &Host, sample: &::SampleType) -> CostTracker { + ::get_tracker(host, sample) } // This is kind of a hack to account for the additional cpu_insn overhead @@ -340,7 +348,8 @@ fn harness( host: &Host, alloc_group_token: Option<&mut AllocationGroupToken>, runner: &mut R, - samples: Vec<<::Runner as CostRunner>::SampleType>, + sample: <::Runner as CostRunner>::SampleType, + repeat_iters: u64, ) -> Measurement where R: FnMut( @@ -349,7 +358,8 @@ where &mut Vec<<::Runner as CostRunner>::RecycledType>, ), { - let mut recycled_samples = Vec::with_capacity(samples.len()); + let samples = (0..repeat_iters).map(|_| sample.clone()).collect(); + let mut recycled_samples = Vec::with_capacity(repeat_iters as usize); host.as_budget().reset_unlimited().unwrap(); let mut ht = HostTracker::new(); @@ -361,7 +371,7 @@ where // Note: the `iterations` here is not same as `RUN_ITERATIONS`. This is the `N` part of the // cost model, which is `RUN_ITERATIONS` * "model iterations from the sample" - let ct = HCM::get_tracker(&host); + let ct = HCM::get_tracker(&host, &sample); Measurement { iterations: ct.iterations, inputs: ct.inputs, @@ -398,15 +408,18 @@ where Some(s) => s, None => break, }; - let samples = (0..::RUN_ITERATIONS) - .map(|_| sample.clone()) - .collect(); // This part is the `N_r * Overhead_s` part of equation [2]. // This is 0 unless we are doing wasm-insn level calibration let samples_cpu_insns_overhead = ::RUN_ITERATIONS .saturating_mul(HCM::get_insns_overhead_per_sample(&host, &sample)); - let mut mes = harness::(&host, Some(&mut alloc_group_token), &mut runner, samples); + let mut mes = harness::( + &host, + Some(&mut alloc_group_token), + &mut runner, + sample, + ::RUN_ITERATIONS, + ); mes.cpu_insns -= samples_cpu_insns_overhead; // the return result contains `N_r * (f(x) + Overhead_b)` (see equation [2]) ret.push(mes); diff --git a/soroban-env-host/benches/common/mod.rs b/soroban-env-host/benches/common/mod.rs index c427eea65..0571c2644 100644 --- a/soroban-env-host/benches/common/mod.rs +++ b/soroban-env-host/benches/common/mod.rs @@ -60,6 +60,18 @@ pub(crate) fn for_each_experimental_cost_measurement( call_bench::(&mut params)?; call_bench::(&mut params)?; call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + Ok(params) } @@ -115,6 +127,34 @@ pub(crate) fn for_each_host_cost_measurement( call_bench::(&mut params)?; call_bench::(&mut params)?; + // P22 cost types + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + call_bench::(&mut params)?; + // These three mem ones are derived analytically, we do not calibrate them typically if std::env::var("INCLUDE_ANALYTICAL_COSTTYPES").is_ok() { call_bench::(&mut params)?; diff --git a/soroban-env-host/benches/variation_histograms.rs b/soroban-env-host/benches/variation_histograms.rs index d0d4992ce..d612f8d94 100644 --- a/soroban-env-host/benches/variation_histograms.rs +++ b/soroban-env-host/benches/variation_histograms.rs @@ -16,7 +16,12 @@ impl Benchmark for LinearModelTables { fn bench( ) -> std::io::Result<(MeteredCostComponent, MeteredCostComponent)> { // the inputs will be ignored if the measurment is for a constant model - let mut measurements = measure_cost_variation::(100_000, || 0, || 0, false)?; + let sample_count = std::env::var("SAMPLE_COUNT") + .ok() + .map(|v| v.parse::().ok()) + .flatten() + .unwrap_or(1000); + let mut measurements = measure_cost_variation::(sample_count, || 10, || 10, false)?; measurements.check_range_against_baseline(&HCM::Runner::COST_TYPE)?; measurements.preprocess(); measurements.report_histogram("cpu", |m| m.cpu_insns); diff --git a/soroban-env-host/observations/22/test__bls12_381__check_g1_is_in_subgroup.json b/soroban-env-host/observations/22/test__bls12_381__check_g1_is_in_subgroup.json new file mode 100644 index 000000000..1dd32fe3c --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__check_g1_is_in_subgroup.json @@ -0,0 +1,78 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_insert(Bytes(obj#1), U32(96), U32(0))": "cpu:2307, mem:176, objs:-/1@2142c5f5", + " 2 ret bytes_insert -> Ok(Bytes(obj#3))": "cpu:3475, mem:353, objs:-/2@9a3f90d4", + " 3 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#3))": "", + " 4 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:3597", + " 5 call bytes_del(Bytes(obj#5), U32(95))": "cpu:5904, mem:529, objs:-/3@abbe8c98", + " 6 ret bytes_del -> Ok(Bytes(obj#7))": "cpu:7114, mem:705, objs:-/4@49ff18c1", + " 7 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#7))": "", + " 8 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:7236", + " 9 call bytes_get(Bytes(obj#9), U32(0))": "cpu:9543, mem:881, objs:-/5@6bc306d7", + " 10 ret bytes_get -> Ok(U32(9))": "cpu:9665", + " 11 call bytes_put(Bytes(obj#9), U32(0), U32(137))": "", + " 12 ret bytes_put -> Ok(Bytes(obj#11))": "cpu:10833, mem:1057, objs:-/6@d0338803", + " 13 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#11))": "", + " 14 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:10955", + " 15 call bytes_get(Bytes(obj#13), U32(0))": "cpu:13262, mem:1233, objs:-/7@9cb6052", + " 16 ret bytes_get -> Ok(U32(25))": "cpu:13384", + " 17 call bytes_put(Bytes(obj#13), U32(0), U32(89))": "", + " 18 ret bytes_put -> Ok(Bytes(obj#15))": "cpu:14552, mem:1409, objs:-/8@b54f75b7", + " 19 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#15))": "", + " 20 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:14674", + " 21 call bytes_get(Bytes(obj#17), U32(0))": "cpu:16981, mem:1585, objs:-/9@3d7c315e", + " 22 ret bytes_get -> Ok(U32(4))": "cpu:17103", + " 23 call bytes_put(Bytes(obj#17), U32(0), U32(36))": "", + " 24 ret bytes_put -> Ok(Bytes(obj#19))": "cpu:18271, mem:1761, objs:-/10@926d6fcb", + " 25 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#19))": "", + " 26 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:18393", + " 27 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#23))": "cpu:23007, mem:2113, objs:-/12@85f05c1a", + " 28 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:27033", + " 29 call bytes_copy_from_slice(Bytes(obj#27), U32(0), 98)": "cpu:31647, mem:2465, objs:-/14@38656519", + " 30 ret bytes_copy_from_slice -> Ok(Bytes(obj#29))": "cpu:33181, mem:2659, objs:-/15@a4950fe8", + " 31 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#29))": "", + " 32 ret bls12_381_check_g1_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:33303", + " 33 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#31))": "cpu:35610, mem:2835, objs:-/16@500e79a7", + " 34 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:770146", + " 35 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#33))": "cpu:772453, mem:3011, objs:-/17@8f4ffce", + " 36 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:1506989", + " 37 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#35))": "cpu:1509296, mem:3187, objs:-/18@2f9e8c61", + " 38 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:2243832", + " 39 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#37))": "cpu:2246139, mem:3363, objs:-/19@69985e40", + " 40 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:2980675", + " 41 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#39))": "cpu:2982982, mem:3539, objs:-/20@d096ebd0", + " 42 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:3717518", + " 43 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#41))": "cpu:3719825, mem:3715, objs:-/21@68ab7bd3", + " 44 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:4454361", + " 45 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#43))": "cpu:4456668, mem:3891, objs:-/22@7e3dc994", + " 46 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:5191204", + " 47 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#45))": "cpu:5193511, mem:4067, objs:-/23@a6f58142", + " 48 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:5928047", + " 49 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#47))": "cpu:5930354, mem:4243, objs:-/24@25b1a124", + " 50 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:6664890", + " 51 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#49))": "cpu:6667197, mem:4419, objs:-/25@ad6b88e5", + " 52 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:7401733", + " 53 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#51))": "cpu:7404040, mem:4595, objs:-/26@bde93363", + " 54 ret bls12_381_check_g1_is_in_subgroup -> Ok(True)": "cpu:8138576", + " 55 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#55))": "cpu:8143190, mem:4947, objs:-/28@200189b4", + " 56 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:8877726", + " 57 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#59))": "cpu:8882340, mem:5299, objs:-/30@9133038c", + " 58 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:9616876", + " 59 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#63))": "cpu:9621490, mem:5651, objs:-/32@db0fc406", + " 60 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:10356026", + " 61 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#67))": "cpu:10360640, mem:6003, objs:-/34@352a99fb", + " 62 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:11095176", + " 63 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#71))": "cpu:11099790, mem:6355, objs:-/36@fc80803a", + " 64 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:11834326", + " 65 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#75))": "cpu:11838940, mem:6707, objs:-/38@6e4b656f", + " 66 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:12573476", + " 67 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#79))": "cpu:12578090, mem:7059, objs:-/40@874192c8", + " 68 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:13312626", + " 69 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#83))": "cpu:13317240, mem:7411, objs:-/42@c24e82e7", + " 70 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:14051776", + " 71 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#87))": "cpu:14056390, mem:7763, objs:-/44@bf8f3db5", + " 72 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:14790926", + " 73 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#91))": "cpu:14795540, mem:8115, objs:-/46@4de2e45d", + " 74 ret bls12_381_check_g1_is_in_subgroup -> Ok(False)": "cpu:15530076", + " 75 end": "cpu:15530076, mem:8115, prngs:-/-, objs:-/46@4de2e45d, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__check_g2_is_in_subgroup.json b/soroban-env-host/observations/22/test__bls12_381__check_g2_is_in_subgroup.json new file mode 100644 index 000000000..4b68ffe31 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__check_g2_is_in_subgroup.json @@ -0,0 +1,78 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_insert(Bytes(obj#1), U32(192), U32(0))": "cpu:3653, mem:272, objs:-/1@f4e2a936", + " 2 ret bytes_insert -> Ok(Bytes(obj#3))": "cpu:4845, mem:545, objs:-/2@50b483f6", + " 3 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#3))": "", + " 4 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:4967", + " 5 call bytes_del(Bytes(obj#5), U32(191))": "cpu:8620, mem:817, objs:-/3@b63c31e6", + " 6 ret bytes_del -> Ok(Bytes(obj#7))": "cpu:9854, mem:1089, objs:-/4@9429b9d3", + " 7 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#7))": "", + " 8 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:9976", + " 9 call bytes_get(Bytes(obj#9), U32(0))": "cpu:13629, mem:1361, objs:-/5@b129e6eb", + " 10 ret bytes_get -> Ok(U32(15))": "cpu:13751", + " 11 call bytes_put(Bytes(obj#9), U32(0), U32(143))": "", + " 12 ret bytes_put -> Ok(Bytes(obj#11))": "cpu:14943, mem:1633, objs:-/6@ce0a242c", + " 13 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#11))": "", + " 14 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:15065", + " 15 call bytes_get(Bytes(obj#13), U32(0))": "cpu:18718, mem:1905, objs:-/7@a3615ea0", + " 16 ret bytes_get -> Ok(U32(19))": "cpu:18840", + " 17 call bytes_put(Bytes(obj#13), U32(0), U32(83))": "", + " 18 ret bytes_put -> Ok(Bytes(obj#15))": "cpu:20032, mem:2177, objs:-/8@ddf0ef86", + " 19 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#15))": "", + " 20 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:20154", + " 21 call bytes_get(Bytes(obj#17), U32(0))": "cpu:23807, mem:2449, objs:-/9@b15fcfaf", + " 22 ret bytes_get -> Ok(U32(8))": "cpu:23929", + " 23 call bytes_put(Bytes(obj#17), U32(0), U32(40))": "", + " 24 ret bytes_put -> Ok(Bytes(obj#19))": "cpu:25121, mem:2721, objs:-/10@ff15ca10", + " 25 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#19))": "", + " 26 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:25243", + " 27 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#23))": "cpu:32549, mem:3265, objs:-/12@345f9e87", + " 28 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:42532", + " 29 call bytes_copy_from_slice(Bytes(obj#27), U32(0), 98)": "cpu:49838, mem:3809, objs:-/14@5bbf9054", + " 30 ret bytes_copy_from_slice -> Ok(Bytes(obj#29))": "cpu:50962, mem:4081, objs:-/15@59d72b9d", + " 31 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#29))": "", + " 32 ret bls12_381_check_g2_is_in_subgroup -> Err(Error(Crypto, InvalidInput))": "cpu:51084", + " 33 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#31))": "cpu:54737, mem:4353, objs:-/16@383aa473", + " 34 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:1122542", + " 35 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#33))": "cpu:1126195, mem:4625, objs:-/17@10e08142", + " 36 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:2194000", + " 37 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#35))": "cpu:2197653, mem:4897, objs:-/18@257c5aed", + " 38 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:3265458", + " 39 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#37))": "cpu:3269111, mem:5169, objs:-/19@bd25c348", + " 40 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:4336916", + " 41 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#39))": "cpu:4340569, mem:5441, objs:-/20@aac1ed33", + " 42 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:5408374", + " 43 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#41))": "cpu:5412027, mem:5713, objs:-/21@485881be", + " 44 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:6479832", + " 45 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#43))": "cpu:6483485, mem:5985, objs:-/22@f6c251d8", + " 46 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:7551290", + " 47 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#45))": "cpu:7554943, mem:6257, objs:-/23@28f2277a", + " 48 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:8622748", + " 49 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#47))": "cpu:8626401, mem:6529, objs:-/24@b60b70c0", + " 50 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:9694206", + " 51 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#49))": "cpu:9697859, mem:6801, objs:-/25@b1831620", + " 52 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:10765664", + " 53 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#51))": "cpu:10769317, mem:7073, objs:-/26@12a73c61", + " 54 ret bls12_381_check_g2_is_in_subgroup -> Ok(True)": "cpu:11837122", + " 55 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#55))": "cpu:11844428, mem:7617, objs:-/28@b222759", + " 56 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:12912233", + " 57 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#59))": "cpu:12919539, mem:8161, objs:-/30@d53d3525", + " 58 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:13987344", + " 59 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#63))": "cpu:13994650, mem:8705, objs:-/32@f338c504", + " 60 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:15062455", + " 61 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#67))": "cpu:15069761, mem:9249, objs:-/34@355470cc", + " 62 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:16137566", + " 63 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#71))": "cpu:16144872, mem:9793, objs:-/36@c13ff257", + " 64 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:17212677", + " 65 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#75))": "cpu:17219983, mem:10337, objs:-/38@89aa31a3", + " 66 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:18287788", + " 67 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#79))": "cpu:18295094, mem:10881, objs:-/40@6af1f9a8", + " 68 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:19362899", + " 69 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#83))": "cpu:19370205, mem:11425, objs:-/42@563d3e28", + " 70 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:20438010", + " 71 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#87))": "cpu:20445316, mem:11969, objs:-/44@3997f663", + " 72 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:21513121", + " 73 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#91))": "cpu:21520427, mem:12513, objs:-/46@ca7e6ad6", + " 74 ret bls12_381_check_g2_is_in_subgroup -> Ok(False)": "cpu:22588232", + " 75 end": "cpu:22588232, mem:12513, prngs:-/-, objs:-/46@ca7e6ad6, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g1_add.json b/soroban-env-host/observations/22/test__bls12_381__g1_add.json new file mode 100644 index 000000000..003bb349d --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g1_add.json @@ -0,0 +1,92 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_insert(Bytes(obj#3), U32(96), U32(0))": "cpu:4614, mem:352, objs:-/2@a5d3f802", + " 2 ret bytes_insert -> Ok(Bytes(obj#5))": "cpu:5782, mem:529, objs:-/3@7b4d6097", + " 3 call bls12_381_g1_add(Bytes(obj#5), Bytes(obj#1))": "", + " 4 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:5965", + " 5 call bytes_del(Bytes(obj#7), U32(95))": "cpu:8272, mem:705, objs:-/4@f718b107", + " 6 ret bytes_del -> Ok(Bytes(obj#9))": "cpu:9482, mem:881, objs:-/5@8bb34c65", + " 7 call bls12_381_g1_add(Bytes(obj#9), Bytes(obj#1))": "", + " 8 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:9665", + " 9 call bytes_get(Bytes(obj#11), U32(0))": "cpu:11972, mem:1057, objs:-/6@e3a21556", + " 10 ret bytes_get -> Ok(U32(25))": "cpu:12094", + " 11 call bytes_put(Bytes(obj#11), U32(0), U32(153))": "", + " 12 ret bytes_put -> Ok(Bytes(obj#13))": "cpu:13262, mem:1233, objs:-/7@d85c26db", + " 13 call bls12_381_g1_add(Bytes(obj#13), Bytes(obj#1))": "", + " 14 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:13445", + " 15 call bytes_get(Bytes(obj#15), U32(0))": "cpu:15752, mem:1409, objs:-/8@85513dde", + " 16 ret bytes_get -> Ok(U32(4))": "cpu:15874", + " 17 call bytes_put(Bytes(obj#15), U32(0), U32(68))": "", + " 18 ret bytes_put -> Ok(Bytes(obj#17))": "cpu:17042, mem:1585, objs:-/9@a1a8357e", + " 19 call bls12_381_g1_add(Bytes(obj#17), Bytes(obj#1))": "", + " 20 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:17225", + " 21 call bytes_get(Bytes(obj#19), U32(0))": "cpu:19532, mem:1761, objs:-/10@7b1eabc1", + " 22 ret bytes_get -> Ok(U32(15))": "cpu:19654", + " 23 call bytes_put(Bytes(obj#19), U32(0), U32(47))": "", + " 24 ret bytes_put -> Ok(Bytes(obj#21))": "cpu:20822, mem:1937, objs:-/11@a79b741d", + " 25 call bls12_381_g1_add(Bytes(obj#21), Bytes(obj#1))": "", + " 26 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:21005", + " 27 call bls12_381_g1_add(Bytes(obj#25), Bytes(obj#1))": "cpu:25619, mem:2289, objs:-/13@245336f9", + " 28 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:29706", + " 29 call bls12_381_g1_add(Bytes(obj#29), Bytes(obj#1))": "cpu:34320, mem:2641, objs:-/15@d7205b72", + " 30 ret bls12_381_g1_add -> Ok(Bytes(obj#31))": "cpu:145071, mem:2817, objs:-/16@aa5ae19f", + " 31 call bytes_insert(Bytes(obj#35), U32(96), U32(0))": "cpu:149685, mem:3169, objs:-/18@6a3073a3", + " 32 ret bytes_insert -> Ok(Bytes(obj#37))": "cpu:150853, mem:3346, objs:-/19@453802c4", + " 33 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#37))": "", + " 34 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:155001", + " 35 call bytes_del(Bytes(obj#39), U32(95))": "cpu:157308, mem:3522, objs:-/20@cfc20b80", + " 36 ret bytes_del -> Ok(Bytes(obj#41))": "cpu:158518, mem:3698, objs:-/21@2343916f", + " 37 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#41))": "", + " 38 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:162666", + " 39 call bytes_get(Bytes(obj#43), U32(0))": "cpu:164973, mem:3874, objs:-/22@d960e8e0", + " 40 ret bytes_get -> Ok(U32(0))": "cpu:165095", + " 41 call bytes_put(Bytes(obj#43), U32(0), U32(128))": "", + " 42 ret bytes_put -> Ok(Bytes(obj#45))": "cpu:166263, mem:4050, objs:-/23@38f39e6", + " 43 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#45))": "", + " 44 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:170411", + " 45 call bytes_get(Bytes(obj#47), U32(0))": "cpu:172718, mem:4226, objs:-/24@41a5ebfe", + " 46 ret bytes_get -> Ok(U32(18))": "cpu:172840", + " 47 call bytes_put(Bytes(obj#47), U32(0), U32(82))": "", + " 48 ret bytes_put -> Ok(Bytes(obj#49))": "cpu:174008, mem:4402, objs:-/25@b2897deb", + " 49 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#49))": "", + " 50 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:178156", + " 51 call bytes_get(Bytes(obj#51), U32(0))": "cpu:180463, mem:4578, objs:-/26@d0fe1b2e", + " 52 ret bytes_get -> Ok(U32(11))": "cpu:180585", + " 53 call bytes_put(Bytes(obj#51), U32(0), U32(43))": "", + " 54 ret bytes_put -> Ok(Bytes(obj#53))": "cpu:181753, mem:4754, objs:-/27@cca6f00c", + " 55 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#53))": "", + " 56 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:185901", + " 57 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#57))": "cpu:190515, mem:5106, objs:-/29@8354f99f", + " 58 ret bls12_381_g1_add -> Err(Error(Crypto, InvalidInput))": "cpu:198567", + " 59 call bls12_381_g1_add(Bytes(obj#33), Bytes(obj#61))": "cpu:203181, mem:5458, objs:-/31@841dd7d8", + " 60 ret bls12_381_g1_add -> Ok(Bytes(obj#63))": "cpu:313932, mem:5634, objs:-/32@e053b471", + " 61 call bls12_381_g1_add(Bytes(obj#65), Bytes(obj#67))": "cpu:318546, mem:5986, objs:-/34@267e3ee", + " 62 ret bls12_381_g1_add -> Ok(Bytes(obj#69))": "cpu:429297, mem:6162, objs:-/35@6c45b139", + " 63 call obj_cmp(Bytes(obj#65), Bytes(obj#69))": "", + " 64 ret obj_cmp -> Ok(0)": "cpu:429597", + " 65 call bls12_381_g1_add(Bytes(obj#73), Bytes(obj#71))": "cpu:434211, mem:6514, objs:-/37@11069e21", + " 66 ret bls12_381_g1_add -> Ok(Bytes(obj#75))": "cpu:544962, mem:6690, objs:-/38@e93dc5e6", + " 67 call obj_cmp(Bytes(obj#71), Bytes(obj#75))": "", + " 68 ret obj_cmp -> Ok(0)": "cpu:545262", + " 69 call bls12_381_g1_add(Bytes(obj#77), Bytes(obj#79))": "cpu:549876, mem:7042, objs:-/40@cc04c3a", + " 70 ret bls12_381_g1_add -> Ok(Bytes(obj#81))": "cpu:660627, mem:7218, objs:-/41@5356466f", + " 71 call bls12_381_g1_add(Bytes(obj#79), Bytes(obj#77))": "", + " 72 ret bls12_381_g1_add -> Ok(Bytes(obj#83))": "cpu:771378, mem:7394, objs:-/42@5c17d0f7", + " 73 call obj_cmp(Bytes(obj#81), Bytes(obj#83))": "", + " 74 ret obj_cmp -> Ok(0)": "cpu:771678", + " 75 call bls12_381_g1_add(Bytes(obj#85), Bytes(obj#87))": "cpu:778599, mem:7922, objs:-/45@1408a61a", + " 76 ret bls12_381_g1_add -> Ok(Bytes(obj#91))": "cpu:889350, mem:8098, objs:-/46@8ae35b94", + " 77 call bls12_381_g1_add(Bytes(obj#91), Bytes(obj#89))": "", + " 78 ret bls12_381_g1_add -> Ok(Bytes(obj#93))": "cpu:1000101, mem:8274, objs:-/47@65c18b7b", + " 79 call bls12_381_g1_add(Bytes(obj#87), Bytes(obj#89))": "", + " 80 ret bls12_381_g1_add -> Ok(Bytes(obj#95))": "cpu:1110852, mem:8450, objs:-/48@7eb6fc3e", + " 81 call bls12_381_g1_add(Bytes(obj#85), Bytes(obj#95))": "", + " 82 ret bls12_381_g1_add -> Ok(Bytes(obj#97))": "cpu:1221603, mem:8626, objs:-/49@1a3348a6", + " 83 call obj_cmp(Bytes(obj#93), Bytes(obj#97))": "", + " 84 ret obj_cmp -> Ok(0)": "cpu:1221903", + " 85 call bls12_381_g1_add(Bytes(obj#99), Bytes(obj#101))": "cpu:1960992, mem:8978, objs:-/51@d725a826", + " 86 ret bls12_381_g1_add -> Ok(Bytes(obj#103))": "cpu:2071743, mem:9154, objs:-/52@ef372ebe", + " 87 call obj_cmp(Bytes(obj#103), Bytes(obj#105))": "cpu:2074050, mem:9330, objs:-/53@b789aa09", + " 88 ret obj_cmp -> Ok(0)": "cpu:2074350", + " 89 end": "cpu:2074350, mem:9330, prngs:-/-, objs:-/53@b789aa09, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g1_msm.json b/soroban-env-host/observations/22/test__bls12_381__g1_msm.json new file mode 100644 index 000000000..15c587799 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g1_msm.json @@ -0,0 +1,368 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call vec_new()": "", + " 2 ret vec_new -> Ok(Vec(obj#1))": "cpu:501, mem:64, objs:-/1@3e25b2a0", + " 3 call vec_new()": "", + " 4 ret vec_new -> Ok(Vec(obj#3))": "cpu:1002, mem:128, objs:-/2@14339b3d", + " 5 call bls12_381_g1_msm(Vec(obj#1), Vec(obj#3))": "", + " 6 call vec_len(Vec(obj#1))": "cpu:1124", + " 7 ret vec_len -> Ok(U32(0))": "cpu:1246", + " 8 call vec_len(Vec(obj#3))": "cpu:1741, mem:144", + " 9 ret vec_len -> Ok(U32(0))": "cpu:1863", + " 10 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:2429080, mem:109654", + " 11 call bytes_new_from_slice(96)": "cpu:2430402", + " 12 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:2431387, mem:109830, objs:-/3@f987415", + " 13 call bytes_new_from_slice(96)": "cpu:2432709", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:2433694, mem:110006, objs:-/4@f550cb25", + " 15 call vec_new_from_slice(2)": "", + " 16 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:2434781, mem:110102, objs:-/5@27393823", + " 17 call obj_from_u256_pieces(2515383451482204963, 3798294199605637777, 9874121741094930036, 5634530503602181405)": "", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:2435282, mem:110166, objs:-/6@3f49b7c2", + " 19 call obj_from_u256_pieces(16161944172311556037, 9348631246554537043, 7119928359786205760, 2656543668720567255)": "", + " 20 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:2435783, mem:110230, objs:-/7@2ed0a706", + " 21 call obj_from_u256_pieces(9580499452994475139, 12513764331848801915, 17507952593492800906, 8551509165293236575)": "", + " 22 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:2436284, mem:110294, objs:-/8@43230a4b", + " 23 call vec_new_from_slice(3)": "", + " 24 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:2437434, mem:110398, objs:-/9@ac0e3b8c", + " 25 call bls12_381_g1_msm(Vec(obj#9), Vec(obj#17))": "", + " 26 call vec_len(Vec(obj#9))": "cpu:2437556", + " 27 ret vec_len -> Ok(U32(2))": "cpu:2437678", + " 28 call vec_len(Vec(obj#17))": "cpu:3907147, mem:110606", + " 29 ret vec_len -> Ok(U32(3))": "cpu:3907269", + " 30 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:7846876, mem:225753", + " 31 call vec_new_from_slice(3)": "cpu:7856104, mem:226457, objs:-/13@561be3e7", + " 32 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:7857254, mem:226561, objs:-/14@c49c6ff2", + " 33 call obj_from_u256_pieces(11943197420912477102, 14634913559439210090, 15499375484791752188, 12925620935896195067)": "", + " 34 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:7857755, mem:226625, objs:-/15@3da47540", + " 35 call obj_from_u256_pieces(5622195026378228418, 9560417407481221846, 8127851712333271140, 4557073498745857109)": "", + " 36 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:7858256, mem:226689, objs:-/16@d07ec2c0", + " 37 call obj_from_u256_pieces(12072680829433668232, 2892971212195715449, 599041459787463398, 17399677212821182399)": "", + " 38 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:7858757, mem:226753, objs:-/17@2d23aeeb", + " 39 call vec_new_from_slice(3)": "", + " 40 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:7859907, mem:226857, objs:-/18@9ffeec8c", + " 41 call bls12_381_g1_msm(Vec(obj#27), Vec(obj#35))": "", + " 42 call vec_len(Vec(obj#27))": "cpu:7860029", + " 43 ret vec_len -> Ok(U32(3))": "cpu:7860151", + " 44 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:9329632, mem:227161", + " 45 call vec_new_from_slice(3)": "cpu:9331939, mem:227337, objs:-/19@42952458", + " 46 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:9333089, mem:227441, objs:-/20@a0bd3ff", + " 47 call obj_from_u256_pieces(9030446305465662626, 6854247188031249140, 3026823929057343686, 5018424221301027056)": "", + " 48 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:9333590, mem:227505, objs:-/21@5d27dd7c", + " 49 call obj_from_u256_pieces(17540322581155608940, 9042723259083353182, 9336846948556567215, 15266620357577816939)": "", + " 50 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:9334091, mem:227569, objs:-/22@32305aea", + " 51 call obj_from_u256_pieces(2273584195287690476, 203274327658109228, 545101579437905274, 9593152778203258958)": "", + " 52 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:9334592, mem:227633, objs:-/23@d5672c27", + " 53 call vec_new_from_slice(3)": "", + " 54 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:9335742, mem:227737, objs:-/24@f299ae2e", + " 55 call bls12_381_g1_msm(Vec(obj#39), Vec(obj#47))": "", + " 56 call vec_len(Vec(obj#39))": "cpu:9335864", + " 57 ret vec_len -> Ok(U32(3))": "cpu:9335986", + " 58 call vec_len(Vec(obj#47))": "cpu:11539942, mem:228041", + " 59 ret vec_len -> Ok(U32(3))": "cpu:11540064", + " 60 ret bls12_381_g1_msm -> Ok(Bytes(obj#49))": "cpu:16327788, mem:346135, objs:-/25@e3c1a53", + " 61 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:16330095, mem:346311, objs:-/26@f6f4e327", + " 62 ret obj_cmp -> Ok(0)": "cpu:16330395", + " 63 call bytes_new_from_slice(96)": "cpu:16331717", + " 64 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:16332702, mem:346487, objs:-/27@de36fc43", + " 65 call bytes_new_from_slice(96)": "cpu:16334024", + " 66 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:16335009, mem:346663, objs:-/28@d5575135", + " 67 call bytes_new_from_slice(96)": "cpu:16336331", + " 68 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:16337316, mem:346839, objs:-/29@75b6bfd6", + " 69 call vec_new_from_slice(3)": "", + " 70 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:16338466, mem:346943, objs:-/30@a0da8ba2", + " 71 call vec_new_from_slice(3)": "", + " 72 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:16339433, mem:347047, objs:-/31@3969541b", + " 73 call bls12_381_g1_msm(Vec(obj#59), Vec(obj#61))": "", + " 74 call vec_len(Vec(obj#59))": "cpu:16339555", + " 75 ret vec_len -> Ok(U32(3))": "cpu:16339677", + " 76 call vec_len(Vec(obj#61))": "cpu:18543633, mem:347351", + " 77 ret vec_len -> Ok(U32(3))": "cpu:18543755", + " 78 ret bls12_381_g1_msm -> Ok(Bytes(obj#63))": "cpu:23331296, mem:465445, objs:-/32@4cf72b63", + " 79 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:23333603, mem:465621, objs:-/33@2b1e328c", + " 80 ret obj_cmp -> Ok(0)": "cpu:23333903", + " 81 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:23338517, mem:465973, objs:-/35@c5e3864a", + " 82 ret obj_cmp -> Ok(-1)": "cpu:23338817", + " 83 call vec_new_from_slice(2)": "cpu:24075599, mem:466149, objs:-/36@48960b91", + " 84 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:24076686, mem:466245, objs:-/37@9fba2a30", + " 85 call vec_new_from_slice(2)": "", + " 86 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:24077651, mem:466341, objs:-/38@417ebf06", + " 87 call bls12_381_g1_msm(Vec(obj#73), Vec(obj#75))": "", + " 88 call vec_len(Vec(obj#73))": "cpu:24077773", + " 89 ret vec_len -> Ok(U32(2))": "cpu:24077895", + " 90 call vec_len(Vec(obj#75))": "cpu:25547364, mem:466549", + " 91 ret vec_len -> Ok(U32(2))": "cpu:25547486", + " 92 ret bls12_381_g1_msm -> Ok(Bytes(obj#77))": "cpu:29579922, mem:581840, objs:-/39@d2932e3e", + " 93 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:29582229, mem:582016, objs:-/40@3b58e936", + " 94 ret obj_cmp -> Ok(0)": "cpu:29582529", + " 95 call obj_from_u256_pieces(2137869300824195577, 2408943964792666977, 4119820914549582912, 10689500621133072587)": "cpu:9228, mem:704, objs:-/44@bdf24bea", + " 96 ret obj_from_u256_pieces -> Ok(U256(obj#89))": "cpu:9729, mem:768, objs:-/45@ff9db193", + " 97 call obj_from_u256_pieces(1962485755387024656, 9106496787558144827, 9789057793268231909, 16221084701331329973)": "", + " 98 ret obj_from_u256_pieces -> Ok(U256(obj#91))": "cpu:10230, mem:832, objs:-/46@c719630e", + " 99 call obj_from_u256_pieces(1296515190507321084, 10989324616177374759, 8226479548446315792, 5867014538613133674)": "", + " 100 ret obj_from_u256_pieces -> Ok(U256(obj#93))": "cpu:10731, mem:896, objs:-/47@a3ded57a", + " 101 call obj_from_u256_pieces(15796377402950621781, 1952675446632466581, 13889210310322241459, 7969271833534144739)": "", + " 102 ret obj_from_u256_pieces -> Ok(U256(obj#95))": "cpu:11232, mem:960, objs:-/48@d367c748", + " 103 call vec_new_from_slice(4)": "", + " 104 ret vec_new_from_slice -> Ok(Vec(obj#97))": "cpu:12445, mem:1072, objs:-/49@4aa6caa5", + " 105 call vec_new_from_slice(4)": "", + " 106 ret vec_new_from_slice -> Ok(Vec(obj#99))": "cpu:13658, mem:1184, objs:-/50@d6716ebc", + " 107 call bls12_381_g1_msm(Vec(obj#97), Vec(obj#99))": "", + " 108 call vec_len(Vec(obj#97))": "cpu:13780", + " 109 ret vec_len -> Ok(U32(4))": "cpu:13902", + " 110 call vec_len(Vec(obj#99))": "cpu:2952345, mem:1584", + " 111 ret vec_len -> Ok(U32(4))": "cpu:2952467", + " 112 ret bls12_381_g1_msm -> Ok(Bytes(obj#101))": "cpu:8495357, mem:122481, objs:-/51@38fc93bb", + " 113 call vec_new_from_slice(4)": "", + " 114 ret vec_new_from_slice -> Ok(Vec(obj#103))": "cpu:8496570, mem:122593, objs:-/52@332932d6", + " 115 call vec_new_from_slice(4)": "", + " 116 ret vec_new_from_slice -> Ok(Vec(obj#105))": "cpu:8497783, mem:122705, objs:-/53@eb9d99bf", + " 117 call bls12_381_g1_msm(Vec(obj#103), Vec(obj#105))": "", + " 118 call vec_len(Vec(obj#103))": "cpu:8497905", + " 119 ret vec_len -> Ok(U32(4))": "cpu:8498027", + " 120 call vec_len(Vec(obj#105))": "cpu:11436470, mem:123105", + " 121 ret vec_len -> Ok(U32(4))": "cpu:11436592", + " 122 ret bls12_381_g1_msm -> Ok(Bytes(obj#107))": "cpu:16979482, mem:244002, objs:-/54@f3e7e2fb", + " 123 call obj_cmp(Bytes(obj#107), Bytes(obj#101))": "", + " 124 ret obj_cmp -> Ok(0)": "cpu:16979782", + " 125 call vec_new_from_slice(4)": "", + " 126 ret vec_new_from_slice -> Ok(Vec(obj#109))": "cpu:16980995, mem:244114, objs:-/55@c50146aa", + " 127 call vec_new_from_slice(4)": "", + " 128 ret vec_new_from_slice -> Ok(Vec(obj#111))": "cpu:16982208, mem:244226, objs:-/56@c60df128", + " 129 call bls12_381_g1_msm(Vec(obj#109), Vec(obj#111))": "", + " 130 call vec_len(Vec(obj#109))": "cpu:16982330", + " 131 ret vec_len -> Ok(U32(4))": "cpu:16982452", + " 132 call vec_len(Vec(obj#111))": "cpu:19920895, mem:244626", + " 133 ret vec_len -> Ok(U32(4))": "cpu:19921017", + " 134 ret bls12_381_g1_msm -> Ok(Bytes(obj#113))": "cpu:25463907, mem:365523, objs:-/57@bcaec10e", + " 135 call obj_cmp(Bytes(obj#113), Bytes(obj#101))": "", + " 136 ret obj_cmp -> Ok(0)": "cpu:25464207", + " 137 call vec_new_from_slice(4)": "", + " 138 ret vec_new_from_slice -> Ok(Vec(obj#115))": "cpu:25465420, mem:365635, objs:-/58@c312d486", + " 139 call vec_new_from_slice(4)": "", + " 140 ret vec_new_from_slice -> Ok(Vec(obj#117))": "cpu:25466633, mem:365747, objs:-/59@8118160e", + " 141 call bls12_381_g1_msm(Vec(obj#115), Vec(obj#117))": "", + " 142 call vec_len(Vec(obj#115))": "cpu:25466755", + " 143 ret vec_len -> Ok(U32(4))": "cpu:25466877", + " 144 call vec_len(Vec(obj#117))": "cpu:28405320, mem:366147", + " 145 ret vec_len -> Ok(U32(4))": "cpu:28405442", + " 146 ret bls12_381_g1_msm -> Ok(Bytes(obj#119))": "cpu:33948332, mem:487044, objs:-/60@2f469956", + " 147 call obj_cmp(Bytes(obj#119), Bytes(obj#101))": "", + " 148 ret obj_cmp -> Ok(0)": "cpu:33948632", + " 149 call vec_new_from_slice(4)": "", + " 150 ret vec_new_from_slice -> Ok(Vec(obj#121))": "cpu:33949845, mem:487156, objs:-/61@e3634851", + " 151 call vec_new_from_slice(4)": "", + " 152 ret vec_new_from_slice -> Ok(Vec(obj#123))": "cpu:33951058, mem:487268, objs:-/62@efcd97c0", + " 153 call bls12_381_g1_msm(Vec(obj#121), Vec(obj#123))": "", + " 154 call vec_len(Vec(obj#121))": "cpu:33951180", + " 155 ret vec_len -> Ok(U32(4))": "cpu:33951302", + " 156 call vec_len(Vec(obj#123))": "cpu:36889745, mem:487668", + " 157 ret vec_len -> Ok(U32(4))": "cpu:36889867", + " 158 ret bls12_381_g1_msm -> Ok(Bytes(obj#125))": "cpu:42432757, mem:608565, objs:-/63@56df4afe", + " 159 call obj_cmp(Bytes(obj#125), Bytes(obj#101))": "", + " 160 ret obj_cmp -> Ok(0)": "cpu:42433057", + " 161 call vec_new_from_slice(4)": "", + " 162 ret vec_new_from_slice -> Ok(Vec(obj#127))": "cpu:42434270, mem:608677, objs:-/64@c6fa44ae", + " 163 call vec_new_from_slice(4)": "", + " 164 ret vec_new_from_slice -> Ok(Vec(obj#129))": "cpu:42435483, mem:608789, objs:-/65@4be879d9", + " 165 call bls12_381_g1_msm(Vec(obj#127), Vec(obj#129))": "", + " 166 call vec_len(Vec(obj#127))": "cpu:42435605", + " 167 ret vec_len -> Ok(U32(4))": "cpu:42435727", + " 168 call vec_len(Vec(obj#129))": "cpu:45374170, mem:609189", + " 169 ret vec_len -> Ok(U32(4))": "cpu:45374292", + " 170 ret bls12_381_g1_msm -> Ok(Bytes(obj#131))": "cpu:50917182, mem:730086, objs:-/66@cd9321cc", + " 171 call obj_cmp(Bytes(obj#131), Bytes(obj#101))": "", + " 172 ret obj_cmp -> Ok(0)": "cpu:50917482", + " 173 call vec_new_from_slice(4)": "", + " 174 ret vec_new_from_slice -> Ok(Vec(obj#133))": "cpu:50918695, mem:730198, objs:-/67@83139207", + " 175 call vec_new_from_slice(4)": "", + " 176 ret vec_new_from_slice -> Ok(Vec(obj#135))": "cpu:50919908, mem:730310, objs:-/68@bff98043", + " 177 call bls12_381_g1_msm(Vec(obj#133), Vec(obj#135))": "", + " 178 call vec_len(Vec(obj#133))": "cpu:50920030", + " 179 ret vec_len -> Ok(U32(4))": "cpu:50920152", + " 180 call vec_len(Vec(obj#135))": "cpu:53858595, mem:730710", + " 181 ret vec_len -> Ok(U32(4))": "cpu:53858717", + " 182 ret bls12_381_g1_msm -> Ok(Bytes(obj#137))": "cpu:59401607, mem:851607, objs:-/69@57b33ea5", + " 183 call obj_cmp(Bytes(obj#137), Bytes(obj#101))": "", + " 184 ret obj_cmp -> Ok(0)": "cpu:59401907", + " 185 call vec_new_from_slice(4)": "", + " 186 ret vec_new_from_slice -> Ok(Vec(obj#139))": "cpu:59403120, mem:851719, objs:-/70@67ce2467", + " 187 call vec_new_from_slice(4)": "", + " 188 ret vec_new_from_slice -> Ok(Vec(obj#141))": "cpu:59404333, mem:851831, objs:-/71@1a3a91ea", + " 189 call bls12_381_g1_msm(Vec(obj#139), Vec(obj#141))": "", + " 190 call vec_len(Vec(obj#139))": "cpu:59404455", + " 191 ret vec_len -> Ok(U32(4))": "cpu:59404577", + " 192 call vec_len(Vec(obj#141))": "cpu:62343020, mem:852231", + " 193 ret vec_len -> Ok(U32(4))": "cpu:62343142", + " 194 ret bls12_381_g1_msm -> Ok(Bytes(obj#143))": "cpu:67886032, mem:973128, objs:-/72@d3eea58f", + " 195 call obj_cmp(Bytes(obj#143), Bytes(obj#101))": "", + " 196 ret obj_cmp -> Ok(0)": "cpu:67886332", + " 197 call vec_new_from_slice(4)": "", + " 198 ret vec_new_from_slice -> Ok(Vec(obj#145))": "cpu:67887545, mem:973240, objs:-/73@d260e80a", + " 199 call vec_new_from_slice(4)": "", + " 200 ret vec_new_from_slice -> Ok(Vec(obj#147))": "cpu:67888758, mem:973352, objs:-/74@fc820513", + " 201 call bls12_381_g1_msm(Vec(obj#145), Vec(obj#147))": "", + " 202 call vec_len(Vec(obj#145))": "cpu:67888880", + " 203 ret vec_len -> Ok(U32(4))": "cpu:67889002", + " 204 call vec_len(Vec(obj#147))": "cpu:70827445, mem:973752", + " 205 ret vec_len -> Ok(U32(4))": "cpu:70827567", + " 206 ret bls12_381_g1_msm -> Ok(Bytes(obj#149))": "cpu:76370457, mem:1094649, objs:-/75@14642af", + " 207 call obj_cmp(Bytes(obj#149), Bytes(obj#101))": "", + " 208 ret obj_cmp -> Ok(0)": "cpu:76370757", + " 209 call vec_new_from_slice(4)": "", + " 210 ret vec_new_from_slice -> Ok(Vec(obj#151))": "cpu:76371970, mem:1094761, objs:-/76@8e00d86c", + " 211 call vec_new_from_slice(4)": "", + " 212 ret vec_new_from_slice -> Ok(Vec(obj#153))": "cpu:76373183, mem:1094873, objs:-/77@8e3de39e", + " 213 call bls12_381_g1_msm(Vec(obj#151), Vec(obj#153))": "", + " 214 call vec_len(Vec(obj#151))": "cpu:76373305", + " 215 ret vec_len -> Ok(U32(4))": "cpu:76373427", + " 216 call vec_len(Vec(obj#153))": "cpu:79311870, mem:1095273", + " 217 ret vec_len -> Ok(U32(4))": "cpu:79311992", + " 218 ret bls12_381_g1_msm -> Ok(Bytes(obj#155))": "cpu:84854882, mem:1216170, objs:-/78@8bf03081", + " 219 call obj_cmp(Bytes(obj#155), Bytes(obj#101))": "", + " 220 ret obj_cmp -> Ok(0)": "cpu:84855182", + " 221 call vec_new_from_slice(4)": "", + " 222 ret vec_new_from_slice -> Ok(Vec(obj#157))": "cpu:84856395, mem:1216282, objs:-/79@df97cf2f", + " 223 call vec_new_from_slice(4)": "", + " 224 ret vec_new_from_slice -> Ok(Vec(obj#159))": "cpu:84857608, mem:1216394, objs:-/80@a4dbe930", + " 225 call bls12_381_g1_msm(Vec(obj#157), Vec(obj#159))": "", + " 226 call vec_len(Vec(obj#157))": "cpu:84857730", + " 227 ret vec_len -> Ok(U32(4))": "cpu:84857852", + " 228 call vec_len(Vec(obj#159))": "cpu:87796295, mem:1216794", + " 229 ret vec_len -> Ok(U32(4))": "cpu:87796417", + " 230 ret bls12_381_g1_msm -> Ok(Bytes(obj#161))": "cpu:93339307, mem:1337691, objs:-/81@9f62a7d5", + " 231 call obj_cmp(Bytes(obj#161), Bytes(obj#101))": "", + " 232 ret obj_cmp -> Ok(0)": "cpu:93339607", + " 233 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:2307, mem:176, objs:-/82@dd48ce00", + " 235 call bytes_new_from_slice(96)": "cpu:3629", + " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:4614, mem:352, objs:-/83@2ba0a36c", + " 237 call bytes_new_from_slice(96)": "cpu:5936", + " 238 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:6921, mem:528, objs:-/84@a00db887", + " 239 call bytes_new_from_slice(96)": "cpu:8243", + " 240 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:9228, mem:704, objs:-/85@2ff3a0e7", + " 241 call bytes_new_from_slice(96)": "cpu:10550", + " 242 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:11535, mem:880, objs:-/86@67a727f9", + " 243 call bytes_new_from_slice(96)": "cpu:12857", + " 244 ret bytes_new_from_slice -> Ok(Bytes(obj#173))": "cpu:13842, mem:1056, objs:-/87@928f7064", + " 245 call bytes_new_from_slice(96)": "cpu:15164", + " 246 ret bytes_new_from_slice -> Ok(Bytes(obj#175))": "cpu:16149, mem:1232, objs:-/88@8e6f6128", + " 247 call bytes_new_from_slice(96)": "cpu:17471", + " 248 ret bytes_new_from_slice -> Ok(Bytes(obj#177))": "cpu:18456, mem:1408, objs:-/89@8b355a07", + " 249 call bytes_new_from_slice(96)": "cpu:19778", + " 250 ret bytes_new_from_slice -> Ok(Bytes(obj#179))": "cpu:20763, mem:1584, objs:-/90@2bebefc3", + " 251 call bytes_new_from_slice(96)": "cpu:22085", + " 252 ret bytes_new_from_slice -> Ok(Bytes(obj#181))": "cpu:23070, mem:1760, objs:-/91@87d223bb", + " 253 call vec_new_from_slice(10)": "", + " 254 ret vec_new_from_slice -> Ok(Vec(obj#183))": "cpu:24661, mem:1920, objs:-/92@e05d7d45", + " 255 call obj_from_u256_pieces(17618770950827998744, 14662068724577735075, 2249062990298394979, 9977923089826089615)": "", + " 256 ret obj_from_u256_pieces -> Ok(U256(obj#185))": "cpu:25162, mem:1984, objs:-/93@e4abda0a", + " 257 call obj_from_u256_pieces(2821194631792961874, 16547277464900892467, 14819559542962736549, 17981056101655367365)": "", + " 258 ret obj_from_u256_pieces -> Ok(U256(obj#187))": "cpu:25663, mem:2048, objs:-/94@59894c0f", + " 259 call obj_from_u256_pieces(14823680325444367514, 16057910356200631686, 11653412393475167983, 17971148540471083046)": "", + " 260 ret obj_from_u256_pieces -> Ok(U256(obj#189))": "cpu:26164, mem:2112, objs:-/95@f611f183", + " 261 call obj_from_u256_pieces(16502273625602787483, 2713688267813643125, 15061415354752276271, 16690818686241479208)": "", + " 262 ret obj_from_u256_pieces -> Ok(U256(obj#191))": "cpu:26665, mem:2176, objs:-/96@b6efa1b5", + " 263 call obj_from_u256_pieces(7027192125185647877, 17045944964573428771, 10144290202347477085, 10705035438189734679)": "", + " 264 ret obj_from_u256_pieces -> Ok(U256(obj#193))": "cpu:27166, mem:2240, objs:-/97@f626d632", + " 265 call obj_from_u256_pieces(14552017996338670628, 17384320552016825872, 12623460464266321339, 2351693706725345962)": "", + " 266 ret obj_from_u256_pieces -> Ok(U256(obj#195))": "cpu:27667, mem:2304, objs:-/98@dc0fd6a8", + " 267 call obj_from_u256_pieces(4037855643097226315, 3588748593401323528, 18145554024939280631, 6805129555195258487)": "", + " 268 ret obj_from_u256_pieces -> Ok(U256(obj#197))": "cpu:28168, mem:2368, objs:-/99@3a43cf0d", + " 269 call obj_from_u256_pieces(10690484396013942008, 3220507769215303921, 6575779185716732641, 1735816512470570891)": "", + " 270 ret obj_from_u256_pieces -> Ok(U256(obj#199))": "cpu:28669, mem:2432, objs:-/100@72aa4d1", + " 271 call obj_from_u256_pieces(854729243539327218, 14181304886955281704, 12059208175304010597, 16702944845996181439)": "", + " 272 ret obj_from_u256_pieces -> Ok(U256(obj#201))": "cpu:29170, mem:2496, objs:-/101@898aec71", + " 273 call obj_from_u256_pieces(11497158191995684079, 43326291776979156, 14533160951240524555, 12852174102015084654)": "", + " 274 ret obj_from_u256_pieces -> Ok(U256(obj#203))": "cpu:29671, mem:2560, objs:-/102@a0762125", + " 275 call vec_new_from_slice(10)": "", + " 276 ret vec_new_from_slice -> Ok(Vec(obj#205))": "cpu:31262, mem:2720, objs:-/103@d1b8c868", + " 277 call bls12_381_g1_msm(Vec(obj#183), Vec(obj#205))": "", + " 278 call vec_len(Vec(obj#183))": "cpu:31384", + " 279 ret vec_len -> Ok(U32(10))": "cpu:31506", + " 280 call vec_len(Vec(obj#205))": "cpu:7376871, mem:3696", + " 281 ret vec_len -> Ok(U32(10))": "cpu:7376993", + " 282 ret bls12_381_g1_msm -> Ok(Bytes(obj#207))": "cpu:17450878, mem:141410, objs:-/104@5e3fb337", + " 283 call vec_get(Vec(obj#183), U32(0))": "cpu:17453185, mem:141586, objs:-/105@cc1ad99a", + " 284 ret vec_get -> Ok(Bytes(obj#163))": "cpu:17453411", + " 285 call vec_get(Vec(obj#205), U32(0))": "", + " 286 ret vec_get -> Ok(U256(obj#185))": "cpu:17453637", + " 287 call bls12_381_g1_mul(Bytes(obj#163), U256(obj#185))": "", + " 288 ret bls12_381_g1_mul -> Ok(Bytes(obj#211))": "cpu:20744284, mem:141762, objs:-/106@4d87b466", + " 289 call bls12_381_g1_add(Bytes(obj#209), Bytes(obj#211))": "", + " 290 ret bls12_381_g1_add -> Ok(Bytes(obj#213))": "cpu:20855035, mem:141938, objs:-/107@a668862", + " 291 call vec_get(Vec(obj#183), U32(1))": "", + " 292 ret vec_get -> Ok(Bytes(obj#165))": "cpu:20855261", + " 293 call vec_get(Vec(obj#205), U32(1))": "", + " 294 ret vec_get -> Ok(U256(obj#187))": "cpu:20855487", + " 295 call bls12_381_g1_mul(Bytes(obj#165), U256(obj#187))": "", + " 296 ret bls12_381_g1_mul -> Ok(Bytes(obj#215))": "cpu:24146134, mem:142114, objs:-/108@26939bdb", + " 297 call bls12_381_g1_add(Bytes(obj#213), Bytes(obj#215))": "", + " 298 ret bls12_381_g1_add -> Ok(Bytes(obj#217))": "cpu:24256885, mem:142290, objs:-/109@afa942f2", + " 299 call vec_get(Vec(obj#183), U32(2))": "", + " 300 ret vec_get -> Ok(Bytes(obj#167))": "cpu:24257111", + " 301 call vec_get(Vec(obj#205), U32(2))": "", + " 302 ret vec_get -> Ok(U256(obj#189))": "cpu:24257337", + " 303 call bls12_381_g1_mul(Bytes(obj#167), U256(obj#189))": "", + " 304 ret bls12_381_g1_mul -> Ok(Bytes(obj#219))": "cpu:27547984, mem:142466, objs:-/110@80ebabcb", + " 305 call bls12_381_g1_add(Bytes(obj#217), Bytes(obj#219))": "", + " 306 ret bls12_381_g1_add -> Ok(Bytes(obj#221))": "cpu:27658735, mem:142642, objs:-/111@c5129985", + " 307 call vec_get(Vec(obj#183), U32(3))": "", + " 308 ret vec_get -> Ok(Bytes(obj#169))": "cpu:27658961", + " 309 call vec_get(Vec(obj#205), U32(3))": "", + " 310 ret vec_get -> Ok(U256(obj#191))": "cpu:27659187", + " 311 call bls12_381_g1_mul(Bytes(obj#169), U256(obj#191))": "", + " 312 ret bls12_381_g1_mul -> Ok(Bytes(obj#223))": "cpu:30949834, mem:142818, objs:-/112@185b22ec", + " 313 call bls12_381_g1_add(Bytes(obj#221), Bytes(obj#223))": "", + " 314 ret bls12_381_g1_add -> Ok(Bytes(obj#225))": "cpu:31060585, mem:142994, objs:-/113@c4f97300", + " 315 call vec_get(Vec(obj#183), U32(4))": "", + " 316 ret vec_get -> Ok(Bytes(obj#171))": "cpu:31060811", + " 317 call vec_get(Vec(obj#205), U32(4))": "", + " 318 ret vec_get -> Ok(U256(obj#193))": "cpu:31061037", + " 319 call bls12_381_g1_mul(Bytes(obj#171), U256(obj#193))": "", + " 320 ret bls12_381_g1_mul -> Ok(Bytes(obj#227))": "cpu:34351684, mem:143170, objs:-/114@5dcb2245", + " 321 call bls12_381_g1_add(Bytes(obj#225), Bytes(obj#227))": "", + " 322 ret bls12_381_g1_add -> Ok(Bytes(obj#229))": "cpu:34462435, mem:143346, objs:-/115@9b8b7719", + " 323 call vec_get(Vec(obj#183), U32(5))": "", + " 324 ret vec_get -> Ok(Bytes(obj#173))": "cpu:34462661", + " 325 call vec_get(Vec(obj#205), U32(5))": "", + " 326 ret vec_get -> Ok(U256(obj#195))": "cpu:34462887", + " 327 call bls12_381_g1_mul(Bytes(obj#173), U256(obj#195))": "", + " 328 ret bls12_381_g1_mul -> Ok(Bytes(obj#231))": "cpu:37753534, mem:143522, objs:-/116@7e32132b", + " 329 call bls12_381_g1_add(Bytes(obj#229), Bytes(obj#231))": "", + " 330 ret bls12_381_g1_add -> Ok(Bytes(obj#233))": "cpu:37864285, mem:143698, objs:-/117@820927b5", + " 331 call vec_get(Vec(obj#183), U32(6))": "", + " 332 ret vec_get -> Ok(Bytes(obj#175))": "cpu:37864511", + " 333 call vec_get(Vec(obj#205), U32(6))": "", + " 334 ret vec_get -> Ok(U256(obj#197))": "cpu:37864737", + " 335 call bls12_381_g1_mul(Bytes(obj#175), U256(obj#197))": "", + " 336 ret bls12_381_g1_mul -> Ok(Bytes(obj#235))": "cpu:41155384, mem:143874, objs:-/118@734cedc3", + " 337 call bls12_381_g1_add(Bytes(obj#233), Bytes(obj#235))": "", + " 338 ret bls12_381_g1_add -> Ok(Bytes(obj#237))": "cpu:41266135, mem:144050, objs:-/119@9f782901", + " 339 call vec_get(Vec(obj#183), U32(7))": "", + " 340 ret vec_get -> Ok(Bytes(obj#177))": "cpu:41266361", + " 341 call vec_get(Vec(obj#205), U32(7))": "", + " 342 ret vec_get -> Ok(U256(obj#199))": "cpu:41266587", + " 343 call bls12_381_g1_mul(Bytes(obj#177), U256(obj#199))": "", + " 344 ret bls12_381_g1_mul -> Ok(Bytes(obj#239))": "cpu:44557234, mem:144226, objs:-/120@6222b65f", + " 345 call bls12_381_g1_add(Bytes(obj#237), Bytes(obj#239))": "", + " 346 ret bls12_381_g1_add -> Ok(Bytes(obj#241))": "cpu:44667985, mem:144402, objs:-/121@ec08d7b8", + " 347 call vec_get(Vec(obj#183), U32(8))": "", + " 348 ret vec_get -> Ok(Bytes(obj#179))": "cpu:44668211", + " 349 call vec_get(Vec(obj#205), U32(8))": "", + " 350 ret vec_get -> Ok(U256(obj#201))": "cpu:44668437", + " 351 call bls12_381_g1_mul(Bytes(obj#179), U256(obj#201))": "", + " 352 ret bls12_381_g1_mul -> Ok(Bytes(obj#243))": "cpu:47959084, mem:144578, objs:-/122@ed50266c", + " 353 call bls12_381_g1_add(Bytes(obj#241), Bytes(obj#243))": "", + " 354 ret bls12_381_g1_add -> Ok(Bytes(obj#245))": "cpu:48069835, mem:144754, objs:-/123@c4adee2a", + " 355 call vec_get(Vec(obj#183), U32(9))": "", + " 356 ret vec_get -> Ok(Bytes(obj#181))": "cpu:48070061", + " 357 call vec_get(Vec(obj#205), U32(9))": "", + " 358 ret vec_get -> Ok(U256(obj#203))": "cpu:48070287", + " 359 call bls12_381_g1_mul(Bytes(obj#181), U256(obj#203))": "", + " 360 ret bls12_381_g1_mul -> Ok(Bytes(obj#247))": "cpu:51360934, mem:144930, objs:-/124@e5cf2285", + " 361 call bls12_381_g1_add(Bytes(obj#245), Bytes(obj#247))": "", + " 362 ret bls12_381_g1_add -> Ok(Bytes(obj#249))": "cpu:51471685, mem:145106, objs:-/125@e28e8633", + " 363 call obj_cmp(Bytes(obj#249), Bytes(obj#207))": "", + " 364 ret obj_cmp -> Ok(0)": "cpu:51471985", + " 365 end": "cpu:51471985, mem:145106, prngs:-/-, objs:-/125@e28e8633, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g1_mul.json b/soroban-env-host/observations/22/test__bls12_381__g1_mul.json new file mode 100644 index 000000000..804d5ad82 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g1_mul.json @@ -0,0 +1,28 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call obj_from_u256_pieces(0, 0, 0, 0)": "cpu:2307, mem:176, objs:-/1@2142c5f5", + " 2 ret obj_from_u256_pieces -> Ok(U256(obj#3))": "cpu:2808, mem:240, objs:-/2@a8ecc130", + " 3 call bls12_381_g1_mul(Bytes(obj#1), U256(obj#3))": "", + " 4 ret bls12_381_g1_mul -> Ok(Bytes(obj#5))": "cpu:3293455, mem:416, objs:-/3@ee8b49", + " 5 call obj_cmp(Bytes(obj#5), Bytes(obj#7))": "cpu:3295762, mem:592, objs:-/4@ccb573fe", + " 6 ret obj_cmp -> Ok(0)": "cpu:3296062", + " 7 call bls12_381_g1_mul(Bytes(obj#9), U256(1))": "cpu:3298369, mem:768, objs:-/5@cc92d941", + " 8 ret bls12_381_g1_mul -> Ok(Bytes(obj#11))": "cpu:6588894, mem:944, objs:-/6@89567945", + " 9 call obj_cmp(Bytes(obj#11), Bytes(obj#9))": "", + " 10 ret obj_cmp -> Ok(0)": "cpu:6589194", + " 11 call obj_from_u256_pieces(6323299788322677209, 10750116738439201932, 18360906223394982587, 9325364323995100469)": "cpu:6591501, mem:1120, objs:-/7@2a485b17", + " 12 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:6592002, mem:1184, objs:-/8@79217ef9", + " 13 call obj_from_u256_pieces(16907382892538334328, 113782963536904741, 4993972513439703861, 2571702143467752736)": "", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#17))": "cpu:6592503, mem:1248, objs:-/9@36abc0b3", + " 15 call bls12_381_g1_mul(Bytes(obj#13), U256(obj#15))": "", + " 16 ret bls12_381_g1_mul -> Ok(Bytes(obj#19))": "cpu:9883150, mem:1424, objs:-/10@b21c2d2d", + " 17 call bls12_381_g1_mul(Bytes(obj#19), U256(obj#17))": "", + " 18 ret bls12_381_g1_mul -> Ok(Bytes(obj#21))": "cpu:13173797, mem:1600, objs:-/11@a65beffd", + " 19 call bls12_381_g1_mul(Bytes(obj#13), U256(obj#17))": "", + " 20 ret bls12_381_g1_mul -> Ok(Bytes(obj#23))": "cpu:16464444, mem:1776, objs:-/12@142b906a", + " 21 call bls12_381_g1_mul(Bytes(obj#23), U256(obj#15))": "", + " 22 ret bls12_381_g1_mul -> Ok(Bytes(obj#25))": "cpu:19755091, mem:1952, objs:-/13@2c457c1e", + " 23 call obj_cmp(Bytes(obj#21), Bytes(obj#25))": "", + " 24 ret obj_cmp -> Ok(0)": "cpu:19755391", + " 25 end": "cpu:19755391, mem:1952, prngs:-/-, objs:-/13@2c457c1e, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g2_add.json b/soroban-env-host/observations/22/test__bls12_381__g2_add.json new file mode 100644 index 000000000..e57288e69 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g2_add.json @@ -0,0 +1,92 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_insert(Bytes(obj#3), U32(192), U32(0))": "cpu:7306, mem:544, objs:-/2@677d2669", + " 2 ret bytes_insert -> Ok(Bytes(obj#5))": "cpu:8498, mem:817, objs:-/3@aa2f4df7", + " 3 call bls12_381_g2_add(Bytes(obj#5), Bytes(obj#1))": "", + " 4 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:8681", + " 5 call bytes_del(Bytes(obj#7), U32(191))": "cpu:12334, mem:1089, objs:-/4@d40d4e81", + " 6 ret bytes_del -> Ok(Bytes(obj#9))": "cpu:13568, mem:1361, objs:-/5@a828132d", + " 7 call bls12_381_g2_add(Bytes(obj#9), Bytes(obj#1))": "", + " 8 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:13751", + " 9 call bytes_get(Bytes(obj#11), U32(0))": "cpu:17404, mem:1633, objs:-/6@5662b215", + " 10 ret bytes_get -> Ok(U32(19))": "cpu:17526", + " 11 call bytes_put(Bytes(obj#11), U32(0), U32(147))": "", + " 12 ret bytes_put -> Ok(Bytes(obj#13))": "cpu:18718, mem:1905, objs:-/7@9e161ca2", + " 13 call bls12_381_g2_add(Bytes(obj#13), Bytes(obj#1))": "", + " 14 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:18901", + " 15 call bytes_get(Bytes(obj#15), U32(0))": "cpu:22554, mem:2177, objs:-/8@96a3978", + " 16 ret bytes_get -> Ok(U32(8))": "cpu:22676", + " 17 call bytes_put(Bytes(obj#15), U32(0), U32(72))": "", + " 18 ret bytes_put -> Ok(Bytes(obj#17))": "cpu:23868, mem:2449, objs:-/9@69b0d3c3", + " 19 call bls12_381_g2_add(Bytes(obj#17), Bytes(obj#1))": "", + " 20 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:24051", + " 21 call bytes_get(Bytes(obj#19), U32(0))": "cpu:27704, mem:2721, objs:-/10@11342981", + " 22 ret bytes_get -> Ok(U32(14))": "cpu:27826", + " 23 call bytes_put(Bytes(obj#19), U32(0), U32(46))": "", + " 24 ret bytes_put -> Ok(Bytes(obj#21))": "cpu:29018, mem:2993, objs:-/11@272aefa9", + " 25 call bls12_381_g2_add(Bytes(obj#21), Bytes(obj#1))": "", + " 26 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:29201", + " 27 call bls12_381_g2_add(Bytes(obj#25), Bytes(obj#1))": "cpu:36507, mem:3537, objs:-/13@bbc6c210", + " 28 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:46551", + " 29 call bls12_381_g2_add(Bytes(obj#29), Bytes(obj#1))": "cpu:53857, mem:4081, objs:-/15@20ea1ecb", + " 30 ret bls12_381_g2_add -> Ok(Bytes(obj#31))": "cpu:203486, mem:4353, objs:-/16@a8cbceb4", + " 31 call bytes_insert(Bytes(obj#35), U32(192), U32(0))": "cpu:210792, mem:4897, objs:-/18@61fd8415", + " 32 ret bytes_insert -> Ok(Bytes(obj#37))": "cpu:211984, mem:5170, objs:-/19@9f66f3fb", + " 33 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#37))": "", + " 34 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:222089", + " 35 call bytes_del(Bytes(obj#39), U32(191))": "cpu:225742, mem:5442, objs:-/20@b18f1339", + " 36 ret bytes_del -> Ok(Bytes(obj#41))": "cpu:226976, mem:5714, objs:-/21@cb06fd3d", + " 37 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#41))": "", + " 38 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:237081", + " 39 call bytes_get(Bytes(obj#43), U32(0))": "cpu:240734, mem:5986, objs:-/22@e4f17717", + " 40 ret bytes_get -> Ok(U32(25))": "cpu:240856", + " 41 call bytes_put(Bytes(obj#43), U32(0), U32(153))": "", + " 42 ret bytes_put -> Ok(Bytes(obj#45))": "cpu:242048, mem:6258, objs:-/23@628ff496", + " 43 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#45))": "", + " 44 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:252153", + " 45 call bytes_get(Bytes(obj#47), U32(0))": "cpu:255806, mem:6530, objs:-/24@aa5fdd9f", + " 46 ret bytes_get -> Ok(U32(11))": "cpu:255928", + " 47 call bytes_put(Bytes(obj#47), U32(0), U32(75))": "", + " 48 ret bytes_put -> Ok(Bytes(obj#49))": "cpu:257120, mem:6802, objs:-/25@32a4ed1", + " 49 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#49))": "", + " 50 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:267225", + " 51 call bytes_get(Bytes(obj#51), U32(0))": "cpu:270878, mem:7074, objs:-/26@22283cca", + " 52 ret bytes_get -> Ok(U32(20))": "cpu:271000", + " 53 call bytes_put(Bytes(obj#51), U32(0), U32(52))": "", + " 54 ret bytes_put -> Ok(Bytes(obj#53))": "cpu:272192, mem:7346, objs:-/27@dda0c3be", + " 55 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#53))": "", + " 56 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:282297", + " 57 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#57))": "cpu:289603, mem:7890, objs:-/29@573e8380", + " 58 ret bls12_381_g2_add -> Err(Error(Crypto, InvalidInput))": "cpu:309569", + " 59 call bls12_381_g2_add(Bytes(obj#33), Bytes(obj#61))": "cpu:316875, mem:8434, objs:-/31@5fd19068", + " 60 ret bls12_381_g2_add -> Ok(Bytes(obj#63))": "cpu:466504, mem:8706, objs:-/32@ec6b7b2c", + " 61 call bls12_381_g2_add(Bytes(obj#65), Bytes(obj#67))": "cpu:473810, mem:9250, objs:-/34@9b1eefe0", + " 62 ret bls12_381_g2_add -> Ok(Bytes(obj#69))": "cpu:623439, mem:9522, objs:-/35@f71181a1", + " 63 call obj_cmp(Bytes(obj#65), Bytes(obj#69))": "", + " 64 ret obj_cmp -> Ok(0)": "cpu:623751", + " 65 call bls12_381_g2_add(Bytes(obj#73), Bytes(obj#71))": "cpu:631057, mem:10066, objs:-/37@f8dc176b", + " 66 ret bls12_381_g2_add -> Ok(Bytes(obj#75))": "cpu:780686, mem:10338, objs:-/38@2fe7293", + " 67 call obj_cmp(Bytes(obj#71), Bytes(obj#75))": "", + " 68 ret obj_cmp -> Ok(0)": "cpu:780998", + " 69 call bls12_381_g2_add(Bytes(obj#77), Bytes(obj#79))": "cpu:788304, mem:10882, objs:-/40@c4ae35f6", + " 70 ret bls12_381_g2_add -> Ok(Bytes(obj#81))": "cpu:937933, mem:11154, objs:-/41@83a07334", + " 71 call bls12_381_g2_add(Bytes(obj#79), Bytes(obj#77))": "", + " 72 ret bls12_381_g2_add -> Ok(Bytes(obj#83))": "cpu:1087562, mem:11426, objs:-/42@ee36f22d", + " 73 call obj_cmp(Bytes(obj#81), Bytes(obj#83))": "", + " 74 ret obj_cmp -> Ok(0)": "cpu:1087874", + " 75 call bls12_381_g2_add(Bytes(obj#85), Bytes(obj#87))": "cpu:1098833, mem:12242, objs:-/45@6e00248", + " 76 ret bls12_381_g2_add -> Ok(Bytes(obj#91))": "cpu:1248462, mem:12514, objs:-/46@ef715707", + " 77 call bls12_381_g2_add(Bytes(obj#91), Bytes(obj#89))": "", + " 78 ret bls12_381_g2_add -> Ok(Bytes(obj#93))": "cpu:1398091, mem:12786, objs:-/47@90ff55c1", + " 79 call bls12_381_g2_add(Bytes(obj#87), Bytes(obj#89))": "", + " 80 ret bls12_381_g2_add -> Ok(Bytes(obj#95))": "cpu:1547720, mem:13058, objs:-/48@193bd8c1", + " 81 call bls12_381_g2_add(Bytes(obj#85), Bytes(obj#95))": "", + " 82 ret bls12_381_g2_add -> Ok(Bytes(obj#97))": "cpu:1697349, mem:13330, objs:-/49@8486e34a", + " 83 call obj_cmp(Bytes(obj#93), Bytes(obj#97))": "", + " 84 ret obj_cmp -> Ok(0)": "cpu:1697661", + " 85 call bls12_381_g2_add(Bytes(obj#99), Bytes(obj#101))": "cpu:2772711, mem:13874, objs:-/51@43bd7be8", + " 86 ret bls12_381_g2_add -> Ok(Bytes(obj#103))": "cpu:2922340, mem:14146, objs:-/52@29e9945a", + " 87 call obj_cmp(Bytes(obj#103), Bytes(obj#105))": "cpu:2925993, mem:14418, objs:-/53@c4f5e4c0", + " 88 ret obj_cmp -> Ok(0)": "cpu:2926305", + " 89 end": "cpu:2926305, mem:14418, prngs:-/-, objs:-/53@c4f5e4c0, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g2_msm.json b/soroban-env-host/observations/22/test__bls12_381__g2_msm.json new file mode 100644 index 000000000..28c348986 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g2_msm.json @@ -0,0 +1,308 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call vec_new()": "", + " 2 ret vec_new -> Ok(Vec(obj#1))": "cpu:501, mem:64, objs:-/1@3e25b2a0", + " 3 call vec_new()": "", + " 4 ret vec_new -> Ok(Vec(obj#3))": "cpu:1002, mem:128, objs:-/2@14339b3d", + " 5 call bls12_381_g2_msm(Vec(obj#1), Vec(obj#3))": "", + " 6 call vec_len(Vec(obj#1))": "cpu:1124", + " 7 ret vec_len -> Ok(U32(0))": "cpu:1246", + " 8 call vec_len(Vec(obj#3))": "cpu:1741, mem:144", + " 9 ret vec_len -> Ok(U32(0))": "cpu:1863", + " 10 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:8038326, mem:219814", + " 11 call bytes_new_from_slice(192)": "cpu:8040970", + " 12 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:8041979, mem:220086, objs:-/3@bd2bad33", + " 13 call bytes_new_from_slice(192)": "cpu:8044623", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:8045632, mem:220358, objs:-/4@84c0214b", + " 15 call vec_new_from_slice(2)": "", + " 16 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:8046719, mem:220454, objs:-/5@e2867bea", + " 17 call obj_from_u256_pieces(11753201120659576617, 12800183645227990272, 6449591311112480650, 11530214657355711865)": "", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:8047220, mem:220518, objs:-/6@d2c1550a", + " 19 call obj_from_u256_pieces(17867260108045272079, 6594056455511558201, 8394146189024495608, 16477234698079725300)": "", + " 20 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:8047721, mem:220582, objs:-/7@b83c4f1d", + " 21 call obj_from_u256_pieces(5093470543443933884, 12596616304565341690, 2875592832172597214, 8474459150244119113)": "", + " 22 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:8048222, mem:220646, objs:-/8@5b2279ba", + " 23 call vec_new_from_slice(3)": "", + " 24 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:8049372, mem:220750, objs:-/9@2c5030af", + " 25 call bls12_381_g2_msm(Vec(obj#9), Vec(obj#17))": "", + " 26 call vec_len(Vec(obj#9))": "cpu:8049494", + " 27 ret vec_len -> Ok(U32(2))": "cpu:8049616", + " 28 call vec_len(Vec(obj#17))": "cpu:10185647, mem:221150", + " 29 ret vec_len -> Ok(U32(3))": "cpu:10185769", + " 30 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:23066961, mem:446457", + " 31 call vec_new_from_slice(3)": "cpu:23081573, mem:447545, objs:-/13@c72ec5e5", + " 32 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:23082723, mem:447649, objs:-/14@138c972e", + " 33 call obj_from_u256_pieces(2670602178858449459, 7519702381861979968, 12131847362652268029, 15324157160071379208)": "", + " 34 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:23083224, mem:447713, objs:-/15@cca0974f", + " 35 call obj_from_u256_pieces(14448951281277473340, 10183372082303375121, 11609568207825743232, 10582668507445555283)": "", + " 36 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:23083725, mem:447777, objs:-/16@338703b5", + " 37 call obj_from_u256_pieces(8613971480719722045, 14687201964851969652, 13467859308725023972, 5056481814551667924)": "", + " 38 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:23084226, mem:447841, objs:-/17@e29c96a4", + " 39 call vec_new_from_slice(3)": "", + " 40 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:23085376, mem:447945, objs:-/18@bd3fe61d", + " 41 call bls12_381_g2_msm(Vec(obj#27), Vec(obj#35))": "", + " 42 call vec_len(Vec(obj#27))": "cpu:23085498", + " 43 ret vec_len -> Ok(U32(3))": "cpu:23085620", + " 44 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:25221675, mem:448537", + " 45 call vec_new_from_slice(3)": "cpu:25225328, mem:448809, objs:-/19@fc4eae83", + " 46 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:25226478, mem:448913, objs:-/20@fc5a7848", + " 47 call obj_from_u256_pieces(10885390432521285204, 10089357480003724487, 11017657889674374380, 349979284301977343)": "", + " 48 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:25226979, mem:448977, objs:-/21@c11c1e9", + " 49 call obj_from_u256_pieces(15502034860521929120, 5197508503879521041, 10172360046471299633, 18026852881196000031)": "", + " 50 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:25227480, mem:449041, objs:-/22@fbed0030", + " 51 call obj_from_u256_pieces(7434520258580032483, 1508470301556677986, 6272863840242768080, 12830499169355232182)": "", + " 52 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:25227981, mem:449105, objs:-/23@7c759a0d", + " 53 call vec_new_from_slice(3)": "", + " 54 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:25229131, mem:449209, objs:-/24@892a5924", + " 55 call bls12_381_g2_msm(Vec(obj#39), Vec(obj#47))": "", + " 56 call vec_len(Vec(obj#39))": "cpu:25229253", + " 57 ret vec_len -> Ok(U32(3))": "cpu:25229375", + " 58 call vec_len(Vec(obj#47))": "cpu:28433174, mem:449801", + " 59 ret vec_len -> Ok(U32(3))": "cpu:28433296", + " 60 ret bls12_381_g2_msm -> Ok(Bytes(obj#49))": "cpu:43838220, mem:678151, objs:-/25@b3e2fb94", + " 61 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:43841873, mem:678423, objs:-/26@36256f36", + " 62 ret obj_cmp -> Ok(0)": "cpu:43842185", + " 63 call bytes_new_from_slice(192)": "cpu:43844829", + " 64 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:43845838, mem:678695, objs:-/27@8ed979ac", + " 65 call bytes_new_from_slice(192)": "cpu:43848482", + " 66 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:43849491, mem:678967, objs:-/28@a3eb6aea", + " 67 call bytes_new_from_slice(192)": "cpu:43852135", + " 68 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:43853144, mem:679239, objs:-/29@9bc29a7f", + " 69 call vec_new_from_slice(3)": "", + " 70 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:43854294, mem:679343, objs:-/30@379dffd4", + " 71 call vec_new_from_slice(3)": "", + " 72 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:43855261, mem:679447, objs:-/31@f3d911e6", + " 73 call bls12_381_g2_msm(Vec(obj#59), Vec(obj#61))": "", + " 74 call vec_len(Vec(obj#59))": "cpu:43855383", + " 75 ret vec_len -> Ok(U32(3))": "cpu:43855505", + " 76 call vec_len(Vec(obj#61))": "cpu:47059304, mem:680039", + " 77 ret vec_len -> Ok(U32(3))": "cpu:47059426", + " 78 ret bls12_381_g2_msm -> Ok(Bytes(obj#63))": "cpu:62464167, mem:908389, objs:-/32@99e86db8", + " 79 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:62467820, mem:908661, objs:-/33@d5a55acc", + " 80 ret obj_cmp -> Ok(0)": "cpu:62468132", + " 81 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:7306, mem:544, objs:-/35@52d12591", + " 82 ret obj_cmp -> Ok(-1)": "cpu:7618", + " 83 call vec_new_from_slice(2)": "cpu:1079015, mem:816, objs:-/36@f4b12971", + " 84 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:1080102, mem:912, objs:-/37@43b753fc", + " 85 call vec_new_from_slice(2)": "", + " 86 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:1081067, mem:1008, objs:-/38@d88a608d", + " 87 call bls12_381_g2_msm(Vec(obj#73), Vec(obj#75))": "", + " 88 call vec_len(Vec(obj#73))": "cpu:1081189", + " 89 ret vec_len -> Ok(U32(2))": "cpu:1081311", + " 90 call vec_len(Vec(obj#75))": "cpu:3217342, mem:1408", + " 91 ret vec_len -> Ok(U32(2))": "cpu:3217464", + " 92 ret bls12_381_g2_msm -> Ok(Bytes(obj#77))": "cpu:16200931, mem:226955, objs:-/39@308f505c", + " 93 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:16204584, mem:227227, objs:-/40@9dfbcd24", + " 94 ret obj_cmp -> Ok(0)": "cpu:16204896", + " 95 call obj_from_u256_pieces(576349249354864704, 6205532040440579369, 13730557568579417905, 2677733454007168321)": "cpu:16219508, mem:228315, objs:-/44@cd73d980", + " 96 ret obj_from_u256_pieces -> Ok(U256(obj#89))": "cpu:16220009, mem:228379, objs:-/45@d173b8e8", + " 97 call obj_from_u256_pieces(15107729625736847273, 3736362233123338213, 1310693883286457402, 15587527586950209119)": "", + " 98 ret obj_from_u256_pieces -> Ok(U256(obj#91))": "cpu:16220510, mem:228443, objs:-/46@8a8ce1f3", + " 99 call obj_from_u256_pieces(7130333837602304766, 15809650852848135414, 16809337653702689547, 14300891233011973695)": "", + " 100 ret obj_from_u256_pieces -> Ok(U256(obj#93))": "cpu:16221011, mem:228507, objs:-/47@eacff4b8", + " 101 call obj_from_u256_pieces(5531006726045309341, 889630097820975985, 16583573122393188327, 9061467097759417586)": "", + " 102 ret obj_from_u256_pieces -> Ok(U256(obj#95))": "cpu:16221512, mem:228571, objs:-/48@42874a94", + " 103 call vec_new_from_slice(4)": "", + " 104 ret vec_new_from_slice -> Ok(Vec(obj#97))": "cpu:16222725, mem:228683, objs:-/49@239aaa14", + " 105 call vec_new_from_slice(4)": "", + " 106 ret vec_new_from_slice -> Ok(Vec(obj#99))": "cpu:16223938, mem:228795, objs:-/50@60ff6572", + " 107 call bls12_381_g2_msm(Vec(obj#97), Vec(obj#99))": "", + " 108 call vec_len(Vec(obj#97))": "cpu:16224060", + " 109 ret vec_len -> Ok(U32(4))": "cpu:16224182", + " 110 call vec_len(Vec(obj#99))": "cpu:20495749, mem:229579", + " 111 ret vec_len -> Ok(U32(4))": "cpu:20495871", + " 112 ret bls12_381_g2_msm -> Ok(Bytes(obj#101))": "cpu:38322130, mem:460732, objs:-/51@6bf9c3f3", + " 113 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 114 ret vec_new_from_slice -> Ok(Vec(obj#103))": "cpu:1213, mem:112, objs:-/52@c42f87dd", + " 115 call vec_new_from_slice(4)": "", + " 116 ret vec_new_from_slice -> Ok(Vec(obj#105))": "cpu:2426, mem:224, objs:-/53@6a9d8396", + " 117 call bls12_381_g2_msm(Vec(obj#103), Vec(obj#105))": "", + " 118 call vec_len(Vec(obj#103))": "cpu:2548", + " 119 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 120 call vec_len(Vec(obj#105))": "cpu:4274237, mem:1008", + " 121 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 122 ret bls12_381_g2_msm -> Ok(Bytes(obj#107))": "cpu:22100618, mem:232161, objs:-/54@3472db57", + " 123 call obj_cmp(Bytes(obj#107), Bytes(obj#101))": "", + " 124 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 125 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 126 ret vec_new_from_slice -> Ok(Vec(obj#109))": "cpu:1213, mem:112, objs:-/55@472ba905", + " 127 call vec_new_from_slice(4)": "", + " 128 ret vec_new_from_slice -> Ok(Vec(obj#111))": "cpu:2426, mem:224, objs:-/56@e84328b6", + " 129 call bls12_381_g2_msm(Vec(obj#109), Vec(obj#111))": "", + " 130 call vec_len(Vec(obj#109))": "cpu:2548", + " 131 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 132 call vec_len(Vec(obj#111))": "cpu:4274237, mem:1008", + " 133 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 134 ret bls12_381_g2_msm -> Ok(Bytes(obj#113))": "cpu:22100618, mem:232161, objs:-/57@5cd90966", + " 135 call obj_cmp(Bytes(obj#113), Bytes(obj#101))": "", + " 136 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 137 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 138 ret vec_new_from_slice -> Ok(Vec(obj#115))": "cpu:1213, mem:112, objs:-/58@5477447f", + " 139 call vec_new_from_slice(4)": "", + " 140 ret vec_new_from_slice -> Ok(Vec(obj#117))": "cpu:2426, mem:224, objs:-/59@42339f28", + " 141 call bls12_381_g2_msm(Vec(obj#115), Vec(obj#117))": "", + " 142 call vec_len(Vec(obj#115))": "cpu:2548", + " 143 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 144 call vec_len(Vec(obj#117))": "cpu:4274237, mem:1008", + " 145 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 146 ret bls12_381_g2_msm -> Ok(Bytes(obj#119))": "cpu:22100618, mem:232161, objs:-/60@142a3f6", + " 147 call obj_cmp(Bytes(obj#119), Bytes(obj#101))": "", + " 148 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 149 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 150 ret vec_new_from_slice -> Ok(Vec(obj#121))": "cpu:1213, mem:112, objs:-/61@f554fdda", + " 151 call vec_new_from_slice(4)": "", + " 152 ret vec_new_from_slice -> Ok(Vec(obj#123))": "cpu:2426, mem:224, objs:-/62@392d78a5", + " 153 call bls12_381_g2_msm(Vec(obj#121), Vec(obj#123))": "", + " 154 call vec_len(Vec(obj#121))": "cpu:2548", + " 155 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 156 call vec_len(Vec(obj#123))": "cpu:4274237, mem:1008", + " 157 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 158 ret bls12_381_g2_msm -> Ok(Bytes(obj#125))": "cpu:22100618, mem:232161, objs:-/63@a37c7b18", + " 159 call obj_cmp(Bytes(obj#125), Bytes(obj#101))": "", + " 160 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 161 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 162 ret vec_new_from_slice -> Ok(Vec(obj#127))": "cpu:1213, mem:112, objs:-/64@d830e19", + " 163 call vec_new_from_slice(4)": "", + " 164 ret vec_new_from_slice -> Ok(Vec(obj#129))": "cpu:2426, mem:224, objs:-/65@de9f2d72", + " 165 call bls12_381_g2_msm(Vec(obj#127), Vec(obj#129))": "", + " 166 call vec_len(Vec(obj#127))": "cpu:2548", + " 167 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 168 call vec_len(Vec(obj#129))": "cpu:4274237, mem:1008", + " 169 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 170 ret bls12_381_g2_msm -> Ok(Bytes(obj#131))": "cpu:22100618, mem:232161, objs:-/66@12bd397c", + " 171 call obj_cmp(Bytes(obj#131), Bytes(obj#101))": "", + " 172 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 173 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 174 ret vec_new_from_slice -> Ok(Vec(obj#133))": "cpu:1213, mem:112, objs:-/67@9fc98ec8", + " 175 call vec_new_from_slice(4)": "", + " 176 ret vec_new_from_slice -> Ok(Vec(obj#135))": "cpu:2426, mem:224, objs:-/68@2e15d9f1", + " 177 call bls12_381_g2_msm(Vec(obj#133), Vec(obj#135))": "", + " 178 call vec_len(Vec(obj#133))": "cpu:2548", + " 179 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 180 call vec_len(Vec(obj#135))": "cpu:4274237, mem:1008", + " 181 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 182 ret bls12_381_g2_msm -> Ok(Bytes(obj#137))": "cpu:22100618, mem:232161, objs:-/69@516fe495", + " 183 call obj_cmp(Bytes(obj#137), Bytes(obj#101))": "", + " 184 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 185 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 186 ret vec_new_from_slice -> Ok(Vec(obj#139))": "cpu:1213, mem:112, objs:-/70@745e9418", + " 187 call vec_new_from_slice(4)": "", + " 188 ret vec_new_from_slice -> Ok(Vec(obj#141))": "cpu:2426, mem:224, objs:-/71@db69de4c", + " 189 call bls12_381_g2_msm(Vec(obj#139), Vec(obj#141))": "", + " 190 call vec_len(Vec(obj#139))": "cpu:2548", + " 191 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 192 call vec_len(Vec(obj#141))": "cpu:4274237, mem:1008", + " 193 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 194 ret bls12_381_g2_msm -> Ok(Bytes(obj#143))": "cpu:22100618, mem:232161, objs:-/72@8a46f90c", + " 195 call obj_cmp(Bytes(obj#143), Bytes(obj#101))": "", + " 196 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 197 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 198 ret vec_new_from_slice -> Ok(Vec(obj#145))": "cpu:1213, mem:112, objs:-/73@1e08429e", + " 199 call vec_new_from_slice(4)": "", + " 200 ret vec_new_from_slice -> Ok(Vec(obj#147))": "cpu:2426, mem:224, objs:-/74@b5ef3ee0", + " 201 call bls12_381_g2_msm(Vec(obj#145), Vec(obj#147))": "", + " 202 call vec_len(Vec(obj#145))": "cpu:2548", + " 203 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 204 call vec_len(Vec(obj#147))": "cpu:4274237, mem:1008", + " 205 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 206 ret bls12_381_g2_msm -> Ok(Bytes(obj#149))": "cpu:22100618, mem:232161, objs:-/75@5ece035c", + " 207 call obj_cmp(Bytes(obj#149), Bytes(obj#101))": "", + " 208 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 209 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 210 ret vec_new_from_slice -> Ok(Vec(obj#151))": "cpu:1213, mem:112, objs:-/76@f42c812e", + " 211 call vec_new_from_slice(4)": "", + " 212 ret vec_new_from_slice -> Ok(Vec(obj#153))": "cpu:2426, mem:224, objs:-/77@a0486908", + " 213 call bls12_381_g2_msm(Vec(obj#151), Vec(obj#153))": "", + " 214 call vec_len(Vec(obj#151))": "cpu:2548", + " 215 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 216 call vec_len(Vec(obj#153))": "cpu:4274237, mem:1008", + " 217 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 218 ret bls12_381_g2_msm -> Ok(Bytes(obj#155))": "cpu:22100618, mem:232161, objs:-/78@de21d2fc", + " 219 call obj_cmp(Bytes(obj#155), Bytes(obj#101))": "", + " 220 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 221 call vec_new_from_slice(4)": "cpu:0, mem:0", + " 222 ret vec_new_from_slice -> Ok(Vec(obj#157))": "cpu:1213, mem:112, objs:-/79@4620805c", + " 223 call vec_new_from_slice(4)": "", + " 224 ret vec_new_from_slice -> Ok(Vec(obj#159))": "cpu:2426, mem:224, objs:-/80@89a4898d", + " 225 call bls12_381_g2_msm(Vec(obj#157), Vec(obj#159))": "", + " 226 call vec_len(Vec(obj#157))": "cpu:2548", + " 227 ret vec_len -> Ok(U32(4))": "cpu:2670", + " 228 call vec_len(Vec(obj#159))": "cpu:4274237, mem:1008", + " 229 ret vec_len -> Ok(U32(4))": "cpu:4274359", + " 230 ret bls12_381_g2_msm -> Ok(Bytes(obj#161))": "cpu:22100618, mem:232161, objs:-/81@151aaaa4", + " 231 call obj_cmp(Bytes(obj#161), Bytes(obj#101))": "", + " 232 ret obj_cmp -> Ok(0)": "cpu:22100930", + " 233 call bytes_new_from_slice(192)": "cpu:2644, mem:0", + " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:3653, mem:272, objs:-/82@526b5995", + " 235 call bytes_new_from_slice(192)": "cpu:6297", + " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:7306, mem:544, objs:-/83@6efe8bf2", + " 237 call bytes_new_from_slice(192)": "cpu:9950", + " 238 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:10959, mem:816, objs:-/84@d65370d1", + " 239 call bytes_new_from_slice(192)": "cpu:13603", + " 240 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:14612, mem:1088, objs:-/85@768353f3", + " 241 call bytes_new_from_slice(192)": "cpu:17256", + " 242 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:18265, mem:1360, objs:-/86@d38309a4", + " 243 call vec_new_from_slice(5)": "", + " 244 ret vec_new_from_slice -> Ok(Vec(obj#173))": "cpu:19541, mem:1480, objs:-/87@3939bbac", + " 245 call obj_from_u256_pieces(17073613341124213686, 9800153404225276109, 6607116724722439497, 842746758976683084)": "", + " 246 ret obj_from_u256_pieces -> Ok(U256(obj#175))": "cpu:20042, mem:1544, objs:-/88@a1c554a1", + " 247 call obj_from_u256_pieces(16040841695964229797, 5061605267848115623, 14000740750614834722, 13904863006945675968)": "", + " 248 ret obj_from_u256_pieces -> Ok(U256(obj#177))": "cpu:20543, mem:1608, objs:-/89@5dbca5f2", + " 249 call obj_from_u256_pieces(5830218664442262694, 4114147737062195718, 16434537214804972826, 1396935906550304884)": "", + " 250 ret obj_from_u256_pieces -> Ok(U256(obj#179))": "cpu:21044, mem:1672, objs:-/90@329f03eb", + " 251 call obj_from_u256_pieces(8756542147870587062, 2334579494105318157, 3880849428716171604, 577514052903835922)": "", + " 252 ret obj_from_u256_pieces -> Ok(U256(obj#181))": "cpu:21545, mem:1736, objs:-/91@8451f38d", + " 253 call obj_from_u256_pieces(5259919734814292314, 1486637374753912723, 9060486243487422013, 18066450239200677051)": "", + " 254 ret obj_from_u256_pieces -> Ok(U256(obj#183))": "cpu:22046, mem:1800, objs:-/92@c5a670c", + " 255 call vec_new_from_slice(5)": "", + " 256 ret vec_new_from_slice -> Ok(Vec(obj#185))": "cpu:23322, mem:1920, objs:-/93@80ddd82c", + " 257 call bls12_381_g2_msm(Vec(obj#173), Vec(obj#185))": "", + " 258 call vec_len(Vec(obj#173))": "cpu:23444", + " 259 ret vec_len -> Ok(U32(5))": "cpu:23566", + " 260 call vec_len(Vec(obj#185))": "cpu:5362901, mem:2896", + " 261 ret vec_len -> Ok(U32(5))": "cpu:5363023", + " 262 ret bls12_381_g2_msm -> Ok(Bytes(obj#187))": "cpu:25610617, mem:236852, objs:-/94@37bd5b7d", + " 263 call vec_get(Vec(obj#173), U32(0))": "cpu:25614270, mem:237124, objs:-/95@47f3520c", + " 264 ret vec_get -> Ok(Bytes(obj#163))": "cpu:25614496", + " 265 call vec_get(Vec(obj#185), U32(0))": "", + " 266 ret vec_get -> Ok(U256(obj#175))": "cpu:25614722", + " 267 call bls12_381_g2_mul(Bytes(obj#163), U256(obj#175))": "", + " 268 ret bls12_381_g2_mul -> Ok(Bytes(obj#191))": "cpu:34662318, mem:237396, objs:-/96@8cc676a4", + " 269 call bls12_381_g2_add(Bytes(obj#189), Bytes(obj#191))": "", + " 270 ret bls12_381_g2_add -> Ok(Bytes(obj#193))": "cpu:34811947, mem:237668, objs:-/97@fd5accef", + " 271 call vec_get(Vec(obj#173), U32(1))": "", + " 272 ret vec_get -> Ok(Bytes(obj#165))": "cpu:34812173", + " 273 call vec_get(Vec(obj#185), U32(1))": "", + " 274 ret vec_get -> Ok(U256(obj#177))": "cpu:34812399", + " 275 call bls12_381_g2_mul(Bytes(obj#165), U256(obj#177))": "", + " 276 ret bls12_381_g2_mul -> Ok(Bytes(obj#195))": "cpu:43859995, mem:237940, objs:-/98@287ee088", + " 277 call bls12_381_g2_add(Bytes(obj#193), Bytes(obj#195))": "", + " 278 ret bls12_381_g2_add -> Ok(Bytes(obj#197))": "cpu:44009624, mem:238212, objs:-/99@85bfd7f9", + " 279 call vec_get(Vec(obj#173), U32(2))": "", + " 280 ret vec_get -> Ok(Bytes(obj#167))": "cpu:44009850", + " 281 call vec_get(Vec(obj#185), U32(2))": "", + " 282 ret vec_get -> Ok(U256(obj#179))": "cpu:44010076", + " 283 call bls12_381_g2_mul(Bytes(obj#167), U256(obj#179))": "", + " 284 ret bls12_381_g2_mul -> Ok(Bytes(obj#199))": "cpu:53057672, mem:238484, objs:-/100@83eb557e", + " 285 call bls12_381_g2_add(Bytes(obj#197), Bytes(obj#199))": "", + " 286 ret bls12_381_g2_add -> Ok(Bytes(obj#201))": "cpu:53207301, mem:238756, objs:-/101@356eda48", + " 287 call vec_get(Vec(obj#173), U32(3))": "", + " 288 ret vec_get -> Ok(Bytes(obj#169))": "cpu:53207527", + " 289 call vec_get(Vec(obj#185), U32(3))": "", + " 290 ret vec_get -> Ok(U256(obj#181))": "cpu:53207753", + " 291 call bls12_381_g2_mul(Bytes(obj#169), U256(obj#181))": "", + " 292 ret bls12_381_g2_mul -> Ok(Bytes(obj#203))": "cpu:62255349, mem:239028, objs:-/102@633754c7", + " 293 call bls12_381_g2_add(Bytes(obj#201), Bytes(obj#203))": "", + " 294 ret bls12_381_g2_add -> Ok(Bytes(obj#205))": "cpu:62404978, mem:239300, objs:-/103@d51e3c43", + " 295 call vec_get(Vec(obj#173), U32(4))": "", + " 296 ret vec_get -> Ok(Bytes(obj#171))": "cpu:62405204", + " 297 call vec_get(Vec(obj#185), U32(4))": "", + " 298 ret vec_get -> Ok(U256(obj#183))": "cpu:62405430", + " 299 call bls12_381_g2_mul(Bytes(obj#171), U256(obj#183))": "", + " 300 ret bls12_381_g2_mul -> Ok(Bytes(obj#207))": "cpu:71453026, mem:239572, objs:-/104@e5da1eed", + " 301 call bls12_381_g2_add(Bytes(obj#205), Bytes(obj#207))": "", + " 302 ret bls12_381_g2_add -> Ok(Bytes(obj#209))": "cpu:71602655, mem:239844, objs:-/105@395f149e", + " 303 call obj_cmp(Bytes(obj#209), Bytes(obj#187))": "", + " 304 ret obj_cmp -> Ok(0)": "cpu:71602967", + " 305 end": "cpu:71602967, mem:239844, prngs:-/-, objs:-/105@395f149e, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g2_mul.json b/soroban-env-host/observations/22/test__bls12_381__g2_mul.json new file mode 100644 index 000000000..709857061 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__g2_mul.json @@ -0,0 +1,28 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call obj_from_u256_pieces(0, 0, 0, 0)": "cpu:3653, mem:272, objs:-/1@f4e2a936", + " 2 ret obj_from_u256_pieces -> Ok(U256(obj#3))": "cpu:4154, mem:336, objs:-/2@74092ac8", + " 3 call bls12_381_g2_mul(Bytes(obj#1), U256(obj#3))": "", + " 4 ret bls12_381_g2_mul -> Ok(Bytes(obj#5))": "cpu:9051750, mem:608, objs:-/3@cb12abce", + " 5 call obj_cmp(Bytes(obj#5), Bytes(obj#7))": "cpu:9055403, mem:880, objs:-/4@eac588f7", + " 6 ret obj_cmp -> Ok(0)": "cpu:9055715", + " 7 call bls12_381_g2_mul(Bytes(obj#9), U256(1))": "cpu:9059368, mem:1152, objs:-/5@179c643c", + " 8 ret bls12_381_g2_mul -> Ok(Bytes(obj#11))": "cpu:18106842, mem:1424, objs:-/6@600e3e5f", + " 9 call obj_cmp(Bytes(obj#11), Bytes(obj#9))": "", + " 10 ret obj_cmp -> Ok(0)": "cpu:18107154", + " 11 call obj_from_u256_pieces(1382979248101647873, 6440934971723338514, 11359438960946870190, 8732565108313877893)": "cpu:18110807, mem:1696, objs:-/7@a0418ad2", + " 12 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:18111308, mem:1760, objs:-/8@158badf", + " 13 call obj_from_u256_pieces(17461574590958800305, 8018887662353493686, 7541867957794240230, 5239794445475264807)": "", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#17))": "cpu:18111809, mem:1824, objs:-/9@d59c1d05", + " 15 call bls12_381_g2_mul(Bytes(obj#13), U256(obj#15))": "", + " 16 ret bls12_381_g2_mul -> Ok(Bytes(obj#19))": "cpu:27159405, mem:2096, objs:-/10@f37fed3a", + " 17 call bls12_381_g2_mul(Bytes(obj#19), U256(obj#17))": "", + " 18 ret bls12_381_g2_mul -> Ok(Bytes(obj#21))": "cpu:36207001, mem:2368, objs:-/11@4c677c04", + " 19 call bls12_381_g2_mul(Bytes(obj#13), U256(obj#17))": "", + " 20 ret bls12_381_g2_mul -> Ok(Bytes(obj#23))": "cpu:45254597, mem:2640, objs:-/12@6476867", + " 21 call bls12_381_g2_mul(Bytes(obj#23), U256(obj#15))": "", + " 22 ret bls12_381_g2_mul -> Ok(Bytes(obj#25))": "cpu:54302193, mem:2912, objs:-/13@63236f75", + " 23 call obj_cmp(Bytes(obj#21), Bytes(obj#25))": "", + " 24 ret obj_cmp -> Ok(0)": "cpu:54302505", + " 25 end": "cpu:54302505, mem:2912, prngs:-/-, objs:-/13@63236f75, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__hash_to_g1.json b/soroban-env-host/observations/22/test__bls12_381__hash_to_g1.json new file mode 100644 index 000000000..b8f848fdf --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__hash_to_g1.json @@ -0,0 +1,58 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(0)": "", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:961, mem:80, objs:-/1@5b7170d7", + " 3 call bytes_new_from_slice(12)": "", + " 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:1924, mem:172, objs:-/2@aa596e87", + " 5 call bls12_381_hash_to_g1(Bytes(obj#3), Bytes(obj#1))": "", + " 6 ret bls12_381_hash_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:3213988, mem:9596", + " 7 call bytes_new_from_slice(256)": "", + " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:3215013, mem:9932, objs:-/3@3a5eafff", + " 9 call bytes_new_from_slice(12)": "", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:3215976, mem:10024, objs:-/4@88a2acc3", + " 11 call bls12_381_hash_to_g1(Bytes(obj#7), Bytes(obj#5))": "", + " 12 ret bls12_381_hash_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:6428040, mem:19448", + " 13 call bytes_new_from_slice(50)": "", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:6429013, mem:19578, objs:-/5@28b6d694", + " 15 call bytes_new_from_slice(0)": "", + " 16 ret bytes_new_from_slice -> Ok(Bytes(obj#11))": "cpu:6429974, mem:19658, objs:-/6@56ac3668", + " 17 call bls12_381_hash_to_g1(Bytes(obj#11), Bytes(obj#9))": "", + " 18 ret bls12_381_hash_to_g1 -> Ok(Bytes(obj#13))": "cpu:9643777, mem:29258, objs:-/7@9efbbcc1", + " 19 call bytes_new_from_slice(96)": "", + " 20 ret bytes_new_from_slice -> Ok(Bytes(obj#15))": "cpu:9644762, mem:29434, objs:-/8@51896357", + " 21 call obj_cmp(Bytes(obj#13), Bytes(obj#15))": "", + " 22 ret obj_cmp -> Ok(0)": "cpu:9645062", + " 23 call bytes_new_from_slice(3)": "", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#17))": "cpu:9646023, mem:29517, objs:-/9@5ec59f82", + " 25 call bls12_381_hash_to_g1(Bytes(obj#17), Bytes(obj#9))": "", + " 26 ret bls12_381_hash_to_g1 -> Ok(Bytes(obj#19))": "cpu:12859983, mem:39117, objs:-/10@e79bbbfb", + " 27 call bytes_new_from_slice(96)": "", + " 28 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:12860968, mem:39293, objs:-/11@68e099a7", + " 29 call obj_cmp(Bytes(obj#19), Bytes(obj#21))": "", + " 30 ret obj_cmp -> Ok(0)": "cpu:12861268", + " 31 call bytes_new_from_slice(16)": "", + " 32 ret bytes_new_from_slice -> Ok(Bytes(obj#23))": "cpu:12862233, mem:39389, objs:-/12@42e4358e", + " 33 call bls12_381_hash_to_g1(Bytes(obj#23), Bytes(obj#9))": "", + " 34 ret bls12_381_hash_to_g1 -> Ok(Bytes(obj#25))": "cpu:16076875, mem:48989, objs:-/13@a5112be9", + " 35 call bytes_new_from_slice(96)": "", + " 36 ret bytes_new_from_slice -> Ok(Bytes(obj#27))": "cpu:16077860, mem:49165, objs:-/14@c90f15b6", + " 37 call obj_cmp(Bytes(obj#25), Bytes(obj#27))": "", + " 38 ret obj_cmp -> Ok(0)": "cpu:16078160", + " 39 call bytes_new_from_slice(133)": "", + " 40 ret bytes_new_from_slice -> Ok(Bytes(obj#29))": "cpu:16079153, mem:49378, objs:-/15@78b64378", + " 41 call bls12_381_hash_to_g1(Bytes(obj#29), Bytes(obj#9))": "", + " 42 ret bls12_381_hash_to_g1 -> Ok(Bytes(obj#31))": "cpu:19299931, mem:58978, objs:-/16@eb416cc7", + " 43 call bytes_new_from_slice(96)": "", + " 44 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:19300916, mem:59154, objs:-/17@14001e17", + " 45 call obj_cmp(Bytes(obj#31), Bytes(obj#33))": "", + " 46 ret obj_cmp -> Ok(0)": "cpu:19301216", + " 47 call bytes_new_from_slice(517)": "", + " 48 ret bytes_new_from_slice -> Ok(Bytes(obj#35))": "cpu:19302305, mem:59751, objs:-/18@3077ed4e", + " 49 call bls12_381_hash_to_g1(Bytes(obj#35), Bytes(obj#9))": "", + " 50 ret bls12_381_hash_to_g1 -> Ok(Bytes(obj#37))": "cpu:22543222, mem:69351, objs:-/19@70daa102", + " 51 call bytes_new_from_slice(96)": "", + " 52 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:22544207, mem:69527, objs:-/20@19d2fca4", + " 53 call obj_cmp(Bytes(obj#37), Bytes(obj#39))": "", + " 54 ret obj_cmp -> Ok(0)": "cpu:22544507", + " 55 end": "cpu:22544507, mem:69527, prngs:-/-, objs:-/20@19d2fca4, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__hash_to_g2.json b/soroban-env-host/observations/22/test__bls12_381__hash_to_g2.json new file mode 100644 index 000000000..fbeccc98f --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__hash_to_g2.json @@ -0,0 +1,58 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(0)": "", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:961, mem:80, objs:-/1@5b7170d7", + " 3 call bytes_new_from_slice(12)": "", + " 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:1924, mem:172, objs:-/2@aa596e87", + " 5 call bls12_381_hash_to_g2(Bytes(obj#3), Bytes(obj#1))": "", + " 6 ret bls12_381_hash_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:7053369, mem:6988", + " 7 call bytes_new_from_slice(256)": "", + " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:7054394, mem:7324, objs:-/3@3a5eafff", + " 9 call bytes_new_from_slice(12)": "", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:7055357, mem:7416, objs:-/4@88a2acc3", + " 11 call bls12_381_hash_to_g2(Bytes(obj#7), Bytes(obj#5))": "", + " 12 ret bls12_381_hash_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:14106802, mem:14232", + " 13 call bytes_new_from_slice(50)": "", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:14107775, mem:14362, objs:-/5@3f4657f8", + " 15 call bytes_new_from_slice(0)": "", + " 16 ret bytes_new_from_slice -> Ok(Bytes(obj#11))": "cpu:14108736, mem:14442, objs:-/6@2e40259c", + " 17 call bls12_381_hash_to_g2(Bytes(obj#11), Bytes(obj#9))": "", + " 18 ret bls12_381_hash_to_g2 -> Ok(Bytes(obj#13))": "cpu:21163258, mem:21530, objs:-/7@2d317ca4", + " 19 call bytes_new_from_slice(192)": "", + " 20 ret bytes_new_from_slice -> Ok(Bytes(obj#15))": "cpu:21164267, mem:21802, objs:-/8@f21b2fa0", + " 21 call obj_cmp(Bytes(obj#13), Bytes(obj#15))": "", + " 22 ret obj_cmp -> Ok(0)": "cpu:21164579", + " 23 call bytes_new_from_slice(3)": "", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#17))": "cpu:21165540, mem:21885, objs:-/9@aba7a202", + " 25 call bls12_381_hash_to_g2(Bytes(obj#17), Bytes(obj#9))": "", + " 26 ret bls12_381_hash_to_g2 -> Ok(Bytes(obj#19))": "cpu:28220221, mem:28973, objs:-/10@ba39dec3", + " 27 call bytes_new_from_slice(192)": "", + " 28 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:28221230, mem:29245, objs:-/11@dd6c306d", + " 29 call obj_cmp(Bytes(obj#19), Bytes(obj#21))": "", + " 30 ret obj_cmp -> Ok(0)": "cpu:28221542", + " 31 call bytes_new_from_slice(16)": "", + " 32 ret bytes_new_from_slice -> Ok(Bytes(obj#23))": "cpu:28222507, mem:29341, objs:-/12@aab36c6f", + " 33 call bls12_381_hash_to_g2(Bytes(obj#23), Bytes(obj#9))": "", + " 34 ret bls12_381_hash_to_g2 -> Ok(Bytes(obj#25))": "cpu:35277878, mem:36429, objs:-/13@860c1403", + " 35 call bytes_new_from_slice(192)": "", + " 36 ret bytes_new_from_slice -> Ok(Bytes(obj#27))": "cpu:35278887, mem:36701, objs:-/14@ca75fa0f", + " 37 call obj_cmp(Bytes(obj#25), Bytes(obj#27))": "", + " 38 ret obj_cmp -> Ok(0)": "cpu:35279199", + " 39 call bytes_new_from_slice(133)": "", + " 40 ret bytes_new_from_slice -> Ok(Bytes(obj#29))": "cpu:35280192, mem:36914, objs:-/15@55b1f41", + " 41 call bls12_381_hash_to_g2(Bytes(obj#29), Bytes(obj#9))": "", + " 42 ret bls12_381_hash_to_g2 -> Ok(Bytes(obj#31))": "cpu:42341776, mem:44002, objs:-/16@67cc16f5", + " 43 call bytes_new_from_slice(192)": "", + " 44 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:42342785, mem:44274, objs:-/17@91beebd2", + " 45 call obj_cmp(Bytes(obj#31), Bytes(obj#33))": "", + " 46 ret obj_cmp -> Ok(0)": "cpu:42343097", + " 47 call bytes_new_from_slice(517)": "", + " 48 ret bytes_new_from_slice -> Ok(Bytes(obj#35))": "cpu:42344186, mem:44871, objs:-/18@77fa1166", + " 49 call bls12_381_hash_to_g2(Bytes(obj#35), Bytes(obj#9))": "", + " 50 ret bls12_381_hash_to_g2 -> Ok(Bytes(obj#37))": "cpu:49426161, mem:51959, objs:-/19@42a8b15f", + " 51 call bytes_new_from_slice(192)": "", + " 52 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:49427170, mem:52231, objs:-/20@dd93bdf4", + " 53 call obj_cmp(Bytes(obj#37), Bytes(obj#39))": "", + " 54 ret obj_cmp -> Ok(0)": "cpu:49427482", + " 55 end": "cpu:49427482, mem:52231, prngs:-/-, objs:-/20@dd93bdf4, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json b/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json new file mode 100644 index 000000000..36bf7e5b6 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json @@ -0,0 +1,96 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(95)": "cpu:1322", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:2305, mem:175, objs:-/1@14742518", + " 3 call bls12_381_map_fp2_to_g2(Bytes(obj#1))": "", + " 4 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:2427", + " 5 call bytes_new_from_slice(97)": "cpu:4410", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:5395, mem:352, objs:-/2@b8cae411", + " 7 call bls12_381_map_fp2_to_g2(Bytes(obj#3))": "", + " 8 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:5517", + " 9 call bytes_new_from_slice(48)": "", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:6490, mem:480, objs:-/3@7baf5e49", + " 11 call bls12_381_map_fp2_to_g2(Bytes(obj#5))": "", + " 12 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:6612", + " 13 call bytes_new_from_slice(192)": "cpu:0, mem:0", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:1009, mem:272, objs:-/4@b4677fca", + " 15 call bytes_new_from_slice(96)": "", + " 16 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:1994, mem:448, objs:-/5@51dc820f", + " 17 call bls12_381_map_fp2_to_g2(Bytes(obj#9))": "", + " 18 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#11))": "cpu:2428056, mem:4064, objs:-/6@79529ee5", + " 19 call obj_cmp(Bytes(obj#11), Bytes(obj#7))": "", + " 20 ret obj_cmp -> Ok(0)": "cpu:2428368", + " 21 call bytes_new_from_slice(192)": "", + " 22 ret bytes_new_from_slice -> Ok(Bytes(obj#13))": "cpu:2429377, mem:4336, objs:-/7@63a0b212", + " 23 call bytes_new_from_slice(96)": "", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#15))": "cpu:2430362, mem:4512, objs:-/8@cc13af37", + " 25 call bls12_381_map_fp2_to_g2(Bytes(obj#15))": "", + " 26 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#17))": "cpu:4856424, mem:8128, objs:-/9@5b6d0aa0", + " 27 call obj_cmp(Bytes(obj#17), Bytes(obj#13))": "", + " 28 ret obj_cmp -> Ok(0)": "cpu:4856736", + " 29 call bytes_new_from_slice(192)": "", + " 30 ret bytes_new_from_slice -> Ok(Bytes(obj#19))": "cpu:4857745, mem:8400, objs:-/10@82ed820f", + " 31 call bytes_new_from_slice(96)": "", + " 32 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:4858730, mem:8576, objs:-/11@b92a252b", + " 33 call bls12_381_map_fp2_to_g2(Bytes(obj#21))": "", + " 34 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#23))": "cpu:7284792, mem:12192, objs:-/12@ece25005", + " 35 call obj_cmp(Bytes(obj#23), Bytes(obj#19))": "", + " 36 ret obj_cmp -> Ok(0)": "cpu:7285104", + " 37 call bytes_new_from_slice(192)": "", + " 38 ret bytes_new_from_slice -> Ok(Bytes(obj#25))": "cpu:7286113, mem:12464, objs:-/13@bc2389f1", + " 39 call bytes_new_from_slice(96)": "", + " 40 ret bytes_new_from_slice -> Ok(Bytes(obj#27))": "cpu:7287098, mem:12640, objs:-/14@c5da4223", + " 41 call bls12_381_map_fp2_to_g2(Bytes(obj#27))": "", + " 42 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#29))": "cpu:9713160, mem:16256, objs:-/15@fd857683", + " 43 call obj_cmp(Bytes(obj#29), Bytes(obj#25))": "", + " 44 ret obj_cmp -> Ok(0)": "cpu:9713472", + " 45 call bytes_new_from_slice(192)": "", + " 46 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:9714481, mem:16528, objs:-/16@6fb0f894", + " 47 call bytes_new_from_slice(96)": "", + " 48 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:9715466, mem:16704, objs:-/17@2a325ae4", + " 49 call bls12_381_map_fp2_to_g2(Bytes(obj#33))": "", + " 50 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#35))": "cpu:12141528, mem:20320, objs:-/18@7c6c7549", + " 51 call obj_cmp(Bytes(obj#35), Bytes(obj#31))": "", + " 52 ret obj_cmp -> Ok(0)": "cpu:12141840", + " 53 call bytes_new_from_slice(192)": "", + " 54 ret bytes_new_from_slice -> Ok(Bytes(obj#37))": "cpu:12142849, mem:20592, objs:-/19@1fce6840", + " 55 call bytes_new_from_slice(96)": "", + " 56 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:12143834, mem:20768, objs:-/20@be9137c1", + " 57 call bls12_381_map_fp2_to_g2(Bytes(obj#39))": "", + " 58 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#41))": "cpu:14569896, mem:24384, objs:-/21@9c7995a", + " 59 call obj_cmp(Bytes(obj#41), Bytes(obj#37))": "", + " 60 ret obj_cmp -> Ok(0)": "cpu:14570208", + " 61 call bytes_new_from_slice(192)": "", + " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#43))": "cpu:14571217, mem:24656, objs:-/22@78f3899d", + " 63 call bytes_new_from_slice(96)": "", + " 64 ret bytes_new_from_slice -> Ok(Bytes(obj#45))": "cpu:14572202, mem:24832, objs:-/23@e72573e0", + " 65 call bls12_381_map_fp2_to_g2(Bytes(obj#45))": "", + " 66 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#47))": "cpu:16998264, mem:28448, objs:-/24@f38a60c9", + " 67 call obj_cmp(Bytes(obj#47), Bytes(obj#43))": "", + " 68 ret obj_cmp -> Ok(0)": "cpu:16998576", + " 69 call bytes_new_from_slice(192)": "", + " 70 ret bytes_new_from_slice -> Ok(Bytes(obj#49))": "cpu:16999585, mem:28720, objs:-/25@14f7400d", + " 71 call bytes_new_from_slice(96)": "", + " 72 ret bytes_new_from_slice -> Ok(Bytes(obj#51))": "cpu:17000570, mem:28896, objs:-/26@2203764c", + " 73 call bls12_381_map_fp2_to_g2(Bytes(obj#51))": "", + " 74 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#53))": "cpu:19426632, mem:32512, objs:-/27@d5d727e5", + " 75 call obj_cmp(Bytes(obj#53), Bytes(obj#49))": "", + " 76 ret obj_cmp -> Ok(0)": "cpu:19426944", + " 77 call bytes_new_from_slice(192)": "", + " 78 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:19427953, mem:32784, objs:-/28@ef906b0", + " 79 call bytes_new_from_slice(96)": "", + " 80 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:19428938, mem:32960, objs:-/29@851a81a4", + " 81 call bls12_381_map_fp2_to_g2(Bytes(obj#57))": "", + " 82 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#59))": "cpu:21855000, mem:36576, objs:-/30@18e42593", + " 83 call obj_cmp(Bytes(obj#59), Bytes(obj#55))": "", + " 84 ret obj_cmp -> Ok(0)": "cpu:21855312", + " 85 call bytes_new_from_slice(192)": "", + " 86 ret bytes_new_from_slice -> Ok(Bytes(obj#61))": "cpu:21856321, mem:36848, objs:-/31@3b459b2e", + " 87 call bytes_new_from_slice(96)": "", + " 88 ret bytes_new_from_slice -> Ok(Bytes(obj#63))": "cpu:21857306, mem:37024, objs:-/32@9d03f4e3", + " 89 call bls12_381_map_fp2_to_g2(Bytes(obj#63))": "", + " 90 ret bls12_381_map_fp2_to_g2 -> Ok(Bytes(obj#65))": "cpu:24283368, mem:40640, objs:-/33@102db400", + " 91 call obj_cmp(Bytes(obj#65), Bytes(obj#61))": "", + " 92 ret obj_cmp -> Ok(0)": "cpu:24283680", + " 93 end": "cpu:24283680, mem:40640, prngs:-/-, objs:-/33@102db400, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json b/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json new file mode 100644 index 000000000..5fd970a29 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json @@ -0,0 +1,96 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(47)": "cpu:661", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1632, mem:127, objs:-/1@705fbc72", + " 3 call bls12_381_map_fp_to_g1(Bytes(obj#1))": "", + " 4 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:1754", + " 5 call bytes_new_from_slice(49)": "cpu:3076", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:4049, mem:256, objs:-/2@7385e39e", + " 7 call bls12_381_map_fp_to_g1(Bytes(obj#3))": "", + " 8 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:4171", + " 9 call bytes_new_from_slice(48)": "", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:5144, mem:384, objs:-/3@80e43591", + " 11 call bls12_381_map_fp_to_g1(Bytes(obj#5))": "", + " 12 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:6299", + " 13 call bytes_new_from_slice(96)": "cpu:0, mem:0", + " 14 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:985, mem:176, objs:-/4@6bc2aad1", + " 15 call bytes_new_from_slice(48)": "", + " 16 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:1958, mem:304, objs:-/5@5c1201b8", + " 17 call bls12_381_map_fp_to_g1(Bytes(obj#9))": "", + " 18 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#11))": "cpu:1547035, mem:6032, objs:-/6@efa8720b", + " 19 call obj_cmp(Bytes(obj#11), Bytes(obj#7))": "", + " 20 ret obj_cmp -> Ok(0)": "cpu:1547335", + " 21 call bytes_new_from_slice(96)": "", + " 22 ret bytes_new_from_slice -> Ok(Bytes(obj#13))": "cpu:1548320, mem:6208, objs:-/7@a344b20f", + " 23 call bytes_new_from_slice(48)": "", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#15))": "cpu:1549293, mem:6336, objs:-/8@cebe8368", + " 25 call bls12_381_map_fp_to_g1(Bytes(obj#15))": "", + " 26 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#17))": "cpu:3094370, mem:12064, objs:-/9@60d4b257", + " 27 call obj_cmp(Bytes(obj#17), Bytes(obj#13))": "", + " 28 ret obj_cmp -> Ok(0)": "cpu:3094670", + " 29 call bytes_new_from_slice(96)": "", + " 30 ret bytes_new_from_slice -> Ok(Bytes(obj#19))": "cpu:3095655, mem:12240, objs:-/10@c8dd0777", + " 31 call bytes_new_from_slice(48)": "", + " 32 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:3096628, mem:12368, objs:-/11@7ded6720", + " 33 call bls12_381_map_fp_to_g1(Bytes(obj#21))": "", + " 34 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#23))": "cpu:4641705, mem:18096, objs:-/12@b43943ab", + " 35 call obj_cmp(Bytes(obj#23), Bytes(obj#19))": "", + " 36 ret obj_cmp -> Ok(0)": "cpu:4642005", + " 37 call bytes_new_from_slice(96)": "", + " 38 ret bytes_new_from_slice -> Ok(Bytes(obj#25))": "cpu:4642990, mem:18272, objs:-/13@a2684387", + " 39 call bytes_new_from_slice(48)": "", + " 40 ret bytes_new_from_slice -> Ok(Bytes(obj#27))": "cpu:4643963, mem:18400, objs:-/14@715274dc", + " 41 call bls12_381_map_fp_to_g1(Bytes(obj#27))": "", + " 42 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#29))": "cpu:6189040, mem:24128, objs:-/15@10993226", + " 43 call obj_cmp(Bytes(obj#29), Bytes(obj#25))": "", + " 44 ret obj_cmp -> Ok(0)": "cpu:6189340", + " 45 call bytes_new_from_slice(96)": "", + " 46 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:6190325, mem:24304, objs:-/16@6b210d16", + " 47 call bytes_new_from_slice(48)": "", + " 48 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:6191298, mem:24432, objs:-/17@200edbf", + " 49 call bls12_381_map_fp_to_g1(Bytes(obj#33))": "", + " 50 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#35))": "cpu:7736375, mem:30160, objs:-/18@b70ee9ef", + " 51 call obj_cmp(Bytes(obj#35), Bytes(obj#31))": "", + " 52 ret obj_cmp -> Ok(0)": "cpu:7736675", + " 53 call bytes_new_from_slice(96)": "", + " 54 ret bytes_new_from_slice -> Ok(Bytes(obj#37))": "cpu:7737660, mem:30336, objs:-/19@3870175b", + " 55 call bytes_new_from_slice(48)": "", + " 56 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:7738633, mem:30464, objs:-/20@d86aad53", + " 57 call bls12_381_map_fp_to_g1(Bytes(obj#39))": "", + " 58 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#41))": "cpu:9283710, mem:36192, objs:-/21@30c9e1a4", + " 59 call obj_cmp(Bytes(obj#41), Bytes(obj#37))": "", + " 60 ret obj_cmp -> Ok(0)": "cpu:9284010", + " 61 call bytes_new_from_slice(96)": "", + " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#43))": "cpu:9284995, mem:36368, objs:-/22@90cc3e60", + " 63 call bytes_new_from_slice(48)": "", + " 64 ret bytes_new_from_slice -> Ok(Bytes(obj#45))": "cpu:9285968, mem:36496, objs:-/23@e85d1d60", + " 65 call bls12_381_map_fp_to_g1(Bytes(obj#45))": "", + " 66 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#47))": "cpu:10831045, mem:42224, objs:-/24@c6fa6f0c", + " 67 call obj_cmp(Bytes(obj#47), Bytes(obj#43))": "", + " 68 ret obj_cmp -> Ok(0)": "cpu:10831345", + " 69 call bytes_new_from_slice(96)": "", + " 70 ret bytes_new_from_slice -> Ok(Bytes(obj#49))": "cpu:10832330, mem:42400, objs:-/25@53450af3", + " 71 call bytes_new_from_slice(48)": "", + " 72 ret bytes_new_from_slice -> Ok(Bytes(obj#51))": "cpu:10833303, mem:42528, objs:-/26@f5960012", + " 73 call bls12_381_map_fp_to_g1(Bytes(obj#51))": "", + " 74 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#53))": "cpu:12378380, mem:48256, objs:-/27@9d2fb1f6", + " 75 call obj_cmp(Bytes(obj#53), Bytes(obj#49))": "", + " 76 ret obj_cmp -> Ok(0)": "cpu:12378680", + " 77 call bytes_new_from_slice(96)": "", + " 78 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:12379665, mem:48432, objs:-/28@a13fa1a3", + " 79 call bytes_new_from_slice(48)": "", + " 80 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:12380638, mem:48560, objs:-/29@2816bcaf", + " 81 call bls12_381_map_fp_to_g1(Bytes(obj#57))": "", + " 82 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#59))": "cpu:13925715, mem:54288, objs:-/30@7be5db06", + " 83 call obj_cmp(Bytes(obj#59), Bytes(obj#55))": "", + " 84 ret obj_cmp -> Ok(0)": "cpu:13926015", + " 85 call bytes_new_from_slice(96)": "", + " 86 ret bytes_new_from_slice -> Ok(Bytes(obj#61))": "cpu:13927000, mem:54464, objs:-/31@37bc8fe", + " 87 call bytes_new_from_slice(48)": "", + " 88 ret bytes_new_from_slice -> Ok(Bytes(obj#63))": "cpu:13927973, mem:54592, objs:-/32@73973499", + " 89 call bls12_381_map_fp_to_g1(Bytes(obj#63))": "", + " 90 ret bls12_381_map_fp_to_g1 -> Ok(Bytes(obj#65))": "cpu:15473050, mem:60320, objs:-/33@8a8027cd", + " 91 call obj_cmp(Bytes(obj#65), Bytes(obj#61))": "", + " 92 ret obj_cmp -> Ok(0)": "cpu:15473350", + " 93 end": "cpu:15473350, mem:60320, prngs:-/-, objs:-/33@8a8027cd, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__pairing.json b/soroban-env-host/observations/22/test__bls12_381__pairing.json new file mode 100644 index 000000000..3ea23e46d --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__pairing.json @@ -0,0 +1,180 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(96)": "cpu:1322", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:2307, mem:176, objs:-/1@2142c5f5", + " 3 call bytes_new_from_slice(96)": "cpu:3629", + " 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:4614, mem:352, objs:-/2@a5d3f802", + " 5 call bytes_new_from_slice(96)": "cpu:5936", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:6921, mem:528, objs:-/3@d1e19abc", + " 7 call vec_new_from_slice(3)": "", + " 8 ret vec_new_from_slice -> Ok(Vec(obj#7))": "cpu:8071, mem:632, objs:-/4@8244fa30", + " 9 call bytes_new_from_slice(192)": "cpu:10715", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:11724, mem:904, objs:-/5@7db97cd4", + " 11 call bytes_new_from_slice(192)": "cpu:14368", + " 12 ret bytes_new_from_slice -> Ok(Bytes(obj#11))": "cpu:15377, mem:1176, objs:-/6@2f986967", + " 13 call vec_new_from_slice(2)": "", + " 14 ret vec_new_from_slice -> Ok(Vec(obj#13))": "cpu:16464, mem:1272, objs:-/7@e86d844b", + " 15 call bls12_381_multi_pairing_check(Vec(obj#7), Vec(obj#13))": "", + " 16 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:16708", + " 17 call vec_new_from_slice(0)": "", + " 18 ret vec_new_from_slice -> Ok(Vec(obj#15))": "cpu:17669, mem:1352, objs:-/8@aefe5995", + " 19 call vec_new_from_slice(0)": "", + " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:18630, mem:1432, objs:-/9@e19454cb", + " 21 call bls12_381_multi_pairing_check(Vec(obj#15), Vec(obj#17))": "", + " 22 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:18874", + " 23 call bytes_new_from_slice(96)": "cpu:20196", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#19))": "cpu:21181, mem:1608, objs:-/10@d5c411e9", + " 25 call bytes_new_from_slice(96)": "cpu:22503", + " 26 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:23488, mem:1784, objs:-/11@9371ef1d", + " 27 call bytes_new_from_slice(96)": "cpu:24810", + " 28 ret bytes_new_from_slice -> Ok(Bytes(obj#23))": "cpu:25795, mem:1960, objs:-/12@3462be9a", + " 29 call vec_new_from_slice(3)": "", + " 30 ret vec_new_from_slice -> Ok(Vec(obj#25))": "cpu:26945, mem:2064, objs:-/13@21b206a8", + " 31 call vec_put(Vec(obj#25), U32(1), Bytes(obj#27))": "cpu:29252, mem:2240, objs:-/14@211e7ae", + " 32 ret vec_put -> Ok(Vec(obj#29))": "cpu:30506, mem:2344, objs:-/15@d6218c40", + " 33 call bytes_new_from_slice(192)": "cpu:33150", + " 34 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:34159, mem:2616, objs:-/16@1fbd75b9", + " 35 call bytes_new_from_slice(192)": "cpu:36803", + " 36 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:37812, mem:2888, objs:-/17@eb01b50b", + " 37 call vec_new_from_slice(2)": "", + " 38 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:38899, mem:2984, objs:-/18@88878336", + " 39 call bls12_381_multi_pairing_check(Vec(obj#29), Vec(obj#35))": "", + " 40 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:39143", + " 41 call bytes_new_from_slice(96)": "cpu:40465", + " 42 ret bytes_new_from_slice -> Ok(Bytes(obj#37))": "cpu:41450, mem:3160, objs:-/19@bef467b3", + " 43 call bytes_new_from_slice(96)": "cpu:42772", + " 44 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:43757, mem:3336, objs:-/20@7711af03", + " 45 call bytes_new_from_slice(96)": "cpu:45079", + " 46 ret bytes_new_from_slice -> Ok(Bytes(obj#41))": "cpu:46064, mem:3512, objs:-/21@bd0eaa67", + " 47 call vec_new_from_slice(3)": "", + " 48 ret vec_new_from_slice -> Ok(Vec(obj#43))": "cpu:47214, mem:3616, objs:-/22@4745d9cc", + " 49 call bytes_new_from_slice(192)": "cpu:49858", + " 50 ret bytes_new_from_slice -> Ok(Bytes(obj#45))": "cpu:50867, mem:3888, objs:-/23@2ac90b2", + " 51 call bytes_new_from_slice(192)": "cpu:53511", + " 52 ret bytes_new_from_slice -> Ok(Bytes(obj#47))": "cpu:54520, mem:4160, objs:-/24@d104dc23", + " 53 call bytes_new_from_slice(192)": "cpu:57164", + " 54 ret bytes_new_from_slice -> Ok(Bytes(obj#49))": "cpu:58173, mem:4432, objs:-/25@11f7750c", + " 55 call vec_new_from_slice(3)": "", + " 56 ret vec_new_from_slice -> Ok(Vec(obj#51))": "cpu:59323, mem:4536, objs:-/26@ada08c01", + " 57 call vec_put(Vec(obj#51), U32(1), Bytes(obj#53))": "cpu:62976, mem:4808, objs:-/27@f2ac27ac", + " 58 ret vec_put -> Ok(Vec(obj#55))": "cpu:64230, mem:4912, objs:-/28@6d6b0a1", + " 59 call bls12_381_multi_pairing_check(Vec(obj#43), Vec(obj#55))": "", + " 60 call vec_len(Vec(obj#43))": "cpu:64474", + " 61 ret vec_len -> Ok(U32(3))": "cpu:64596", + " 62 call vec_len(Vec(obj#55))": "cpu:2268552, mem:5216", + " 63 ret vec_len -> Ok(U32(3))": "cpu:2268674", + " 64 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:3346907, mem:5808", + " 65 call bls12_381_g2_add(Bytes(obj#61), Bytes(obj#63))": "cpu:746395, mem:896, objs:-/32@be1f7a8e", + " 66 ret bls12_381_g2_add -> Ok(Bytes(obj#65))": "cpu:896024, mem:1168, objs:-/33@9d890a7b", + " 67 call vec_new_from_slice(3)": "", + " 68 ret vec_new_from_slice -> Ok(Vec(obj#67))": "cpu:897174, mem:1272, objs:-/34@7f96f85d", + " 69 call vec_new_from_slice(3)": "", + " 70 ret vec_new_from_slice -> Ok(Vec(obj#69))": "cpu:898324, mem:1376, objs:-/35@66669ec2", + " 71 call bls12_381_multi_pairing_check(Vec(obj#67), Vec(obj#69))": "", + " 72 call vec_len(Vec(obj#67))": "cpu:898568", + " 73 ret vec_len -> Ok(U32(3))": "cpu:898690", + " 74 call vec_len(Vec(obj#69))": "cpu:3102646, mem:1680", + " 75 ret vec_len -> Ok(U32(3))": "cpu:3102768", + " 76 ret bls12_381_multi_pairing_check -> Ok(True)": "cpu:31698309, mem:223393", + " 77 call bls12_381_g1_add(Bytes(obj#71), Bytes(obj#73))": "cpu:1079664, mem:896, objs:-/39@755a50d2", + " 78 ret bls12_381_g1_add -> Ok(Bytes(obj#79))": "cpu:1190415, mem:1072, objs:-/40@ef7b3d9a", + " 79 call vec_new_from_slice(3)": "", + " 80 ret vec_new_from_slice -> Ok(Vec(obj#81))": "cpu:1191565, mem:1176, objs:-/41@8c07b073", + " 81 call vec_new_from_slice(3)": "", + " 82 ret vec_new_from_slice -> Ok(Vec(obj#83))": "cpu:1192715, mem:1280, objs:-/42@371e0485", + " 83 call bls12_381_multi_pairing_check(Vec(obj#81), Vec(obj#83))": "", + " 84 call vec_len(Vec(obj#81))": "cpu:1192959", + " 85 ret vec_len -> Ok(U32(3))": "cpu:1193081", + " 86 call vec_len(Vec(obj#83))": "cpu:3397037, mem:1584", + " 87 ret vec_len -> Ok(U32(3))": "cpu:3397159", + " 88 ret bls12_381_multi_pairing_check -> Ok(True)": "cpu:31992700, mem:223297", + " 89 call obj_from_u256_pieces(6129283836900174032, 16343279146958341100, 9908221645225222661, 8687387636374822629)": "cpu:0, mem:0", + " 90 ret obj_from_u256_pieces -> Ok(U256(obj#85))": "cpu:501, mem:64, objs:-/43@51ce4e80", + " 91 call obj_from_u256_pieces(8164028848054823783, 11448276494886701632, 11152981594053410458, 373243503504028211)": "", + " 92 ret obj_from_u256_pieces -> Ok(U256(obj#87))": "cpu:1002, mem:128, objs:-/44@1d526a4f", + " 93 call bls12_381_g1_mul(Bytes(obj#89), U256(obj#85))": "cpu:1815141, mem:1024, objs:-/48@1b0394df", + " 94 ret bls12_381_g1_mul -> Ok(Bytes(obj#97))": "cpu:5105788, mem:1200, objs:-/49@1c776a4c", + " 95 call bls12_381_g1_mul(Bytes(obj#89), U256(obj#87))": "", + " 96 ret bls12_381_g1_mul -> Ok(Bytes(obj#99))": "cpu:8396435, mem:1376, objs:-/50@3329b7ae", + " 97 call bls12_381_g2_mul(Bytes(obj#93), U256(obj#85))": "", + " 98 ret bls12_381_g2_mul -> Ok(Bytes(obj#101))": "cpu:17444031, mem:1648, objs:-/51@68dc4508", + " 99 call bls12_381_g2_mul(Bytes(obj#93), U256(obj#87))": "", + " 100 ret bls12_381_g2_mul -> Ok(Bytes(obj#103))": "cpu:26491627, mem:1920, objs:-/52@9cf48a9c", + " 101 call bls12_381_fr_mul(U256(obj#85), U256(obj#87))": "", + " 102 call obj_from_u256_pieces(2142470011221189497, 10010429218490043362, 1572835870010363575, 4223291951915259218)": "cpu:26497346, mem:2168", + " 103 ret obj_from_u256_pieces -> Ok(U256(obj#105))": "cpu:26497847, mem:2232, objs:-/53@6b319212", + " 104 ret bls12_381_fr_mul -> Ok(U256(obj#105))": "cpu:26497908", + " 105 call bls12_381_g1_mul(Bytes(obj#89), U256(obj#105))": "", + " 106 ret bls12_381_g1_mul -> Ok(Bytes(obj#107))": "cpu:29788555, mem:2408, objs:-/54@3a87a2a8", + " 107 call bls12_381_g2_mul(Bytes(obj#93), U256(obj#105))": "", + " 108 ret bls12_381_g2_mul -> Ok(Bytes(obj#109))": "cpu:38836151, mem:2680, objs:-/55@4537f126", + " 109 call vec_new_from_slice(4)": "", + " 110 ret vec_new_from_slice -> Ok(Vec(obj#111))": "cpu:38837364, mem:2792, objs:-/56@e347f8a8", + " 111 call vec_new_from_slice(4)": "", + " 112 ret vec_new_from_slice -> Ok(Vec(obj#113))": "cpu:38838577, mem:2904, objs:-/57@cba81af", + " 113 call bls12_381_multi_pairing_check(Vec(obj#111), Vec(obj#113))": "", + " 114 call vec_len(Vec(obj#111))": "cpu:38838821", + " 115 ret vec_len -> Ok(U32(4))": "cpu:38838943", + " 116 call vec_len(Vec(obj#113))": "cpu:41777386, mem:3304", + " 117 ret vec_len -> Ok(U32(4))": "cpu:41777508", + " 118 ret bls12_381_multi_pairing_check -> Ok(True)": "cpu:76385043, mem:298181", + " 119 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 120 ret bytes_new_from_slice -> Ok(Bytes(obj#115))": "cpu:2307, mem:176, objs:-/58@ac299a82", + " 121 call bytes_new_from_slice(96)": "cpu:3629", + " 122 ret bytes_new_from_slice -> Ok(Bytes(obj#117))": "cpu:4614, mem:352, objs:-/59@113198f9", + " 123 call bytes_new_from_slice(96)": "cpu:5936", + " 124 ret bytes_new_from_slice -> Ok(Bytes(obj#119))": "cpu:6921, mem:528, objs:-/60@37eadd60", + " 125 call vec_new_from_slice(3)": "", + " 126 ret vec_new_from_slice -> Ok(Vec(obj#121))": "cpu:8071, mem:632, objs:-/61@b3526a16", + " 127 call vec_put(Vec(obj#121), U32(1), Bytes(obj#123))": "cpu:10378, mem:808, objs:-/62@e4a76af5", + " 128 ret vec_put -> Ok(Vec(obj#125))": "cpu:11632, mem:912, objs:-/63@5b689763", + " 129 call bytes_new_from_slice(192)": "cpu:14276", + " 130 ret bytes_new_from_slice -> Ok(Bytes(obj#127))": "cpu:15285, mem:1184, objs:-/64@8aa5fc15", + " 131 call bytes_new_from_slice(192)": "cpu:17929", + " 132 ret bytes_new_from_slice -> Ok(Bytes(obj#129))": "cpu:18938, mem:1456, objs:-/65@b4fc63e0", + " 133 call bytes_new_from_slice(192)": "cpu:21582", + " 134 ret bytes_new_from_slice -> Ok(Bytes(obj#131))": "cpu:22591, mem:1728, objs:-/66@5c98ecb1", + " 135 call vec_new_from_slice(3)": "", + " 136 ret vec_new_from_slice -> Ok(Vec(obj#133))": "cpu:23741, mem:1832, objs:-/67@3f3912a7", + " 137 call bls12_381_multi_pairing_check(Vec(obj#125), Vec(obj#133))": "", + " 138 call vec_len(Vec(obj#125))": "cpu:23985", + " 139 ret vec_len -> Ok(U32(3))": "cpu:24107", + " 140 call vec_len(Vec(obj#133))": "cpu:2228063, mem:2136", + " 141 ret vec_len -> Ok(U32(3))": "cpu:2228185", + " 142 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30823726, mem:223849", + " 143 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 144 ret bytes_new_from_slice -> Ok(Bytes(obj#135))": "cpu:2307, mem:176, objs:-/68@47cc533a", + " 145 call bytes_new_from_slice(96)": "cpu:3629", + " 146 ret bytes_new_from_slice -> Ok(Bytes(obj#137))": "cpu:4614, mem:352, objs:-/69@9420de5f", + " 147 call bytes_new_from_slice(96)": "cpu:5936", + " 148 ret bytes_new_from_slice -> Ok(Bytes(obj#139))": "cpu:6921, mem:528, objs:-/70@f09a5b7a", + " 149 call vec_new_from_slice(3)": "", + " 150 ret vec_new_from_slice -> Ok(Vec(obj#141))": "cpu:8071, mem:632, objs:-/71@71e61918", + " 151 call bytes_new_from_slice(192)": "cpu:10715", + " 152 ret bytes_new_from_slice -> Ok(Bytes(obj#143))": "cpu:11724, mem:904, objs:-/72@b2c885b9", + " 153 call bytes_new_from_slice(192)": "cpu:14368", + " 154 ret bytes_new_from_slice -> Ok(Bytes(obj#145))": "cpu:15377, mem:1176, objs:-/73@890ee9f4", + " 155 call bytes_new_from_slice(192)": "cpu:18021", + " 156 ret bytes_new_from_slice -> Ok(Bytes(obj#147))": "cpu:19030, mem:1448, objs:-/74@c894f888", + " 157 call vec_new_from_slice(3)": "", + " 158 ret vec_new_from_slice -> Ok(Vec(obj#149))": "cpu:20180, mem:1552, objs:-/75@6f0bc56a", + " 159 call vec_put(Vec(obj#149), U32(2), Bytes(obj#151))": "cpu:23833, mem:1824, objs:-/76@85e20168", + " 160 ret vec_put -> Ok(Vec(obj#153))": "cpu:25087, mem:1928, objs:-/77@35e77666", + " 161 call bls12_381_multi_pairing_check(Vec(obj#141), Vec(obj#153))": "", + " 162 call vec_len(Vec(obj#141))": "cpu:25331", + " 163 ret vec_len -> Ok(U32(3))": "cpu:25453", + " 164 call vec_len(Vec(obj#153))": "cpu:2229409, mem:2232", + " 165 ret vec_len -> Ok(U32(3))": "cpu:2229531", + " 166 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30825072, mem:223945", + " 167 call vec_new_from_slice(5)": "cpu:11535, mem:880, objs:-/82@40297403", + " 168 ret vec_new_from_slice -> Ok(Vec(obj#165))": "cpu:12811, mem:1000, objs:-/83@2d838f8e", + " 169 call vec_new_from_slice(5)": "cpu:31076, mem:2360, objs:-/88@c33dc4c0", + " 170 ret vec_new_from_slice -> Ok(Vec(obj#177))": "cpu:32352, mem:2480, objs:-/89@cb153807", + " 171 call bls12_381_multi_pairing_check(Vec(obj#165), Vec(obj#177))": "", + " 172 call vec_len(Vec(obj#165))": "cpu:32596", + " 173 ret vec_len -> Ok(U32(5))": "cpu:32718", + " 174 call vec_len(Vec(obj#177))": "cpu:3705648, mem:2976", + " 175 ret vec_len -> Ok(U32(5))": "cpu:3705770", + " 176 ret bls12_381_multi_pairing_check -> Ok(True)": "cpu:44325299, mem:371018", + " 177 end": "cpu:44325299, mem:371018, prngs:-/-, objs:-/89@cb153807, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json b/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json new file mode 100644 index 000000000..c726bf0d3 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json @@ -0,0 +1,44 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call obj_from_u256_pieces(2395589458197215953, 3306305587277880961, 1302117398068482837, 1091207826991875146)": "cpu:50772796, mem:28008, objs:-/137@d07a46d8", + " 2 ret obj_from_u256_pieces -> Ok(U256(obj#275))": "cpu:50773297, mem:28072, objs:-/138@99d5e5d2", + " 3 call obj_from_u256_pieces(4030740013859617607, 13817590489558995017, 443594582117458576, 245589856645029399)": "cpu:50776507, mem:28320", + " 4 ret obj_from_u256_pieces -> Ok(U256(obj#277))": "cpu:50777008, mem:28384, objs:-/139@ce81e5d9", + " 5 call obj_from_u256_pieces(2309403286221278731, 240231957602763745, 18358523006851037387, 13739599435256500115)": "cpu:50780218, mem:28632", + " 6 ret obj_from_u256_pieces -> Ok(U256(obj#279))": "cpu:50780719, mem:28696, objs:-/140@279a975", + " 7 call obj_from_u256_pieces(5744460099082395691, 11679559040025848215, 5800079206407269482, 14330949528024819573)": "cpu:50783929, mem:28944", + " 8 ret obj_from_u256_pieces -> Ok(U256(obj#281))": "cpu:50784430, mem:29008, objs:-/141@3f854b89", + " 9 call obj_from_u256_pieces(912784256554815413, 7739630991749586382, 11693624627592045674, 9648884353269389255)": "cpu:50787640, mem:29256", + " 10 ret obj_from_u256_pieces -> Ok(U256(obj#283))": "cpu:50788141, mem:29320, objs:-/142@24879da6", + " 11 call obj_from_u256_pieces(1298169624505566978, 11840534902383509259, 10489044078202748843, 10046771591107357601)": "cpu:50791351, mem:29568", + " 12 ret obj_from_u256_pieces -> Ok(U256(obj#285))": "cpu:50791852, mem:29632, objs:-/143@765f0703", + " 13 call obj_from_u256_pieces(4462537922610993750, 5476907946140276402, 15301198056592352265, 8829090581031049060)": "cpu:50795062, mem:29880", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#287))": "cpu:50795563, mem:29944, objs:-/144@fc5d4293", + " 15 call obj_from_u256_pieces(1483814255270150809, 2240693107019974066, 11035480608488985609, 5591664456856301659)": "cpu:50798773, mem:30192", + " 16 ret obj_from_u256_pieces -> Ok(U256(obj#289))": "cpu:50799274, mem:30256, objs:-/145@3c777c38", + " 17 call obj_from_u256_pieces(2823066946149997955, 4017845098771023863, 2091132495329236295, 4382883068235871617)": "cpu:50802484, mem:30504", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#291))": "cpu:50802985, mem:30568, objs:-/146@5fdd6fd7", + " 19 call obj_from_u256_pieces(8147738635046659263, 10838147310065800303, 9456691195047663294, 4156381095270017721)": "cpu:50806195, mem:30816", + " 20 ret obj_from_u256_pieces -> Ok(U256(obj#293))": "cpu:50806696, mem:30880, objs:-/147@d2116a6", + " 21 call obj_from_u256_pieces(4759692657470168240, 3248115619405505989, 1935398248938956755, 17870100943070610895)": "cpu:50809906, mem:31128", + " 22 ret obj_from_u256_pieces -> Ok(U256(obj#295))": "cpu:50810407, mem:31192, objs:-/148@d3aca663", + " 23 call obj_from_u256_pieces(6299505550503794325, 934313480772554357, 9575559878597866574, 13968606194827052782)": "cpu:50813617, mem:31440", + " 24 ret obj_from_u256_pieces -> Ok(U256(obj#297))": "cpu:50814118, mem:31504, objs:-/149@49b852dc", + " 25 call obj_from_u256_pieces(5154620316501156786, 16487987160575941779, 7214314208877781085, 7991574812575765638)": "cpu:50817328, mem:31752", + " 26 ret obj_from_u256_pieces -> Ok(U256(obj#299))": "cpu:50817829, mem:31816, objs:-/150@9ae0887", + " 27 call obj_from_u256_pieces(532576566866806321, 10721499738797675969, 16215558025196189643, 12632335931862967898)": "cpu:50821039, mem:32064", + " 28 ret obj_from_u256_pieces -> Ok(U256(obj#301))": "cpu:50821540, mem:32128, objs:-/151@22cb95b8", + " 29 call obj_from_u256_pieces(8159131102163283424, 8923210778304361529, 1540766709305171743, 2989208879561351542)": "cpu:50824750, mem:32376", + " 30 ret obj_from_u256_pieces -> Ok(U256(obj#303))": "cpu:50825251, mem:32440, objs:-/152@ed27ba1d", + " 31 call obj_from_u256_pieces(5698022951443837324, 16779749181027918978, 6902233456353033725, 10646855747138121935)": "cpu:50828461, mem:32688", + " 32 ret obj_from_u256_pieces -> Ok(U256(obj#305))": "cpu:50828962, mem:32752, objs:-/153@7d1f6066", + " 33 call obj_from_u256_pieces(3849184316064635501, 8312667462643589578, 14602721145082682090, 4963389936466161700)": "cpu:50832172, mem:33000", + " 34 ret obj_from_u256_pieces -> Ok(U256(obj#307))": "cpu:50832673, mem:33064, objs:-/154@610bedde", + " 35 call obj_from_u256_pieces(6428876429662729984, 1159517746365042179, 5484564165453778753, 15411623082197541403)": "cpu:50835883, mem:33312", + " 36 ret obj_from_u256_pieces -> Ok(U256(obj#309))": "cpu:50836384, mem:33376, objs:-/155@40c4136a", + " 37 call obj_from_u256_pieces(801460342213299702, 9908357551484169280, 1024931740778734376, 6858226285216280857)": "cpu:50839594, mem:33624", + " 38 ret obj_from_u256_pieces -> Ok(U256(obj#311))": "cpu:50840095, mem:33688, objs:-/156@794e1c81", + " 39 call obj_from_u256_pieces(3249626194219012092, 12917896548134785039, 10675741979518937446, 3611643771666195033)": "cpu:50843305, mem:33936", + " 40 ret obj_from_u256_pieces -> Ok(U256(obj#313))": "cpu:50843806, mem:34000, objs:-/157@1912f2a7", + " 41 end": "cpu:50845861, mem:34000, prngs:-/-, objs:-/157@1912f2a7, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__dispatch_with_wrong_arg_type_bls12_381_fr_pow.json b/soroban-env-host/observations/22/test__dispatch__dispatch_with_wrong_arg_type_bls12_381_fr_pow.json new file mode 100644 index 000000000..081a869dd --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__dispatch_with_wrong_arg_type_bls12_381_fr_pow.json @@ -0,0 +1,189 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@ee2a8e42", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@7702446, store:-/1@44b28863, foot:1@e0562551", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@8a59423e", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@678ee693", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@9446281f, auth:1@7c4deece/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@7c4deece/1@df277b72", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@61b4d110", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@c2fce516, foot:2@41772cdd", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@57c1e830", + " 14 push VM:2b3f5537:sym#13()": "cpu:587479, mem:734545, objs:-/8@2400186a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c8503790, auth:2@d20a0cd1/1@b3979d65", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:2b3f5537:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@3e3fd592, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:591938, mem:734720, objs:-/10@4400abd9", + " 22 push VM:2b3f5537:test(U256(123), Address(obj#123))": "cpu:756728, mem:897027, objs:-/11@7661d2, vm:65536@b1cd98b9/2@2f94d90d, stk:1@1a0b9e40, auth:1@b1b428e/-", + " 23 call bls12_381_fr_pow(U256(123), bad:77)": "cpu:759841, mem:897114, objs:1@f40b9f61/11@7661d2, vm:-/-, stk:1@dfe6b788", + " 24 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:760163, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:760785, mem:897130, objs:-/11@7661d2, vm:-/-, stk:-, auth:-/-", + " 26 call call(Address(obj#17), Symbol(test), Vec(obj#23))": "cpu:761225, mem:897194, objs:-/12@a0b8adea", + " 27 push VM:2b3f5537:test(U256(123), False)": "cpu:926015, mem:1059501, objs:-/13@4791a26a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@5dbe5c59, auth:1@73b1caf7/-", + " 28 call bls12_381_fr_pow(U256(123), bad:0)": "cpu:928693, mem:1059564, vm:-/-", + " 29 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:929015, vm:65536@b1cd98b9/2@2f94d90d", + " 30 ret call -> Err(Error(Value, InvalidInput))": "cpu:929637, mem:1059580, vm:-/-, stk:-, auth:-/-", + " 31 call call(Address(obj#17), Symbol(test), Vec(obj#27))": "cpu:930077, mem:1059644, objs:-/14@250ecba4", + " 32 push VM:2b3f5537:test(U256(123), Bytes(obj#123))": "cpu:1094867, mem:1221951, objs:-/15@883288e0, vm:65536@b1cd98b9/2@2f94d90d, stk:1@f274f388, auth:1@3c3a4a50/-", + " 33 call bls12_381_fr_pow(U256(123), bad:72)": "cpu:1097980, mem:1222038, objs:1@1c4ba01b/15@883288e0, vm:-/-, stk:1@31650e05", + " 34 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1098302, vm:65536@b1cd98b9/2@2f94d90d", + " 35 ret call -> Err(Error(Value, InvalidInput))": "cpu:1098924, mem:1222054, objs:-/15@883288e0, vm:-/-, stk:-, auth:-/-", + " 36 call call(Address(obj#17), Symbol(test), Vec(obj#31))": "cpu:1099364, mem:1222118, objs:-/16@8cdb93fd", + " 37 push VM:2b3f5537:test(U256(123), Duration(obj#123))": "cpu:1264154, mem:1384425, objs:-/17@cdd3bb89, vm:65536@b1cd98b9/2@2f94d90d, stk:1@9de7a9b1, auth:1@f34bc5d3/-", + " 38 call bls12_381_fr_pow(U256(123), bad:67)": "cpu:1267267, mem:1384512, objs:1@a2f54a81/17@cdd3bb89, vm:-/-, stk:1@9fd77637", + " 39 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1267589, vm:65536@b1cd98b9/2@2f94d90d", + " 40 ret call -> Err(Error(Value, InvalidInput))": "cpu:1268211, mem:1384528, objs:-/17@cdd3bb89, vm:-/-, stk:-, auth:-/-", + " 41 call call(Address(obj#17), Symbol(test), Vec(obj#35))": "cpu:1268651, mem:1384592, objs:-/18@cd7698b", + " 42 push VM:2b3f5537:test(U256(123), Duration(123))": "cpu:1433441, mem:1546899, objs:-/19@c2f6d067, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c11c667c, auth:1@a916afbc/-", + " 43 call bls12_381_fr_pow(U256(123), bad:31497)": "cpu:1436119, mem:1546962, vm:-/-", + " 44 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1436441, vm:65536@b1cd98b9/2@2f94d90d", + " 45 ret call -> Err(Error(Value, InvalidInput))": "cpu:1437063, mem:1546978, vm:-/-, stk:-, auth:-/-", + " 46 call call(Address(obj#17), Symbol(test), Vec(obj#39))": "cpu:1437503, mem:1547042, objs:-/20@89006a7b", + " 47 push VM:2b3f5537:test(U256(123), Duration(123))": "cpu:1602293, mem:1709349, objs:-/21@c2069291, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c11c667c, auth:1@5fa62d7a/-", + " 48 call bls12_381_fr_pow(U256(123), bad:31497)": "cpu:1604971, mem:1709412, vm:-/-", + " 49 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1605293, vm:65536@b1cd98b9/2@2f94d90d", + " 50 ret call -> Err(Error(Value, InvalidInput))": "cpu:1605915, mem:1709428, vm:-/-, stk:-, auth:-/-", + " 51 call call(Address(obj#17), Symbol(test), Vec(obj#43))": "cpu:1606355, mem:1709492, objs:-/22@e7871f55", + " 52 push VM:2b3f5537:test(U256(123), Error(Context, ExceededLimit))": "cpu:1771145, mem:1871799, objs:-/23@4bf4324a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@d7edf7a4, auth:1@50cfe0e0/-", + " 53 call bls12_381_fr_pow(U256(123), bad:21474836995)": "cpu:1773823, mem:1871862, vm:-/-", + " 54 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1774145, vm:65536@b1cd98b9/2@2f94d90d", + " 55 ret call -> Err(Error(Value, InvalidInput))": "cpu:1774767, mem:1871878, vm:-/-, stk:-, auth:-/-", + " 56 call call(Address(obj#17), Symbol(test), Vec(obj#47))": "cpu:1775207, mem:1871942, objs:-/24@6801d1c3", + " 57 push VM:2b3f5537:test(U256(123), I128(obj#123))": "cpu:1939997, mem:2034249, objs:-/25@99f9e52a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@a22063f8, auth:1@30dfa4bc/-", + " 58 call bls12_381_fr_pow(U256(123), bad:69)": "cpu:1943110, mem:2034336, objs:1@5bb429fc/25@99f9e52a, vm:-/-, stk:1@6a08d9eb", + " 59 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:1943432, vm:65536@b1cd98b9/2@2f94d90d", + " 60 ret call -> Err(Error(Value, InvalidInput))": "cpu:1944054, mem:2034352, objs:-/25@99f9e52a, vm:-/-, stk:-, auth:-/-", + " 61 call call(Address(obj#17), Symbol(test), Vec(obj#51))": "cpu:1944494, mem:2034416, objs:-/26@520697eb", + " 62 push VM:2b3f5537:test(U256(123), I128(-123))": "cpu:2109284, mem:2196723, objs:-/27@711b10f, vm:65536@b1cd98b9/2@2f94d90d, stk:1@49db046f, auth:1@a73502b2/-", + " 63 call bls12_381_fr_pow(U256(123), bad:-31477)": "cpu:2111962, mem:2196786, vm:-/-", + " 64 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2112284, vm:65536@b1cd98b9/2@2f94d90d", + " 65 ret call -> Err(Error(Value, InvalidInput))": "cpu:2112906, mem:2196802, vm:-/-, stk:-, auth:-/-", + " 66 call call(Address(obj#17), Symbol(test), Vec(obj#55))": "cpu:2113346, mem:2196866, objs:-/28@33a546b9", + " 67 push VM:2b3f5537:test(U256(123), I128(-123))": "cpu:2278136, mem:2359173, objs:-/29@756e4359, vm:65536@b1cd98b9/2@2f94d90d, stk:1@49db046f, auth:1@bff751bb/-", + " 68 call bls12_381_fr_pow(U256(123), bad:-31477)": "cpu:2280814, mem:2359236, vm:-/-", + " 69 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2281136, vm:65536@b1cd98b9/2@2f94d90d", + " 70 ret call -> Err(Error(Value, InvalidInput))": "cpu:2281758, mem:2359252, vm:-/-, stk:-, auth:-/-", + " 71 call call(Address(obj#17), Symbol(test), Vec(obj#59))": "cpu:2282198, mem:2359316, objs:-/30@d49ec5dc", + " 72 push VM:2b3f5537:test(U256(123), I256(obj#123))": "cpu:2446988, mem:2521623, objs:-/31@d7c2ce5d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@b6c61a89, auth:1@74ca8f1b/-", + " 73 call bls12_381_fr_pow(U256(123), bad:71)": "cpu:2450101, mem:2521710, objs:1@36f43d1e/31@d7c2ce5d, vm:-/-, stk:1@6e1c4765", + " 74 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2450423, vm:65536@b1cd98b9/2@2f94d90d", + " 75 ret call -> Err(Error(Value, InvalidInput))": "cpu:2451045, mem:2521726, objs:-/31@d7c2ce5d, vm:-/-, stk:-, auth:-/-", + " 76 call call(Address(obj#17), Symbol(test), Vec(obj#63))": "cpu:2451485, mem:2521790, objs:-/32@59d78f9a", + " 77 push VM:2b3f5537:test(U256(123), I256(-123))": "cpu:2616275, mem:2684097, objs:-/33@f7a7bd20, vm:65536@b1cd98b9/2@2f94d90d, stk:1@22e68f45, auth:1@c74f2468/-", + " 78 call bls12_381_fr_pow(U256(123), bad:-31475)": "cpu:2618953, mem:2684160, vm:-/-", + " 79 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2619275, vm:65536@b1cd98b9/2@2f94d90d", + " 80 ret call -> Err(Error(Value, InvalidInput))": "cpu:2619897, mem:2684176, vm:-/-, stk:-, auth:-/-", + " 81 call call(Address(obj#17), Symbol(test), Vec(obj#67))": "cpu:2620337, mem:2684240, objs:-/34@41d07a6a", + " 82 push VM:2b3f5537:test(U256(123), I256(-123))": "cpu:2785127, mem:2846547, objs:-/35@be476162, vm:65536@b1cd98b9/2@2f94d90d, stk:1@22e68f45, auth:1@f20baebf/-", + " 83 call bls12_381_fr_pow(U256(123), bad:-31475)": "cpu:2787805, mem:2846610, vm:-/-", + " 84 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2788127, vm:65536@b1cd98b9/2@2f94d90d", + " 85 ret call -> Err(Error(Value, InvalidInput))": "cpu:2788749, mem:2846626, vm:-/-, stk:-, auth:-/-", + " 86 call call(Address(obj#17), Symbol(test), Vec(obj#71))": "cpu:2789189, mem:2846690, objs:-/36@c6bed2ae", + " 87 push VM:2b3f5537:test(U256(123), I32(-123))": "cpu:2953979, mem:3008997, objs:-/37@57dd2ebf, vm:65536@b1cd98b9/2@2f94d90d, stk:1@4a917a6c, auth:1@1cd815b8/-", + " 88 call bls12_381_fr_pow(U256(123), bad:-528280977403)": "cpu:2956657, mem:3009060, vm:-/-", + " 89 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:2956979, vm:65536@b1cd98b9/2@2f94d90d", + " 90 ret call -> Err(Error(Value, InvalidInput))": "cpu:2957601, mem:3009076, vm:-/-, stk:-, auth:-/-", + " 91 call call(Address(obj#17), Symbol(test), Vec(obj#75))": "cpu:2958041, mem:3009140, objs:-/38@232a4bf2", + " 92 push VM:2b3f5537:test(U256(123), I64(obj#123))": "cpu:3122831, mem:3171447, objs:-/39@f5d59d64, vm:65536@b1cd98b9/2@2f94d90d, stk:1@20216330, auth:1@cf8ac60a/-", + " 93 call bls12_381_fr_pow(U256(123), bad:65)": "cpu:3125944, mem:3171534, objs:1@bc2f994b/39@f5d59d64, vm:-/-, stk:1@102b9221", + " 94 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3126266, vm:65536@b1cd98b9/2@2f94d90d", + " 95 ret call -> Err(Error(Value, InvalidInput))": "cpu:3126888, mem:3171550, objs:-/39@f5d59d64, vm:-/-, stk:-, auth:-/-", + " 96 call call(Address(obj#17), Symbol(test), Vec(obj#79))": "cpu:3127328, mem:3171614, objs:-/40@8a49bbb9", + " 97 push VM:2b3f5537:test(U256(123), I64(-123))": "cpu:3292118, mem:3333921, objs:-/41@4e04f6f7, vm:65536@b1cd98b9/2@2f94d90d, stk:1@ea29419b, auth:1@17f50ed3/-", + " 98 call bls12_381_fr_pow(U256(123), bad:-31481)": "cpu:3294796, mem:3333984, vm:-/-", + " 99 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3295118, vm:65536@b1cd98b9/2@2f94d90d", + " 100 ret call -> Err(Error(Value, InvalidInput))": "cpu:3295740, mem:3334000, vm:-/-, stk:-, auth:-/-", + " 101 call call(Address(obj#17), Symbol(test), Vec(obj#83))": "cpu:3296180, mem:3334064, objs:-/42@ee967d38", + " 102 push VM:2b3f5537:test(U256(123), Map(obj#123))": "cpu:3460970, mem:3496371, objs:-/43@48b070a8, vm:65536@b1cd98b9/2@2f94d90d, stk:1@471f75c, auth:1@9cadbca8/-", + " 103 call bls12_381_fr_pow(U256(123), bad:76)": "cpu:3464083, mem:3496458, objs:1@a940116a/43@48b070a8, vm:-/-, stk:1@949c7975", + " 104 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3464405, vm:65536@b1cd98b9/2@2f94d90d", + " 105 ret call -> Err(Error(Value, InvalidInput))": "cpu:3465027, mem:3496474, objs:-/43@48b070a8, vm:-/-, stk:-, auth:-/-", + " 106 call call(Address(obj#17), Symbol(test), Vec(obj#87))": "cpu:3465467, mem:3496538, objs:-/44@b849daf6", + " 107 push VM:2b3f5537:test(U256(123), String(obj#123))": "cpu:3630257, mem:3658845, objs:-/45@348aa235, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e27164f6, auth:1@bc972186/-", + " 108 call bls12_381_fr_pow(U256(123), bad:73)": "cpu:3633370, mem:3658932, objs:1@a1dcd3f9/45@348aa235, vm:-/-, stk:1@3fcb7902", + " 109 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3633692, vm:65536@b1cd98b9/2@2f94d90d", + " 110 ret call -> Err(Error(Value, InvalidInput))": "cpu:3634314, mem:3658948, objs:-/45@348aa235, vm:-/-, stk:-, auth:-/-", + " 111 call call(Address(obj#17), Symbol(test), Vec(obj#91))": "cpu:3634754, mem:3659012, objs:-/46@bed06ad4", + " 112 push VM:2b3f5537:test(U256(123), Symbol(abc))": "cpu:3799544, mem:3821319, objs:-/47@27195197, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e531bddc, auth:1@430af039/-", + " 113 call bls12_381_fr_pow(U256(123), bad:40495118)": "cpu:3802222, mem:3821382, vm:-/-", + " 114 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3802544, vm:65536@b1cd98b9/2@2f94d90d", + " 115 ret call -> Err(Error(Value, InvalidInput))": "cpu:3803166, mem:3821398, vm:-/-, stk:-, auth:-/-", + " 116 call call(Address(obj#17), Symbol(test), Vec(obj#95))": "cpu:3803606, mem:3821462, objs:-/48@337e4fe2", + " 117 push VM:2b3f5537:test(U256(123), Symbol(obj#123))": "cpu:3968396, mem:3983769, objs:-/49@f6ce0231, vm:65536@b1cd98b9/2@2f94d90d, stk:1@ba78416b, auth:1@1824f0f4/-", + " 118 call bls12_381_fr_pow(U256(123), bad:74)": "cpu:3971509, mem:3983856, objs:1@d6584255/49@f6ce0231, vm:-/-, stk:1@3864bd0d", + " 119 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:3971831, vm:65536@b1cd98b9/2@2f94d90d", + " 120 ret call -> Err(Error(Value, InvalidInput))": "cpu:3972453, mem:3983872, objs:-/49@f6ce0231, vm:-/-, stk:-, auth:-/-", + " 121 call call(Address(obj#17), Symbol(test), Vec(obj#99))": "cpu:3972893, mem:3983936, objs:-/50@7200113f", + " 122 push VM:2b3f5537:test(U256(123), Symbol(abc))": "cpu:4137683, mem:4146243, objs:-/51@1ba7f57, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e531bddc, auth:1@47dc6783/-", + " 123 call bls12_381_fr_pow(U256(123), bad:40495118)": "cpu:4140361, mem:4146306, vm:-/-", + " 124 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4140683, vm:65536@b1cd98b9/2@2f94d90d", + " 125 ret call -> Err(Error(Value, InvalidInput))": "cpu:4141305, mem:4146322, vm:-/-, stk:-, auth:-/-", + " 126 call call(Address(obj#17), Symbol(test), Vec(obj#103))": "cpu:4141745, mem:4146386, objs:-/52@59fd2b41", + " 127 push VM:2b3f5537:test(U256(123), Timepoint(obj#123))": "cpu:4306535, mem:4308693, objs:-/53@5311e197, vm:65536@b1cd98b9/2@2f94d90d, stk:1@fdaa7236, auth:1@5559c1ca/-", + " 128 call bls12_381_fr_pow(U256(123), bad:66)": "cpu:4309648, mem:4308780, objs:1@710f8d02/53@5311e197, vm:-/-, stk:1@2efa2512", + " 129 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4309970, vm:65536@b1cd98b9/2@2f94d90d", + " 130 ret call -> Err(Error(Value, InvalidInput))": "cpu:4310592, mem:4308796, objs:-/53@5311e197, vm:-/-, stk:-, auth:-/-", + " 131 call call(Address(obj#17), Symbol(test), Vec(obj#107))": "cpu:4311032, mem:4308860, objs:-/54@ef0c1bd5", + " 132 push VM:2b3f5537:test(U256(123), Timepoint(123))": "cpu:4475822, mem:4471167, objs:-/55@fb738caa, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e84e9fdd, auth:1@d0636f0/-", + " 133 call bls12_381_fr_pow(U256(123), bad:31496)": "cpu:4478500, mem:4471230, vm:-/-", + " 134 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4478822, vm:65536@b1cd98b9/2@2f94d90d", + " 135 ret call -> Err(Error(Value, InvalidInput))": "cpu:4479444, mem:4471246, vm:-/-, stk:-, auth:-/-", + " 136 call call(Address(obj#17), Symbol(test), Vec(obj#111))": "cpu:4479884, mem:4471310, objs:-/56@d701bbc1", + " 137 push VM:2b3f5537:test(U256(123), Timepoint(123))": "cpu:4644674, mem:4633617, objs:-/57@36ea7849, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e84e9fdd, auth:1@c8a5df3/-", + " 138 call bls12_381_fr_pow(U256(123), bad:31496)": "cpu:4647352, mem:4633680, vm:-/-", + " 139 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4647674, vm:65536@b1cd98b9/2@2f94d90d", + " 140 ret call -> Err(Error(Value, InvalidInput))": "cpu:4648296, mem:4633696, vm:-/-, stk:-, auth:-/-", + " 141 call call(Address(obj#17), Symbol(test), Vec(obj#115))": "cpu:4648736, mem:4633760, objs:-/58@ef16c667", + " 142 push VM:2b3f5537:test(U256(123), U128(obj#123))": "cpu:4813526, mem:4796067, objs:-/59@37b69653, vm:65536@b1cd98b9/2@2f94d90d, stk:1@2a4acbc7, auth:1@4f3765d6/-", + " 143 call bls12_381_fr_pow(U256(123), bad:68)": "cpu:4816639, mem:4796154, objs:1@32400498/59@37b69653, vm:-/-, stk:1@3984fbaa", + " 144 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4816961, vm:65536@b1cd98b9/2@2f94d90d", + " 145 ret call -> Err(Error(Value, InvalidInput))": "cpu:4817583, mem:4796170, objs:-/59@37b69653, vm:-/-, stk:-, auth:-/-", + " 146 call call(Address(obj#17), Symbol(test), Vec(obj#119))": "cpu:4818023, mem:4796234, objs:-/60@5afd1883", + " 147 push VM:2b3f5537:test(U256(123), U128(123))": "cpu:4982813, mem:4958541, objs:-/61@69f3a359, vm:65536@b1cd98b9/2@2f94d90d, stk:1@bbbf2874, auth:1@1ed43931/-", + " 148 call bls12_381_fr_pow(U256(123), bad:31498)": "cpu:4985491, mem:4958604, vm:-/-", + " 149 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:4985813, vm:65536@b1cd98b9/2@2f94d90d", + " 150 ret call -> Err(Error(Value, InvalidInput))": "cpu:4986435, mem:4958620, vm:-/-, stk:-, auth:-/-", + " 151 call call(Address(obj#17), Symbol(test), Vec(obj#123))": "cpu:4986875, mem:4958684, objs:-/62@9da94a32", + " 152 push VM:2b3f5537:test(U256(123), U128(123))": "cpu:5151665, mem:5120991, objs:-/63@5613a95b, vm:65536@b1cd98b9/2@2f94d90d, stk:1@bbbf2874, auth:1@4289d549/-", + " 153 call bls12_381_fr_pow(U256(123), bad:31498)": "cpu:5154343, mem:5121054, vm:-/-", + " 154 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5154665, vm:65536@b1cd98b9/2@2f94d90d", + " 155 ret call -> Err(Error(Value, InvalidInput))": "cpu:5155287, mem:5121070, vm:-/-, stk:-, auth:-/-", + " 156 call call(Address(obj#17), Symbol(test), Vec(obj#127))": "cpu:5155727, mem:5121134, objs:-/64@fb92f288", + " 157 push VM:2b3f5537:test(U256(123), U256(obj#123))": "cpu:5320517, mem:5283441, objs:-/65@53050d38, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c11e4e96, auth:1@b1b6c254/-", + " 158 call bls12_381_fr_pow(U256(123), bad:70)": "cpu:5323630, mem:5283528, objs:1@7546caa9/65@53050d38, vm:-/-, stk:1@19276129", + " 159 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5323952, vm:65536@b1cd98b9/2@2f94d90d", + " 160 ret call -> Err(Error(Value, InvalidInput))": "cpu:5324574, mem:5283544, objs:-/65@53050d38, vm:-/-, stk:-, auth:-/-", + " 161 call call(Address(obj#17), Symbol(test), Vec(obj#131))": "cpu:5325014, mem:5283608, objs:-/66@58173391", + " 162 push VM:2b3f5537:test(U256(123), U256(123))": "cpu:5489804, mem:5445915, objs:-/67@adf71efa, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c20bce88, auth:1@7b356395/-", + " 163 call bls12_381_fr_pow(U256(123), bad:31500)": "cpu:5492482, mem:5445978, vm:-/-", + " 164 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5492804, vm:65536@b1cd98b9/2@2f94d90d", + " 165 ret call -> Err(Error(Value, InvalidInput))": "cpu:5493426, mem:5445994, vm:-/-, stk:-, auth:-/-", + " 166 call call(Address(obj#17), Symbol(test), Vec(obj#135))": "cpu:5493866, mem:5446058, objs:-/68@7de1ddef", + " 167 push VM:2b3f5537:test(U256(123), U256(123))": "cpu:5658656, mem:5608365, objs:-/69@4c535481, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c20bce88, auth:1@a0a66d73/-", + " 168 call bls12_381_fr_pow(U256(123), bad:31500)": "cpu:5661334, mem:5608428, vm:-/-", + " 169 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5661656, vm:65536@b1cd98b9/2@2f94d90d", + " 170 ret call -> Err(Error(Value, InvalidInput))": "cpu:5662278, mem:5608444, vm:-/-, stk:-, auth:-/-", + " 171 call call(Address(obj#17), Symbol(test), Vec(obj#139))": "cpu:5662718, mem:5608508, objs:-/70@b4daaa89", + " 172 push VM:2b3f5537:test(U256(123), U32(123))": "cpu:5827508, mem:5770815, objs:-/71@923921e4, vm:65536@b1cd98b9/2@2f94d90d, stk:1@11a4d572, auth:1@4ffc0bd9/-", + " 173 call bls12_381_fr_pow(U256(123), bad:528280977412)": "cpu:5830186, mem:5770878, vm:-/-", + " 174 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5830508, vm:65536@b1cd98b9/2@2f94d90d", + " 175 ret call -> Err(Error(Value, InvalidInput))": "cpu:5831130, mem:5770894, vm:-/-, stk:-, auth:-/-", + " 176 call call(Address(obj#17), Symbol(test), Vec(obj#143))": "cpu:5831570, mem:5770958, objs:-/72@ed493e2b", + " 177 push VM:2b3f5537:test(U256(123), Vec(obj#123))": "cpu:5996360, mem:5933265, objs:-/73@7b5ee398, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e7192f77, auth:1@3426acce/-", + " 178 call bls12_381_fr_pow(U256(123), bad:75)": "cpu:5999473, mem:5933352, objs:1@2f6908f/73@7b5ee398, vm:-/-, stk:1@647fd49b", + " 179 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:5999795, vm:65536@b1cd98b9/2@2f94d90d", + " 180 ret call -> Err(Error(Value, InvalidInput))": "cpu:6000417, mem:5933368, objs:-/73@7b5ee398, vm:-/-, stk:-, auth:-/-", + " 181 call call(Address(obj#17), Symbol(test), Vec(obj#147))": "cpu:6000857, mem:5933432, objs:-/74@6b281dc8", + " 182 push VM:2b3f5537:test(U256(123), Void)": "cpu:6165647, mem:6095739, objs:-/75@a85e5140, vm:65536@b1cd98b9/2@2f94d90d, stk:1@7fd66ee6, auth:1@be16596e/-", + " 183 call bls12_381_fr_pow(U256(123), bad:2)": "cpu:6168325, mem:6095802, vm:-/-", + " 184 pop VM:2b3f5537:test -> Err(Error(Value, InvalidInput))": "cpu:6168647, vm:65536@b1cd98b9/2@2f94d90d", + " 185 ret call -> Err(Error(Value, InvalidInput))": "cpu:6169269, mem:6095818, vm:-/-, stk:-, auth:-/-", + " 186 end": "cpu:6169269, mem:6095818, prngs:-/9b4a753, objs:-/75@a85e5140, vm:-/-, evt:-, store:-/2@c2fce516, foot:2@41772cdd, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g1_is_in_subgroup_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g1_is_in_subgroup_arg_0.json new file mode 100644 index 000000000..7597b03c9 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g1_is_in_subgroup_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(119)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1036, mem:199, objs:-/1@c9f770fe", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:238338, mem:407206, objs:-/2@bf0b985, store:-/1@838925c0, foot:1@768940e3", + " 5 call bytes_new_from_slice(32)": "cpu:238778, mem:407270, objs:-/3@675c9cba", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:239747, mem:407382, objs:-/4@ad707131", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:242358, mem:407622, objs:-/5@f8f1bd6e, auth:1@2412f106/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:242650", + " 10 call get_ledger_network_id()": "cpu:242700, auth:1@2412f106/1@a72ea64a", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:243730, mem:407734, objs:-/6@b5967da4", + " 12 call symbol_new_from_slice(13)": "cpu:420583, mem:572038, store:-/2@2382484e, foot:2@ed17da78", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:421591, mem:572131, objs:-/7@2fa8e06f", + " 14 push VM:74178e74:sym#13()": "cpu:584594, mem:734257, objs:-/8@b9e5d36d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c3298655, auth:2@a192784a/1@3070549e", + " 15 call symbol_len(Symbol(obj#13))": "cpu:587264, mem:734288", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:587386", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:587490", + " 19 pop VM:74178e74:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:588613, mem:734368, objs:-/9@f8d3daa5, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:589053, mem:734432, objs:-/10@f5cdca2d", + " 22 push VM:74178e74:test(Bytes(obj#123))": "cpu:753837, mem:896718, objs:-/11@b932628a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@de4255ce, auth:1@b1b428e/-", + " 23 call bls12_381_check_g1_is_in_subgroup(Bytes(obj#123))": "cpu:756946, mem:896789, objs:1@1c4ba01b/11@b932628a, vm:-/-, stk:1@e6e04471", + " 24 pop VM:74178e74:test -> Err(Error(Value, InvalidInput))": "cpu:757329, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:757951, mem:896805, objs:-/11@b932628a, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:757951, mem:896805, prngs:-/9b4a753, objs:-/11@b932628a, vm:-/-, evt:-, store:-/2@2382484e, foot:2@ed17da78, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g2_is_in_subgroup_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g2_is_in_subgroup_arg_0.json new file mode 100644 index 000000000..92e174363 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_check_g2_is_in_subgroup_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(119)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1036, mem:199, objs:-/1@d546ce6a", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:238338, mem:407206, objs:-/2@3cb426b8, store:-/1@d4d1a697, foot:1@49975f0c", + " 5 call bytes_new_from_slice(32)": "cpu:238778, mem:407270, objs:-/3@c92ad0f3", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:239747, mem:407382, objs:-/4@1677f9a0", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:242358, mem:407622, objs:-/5@e71e7d65, auth:1@d47c12f4/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:242650", + " 10 call get_ledger_network_id()": "cpu:242700, auth:1@d47c12f4/1@a56cfc68", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:243730, mem:407734, objs:-/6@bd5fc117", + " 12 call symbol_new_from_slice(13)": "cpu:420583, mem:572038, store:-/2@34b5472, foot:2@eabf0af1", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:421591, mem:572131, objs:-/7@9fde93ce", + " 14 push VM:e40d19d0:sym#13()": "cpu:584594, mem:734257, objs:-/8@7fb4019d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@81d4373c, auth:2@d137dd4d/1@e2f2ee2e", + " 15 call symbol_len(Symbol(obj#13))": "cpu:587264, mem:734288", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:587386", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:587490", + " 19 pop VM:e40d19d0:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:588613, mem:734368, objs:-/9@b5be1093, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:589053, mem:734432, objs:-/10@3259d82c", + " 22 push VM:e40d19d0:test(Bytes(obj#123))": "cpu:753837, mem:896718, objs:-/11@e7e2a007, vm:65536@b1cd98b9/2@2f94d90d, stk:1@35cce9a8, auth:1@b1b428e/-", + " 23 call bls12_381_check_g2_is_in_subgroup(Bytes(obj#123))": "cpu:756946, mem:896789, objs:1@1c4ba01b/11@e7e2a007, vm:-/-, stk:1@d71170c8", + " 24 pop VM:e40d19d0:test -> Err(Error(Value, InvalidInput))": "cpu:757329, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:757951, mem:896805, objs:-/11@e7e2a007, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:757951, mem:896805, prngs:-/9b4a753, objs:-/11@e7e2a007, vm:-/-, evt:-, store:-/2@34b5472, foot:2@eabf0af1, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_0.json new file mode 100644 index 000000000..fdf28fa99 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@5d68d0ec", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@112afdc, store:-/1@67d4280, foot:1@56c7efdd", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@b9248f03", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@b026096d", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@4e4d6241, auth:1@38bf146a/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@38bf146a/1@43383b03", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@1de0a5d5", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@a597cdd5, foot:2@d720294f", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@b66d50c5", + " 14 push VM:3e9df894:sym#13()": "cpu:587479, mem:734545, objs:-/8@c841d678, vm:65536@b1cd98b9/2@2f94d90d, stk:1@b3c58ecc, auth:2@3c0501b4/1@d7a73daf", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:3e9df894:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@297bd2cf, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@31a2ee4f", + " 22 push VM:3e9df894:test(Bytes(obj#123), Bytes(obj#19))": "cpu:757168, mem:897091, objs:-/12@921f8b7d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@f7634505, auth:1@2eefa960/-", + " 23 call bls12_381_g1_add(Bytes(obj#123), Bytes(obj#19))": "cpu:760716, mem:897202, objs:2@8ea461ac/12@921f8b7d, vm:-/-, stk:1@7585e993", + " 24 pop VM:3e9df894:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@921f8b7d, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@921f8b7d, vm:-/-, evt:-, store:-/2@a597cdd5, foot:2@d720294f, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_1.json new file mode 100644 index 000000000..3cdf40853 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_add_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@5d68d0ec", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@112afdc, store:-/1@67d4280, foot:1@56c7efdd", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@b9248f03", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@b026096d", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@4e4d6241, auth:1@38bf146a/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@38bf146a/1@43383b03", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@1de0a5d5", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@a597cdd5, foot:2@d720294f", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@b66d50c5", + " 14 push VM:3e9df894:sym#13()": "cpu:587479, mem:734545, objs:-/8@c841d678, vm:65536@b1cd98b9/2@2f94d90d, stk:1@b3c58ecc, auth:2@3c0501b4/1@d7a73daf", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:3e9df894:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@297bd2cf, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@85e72125", + " 22 push VM:3e9df894:test(Bytes(obj#19), Bytes(obj#123))": "cpu:757168, mem:897091, objs:-/12@639077a6, vm:65536@b1cd98b9/2@2f94d90d, stk:1@9f17acf0, auth:1@2eefa960/-", + " 23 call bls12_381_g1_add(Bytes(obj#19), Bytes(obj#123))": "cpu:760716, mem:897202, objs:2@ed767fd2/12@639077a6, vm:-/-, stk:1@1809fc43", + " 24 pop VM:3e9df894:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@639077a6, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@639077a6, vm:-/-, evt:-, store:-/2@a597cdd5, foot:2@d720294f, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_0.json new file mode 100644 index 000000000..4d3c746ff --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@8207fc2e", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@b527cf6f, store:-/1@d6941a6c, foot:1@db252443", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@e7eb580e", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@1c4eeb54", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@c2214f05, auth:1@4e5a1000/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@4e5a1000/1@c6fa402d", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@96b16f1b", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@b6749551, foot:2@ce4fd972", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@82c7fef5", + " 14 push VM:d6c11929:sym#13()": "cpu:587479, mem:734545, objs:-/8@692603f6, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c8793e8b, auth:2@c4b1589c/1@388ad566", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:d6c11929:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@c0e8d59f, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@4de767d9", + " 22 push VM:d6c11929:test(Vec(obj#123), Vec(obj#19))": "cpu:757168, mem:897091, objs:-/12@8047496, vm:65536@b1cd98b9/2@2f94d90d, stk:1@f06fc4fa, auth:1@2eefa960/-", + " 23 call bls12_381_g1_msm(Vec(obj#123), Vec(obj#19))": "cpu:760716, mem:897202, objs:2@7a88623e/12@8047496, vm:-/-, stk:1@74bfb527", + " 24 pop VM:d6c11929:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@8047496, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@8047496, vm:-/-, evt:-, store:-/2@b6749551, foot:2@ce4fd972, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_1.json new file mode 100644 index 000000000..6feb71092 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_msm_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@8207fc2e", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@b527cf6f, store:-/1@d6941a6c, foot:1@db252443", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@e7eb580e", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@1c4eeb54", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@c2214f05, auth:1@4e5a1000/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@4e5a1000/1@c6fa402d", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@96b16f1b", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@b6749551, foot:2@ce4fd972", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@82c7fef5", + " 14 push VM:d6c11929:sym#13()": "cpu:587479, mem:734545, objs:-/8@692603f6, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c8793e8b, auth:2@c4b1589c/1@388ad566", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:d6c11929:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@c0e8d59f, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@796751a", + " 22 push VM:d6c11929:test(Vec(obj#19), Vec(obj#123))": "cpu:757168, mem:897091, objs:-/12@64dae596, vm:65536@b1cd98b9/2@2f94d90d, stk:1@2d70e88b, auth:1@2eefa960/-", + " 23 call bls12_381_g1_msm(Vec(obj#19), Vec(obj#123))": "cpu:760716, mem:897202, objs:2@9973ea16/12@64dae596, vm:-/-, stk:1@e3b9ce4", + " 24 pop VM:d6c11929:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@64dae596, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@64dae596, vm:-/-, evt:-, store:-/2@b6749551, foot:2@ce4fd972, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_mul_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_mul_arg_0.json new file mode 100644 index 000000000..82f63331c --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g1_mul_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@9b8a909c", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@efeb3f54, store:-/1@bb858fb7, foot:1@ece417a3", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@2749e8d4", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@80f7841", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@716a7b39, auth:1@2b0e5b7c/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@2b0e5b7c/1@3837d243", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@db65c405", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@f83a6a57, foot:2@36710152", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@74b3709d", + " 14 push VM:9260878f:sym#13()": "cpu:587479, mem:734545, objs:-/8@8001ceb9, vm:65536@b1cd98b9/2@2f94d90d, stk:1@ef4afa91, auth:2@17fa48bc/1@34e27ae0", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:9260878f:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@f82a37ee, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:591938, mem:734720, objs:-/10@5b1f2a50", + " 22 push VM:9260878f:test(Bytes(obj#123), U256(123))": "cpu:756728, mem:897027, objs:-/11@f1eaa65a, vm:65536@b1cd98b9/2@2f94d90d, stk:1@be7b2e10, auth:1@b1b428e/-", + " 23 call bls12_381_g1_mul(Bytes(obj#123), U256(123))": "cpu:759841, mem:897114, objs:1@1c4ba01b/11@f1eaa65a, vm:-/-, stk:1@e874a835", + " 24 pop VM:9260878f:test -> Err(Error(Value, InvalidInput))": "cpu:760224, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:760846, mem:897130, objs:-/11@f1eaa65a, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:760846, mem:897130, prngs:-/9b4a753, objs:-/11@f1eaa65a, vm:-/-, evt:-, store:-/2@f83a6a57, foot:2@36710152, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_0.json new file mode 100644 index 000000000..58d897ea6 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@6167eb8f", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@b1018bfd, store:-/1@11c14a63, foot:1@4b225d08", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@92324", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@96b271b6", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@b746160c, auth:1@67d60a88/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@67d60a88/1@5e9ab55d", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@6daa9397", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@cf024a3a, foot:2@bed7dcee", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@2b632d", + " 14 push VM:8fe91e5e:sym#13()": "cpu:587479, mem:734545, objs:-/8@17db6ce6, vm:65536@b1cd98b9/2@2f94d90d, stk:1@a8dbb6d2, auth:2@411fe97a/1@100968af", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:8fe91e5e:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@f9a550b8, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@e722a5e6", + " 22 push VM:8fe91e5e:test(Bytes(obj#123), Bytes(obj#19))": "cpu:757168, mem:897091, objs:-/12@5fce79bd, vm:65536@b1cd98b9/2@2f94d90d, stk:1@f351c6e7, auth:1@2eefa960/-", + " 23 call bls12_381_g2_add(Bytes(obj#123), Bytes(obj#19))": "cpu:760716, mem:897202, objs:2@8ea461ac/12@5fce79bd, vm:-/-, stk:1@8a166343", + " 24 pop VM:8fe91e5e:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@5fce79bd, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@5fce79bd, vm:-/-, evt:-, store:-/2@cf024a3a, foot:2@bed7dcee, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_1.json new file mode 100644 index 000000000..ea8f359c5 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_add_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@6167eb8f", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@b1018bfd, store:-/1@11c14a63, foot:1@4b225d08", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@92324", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@96b271b6", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@b746160c, auth:1@67d60a88/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@67d60a88/1@5e9ab55d", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@6daa9397", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@cf024a3a, foot:2@bed7dcee", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@2b632d", + " 14 push VM:8fe91e5e:sym#13()": "cpu:587479, mem:734545, objs:-/8@17db6ce6, vm:65536@b1cd98b9/2@2f94d90d, stk:1@a8dbb6d2, auth:2@411fe97a/1@100968af", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:8fe91e5e:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@f9a550b8, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@d0faed5f", + " 22 push VM:8fe91e5e:test(Bytes(obj#19), Bytes(obj#123))": "cpu:757168, mem:897091, objs:-/12@574f71d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@1cc86925, auth:1@2eefa960/-", + " 23 call bls12_381_g2_add(Bytes(obj#19), Bytes(obj#123))": "cpu:760716, mem:897202, objs:2@ed767fd2/12@574f71d, vm:-/-, stk:1@976430e", + " 24 pop VM:8fe91e5e:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@574f71d, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@574f71d, vm:-/-, evt:-, store:-/2@cf024a3a, foot:2@bed7dcee, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_0.json new file mode 100644 index 000000000..54bdc1f65 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@e652b341", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@4e24e8fb, store:-/1@4ee9a390, foot:1@6258bc59", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@b2b8465f", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@55fdb8e6", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@6789640d, auth:1@a28d2bc5/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@a28d2bc5/1@afc282f7", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@5675844f", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@8d1aad92, foot:2@67664879", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@51a69b40", + " 14 push VM:319e95a6:sym#13()": "cpu:587479, mem:734545, objs:-/8@8619fff, vm:65536@b1cd98b9/2@2f94d90d, stk:1@3c77e611, auth:2@bc67f9ed/1@918ae649", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:319e95a6:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@de342357, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@814912ba", + " 22 push VM:319e95a6:test(Vec(obj#123), Vec(obj#19))": "cpu:757168, mem:897091, objs:-/12@3dfed9dc, vm:65536@b1cd98b9/2@2f94d90d, stk:1@b8b43733, auth:1@2eefa960/-", + " 23 call bls12_381_g2_msm(Vec(obj#123), Vec(obj#19))": "cpu:760716, mem:897202, objs:2@7a88623e/12@3dfed9dc, vm:-/-, stk:1@ee49b90b", + " 24 pop VM:319e95a6:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@3dfed9dc, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@3dfed9dc, vm:-/-, evt:-, store:-/2@8d1aad92, foot:2@67664879, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_1.json new file mode 100644 index 000000000..d825c1e0a --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_msm_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@e652b341", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@4e24e8fb, store:-/1@4ee9a390, foot:1@6258bc59", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@b2b8465f", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@55fdb8e6", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@6789640d, auth:1@a28d2bc5/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@a28d2bc5/1@afc282f7", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@5675844f", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@8d1aad92, foot:2@67664879", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@51a69b40", + " 14 push VM:319e95a6:sym#13()": "cpu:587479, mem:734545, objs:-/8@8619fff, vm:65536@b1cd98b9/2@2f94d90d, stk:1@3c77e611, auth:2@bc67f9ed/1@918ae649", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:319e95a6:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@de342357, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@51ea2938", + " 22 push VM:319e95a6:test(Vec(obj#19), Vec(obj#123))": "cpu:757168, mem:897091, objs:-/12@ac53dc9e, vm:65536@b1cd98b9/2@2f94d90d, stk:1@5f008a3d, auth:1@2eefa960/-", + " 23 call bls12_381_g2_msm(Vec(obj#19), Vec(obj#123))": "cpu:760716, mem:897202, objs:2@9973ea16/12@ac53dc9e, vm:-/-, stk:1@6b699e14", + " 24 pop VM:319e95a6:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@ac53dc9e, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@ac53dc9e, vm:-/-, evt:-, store:-/2@8d1aad92, foot:2@67664879, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_mul_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_mul_arg_0.json new file mode 100644 index 000000000..5a88c08bb --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_g2_mul_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@89b18d4b", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@7e0b4596, store:-/1@dcba5044, foot:1@a784cda9", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@370751dc", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@ca695cc5", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@843d5e7f, auth:1@e4e77220/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@e4e77220/1@f3db61e8", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@9e2f6be", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@bd111451, foot:2@6b72f996", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@ab40979f", + " 14 push VM:3cab0db3:sym#13()": "cpu:587479, mem:734545, objs:-/8@88bbdc87, vm:65536@b1cd98b9/2@2f94d90d, stk:1@c16193c4, auth:2@d19f3515/1@40bd648", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:3cab0db3:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@6415ceab, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:591938, mem:734720, objs:-/10@6b38bd7a", + " 22 push VM:3cab0db3:test(Bytes(obj#123), U256(123))": "cpu:756728, mem:897027, objs:-/11@75a0aac4, vm:65536@b1cd98b9/2@2f94d90d, stk:1@384951df, auth:1@b1b428e/-", + " 23 call bls12_381_g2_mul(Bytes(obj#123), U256(123))": "cpu:759841, mem:897114, objs:1@1c4ba01b/11@75a0aac4, vm:-/-, stk:1@eb76d12a", + " 24 pop VM:3cab0db3:test -> Err(Error(Value, InvalidInput))": "cpu:760224, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:760846, mem:897130, objs:-/11@75a0aac4, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:760846, mem:897130, prngs:-/9b4a753, objs:-/11@75a0aac4, vm:-/-, evt:-, store:-/2@bd111451, foot:2@6b72f996, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_0.json new file mode 100644 index 000000000..0175854f5 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@30ac6ca", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@cf3f5ffd, store:-/1@95396a6f, foot:1@ece7f129", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@2dc86a0e", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@6a505c46", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@c72afdf2, auth:1@4991ced0/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@4991ced0/1@3bc292ca", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@fa0fc22c", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@1d2f22b, foot:2@abcef20", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@b17519b5", + " 14 push VM:52dc4818:sym#13()": "cpu:587479, mem:734545, objs:-/8@aeed3c03, vm:65536@b1cd98b9/2@2f94d90d, stk:1@ec066dcc, auth:2@eb7ae117/1@5c17c4ff", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:52dc4818:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@de84d879, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@6a04878", + " 22 push VM:52dc4818:test(Bytes(obj#123), Bytes(obj#19))": "cpu:757168, mem:897091, objs:-/12@ab72633d, vm:65536@b1cd98b9/2@2f94d90d, stk:1@50179a96, auth:1@2eefa960/-", + " 23 call bls12_381_hash_to_g1(Bytes(obj#123), Bytes(obj#19))": "cpu:760716, mem:897202, objs:2@8ea461ac/12@ab72633d, vm:-/-, stk:1@6d14dc67", + " 24 pop VM:52dc4818:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@ab72633d, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@ab72633d, vm:-/-, evt:-, store:-/2@1d2f22b, foot:2@abcef20, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_1.json new file mode 100644 index 000000000..475699798 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g1_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@30ac6ca", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@cf3f5ffd, store:-/1@95396a6f, foot:1@ece7f129", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@2dc86a0e", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@6a505c46", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@c72afdf2, auth:1@4991ced0/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@4991ced0/1@3bc292ca", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@fa0fc22c", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@1d2f22b, foot:2@abcef20", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@b17519b5", + " 14 push VM:52dc4818:sym#13()": "cpu:587479, mem:734545, objs:-/8@aeed3c03, vm:65536@b1cd98b9/2@2f94d90d, stk:1@ec066dcc, auth:2@eb7ae117/1@5c17c4ff", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:52dc4818:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@de84d879, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@5c0401b8", + " 22 push VM:52dc4818:test(Bytes(obj#19), Bytes(obj#123))": "cpu:757168, mem:897091, objs:-/12@32f0a095, vm:65536@b1cd98b9/2@2f94d90d, stk:1@65867f62, auth:1@2eefa960/-", + " 23 call bls12_381_hash_to_g1(Bytes(obj#19), Bytes(obj#123))": "cpu:760716, mem:897202, objs:2@ed767fd2/12@32f0a095, vm:-/-, stk:1@df0c3cdc", + " 24 pop VM:52dc4818:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@32f0a095, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@32f0a095, vm:-/-, evt:-, store:-/2@1d2f22b, foot:2@abcef20, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_0.json new file mode 100644 index 000000000..daa5fe5b3 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@a3d71a79", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@f73a0b6, store:-/1@b7eed210, foot:1@e5f26416", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@1ae579a3", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@ce4f9f74", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@77a4563f, auth:1@ce7e628a/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@ce7e628a/1@9f6132e2", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@cfcb25b8", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@6540d0cf, foot:2@909af309", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@ef0db824", + " 14 push VM:41168af6:sym#13()": "cpu:587479, mem:734545, objs:-/8@38ad3738, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e22b2fe2, auth:2@59bce04f/1@531567a2", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:41168af6:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@884ebe5c, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@4da4ad09", + " 22 push VM:41168af6:test(Bytes(obj#123), Bytes(obj#19))": "cpu:757168, mem:897091, objs:-/12@2b2104f9, vm:65536@b1cd98b9/2@2f94d90d, stk:1@b9df823b, auth:1@2eefa960/-", + " 23 call bls12_381_hash_to_g2(Bytes(obj#123), Bytes(obj#19))": "cpu:760716, mem:897202, objs:2@8ea461ac/12@2b2104f9, vm:-/-, stk:1@b9fab20c", + " 24 pop VM:41168af6:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@2b2104f9, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@2b2104f9, vm:-/-, evt:-, store:-/2@6540d0cf, foot:2@909af309, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_1.json new file mode 100644 index 000000000..2aa15b5ec --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_hash_to_g2_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@a3d71a79", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@f73a0b6, store:-/1@b7eed210, foot:1@e5f26416", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@1ae579a3", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@ce4f9f74", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@77a4563f, auth:1@ce7e628a/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@ce7e628a/1@9f6132e2", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@cfcb25b8", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@6540d0cf, foot:2@909af309", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@ef0db824", + " 14 push VM:41168af6:sym#13()": "cpu:587479, mem:734545, objs:-/8@38ad3738, vm:65536@b1cd98b9/2@2f94d90d, stk:1@e22b2fe2, auth:2@59bce04f/1@531567a2", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:41168af6:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@884ebe5c, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@fcbf8cfa", + " 22 push VM:41168af6:test(Bytes(obj#19), Bytes(obj#123))": "cpu:757168, mem:897091, objs:-/12@c3ff94f, vm:65536@b1cd98b9/2@2f94d90d, stk:1@5efb6b27, auth:1@2eefa960/-", + " 23 call bls12_381_hash_to_g2(Bytes(obj#19), Bytes(obj#123))": "cpu:760716, mem:897202, objs:2@ed767fd2/12@c3ff94f, vm:-/-, stk:1@49b6164c", + " 24 pop VM:41168af6:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@c3ff94f, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@c3ff94f, vm:-/-, evt:-, store:-/2@6540d0cf, foot:2@909af309, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp2_to_g2_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp2_to_g2_arg_0.json new file mode 100644 index 000000000..d88970398 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp2_to_g2_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(119)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1036, mem:199, objs:-/1@d770cd8a", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:238338, mem:407206, objs:-/2@eded1f6c, store:-/1@ec5141ab, foot:1@61a18f1a", + " 5 call bytes_new_from_slice(32)": "cpu:238778, mem:407270, objs:-/3@f47c58ad", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:239747, mem:407382, objs:-/4@acbb857f", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:242358, mem:407622, objs:-/5@ce048f67, auth:1@fb53f8ab/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:242650", + " 10 call get_ledger_network_id()": "cpu:242700, auth:1@fb53f8ab/1@305cb2bf", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:243730, mem:407734, objs:-/6@cbaf3a7d", + " 12 call symbol_new_from_slice(13)": "cpu:420583, mem:572038, store:-/2@eb983604, foot:2@5ef8e17e", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:421591, mem:572131, objs:-/7@f6a82a3b", + " 14 push VM:f08eed4a:sym#13()": "cpu:584594, mem:734257, objs:-/8@371aa4b1, vm:65536@b1cd98b9/2@2f94d90d, stk:1@20986787, auth:2@2ce95641/1@52412d7", + " 15 call symbol_len(Symbol(obj#13))": "cpu:587264, mem:734288", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:587386", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:587490", + " 19 pop VM:f08eed4a:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:588613, mem:734368, objs:-/9@6b3236f5, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:589053, mem:734432, objs:-/10@2f2d60a5", + " 22 push VM:f08eed4a:test(Bytes(obj#123))": "cpu:753837, mem:896718, objs:-/11@bc3b7105, vm:65536@b1cd98b9/2@2f94d90d, stk:1@40eda9e1, auth:1@b1b428e/-", + " 23 call bls12_381_map_fp2_to_g2(Bytes(obj#123))": "cpu:756946, mem:896789, objs:1@1c4ba01b/11@bc3b7105, vm:-/-, stk:1@456f0032", + " 24 pop VM:f08eed4a:test -> Err(Error(Value, InvalidInput))": "cpu:757329, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:757951, mem:896805, objs:-/11@bc3b7105, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:757951, mem:896805, prngs:-/9b4a753, objs:-/11@bc3b7105, vm:-/-, evt:-, store:-/2@eb983604, foot:2@5ef8e17e, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp_to_g1_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp_to_g1_arg_0.json new file mode 100644 index 000000000..7ef3a5086 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_map_fp_to_g1_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(119)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1036, mem:199, objs:-/1@f54d47a1", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:238338, mem:407206, objs:-/2@17213953, store:-/1@e381693d, foot:1@233b617b", + " 5 call bytes_new_from_slice(32)": "cpu:238778, mem:407270, objs:-/3@93532cdb", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:239747, mem:407382, objs:-/4@6770c1d6", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:242358, mem:407622, objs:-/5@d6919c84, auth:1@c2559472/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:242650", + " 10 call get_ledger_network_id()": "cpu:242700, auth:1@c2559472/1@25e926c2", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:243730, mem:407734, objs:-/6@9000238e", + " 12 call symbol_new_from_slice(13)": "cpu:420583, mem:572038, store:-/2@f7c56d83, foot:2@923e3ff5", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:421591, mem:572131, objs:-/7@ac019723", + " 14 push VM:b68ab99e:sym#13()": "cpu:584594, mem:734257, objs:-/8@7f147d92, vm:65536@b1cd98b9/2@2f94d90d, stk:1@cd220379, auth:2@76da15a5/1@469a428a", + " 15 call symbol_len(Symbol(obj#13))": "cpu:587264, mem:734288", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:587386", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:587490", + " 19 pop VM:b68ab99e:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:588613, mem:734368, objs:-/9@290dbeb, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#19))": "cpu:589053, mem:734432, objs:-/10@5c9b2bc7", + " 22 push VM:b68ab99e:test(Bytes(obj#123))": "cpu:753837, mem:896718, objs:-/11@bed2c221, vm:65536@b1cd98b9/2@2f94d90d, stk:1@156d6d26, auth:1@b1b428e/-", + " 23 call bls12_381_map_fp_to_g1(Bytes(obj#123))": "cpu:756946, mem:896789, objs:1@1c4ba01b/11@bed2c221, vm:-/-, stk:1@23ea204", + " 24 pop VM:b68ab99e:test -> Err(Error(Value, InvalidInput))": "cpu:757329, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:757951, mem:896805, objs:-/11@bed2c221, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:757951, mem:896805, prngs:-/9b4a753, objs:-/11@bed2c221, vm:-/-, evt:-, store:-/2@f7c56d83, foot:2@923e3ff5, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_0.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_0.json new file mode 100644 index 000000000..67fb18447 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_0.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@8a54d213", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@f66e0e1e, store:-/1@feb40b8d, foot:1@b8ba8b4e", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@58798b9b", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@7768e183", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@48dd7797, auth:1@29475bf7/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@29475bf7/1@6597d098", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@fca73d8b", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@a3e9e625, foot:2@dac64e91", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@cc82198d", + " 14 push VM:5c8378ed:sym#13()": "cpu:587479, mem:734545, objs:-/8@80a8aa57, vm:65536@b1cd98b9/2@2f94d90d, stk:1@bf4bb881, auth:2@fc57efd9/1@ac4ec361", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:5c8378ed:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@489e2401, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@3b357db9", + " 22 push VM:5c8378ed:test(Vec(obj#123), Vec(obj#19))": "cpu:757168, mem:897091, objs:-/12@d1225fbb, vm:65536@b1cd98b9/2@2f94d90d, stk:1@955c972, auth:1@2eefa960/-", + " 23 call bls12_381_multi_pairing_check(Vec(obj#123), Vec(obj#19))": "cpu:760716, mem:897202, objs:2@7a88623e/12@d1225fbb, vm:-/-, stk:1@2cad9299", + " 24 pop VM:5c8378ed:test -> Err(Error(Value, InvalidInput))": "cpu:761099, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761721, mem:897218, objs:-/12@d1225fbb, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761721, mem:897218, prngs:-/9b4a753, objs:-/12@d1225fbb, vm:-/-, evt:-, store:-/2@a3e9e625, foot:2@dac64e91, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_1.json b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_1.json new file mode 100644 index 000000000..b2405a593 --- /dev/null +++ b/soroban-env-host/observations/22/test__dispatch__invalid_object_handle_bls12_381_multi_pairing_check_arg_1.json @@ -0,0 +1,29 @@ +{ + " 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call bytes_new_from_slice(122)": "cpu:47", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1038, mem:202, objs:-/1@8a54d213", + " 3 call upload_wasm(Bytes(obj#1))": "", + " 4 ret upload_wasm -> Ok(Bytes(obj#3))": "cpu:241219, mem:407484, objs:-/2@f66e0e1e, store:-/1@feb40b8d, foot:1@b8ba8b4e", + " 5 call bytes_new_from_slice(32)": "cpu:241659, mem:407548, objs:-/3@58798b9b", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:242628, mem:407660, objs:-/4@7768e183", + " 7 call create_contract(Address(obj#5), Bytes(obj#3), Bytes(obj#7))": "", + " 8 call obj_cmp(Address(obj#9), Address(obj#5))": "cpu:245239, mem:407900, objs:-/5@48dd7797, auth:1@29475bf7/-", + " 9 ret obj_cmp -> Ok(0)": "cpu:245531", + " 10 call get_ledger_network_id()": "cpu:245581, auth:1@29475bf7/1@6597d098", + " 11 ret get_ledger_network_id -> Ok(Bytes(obj#11))": "cpu:246611, mem:408012, objs:-/6@fca73d8b", + " 12 call symbol_new_from_slice(13)": "cpu:423466, mem:572321, store:-/2@a3e9e625, foot:2@dac64e91", + " 13 ret symbol_new_from_slice -> Ok(Symbol(obj#13))": "cpu:424474, mem:572414, objs:-/7@cc82198d", + " 14 push VM:5c8378ed:sym#13()": "cpu:587479, mem:734545, objs:-/8@80a8aa57, vm:65536@b1cd98b9/2@2f94d90d, stk:1@bf4bb881, auth:2@fc57efd9/1@ac4ec361", + " 15 call symbol_len(Symbol(obj#13))": "cpu:590149, mem:734576", + " 16 ret symbol_len -> Ok(U32(13))": "cpu:590271", + " 17 call symbol_copy_to_slice(Symbol(obj#13), U32(0), 13)": "", + " 18 ret symbol_copy_to_slice -> Ok(())": "cpu:590375", + " 19 pop VM:5c8378ed:sym#13 -> Ok(Void)": "", + " 20 ret create_contract -> Ok(Address(obj#17))": "cpu:591498, mem:734656, objs:-/9@489e2401, vm:-/-, stk:-, auth:-/-", + " 21 call call(Address(obj#17), Symbol(test), Vec(obj#21))": "cpu:592378, mem:734784, objs:-/11@681e605", + " 22 push VM:5c8378ed:test(Vec(obj#19), Vec(obj#123))": "cpu:757168, mem:897091, objs:-/12@ac2a44cf, vm:65536@b1cd98b9/2@2f94d90d, stk:1@4b1bfd53, auth:1@2eefa960/-", + " 23 call bls12_381_multi_pairing_check(Vec(obj#19), Vec(obj#123))": "cpu:760716, mem:897202, objs:2@9973ea16/12@ac2a44cf, vm:-/-, stk:1@3cb44c13", + " 24 pop VM:5c8378ed:test -> Err(Error(Value, InvalidInput))": "cpu:761160, vm:65536@b1cd98b9/2@2f94d90d", + " 25 ret call -> Err(Error(Value, InvalidInput))": "cpu:761782, mem:897218, objs:-/12@ac2a44cf, vm:-/-, stk:-, auth:-/-", + " 26 end": "cpu:761782, mem:897218, prngs:-/9b4a753, objs:-/12@ac2a44cf, vm:-/-, evt:-, store:-/2@a3e9e625, foot:2@dac64e91, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/src/budget.rs b/soroban-env-host/src/budget.rs index c24a0af3e..533f4272a 100644 --- a/soroban-env-host/src/budget.rs +++ b/soroban-env-host/src/budget.rs @@ -115,6 +115,31 @@ impl Default for BudgetTracker { ContractCostType::InstantiateWasmDataSegmentBytes => init_input(), ContractCostType::Sec1DecodePointUncompressed => (), ContractCostType::VerifyEcdsaSecp256r1Sig => (), + ContractCostType::Bls12381EncodeFp => (), + ContractCostType::Bls12381DecodeFp => (), + ContractCostType::Bls12381G1CheckPointOnCurve => (), + ContractCostType::Bls12381G1CheckPointInSubgroup => (), + ContractCostType::Bls12381G2CheckPointOnCurve => (), + ContractCostType::Bls12381G2CheckPointInSubgroup => (), + ContractCostType::Bls12381G1ProjectiveToAffine => (), + ContractCostType::Bls12381G2ProjectiveToAffine => (), + ContractCostType::Bls12381G1Add => (), + ContractCostType::Bls12381G1Mul => (), + ContractCostType::Bls12381G1Msm => init_input(), // input is number of (G1,Fr) pairs + ContractCostType::Bls12381MapFpToG1 => (), + ContractCostType::Bls12381HashToG1 => init_input(), + ContractCostType::Bls12381G2Add => (), + ContractCostType::Bls12381G2Mul => (), + ContractCostType::Bls12381G2Msm => init_input(), // input is number of (G2,Fr) pairs + ContractCostType::Bls12381MapFp2ToG2 => (), + ContractCostType::Bls12381HashToG2 => init_input(), + ContractCostType::Bls12381Pairing => init_input(), // input is number of (G1,G2) pairs + ContractCostType::Bls12381FrFromU256 => (), + ContractCostType::Bls12381FrToU256 => (), + ContractCostType::Bls12381FrAddSub => (), + ContractCostType::Bls12381FrMul => (), + ContractCostType::Bls12381FrPow => init_input(), // input is number of bits in the u64 exponent excluding leading zeros + ContractCostType::Bls12381FrInv => (), } } mt @@ -557,6 +582,106 @@ impl Default for BudgetImpl { cpu.const_term = 3000906; cpu.lin_term = ScaledU64(0); } + ContractCostType::Bls12381EncodeFp => { + cpu.const_term = 661; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381DecodeFp => { + cpu.const_term = 985; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1CheckPointOnCurve => { + cpu.const_term = 1934; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1CheckPointInSubgroup => { + cpu.const_term = 730510; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2CheckPointOnCurve => { + cpu.const_term = 5921; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2CheckPointInSubgroup => { + cpu.const_term = 1057822; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1ProjectiveToAffine => { + cpu.const_term = 92642; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2ProjectiveToAffine => { + cpu.const_term = 100742; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Add => { + cpu.const_term = 7689; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Mul => { + cpu.const_term = 2458985; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Msm => { + cpu.const_term = 2426722; + cpu.lin_term = ScaledU64(96397671); + } + ContractCostType::Bls12381MapFpToG1 => { + cpu.const_term = 1541554; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381HashToG1 => { + cpu.const_term = 3211191; + cpu.lin_term = ScaledU64(6713); + } + ContractCostType::Bls12381G2Add => { + cpu.const_term = 25207; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2Mul => { + cpu.const_term = 7873219; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2Msm => { + cpu.const_term = 8035968; + cpu.lin_term = ScaledU64(309667335); + } + ContractCostType::Bls12381MapFp2ToG2 => { + cpu.const_term = 2420202; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381HashToG2 => { + cpu.const_term = 7050564; + cpu.lin_term = ScaledU64(6797); + } + ContractCostType::Bls12381Pairing => { + cpu.const_term = 10558948; + cpu.lin_term = ScaledU64(632860943); + } + ContractCostType::Bls12381FrFromU256 => { + cpu.const_term = 1994; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrToU256 => { + cpu.const_term = 1155; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrAddSub => { + cpu.const_term = 74; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrMul => { + cpu.const_term = 332; + cpu.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrPow => { + cpu.const_term = 691; + cpu.lin_term = ScaledU64(74558); + } + ContractCostType::Bls12381FrInv => { + cpu.const_term = 35421; + cpu.lin_term = ScaledU64(0); + } } // define the memory cost model parameters @@ -748,6 +873,106 @@ impl Default for BudgetImpl { mem.const_term = 0; mem.lin_term = ScaledU64(0); } + ContractCostType::Bls12381EncodeFp => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381DecodeFp => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1CheckPointOnCurve => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1CheckPointInSubgroup => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2CheckPointOnCurve => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2CheckPointInSubgroup => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1ProjectiveToAffine => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2ProjectiveToAffine => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Add => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Mul => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G1Msm => { + mem.const_term = 109494; + mem.lin_term = ScaledU64(354667); + } + ContractCostType::Bls12381MapFpToG1 => { + mem.const_term = 5552; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381HashToG1 => { + mem.const_term = 9424; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2Add => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2Mul => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381G2Msm => { + mem.const_term = 219654; + mem.lin_term = ScaledU64(354667); + } + ContractCostType::Bls12381MapFp2ToG2 => { + mem.const_term = 3344; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381HashToG2 => { + mem.const_term = 6816; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381Pairing => { + mem.const_term = 2204; + mem.lin_term = ScaledU64(9340474); + } + ContractCostType::Bls12381FrFromU256 => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrToU256 => { + mem.const_term = 248; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrAddSub => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrMul => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } + ContractCostType::Bls12381FrPow => { + mem.const_term = 0; + mem.lin_term = ScaledU64(128); + } + ContractCostType::Bls12381FrInv => { + mem.const_term = 0; + mem.lin_term = ScaledU64(0); + } } } diff --git a/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs b/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs new file mode 100644 index 000000000..c39aab7b4 --- /dev/null +++ b/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs @@ -0,0 +1,397 @@ +use ark_bls12_381::{Bls12_381, Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; +use ark_ec::pairing::PairingOutput; + +use crate::{ + cost_runner::{CostRunner, CostType}, + crypto::bls12_381::FP_SERIALIZED_SIZE, + impl_const_cost_runner_for_bls_consume_sample, impl_const_cost_runner_for_bls_deref_sample, + impl_lin_cost_runner_for_bls_deref_sample, + xdr::ContractCostType::{ + self, Bls12381DecodeFp, Bls12381EncodeFp, Bls12381FrAddSub, Bls12381FrFromU256, + Bls12381FrInv, Bls12381FrMul, Bls12381FrPow, Bls12381FrToU256, Bls12381G1Add, + Bls12381G1CheckPointInSubgroup, Bls12381G1CheckPointOnCurve, Bls12381G1Msm, Bls12381G1Mul, + Bls12381G1ProjectiveToAffine, Bls12381G2Add, Bls12381G2CheckPointInSubgroup, + Bls12381G2CheckPointOnCurve, Bls12381G2Msm, Bls12381G2Mul, Bls12381G2ProjectiveToAffine, + Bls12381HashToG1, Bls12381HashToG2, Bls12381MapFp2ToG2, Bls12381MapFpToG1, Bls12381Pairing, + }, + Host, U256Val, +}; +use std::hint::black_box; + +pub struct Bls12381EncodeFpRun; +pub struct Bls12381DecodeFpRun; +pub struct Bls12381G1CheckPointOnCurveRun; +pub struct Bls12381G1CheckPointInSubgroupRun; +pub struct Bls12381G2CheckPointOnCurveRun; +pub struct Bls12381G2CheckPointInSubgroupRun; +pub struct Bls12381G1ProjectiveToAffineRun; +pub struct Bls12381G2ProjectiveToAffineRun; +pub struct Bls12381G1AddRun; +pub struct Bls12381G1MulRun; +pub struct Bls12381G1MsmRun; +pub struct Bls12381MapFpToG1Run; +pub struct Bls12381HashToG1Run; +pub struct Bls12381G2AddRun; +pub struct Bls12381G2MulRun; +pub struct Bls12381G2MsmRun; +pub struct Bls12381MapFp2ToG2Run; +pub struct Bls12381HashToG2Run; +pub struct Bls12381PairingRun; +pub struct Bls12381FrFromU256Run; +pub struct Bls12381FrToU256Run; +pub struct Bls12381FrAddRun; +pub struct Bls12381FrSubRun; +pub struct Bls12381FrMulRun; +pub struct Bls12381FrPowRun; +pub struct Bls12381FrInvRun; + +#[derive(Clone)] +pub struct Bls12381G1ProjectiveToAffineSample(pub G1Projective); +#[derive(Clone)] +pub struct Bls12381G1AddSample(pub G1Affine, pub G1Affine); +#[derive(Clone)] +pub struct Bls12381G1MulSample(pub G1Affine, pub Fr); +#[derive(Clone)] +pub struct Bls12381G1MsmSample( + pub Vec, + pub Vec, + pub ContractCostType, + pub String, +); +#[derive(Clone)] +pub struct Bls12381MapFpToG1Sample(pub Fq, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381HashToG1Sample(pub Vec, pub Vec, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381G2ProjectiveToAffineSample(pub G2Projective); +#[derive(Clone)] +pub struct Bls12381G2AddSample(pub G2Affine, pub G2Affine); +#[derive(Clone)] +pub struct Bls12381G2MulSample(pub G2Affine, pub Fr); +#[derive(Clone)] +pub struct Bls12381G2MsmSample( + pub Vec, + pub Vec, + pub ContractCostType, + pub String, +); +#[derive(Clone)] +pub struct Bls12381MapFp2ToG2Sample(pub Fq2, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381HashToG2Sample(pub Vec, pub Vec, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381PairingSample(pub Vec, pub Vec); +#[derive(Clone)] +pub struct Bls12381EncodeFpSample(pub Vec, pub Fq); +#[derive(Clone)] +pub struct Bls12381DecodeFpSample(pub Vec); +#[derive(Clone)] +pub struct Bls12381G1CheckPointOnCurveSample(pub G1Affine, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381G1CheckPointInSubgroupSample(pub G1Affine, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381G2CheckPointOnCurveSample(pub G2Affine, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381G2CheckPointInSubgroupSample(pub G2Affine, pub ContractCostType); +#[derive(Clone)] +pub struct Bls12381FrToU256Sample(pub Fr); +#[derive(Clone)] +pub struct Bls12381FrFromU256Sample(pub U256Val); +#[derive(Clone)] +pub struct Bls12381FrAddSubMulSample(pub Fr, pub Fr); +#[derive(Clone)] +pub struct Bls12381FrPowSample(pub Fr, pub u64); +#[derive(Clone)] +pub struct Bls12381FrInvSample(pub Fr); + +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G1ProjectiveToAffineRun, + Bls12381G1ProjectiveToAffine, + g1_projective_into_affine, + Bls12381G1ProjectiveToAffineSample, + G1Affine, + p0 +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G1AddRun, + Bls12381G1Add, + g1_add_internal, + Bls12381G1AddSample, + G1Projective, + p0, + p1 +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G1MulRun, + Bls12381G1Mul, + g1_mul_internal, + Bls12381G1MulSample, + G1Projective, + p0, + scalar +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381MapFpToG1Run, + Bls12381MapFpToG1, + map_to_curve, + Bls12381MapFpToG1Sample, + G1Affine, + fq, + ty +); + +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G2ProjectiveToAffineRun, + Bls12381G2ProjectiveToAffine, + g2_projective_into_affine, + Bls12381G2ProjectiveToAffineSample, + G2Affine, + p0 +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G2AddRun, + Bls12381G2Add, + g2_add_internal, + Bls12381G2AddSample, + G2Projective, + p0, + p1 +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381G2MulRun, + Bls12381G2Mul, + g2_mul_internal, + Bls12381G2MulSample, + G2Projective, + p0, + scalar +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381MapFp2ToG2Run, + Bls12381MapFp2ToG2, + map_to_curve, + Bls12381MapFp2ToG2Sample, + G2Affine, + fq2, + ty +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381FrFromU256Run, + Bls12381FrFromU256, + fr_from_u256val, + Bls12381FrFromU256Sample, + Fr, + sv +); +impl_const_cost_runner_for_bls_consume_sample!( + Bls12381FrToU256Run, + Bls12381FrToU256, + fr_to_u256val, + Bls12381FrToU256Sample, + U256Val, + fr +); + +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381HashToG1Run, + Bls12381HashToG1, + hash_to_curve, + Bls12381HashToG1Sample, + G1Affine, + domain, + msg, + ty +); +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381HashToG2Run, + Bls12381HashToG2, + hash_to_curve, + Bls12381HashToG2Sample, + G2Affine, + domain, + msg, + ty +); + +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381G1MsmRun, + Bls12381G1Msm, + msm_internal, + Bls12381G1MsmSample, + G1Projective, + vp, + vs, + ty, + tag +); + +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381G2MsmRun, + Bls12381G2Msm, + msm_internal, + Bls12381G2MsmSample, + G2Projective, + vp, + vs, + ty, + tag +); + +type InternalPairingOutput = PairingOutput; +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381PairingRun, + Bls12381Pairing, + pairing_internal, + Bls12381PairingSample, + InternalPairingOutput, + vp1, + vp2 +); + +// ser/deser + +impl CostRunner for Bls12381EncodeFpRun { + const COST_TYPE: CostType = CostType::Contract(Bls12381EncodeFp); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = Bls12381EncodeFpSample; + + type RecycledType = Option; + + fn run_iter( + host: &crate::Host, + _iter: u64, + mut sample: Bls12381EncodeFpSample, + ) -> Self::RecycledType { + let Bls12381EncodeFpSample(buf, fp) = &mut sample; + let _ = host + .serialize_uncompressed_into_slice::(fp, buf, "test") + .unwrap(); + black_box(Some(sample)) + } + + fn run_baseline_iter( + host: &crate::Host, + _iter: u64, + sample: Bls12381EncodeFpSample, + ) -> Self::RecycledType { + black_box(host.charge_budget(Bls12381EncodeFp, None).unwrap()); + black_box(Some(sample)) + } +} + +impl CostRunner for Bls12381DecodeFpRun { + const COST_TYPE: CostType = CostType::Contract(Bls12381DecodeFp); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = Bls12381DecodeFpSample; + + type RecycledType = (Option, Option); + + fn run_iter( + host: &crate::Host, + _iter: u64, + sample: Bls12381DecodeFpSample, + ) -> Self::RecycledType { + let Bls12381DecodeFpSample(buf) = &sample; + let res = host + .deserialize_uncompressed_no_validate::(buf, "test") + .unwrap(); + black_box((Some(sample), Some(res))) + } + + fn run_baseline_iter( + host: &crate::Host, + _iter: u64, + sample: Self::SampleType, + ) -> Self::RecycledType { + black_box(host.charge_budget(Bls12381DecodeFp, None).unwrap()); + black_box((Some(sample), None)) + } +} + +// fr arith + +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381FrAddRun, + Bls12381FrAddSub, + fr_add_internal, + Bls12381FrAddSubMulSample, + (), + lhs, + rhs +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381FrSubRun, + Bls12381FrAddSub, + fr_sub_internal, + Bls12381FrAddSubMulSample, + (), + lhs, + rhs +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381FrMulRun, + Bls12381FrMul, + fr_mul_internal, + Bls12381FrAddSubMulSample, + (), + lhs, + rhs +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381FrInvRun, + Bls12381FrInv, + fr_inv_internal, + Bls12381FrInvSample, + Fr, + lhs +); +impl_lin_cost_runner_for_bls_deref_sample!( + Bls12381FrPowRun, + Bls12381FrPow, + fr_pow_internal, + Bls12381FrPowSample, + Fr, + lhs, + rhs +); + +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381G1CheckPointOnCurveRun, + Bls12381G1CheckPointOnCurve, + check_point_is_on_curve, + Bls12381G1CheckPointOnCurveSample, + bool, + pt, + ty +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381G1CheckPointInSubgroupRun, + Bls12381G1CheckPointInSubgroup, + check_point_is_in_subgroup, + Bls12381G1CheckPointInSubgroupSample, + bool, + pt, + ty +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381G2CheckPointOnCurveRun, + Bls12381G2CheckPointOnCurve, + check_point_is_on_curve, + Bls12381G2CheckPointOnCurveSample, + bool, + pt, + ty +); +impl_const_cost_runner_for_bls_deref_sample!( + Bls12381G2CheckPointInSubgroupRun, + Bls12381G2CheckPointInSubgroup, + check_point_is_in_subgroup, + Bls12381G2CheckPointInSubgroupSample, + bool, + pt, + ty +); diff --git a/soroban-env-host/src/cost_runner/cost_types/compute_sha256_hash.rs b/soroban-env-host/src/cost_runner/cost_types/compute_sha256_hash.rs index d90d0367d..1ed5e338b 100644 --- a/soroban-env-host/src/cost_runner/cost_types/compute_sha256_hash.rs +++ b/soroban-env-host/src/cost_runner/cost_types/compute_sha256_hash.rs @@ -2,7 +2,7 @@ use std::hint::black_box; use crate::{ cost_runner::{CostRunner, CostType}, - host::crypto::sha256_hash_from_bytes_raw, + crypto::sha256_hash_from_bytes_raw, xdr::ContractCostType::ComputeSha256Hash, }; diff --git a/soroban-env-host/src/cost_runner/cost_types/mod.rs b/soroban-env-host/src/cost_runner/cost_types/mod.rs index 84405b512..01e5976cc 100644 --- a/soroban-env-host/src/cost_runner/cost_types/mod.rs +++ b/soroban-env-host/src/cost_runner/cost_types/mod.rs @@ -1,3 +1,4 @@ +mod bls12_381; mod compute_ed25519_pubkey; mod compute_keccak256_hash; mod compute_sha256_hash; @@ -18,6 +19,7 @@ mod visit_object; mod vm_ops; mod wasm_insn_exec; +pub use bls12_381::*; pub use compute_ed25519_pubkey::*; pub use compute_keccak256_hash::*; pub use compute_sha256_hash::*; diff --git a/soroban-env-host/src/cost_runner/cost_types/prng.rs b/soroban-env-host/src/cost_runner/cost_types/prng.rs index 2eab68486..d0840c571 100644 --- a/soroban-env-host/src/cost_runner/cost_types/prng.rs +++ b/soroban-env-host/src/cost_runner/cost_types/prng.rs @@ -4,7 +4,7 @@ use rand_chacha::ChaCha20Rng; use crate::{ cost_runner::{CostRunner, CostType}, - host::crypto::chacha20_fill_bytes, + crypto::chacha20_fill_bytes, xdr::ContractCostType::ChaCha20DrawBytes, }; diff --git a/soroban-env-host/src/cost_runner/experimental/bls12_381.rs b/soroban-env-host/src/cost_runner/experimental/bls12_381.rs new file mode 100644 index 000000000..3261bb704 --- /dev/null +++ b/soroban-env-host/src/cost_runner/experimental/bls12_381.rs @@ -0,0 +1,212 @@ +use ark_bls12_381::{Fq, Fq2, G1Affine, G2Affine}; + +use super::ExperimentalCostType::*; +use crate::{ + budget::CostTracker, + cost_runner::{CostRunner, CostType}, + xdr::ContractCostType, + Host, HostError, +}; +use std::hint::black_box; + +pub struct Bls12381G1AffineSerializeUncompressedRun; +pub struct Bls12381G2AffineSerializeUncompressedRun; +pub struct Bls12381G1AffineDeserializeUncompressedRun; +pub struct Bls12381G2AffineDeserializeUncompressedRun; +pub struct Bls12381Fp2DeserializeUncompressedRun; + +// ser/deser + +macro_rules! impl_ser_runner_for_bls { + ($runner: ident, $cost: ident, $expected_size: literal, $sample: ident) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Experimental($cost); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = $sample; + + type RecycledType = (Option<$sample>, Option>); + + fn run_iter(host: &Host, _iter: u64, sample: $sample) -> Self::RecycledType { + let mut buf = vec![0u8; 1000]; + let _ = host + .serialize_uncompressed_into_slice::<$expected_size, _>( + &sample, &mut buf, "test", + ) + .unwrap(); + black_box((None, Some(buf))) + } + + fn run_baseline_iter(host: &Host, _iter: u64, sample: $sample) -> Self::RecycledType { + black_box( + host.charge_budget(ContractCostType::Int256AddSub, None) + .unwrap(), + ); + black_box((Some(sample), None)) + } + + fn get_tracker(_host: &Host, _sample: &$sample) -> CostTracker { + CostTracker { + iterations: Self::RUN_ITERATIONS, + inputs: None, + cpu: 0, + mem: 0, + } + } + } + }; +} + +impl_ser_runner_for_bls!( + Bls12381G1AffineSerializeUncompressedRun, + Bls12381G1AffineSerializeUncompressed, + 96, + G1Affine +); +impl_ser_runner_for_bls!( + Bls12381G2AffineSerializeUncompressedRun, + Bls12381G2AffineSerializeUncompressed, + 192, + G2Affine +); + +macro_rules! impl_deser_runner_for_bls { + ($runner: ident, $cost: ident, $expected_size: literal, $rt: ty) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Experimental($cost); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = Vec; + + type RecycledType = (Option, Option<$rt>); + + fn run_iter(host: &Host, _iter: u64, sample: Self::SampleType) -> Self::RecycledType { + let res = host + .deserialize_uncompressed_no_validate::<$expected_size, _>(&sample, "test") + .unwrap(); + black_box((None, Some(res))) + } + + fn run_baseline_iter( + host: &Host, + _iter: u64, + sample: Self::SampleType, + ) -> Self::RecycledType { + black_box( + host.charge_budget(ContractCostType::Int256AddSub, None) + .unwrap(), + ); + black_box((Some(sample), None)) + } + + fn get_tracker(_host: &Host, _sample: &Self::SampleType) -> CostTracker { + CostTracker { + iterations: Self::RUN_ITERATIONS, + inputs: None, + cpu: 0, + mem: 0, + } + } + } + }; +} + +impl_deser_runner_for_bls!( + Bls12381G1AffineDeserializeUncompressedRun, + Bls12381G1AffineDeserializeUncompressed, + 2, + G1Affine +); +impl_deser_runner_for_bls!( + Bls12381G2AffineDeserializeUncompressedRun, + Bls12381G2AffineDeserializeUncompressed, + 4, + G2Affine +); +impl_deser_runner_for_bls!( + Bls12381Fp2DeserializeUncompressedRun, + Bls12381Fp2DeserializeUncompressed, + 2, + Fq2 +); + +#[macro_export] +macro_rules! impl_experiment_const_cost_runner_for_bls_deref_sample { + ($runner: ident, $cost: ident, $host_fn: ident, $sample: ident, $rt: ty, $($arg: ident),*) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Experimental($cost); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = $sample; + + type RecycledType = (Option<$sample>, Option<$rt>); + + fn run_iter(host: &Host, _iter: u64, mut sample: $sample) -> Self::RecycledType { + let $sample($( $arg ),*) = &mut sample; + let res = host.$host_fn($($arg),*).unwrap(); + black_box((Some(sample), Some(res))) + } + + fn run_baseline_iter( + host: &Host, + _iter: u64, + sample: $sample, + ) -> Self::RecycledType { + black_box( + host.charge_budget(ContractCostType::Int256AddSub, None) + .unwrap(), + ); + black_box((Some(sample), None)) + } + + fn get_tracker(_host: &Host, _sample: &$sample) -> CostTracker { + CostTracker { + iterations: Self::RUN_ITERATIONS, + inputs: None, + cpu: 0, + mem: 0, + } + } + } + }; +} + +impl Host { + fn g1_compute_y_from_x(&self, pt: &G1Affine) -> Result { + Ok(G1Affine::get_ys_from_x_unchecked(pt.x).unwrap().0) + } + fn g2_compute_y_from_x(&self, pt: &G2Affine) -> Result { + Ok(G2Affine::get_ys_from_x_unchecked(pt.x).unwrap().0) + } +} + +pub struct Bls12381G1ComputeYFromXRun; + +#[derive(Clone)] +pub struct Bls12381G1ComputeYFromXSample(pub G1Affine); + +impl_experiment_const_cost_runner_for_bls_deref_sample!( + Bls12381G1ComputeYFromXRun, + Bls12381G1ComputeYFromX, + g1_compute_y_from_x, + Bls12381G1ComputeYFromXSample, + Fq, + pt +); + +pub struct Bls12381G2ComputeYFromXRun; + +#[derive(Clone)] +pub struct Bls12381G2ComputeYFromXSample(pub G2Affine); + +impl_experiment_const_cost_runner_for_bls_deref_sample!( + Bls12381G2ComputeYFromXRun, + Bls12381G2ComputeYFromX, + g2_compute_y_from_x, + Bls12381G2ComputeYFromXSample, + Fq2, + pt +); diff --git a/soroban-env-host/src/cost_runner/experimental/decode_secp256r1_sig.rs b/soroban-env-host/src/cost_runner/experimental/decode_secp256r1_sig.rs index 3a50a93b1..59fcd070e 100644 --- a/soroban-env-host/src/cost_runner/experimental/decode_secp256r1_sig.rs +++ b/soroban-env-host/src/cost_runner/experimental/decode_secp256r1_sig.rs @@ -27,7 +27,7 @@ impl CostRunner for DecodeSecp256r1SigRun { DecodeEcdsaCurve256SigRun::::run_iter(host, iter, sample) } - fn get_tracker(_host: &crate::Host) -> CostTracker { + fn get_tracker(_host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { CostTracker { iterations: Self::RUN_ITERATIONS, inputs: None, diff --git a/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256k1_verify.rs b/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256k1_verify.rs index 091dc78dd..00058380f 100644 --- a/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256k1_verify.rs +++ b/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256k1_verify.rs @@ -37,7 +37,7 @@ impl CostRunner for EcdsaSecp256k1VerifyRun { black_box(sample) } - fn get_tracker(_host: &crate::Host) -> CostTracker { + fn get_tracker(_host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { CostTracker { iterations: Self::RUN_ITERATIONS, inputs: None, diff --git a/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256r1_recover.rs b/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256r1_recover.rs index 7b6f44177..71234b832 100644 --- a/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256r1_recover.rs +++ b/soroban-env-host/src/cost_runner/experimental/ecdsa_secp256r1_recover.rs @@ -38,7 +38,7 @@ impl CostRunner for EcdsaSecp256r1RecoverRun { black_box(sample) } - fn get_tracker(_host: &crate::Host) -> CostTracker { + fn get_tracker(_host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { CostTracker { iterations: Self::RUN_ITERATIONS, inputs: None, diff --git a/soroban-env-host/src/cost_runner/experimental/ed25519_scalar_mut.rs b/soroban-env-host/src/cost_runner/experimental/ed25519_scalar_mut.rs index f71f911c3..95ed2b5d0 100644 --- a/soroban-env-host/src/cost_runner/experimental/ed25519_scalar_mut.rs +++ b/soroban-env-host/src/cost_runner/experimental/ed25519_scalar_mut.rs @@ -35,7 +35,7 @@ impl CostRunner for Ed25519ScalarMulRun { black_box(sample) } - fn get_tracker(_host: &crate::Host) -> CostTracker { + fn get_tracker(_host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { CostTracker { iterations: Self::RUN_ITERATIONS, inputs: None, diff --git a/soroban-env-host/src/cost_runner/experimental/mod.rs b/soroban-env-host/src/cost_runner/experimental/mod.rs index 1817f508c..ff98ce138 100644 --- a/soroban-env-host/src/cost_runner/experimental/mod.rs +++ b/soroban-env-host/src/cost_runner/experimental/mod.rs @@ -1,3 +1,4 @@ +mod bls12_381; mod decode_secp256r1_sig; mod ecdsa_secp256k1_verify; mod ecdsa_secp256r1_recover; @@ -5,6 +6,7 @@ mod ed25519_scalar_mut; mod read_xdr; mod sec1_decode_point_compressed; +pub use bls12_381::*; pub use decode_secp256r1_sig::*; pub use ecdsa_secp256k1_verify::*; pub use ecdsa_secp256r1_recover::*; @@ -23,6 +25,13 @@ pub enum ExperimentalCostType { Sec1DecodePointCompressed, DecodeSecp256r1Signature, EcdsaSecp256k1Verify, + Bls12381G1AffineDeserializeUncompressed, + Bls12381G1AffineSerializeUncompressed, + Bls12381G2AffineDeserializeUncompressed, + Bls12381G2AffineSerializeUncompressed, + Bls12381Fp2DeserializeUncompressed, + Bls12381G1ComputeYFromX, + Bls12381G2ComputeYFromX, } impl Name for ExperimentalCostType { @@ -36,6 +45,23 @@ impl Name for ExperimentalCostType { ExperimentalCostType::Sec1DecodePointCompressed => "Sec1DecodePointCompressed", ExperimentalCostType::DecodeSecp256r1Signature => "DecodeSecp256r1Signature", ExperimentalCostType::EcdsaSecp256k1Verify => "EcdsaSecp256k1Verify", + ExperimentalCostType::Bls12381G1AffineDeserializeUncompressed => { + "Bls12381G1AffineDeserializeUncompressed" + } + ExperimentalCostType::Bls12381G1AffineSerializeUncompressed => { + "Bls12381G1AffineSerializeUncompressed" + } + ExperimentalCostType::Bls12381G2AffineDeserializeUncompressed => { + "Bls12381G2AffineDeserializeUncompressed" + } + ExperimentalCostType::Bls12381G2AffineSerializeUncompressed => { + "Bls12381G2AffineSerializeUncompressed" + } + ExperimentalCostType::Bls12381Fp2DeserializeUncompressed => { + "Bls12381Fp2DeserializeUncompressed" + } + ExperimentalCostType::Bls12381G1ComputeYFromX => "Bls12381G1ComputeYFromX", + ExperimentalCostType::Bls12381G2ComputeYFromX => "Bls12381G2ComputeYFromX", } } } diff --git a/soroban-env-host/src/cost_runner/experimental/read_xdr.rs b/soroban-env-host/src/cost_runner/experimental/read_xdr.rs index 80639f508..7aeb809cf 100644 --- a/soroban-env-host/src/cost_runner/experimental/read_xdr.rs +++ b/soroban-env-host/src/cost_runner/experimental/read_xdr.rs @@ -32,7 +32,7 @@ impl CostRunner for ReadXdrByteArrayRun { black_box((None, sample)) } - fn get_tracker(host: &crate::Host) -> CostTracker { + fn get_tracker(host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { // internally this is still charged under `ValDeser` host.as_budget().get_tracker(ValDeser).unwrap() } diff --git a/soroban-env-host/src/cost_runner/experimental/sec1_decode_point_compressed.rs b/soroban-env-host/src/cost_runner/experimental/sec1_decode_point_compressed.rs index e5737ed28..036424fd2 100644 --- a/soroban-env-host/src/cost_runner/experimental/sec1_decode_point_compressed.rs +++ b/soroban-env-host/src/cost_runner/experimental/sec1_decode_point_compressed.rs @@ -30,7 +30,7 @@ impl CostRunner for Sec1DecodePointCompressedRun { Sec1DecodePointUncompressedRun::run_iter(host, iter, sample) } - fn get_tracker(_host: &crate::Host) -> CostTracker { + fn get_tracker(_host: &crate::Host, _sample: &Self::SampleType) -> CostTracker { CostTracker { iterations: Self::RUN_ITERATIONS, inputs: None, diff --git a/soroban-env-host/src/cost_runner/runner.rs b/soroban-env-host/src/cost_runner/runner.rs index 6a7e218e5..b673128ea 100644 --- a/soroban-env-host/src/cost_runner/runner.rs +++ b/soroban-env-host/src/cost_runner/runner.rs @@ -70,7 +70,7 @@ pub trait CostRunner: Sized { /// if overridden, there is a risk of the computed input being diverged from the /// actual input from the host's perspective. So use it carefully. This should be /// after the `run`, outside of the CPU-and-memory tracking machineary. - fn get_tracker(host: &Host) -> CostTracker { + fn get_tracker(host: &Host, _sample: &Self::SampleType) -> CostTracker { match Self::COST_TYPE { CostType::Contract(ct) => host.as_budget().get_tracker(ct).unwrap(), CostType::Experimental(_) => { diff --git a/soroban-env-host/src/cost_runner/util.rs b/soroban-env-host/src/cost_runner/util.rs index 0542170ce..90e4eccbf 100644 --- a/soroban-env-host/src/cost_runner/util.rs +++ b/soroban-env-host/src/cost_runner/util.rs @@ -48,3 +48,102 @@ impl Host { )?)) } } + +#[macro_export] +macro_rules! impl_const_cost_runner_for_bls_consume_sample { + ($runner: ident, $cost: ident, $host_fn: ident, $sample: ident, $rt: ty, $($arg: ident),*) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Contract($cost); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = $sample; + + type RecycledType = (Option<$sample>, Option<$rt>); + + fn run_iter(host: &Host, _iter: u64, sample: $sample) -> Self::RecycledType { + let $sample($( $arg ),*) = sample; + let res = host.$host_fn($($arg),*).unwrap(); + black_box((None, Some(res))) + } + + fn run_baseline_iter( + host: &Host, + _iter: u64, + sample: $sample, + ) -> Self::RecycledType { + black_box( + host.charge_budget($cost, None) + .unwrap(), + ); + black_box((Some(sample), None)) + } + } + }; +} + +#[macro_export] +macro_rules! impl_lin_cost_runner_for_bls_deref_sample { + ($runner: ident, $cost: ident, $host_fn: ident, $sample: ident, $rt: ty, $($arg: ident),*) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Contract($cost); + + const RUN_ITERATIONS: u64 = 100; + + type SampleType = $sample; + + type RecycledType = ($sample, Option<$rt>); + + fn run_iter(host: &Host, _iter: u64, mut sample: $sample) -> Self::RecycledType { + let $sample($( $arg ),*) = &mut sample; + let res = host.$host_fn($($arg),*).unwrap(); + black_box((sample, Some(res))) + } + + fn run_baseline_iter( + host: &Host, + _iter: u64, + sample: $sample, + ) -> Self::RecycledType { + black_box( + host.charge_budget($cost, Some(1)) + .unwrap(), + ); + black_box((sample, None)) + } + } + }; +} + +#[macro_export] +macro_rules! impl_const_cost_runner_for_bls_deref_sample { + ($runner: ident, $cost: ident, $host_fn: ident, $sample: ident, $rt: ty, $($arg: ident),*) => { + impl CostRunner for $runner { + const COST_TYPE: CostType = CostType::Contract($cost); + + const RUN_ITERATIONS: u64 = 1; + + type SampleType = $sample; + + type RecycledType = (Option<$sample>, Option<$rt>); + + fn run_iter(host: &Host, _iter: u64, mut sample: $sample) -> Self::RecycledType { + let $sample($( $arg ),*) = &mut sample; + let res = host.$host_fn($($arg),*).unwrap(); + black_box((Some(sample), Some(res))) + } + + fn run_baseline_iter( + host: &Host, + _iter: u64, + sample: $sample, + ) -> Self::RecycledType { + black_box( + host.charge_budget($cost, None) + .unwrap(), + ); + black_box((Some(sample), None)) + } + } + }; +} diff --git a/soroban-env-host/src/crypto/bls12_381.rs b/soroban-env-host/src/crypto/bls12_381.rs new file mode 100644 index 000000000..8b1c862fe --- /dev/null +++ b/soroban-env-host/src/crypto/bls12_381.rs @@ -0,0 +1,803 @@ +use crate::{ + budget::AsBudget, + host_object::HostVec, + xdr::{ContractCostType, ScBytes, ScErrorCode, ScErrorType}, + Bool, BytesObject, ConversionError, Env, Host, HostError, TryFromVal, U256Object, U256Small, + U256Val, Val, VecObject, U256, +}; +use ark_bls12_381::{ + g1::Config as G1Config, g2::Config as G2Config, Bls12_381, Fq, Fq12, Fq2, Fr, G1Affine, + G1Projective, G2Affine, G2Projective, +}; +use ark_ec::{ + hashing::{ + curve_maps::wb::{WBConfig, WBMap}, + map_to_curve_hasher::{MapToCurve, MapToCurveBasedHasher}, + HashToCurve, + }, + pairing::{Pairing, PairingOutput}, + scalar_mul::variable_base::VariableBaseMSM, + short_weierstrass::{Affine, Projective, SWCurveConfig}, + AffineRepr, CurveConfig, CurveGroup, +}; +use ark_ff::{field_hashers::DefaultFieldHasher, BigInteger, Field, PrimeField}; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate}; +use num_traits::Zero; +use sha2::Sha256; +use std::cmp::Ordering; +use std::ops::{Add, AddAssign, Mul, MulAssign, SubAssign}; + +pub(crate) const FP_SERIALIZED_SIZE: usize = 48; +pub(crate) const FP2_SERIALIZED_SIZE: usize = FP_SERIALIZED_SIZE * 2; +pub(crate) const FP12_SERIALIZED_SIZE: usize = FP_SERIALIZED_SIZE * 12; +pub(crate) const G1_SERIALIZED_SIZE: usize = FP_SERIALIZED_SIZE * 2; +pub(crate) const G2_SERIALIZED_SIZE: usize = FP2_SERIALIZED_SIZE * 2; +pub(crate) const FR_SERIALIZED_SIZE: usize = 32; + +#[inline(always)] +fn units_of_fp() -> u64 { + ((EXPECTED_SIZE + FP_SERIALIZED_SIZE - 1) / FP_SERIALIZED_SIZE) as u64 +} + +impl Host { + // This is the internal routine performing deserialization on various + // element types, which can be conceptually decomposed into units of Fp + // (the base field element), and will be charged accordingly. + // Validation of the deserialized entity must be performed outside of this + // function, to keep budget charging isolated. + pub(crate) fn deserialize_uncompressed_no_validate< + const EXPECTED_SIZE: usize, + T: CanonicalDeserialize, + >( + &self, + slice: &[u8], + tag: &str, + ) -> Result { + if EXPECTED_SIZE == 0 || slice.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {tag}: invalid input length to deserialize").as_str(), + &[ + Val::from_u32(slice.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + self.as_budget().bulk_charge( + ContractCostType::Bls12381DecodeFp, + units_of_fp::(), + None, + )?; + // validation turned off here to isolate the cost of serialization. + // proper validation has to be performed outside of this function + T::deserialize_with_mode(slice, Compress::No, Validate::No).map_err(|_e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381: unable to deserialize {tag}").as_str(), + &[], + ) + }) + } + + // This is the internal routine performing serialization on various + // element types, which can be conceptually decomposed into units of Fp + // (the base field element), and will be charged accordingly. + pub(crate) fn serialize_uncompressed_into_slice< + const EXPECTED_SIZE: usize, + T: CanonicalSerialize, + >( + &self, + element: &T, + buf: &mut [u8], + tag: &str, + ) -> Result<(), HostError> { + if EXPECTED_SIZE == 0 || buf.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {tag}: invalid buffer length to serialize into").as_str(), + &[ + Val::from_u32(buf.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + self.as_budget().bulk_charge( + ContractCostType::Bls12381EncodeFp, + units_of_fp::(), + None, + )?; + element.serialize_uncompressed(buf).map_err(|_e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("bls12-381: unable to serialize {tag}").as_str(), + &[], + ) + })?; + Ok(()) + } + + fn validate_point_encoding( + &self, + bytes: &[u8], + tag: &str, + ) -> Result<(), HostError> { + // validate input bytes length + if EXPECTED_SIZE == 0 || bytes.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {tag}: invalid input length to deserialize").as_str(), + &[ + Val::from_u32(bytes.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + // validated encoded flags. The most significant three bits encode the flags, + // i.e. `byte[0] == [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_7]` + // - the compression_flag should be unset + // - the infinity_flag should be set **only if** rest of bits are all zero + // - the sort_flag should be unset + let flags = 0b1110_0000 & bytes[0]; + match flags { + 0b0100_0000 => { + // infinite bit is set, check all other bits are zero + let is_valid = bytes[0] == 0b0100_0000 && bytes[1..].iter().all(|x| x.is_zero()); + if !is_valid { + Err(self.err(ScErrorType::Crypto, ScErrorCode::InvalidInput, format!("bls12-381 {tag} deserialize: infinity flag (bit 1) is set while remaining bits are not all zero").as_str(), &[])) + } else { + Ok(()) + } + }, + 0b0000_0000 => Ok(()), // infinite bit is unset + _ => Err(self.err(ScErrorType::Crypto, ScErrorCode::InvalidInput, format!("bls12-381 {tag} deserialize: either compression flag (bit 0) or the sort flag (bit 2) is set, while the input should be encoded uncompressed").as_str(), &[])) + } + } + + pub(crate) fn check_point_is_on_curve( + &self, + pt: &Affine

, + ty: &ContractCostType, + ) -> Result { + // passing ty by reference in order to make it more template friendly for cost_runner code + self.charge_budget(*ty, None)?; + Ok(pt.is_on_curve()) + } + + pub(crate) fn check_point_is_in_subgroup( + &self, + pt: &Affine

, + ty: &ContractCostType, + ) -> Result { + // passing ty by reference in order to make it more template friendly for cost_runner code + self.charge_budget(*ty, None)?; + Ok(pt.is_in_correct_subgroup_assuming_on_curve()) + } + + pub(crate) fn affine_deserialize( + &self, + bo: BytesObject, + ct_curve: ContractCostType, + subgroup_check: bool, + ct_subgroup: ContractCostType, + tag: &str, + ) -> Result, HostError> { + let pt: Affine

= self.visit_obj(bo, |bytes: &ScBytes| { + self.validate_point_encoding::(&bytes, tag)?; + // `CanonicalDeserialize` of `Affine

` calls into + // `P::deserialize_with_mode`, where `P` is `arc_bls12_381::{g1,g2}::Config`, the + // core logic is in `arc_bls12_381::curves::util::read_{g1,g2}_uncompressed`. + // + // The `arc_bls12_381` lib already expects the input to be serialized in + // big-endian order (aligning with the common standard and contrary + // to ark::serialize's convention), + // + // i.e. `input = be_bytes(X) || be_bytes(Y)` and the + // most-significant three bits of X are flags: + // + // `bits(Affine) = [compression_flag, infinity_flag, sort_flag, ..remaining X_bits.., ..Y_bits..]` + // + // For `G1Affine`, each coordinate is an `Fp` that is 48 bytes. + // + // For `G2Affine`, each coordinate is an `Fp2` which contains two `Fp`, + // i.e. `(c1: Fp, c0: Fp)` see `field_element_deserialize` for more details. + // + // Internally when deserializing `Fp`, the flag bits are masked off + // to get `X: Fp`. The Y however, does not have the top bits masked off + // so it is possible for Y to exceed 381 bits. Internally `Fp` deserialization + // makes sure any value >= prime modulus results in an error. + self.deserialize_uncompressed_no_validate::(bytes.as_slice(), tag) + })?; + if !self.check_point_is_on_curve(&pt, &ct_curve)? { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {}: point not on curve", tag).as_str(), + &[], + )); + } + if subgroup_check && !self.check_point_is_in_subgroup(&pt, &ct_subgroup)? { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {}: point not in the correct subgroup", tag).as_str(), + &[], + )); + } + Ok(pt) + } + + pub(crate) fn g1_affine_deserialize_from_bytesobj( + &self, + bo: BytesObject, + subgroup_check: bool, + ) -> Result { + self.affine_deserialize::( + bo, + ContractCostType::Bls12381G1CheckPointOnCurve, + subgroup_check, + ContractCostType::Bls12381G1CheckPointInSubgroup, + "G1", + ) + } + + pub(crate) fn g2_affine_deserialize_from_bytesobj( + &self, + bo: BytesObject, + subgroup_check: bool, + ) -> Result { + self.affine_deserialize::( + bo, + ContractCostType::Bls12381G2CheckPointOnCurve, + subgroup_check, + ContractCostType::Bls12381G2CheckPointInSubgroup, + "G2", + ) + } + + pub(crate) fn g1_projective_into_affine( + &self, + g1: G1Projective, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G1ProjectiveToAffine, None)?; + Ok(g1.into_affine()) + } + + pub(crate) fn g1_affine_serialize_uncompressed( + &self, + g1: &G1Affine, + ) -> Result { + let mut buf = [0; G1_SERIALIZED_SIZE]; + // `CanonicalSerialize of Affine

` calls into + // `P::serialize_with_mode`, where `P` is `ark_bls12_381::g1::Config`. The + // output bytes will be in following format: `be_bytes(X) || be_bytes(Y)` + // , where the most-significant three bits of X encodes the flags, i.e. + // + // bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383] + // + // This aligns with our chosen standard + // (https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization) + self.serialize_uncompressed_into_slice::(g1, &mut buf, "G1")?; + self.add_host_object(self.scbytes_from_slice(&buf)?) + } + + pub(crate) fn g1_projective_serialize_uncompressed( + &self, + g1: G1Projective, + ) -> Result { + let g1_affine = self.g1_projective_into_affine(g1)?; + self.g1_affine_serialize_uncompressed(&g1_affine) + } + + pub(crate) fn g2_projective_into_affine( + &self, + g2: G2Projective, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G2ProjectiveToAffine, None)?; + Ok(g2.into_affine()) + } + + pub(crate) fn g2_affine_serialize_uncompressed( + &self, + g2: &G2Affine, + ) -> Result { + let mut buf = [0; G2_SERIALIZED_SIZE]; + // `CanonicalSerialization of Affine

` where `P` is `ark_bls12_381::curves::g2::Config`, + // calls into `P::serialize_with_mode`. + // + // The output is in the following format: + // `be_bytes(X_c1) || be_bytes(X_c0) || be_bytes(Y_c1) || be_bytes(Y_c0)` + // + // The most significant three bits of `X_c1` encodes the flags, i.e. + // `bits(X_c1) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` + // + // This aligns with the standard we've picked https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization + self.serialize_uncompressed_into_slice::(g2, &mut buf, "G2")?; + self.add_host_object(self.scbytes_from_slice(&buf)?) + } + + pub(crate) fn g2_projective_serialize_uncompressed( + &self, + g2: G2Projective, + ) -> Result { + let g2_affine = self.g2_projective_into_affine(g2)?; + self.g2_affine_serialize_uncompressed(&g2_affine) + } + + pub(crate) fn fr_from_u256val(&self, sv: U256Val) -> Result { + self.charge_budget(ContractCostType::Bls12381FrFromU256, None)?; + let fr = if let Ok(small) = U256Small::try_from(sv) { + Fr::from_le_bytes_mod_order(&u64::from(small).to_le_bytes()) + } else { + let obj: U256Object = sv.try_into()?; + self.visit_obj(obj, |u: &U256| { + Ok(Fr::from_le_bytes_mod_order(&u.to_le_bytes())) + })? + }; + Ok(fr) + } + + pub(crate) fn fr_to_u256val(&self, scalar: Fr) -> Result { + self.charge_budget(ContractCostType::Bls12381FrToU256, None)?; + // The `into_bigint` carries the majority of the cost. It performs the + // Montgomery reduction on the internal representation, which is doing a + // number of wrapping arithmetics on each u64 word (`Fr` contains 4 + // words). The core routine is in `ark_ff::MontConfig::into_bigint`, + // this cannot panic. + let bytes: [u8; 32] = scalar + .into_bigint() + .to_bytes_be() + .try_into() + .map_err(|_| HostError::from(ConversionError))?; + let u = U256::from_be_bytes(bytes); + self.map_err(U256Val::try_from_val(self, &u)) + } + + pub(crate) fn field_element_deserialize( + &self, + bo: BytesObject, + tag: &str, + ) -> Result { + self.visit_obj(bo, |bytes: &ScBytes| { + if bytes.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!( + "bls12-381 field element {}: invalid input length to deserialize", + tag + ) + .as_str(), + &[ + Val::from_u32(bytes.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + self.charge_budget(ContractCostType::MemCpy, Some(EXPECTED_SIZE as u64))?; + let mut buf = [0u8; EXPECTED_SIZE]; + buf.copy_from_slice(bytes); + buf.reverse(); + + // The field element here an either be a Fp (base field + // element) or QuadExtField

(quadratic extension) + // + // - `CanonicalDeserialize for Fp` assumes input bytes in + // little-endian order, with the highest (right-most) bits being + // empty flags. This is reverse of our rule, which assumes + // big-endian order with the highest (left-most) bits for flags. + // + // - `CanonicalDeserialize for QuadExtField

` reads the first + // chunk, deserialize it into `Fp` as `c0`. Then repeat for `c1`. The + // deserialization for `Fp` follows same rules as above, where the + // bytes are expected in little-endian, with the highest bits being + // empty flags. There is no check involved. This is entirely + // reversed from our input format: `be_bytes(c1) || be_bytes(c0)` from + // [standard](https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization) + // + // In either case, we just need to reverse the input bytes before + // passing them in. There is no other check for `Fp` besides the + // length check, internally it makes sure `Fp` is valid integer + // modulo `q` (the prime modulus) + self.deserialize_uncompressed_no_validate::(&buf, tag) + }) + } + + pub(crate) fn fp_deserialize_from_bytesobj(&self, bo: BytesObject) -> Result { + self.field_element_deserialize::(bo, "Fp") + } + + pub(crate) fn fp2_deserialize_from_bytesobj(&self, bo: BytesObject) -> Result { + self.field_element_deserialize::(bo, "Fp2") + } + + pub(crate) fn fr_vec_from_vecobj(&self, vs: VecObject) -> Result, HostError> { + let len: u32 = self.vec_len(vs)?.into(); + let mut scalars: Vec = vec![]; + self.charge_budget( + ContractCostType::MemAlloc, + Some(len as u64 * FR_SERIALIZED_SIZE as u64), + )?; + scalars.reserve(len as usize); + let _ = self.visit_obj(vs, |vs: &HostVec| { + for s in vs.iter() { + let ss = self.fr_from_u256val(U256Val::try_from_val(self, s)?)?; + scalars.push(ss); + } + Ok(()) + })?; + Ok(scalars) + } + + pub(crate) fn g1_add_internal( + &self, + p0: G1Affine, + p1: G1Affine, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G1Add, None)?; + Ok(p0.add(p1)) + } + + pub(crate) fn g1_mul_internal( + &self, + p0: G1Affine, + scalar: Fr, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G1Mul, None)?; + Ok(p0.mul(scalar)) + } + + pub(crate) fn affine_vec_from_vecobj( + &self, + vp: VecObject, + ct_curve: ContractCostType, + subgroup_check: bool, + ct_subgroup: ContractCostType, + tag: &str, + ) -> Result>, HostError> { + let len: u32 = self.vec_len(vp)?.into(); + self.charge_budget( + ContractCostType::MemAlloc, + Some(len as u64 * EXPECTED_SIZE as u64), + )?; + let mut points: Vec> = Vec::with_capacity(len as usize); + let _ = self.visit_obj(vp, |vp: &HostVec| { + for p in vp.iter() { + let pp = self.affine_deserialize::( + BytesObject::try_from_val(self, p)?, + ct_curve, + subgroup_check, + ct_subgroup, + tag, + )?; + points.push(pp); + } + Ok(()) + })?; + Ok(points) + } + + pub(crate) fn checked_g1_vec_from_vecobj( + &self, + vp: VecObject, + ) -> Result, HostError> { + self.affine_vec_from_vecobj::( + vp, + ContractCostType::Bls12381G1CheckPointOnCurve, + true, + ContractCostType::Bls12381G1CheckPointInSubgroup, + "G1", + ) + } + + pub(crate) fn checked_g2_vec_from_vecobj( + &self, + vp: VecObject, + ) -> Result, HostError> { + self.affine_vec_from_vecobj::( + vp, + ContractCostType::Bls12381G2CheckPointOnCurve, + true, + ContractCostType::Bls12381G2CheckPointInSubgroup, + "G2", + ) + } + + pub(crate) fn g2_add_internal( + &self, + p0: G2Affine, + p1: G2Affine, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G2Add, None)?; + Ok(p0.add(p1)) + } + + pub(crate) fn g2_mul_internal( + &self, + p0: G2Affine, + scalar: Fr, + ) -> Result { + self.charge_budget(ContractCostType::Bls12381G2Mul, None)?; + Ok(p0.mul(scalar)) + } + + pub(crate) fn msm_internal( + &self, + points: &[Affine

], + scalars: &[

::ScalarField], + ty: &ContractCostType, + tag: &str, + ) -> Result, HostError> { + self.charge_budget(*ty, Some(points.len() as u64))?; + if points.len() != scalars.len() || points.len() == 0 { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!( + "{tag} msm: invalid input vector lengths ({}, {})", + points.len(), + scalars.len() + ) + .as_str(), + &[], + )); + } + // The actual logic happens inside msm_bigint_wnaf (ark_ec/variable_base/mod.rs) + // under branch negation is cheap. + // the unchecked version just skips the length equal check + Ok(Projective::

::msm_unchecked(points, scalars)) + } + + pub(crate) fn map_to_curve( + &self, + fp: as AffineRepr>::BaseField, + ty: ContractCostType, + ) -> Result, HostError> { + self.charge_budget(ty, None)?; + + // The `WBMap::new()` first calls + // `P::ISOGENY_MAP.apply(GENERATOR)` which returns error if the result + // point is not on curve. This should not happen if the map constants + // have been correctly defined. otherwise it would be an internal error + // since it's a bug in the library implementation. + // + // Then it returns `WBMap`, which wraps a `SWUMap

` where P is the + // `ark_bls12_381::curves::g2_swu_iso::SwuIsoConfig`. + // + // Potential panic condition: `SWUMap::new().unwrap()` + // + // The `SWUMap::new()` function performs some validation on the static + // parameters `ZETA`, `COEFF_A`, `COEFF_B`, all of which are statically + // defined in `ark_bls12_381::curves::g1_swu_iso` and `g2_swu_iso`. + // Realistically this panic cannot occur, otherwise it will panic every + // time including during tests + let mapper = WBMap::

::new().map_err(|e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("hash-to-curve error {e}").as_str(), + &[], + ) + })?; + + // The `SWUMap::map_to_curve` function contains several panic conditions + // 1. assert!(!div3.is_zero()) + // 2. gx1.sqrt().expect() + // 3. zeta_gx1.sqrt().expect() + // 4. assert!(point_on_curve.is_on_curve()) + // + // While all of these should theoretically just be debug assertions that + // can't happen if the map parameters are correctly defined (several of + // these have recently been downgraded to debug_assert, e.g see + // https://github.com/arkworks-rs/algebra/pull/659#discussion_r1450808159), + // we cannot guaruantee with 100% confidence these panics will never + // happen. + // + // Otherwise, this function should never Err. + mapper.map_to_curve(fp).map_err(|e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("hash-to-curve error {e}").as_str(), + &[], + ) + }) + } + + pub(crate) fn hash_to_curve( + &self, + domain: &[u8], + msg: &[u8], + ty: &ContractCostType, + ) -> Result, HostError> { + self.charge_budget(*ty, Some(msg.len() as u64))?; + // check dst requirements + let dst_len = domain.len(); + if dst_len == 0 || dst_len > 255 { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("hash_to_curve: invalid input dst length {dst_len}, must be > 0 and < 256") + .as_str(), + &[], + )); + } + + // The `new` function here constructs a DefaultFieldHasher and a WBMap. + // - The DefaultFieldHasher::new() function creates an ExpanderXmd with + // Sha256. This cannot fail or panic. + // - Construction of WBMap follows the exact same analysis as map_to_curve + // function earlier. + // This function cannot realistically produce an error or panic. + let mapper = + MapToCurveBasedHasher::, DefaultFieldHasher, WBMap

>::new( + domain, + ) + .map_err(|e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("hash-to-curve error {e}").as_str(), + &[], + ) + })?; + + // `ark_ec::hashing::map_to_curve_hasher::MapToCurveBasedHasher::hash` + // contains the following calls + // - `DefaultFieldHasher::hash_to_field` + // - `SWUMap::map_to_curve` + // - `clear_cofactor`. This cannot fail or panic. + // + // `hash_to_field` calls the ExpanderXmd::expand function, there are two + // assertions on the length of bytes produced by the hash function. Both + // of these cannot happen because the output size can be computed + // analytically. Let's use G2: + // - `block_size = 384 (Fp bit size) + 128 (security padding) / 8 = 64` + // - `len_in_bytes = 2 (number of elements to produce) * 2 (extention + // degree of Fp2) * 64 (block_size) = 256` + // - `ell = 256 (len_in_bytes) / 32 (sha256 output size) = 8` + // + // # Assertion #1. ell <= 255, which is saying the expander cannot expand + // up to a certain length. in our case ell == 8. + // # Assertion #2. len_in_bytes < 2^16, which is clearly true as well. + // + // The rest is just hashing, dividing bytes into element size, and + // producing field elements from bytes. None of these can panic or + // error. + // + // The only panic conditions we cannot 100% exclude comes from + // `map_to_curve`, see previous analysis. + // + // This function should not Err. + mapper.hash(msg.as_ref()).map_err(|e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("hash-to-curve error {e}").as_str(), + &[], + ) + }) + } + + pub(crate) fn pairing_internal( + &self, + vp1: &Vec, + vp2: &Vec, + ) -> Result, HostError> { + self.charge_budget(ContractCostType::Bls12381Pairing, Some(vp1.len() as u64))?; + // check length requirements + if vp1.len() != vp2.len() || vp1.len() == 0 { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!( + "pairing: invalid input vector lengths ({}, {})", + vp1.len(), + vp2.len() + ) + .as_str(), + &[], + )); + } + + // This calls into `Bls12::multi_miller_loop`, which just calls + // `ark_ec::models::bls12::Bls12Config::multi_miller_loop` with specific + // parameters defined in `ark_bls12_381::curves`. + // + // Panic analysis: + // + // The following potential panic conditions could exist: + // 1. if two input vector lengths are not equal. There is a `zip_eq` + // which panics if the length of the two vectors are not equal. This is + // weeded out up front. + // + // 2. `coeffs.next().unwrap()`. This occurs when the algorithm Loops + // over pairs of `(a: G1Affine, b: G2Affine)`, converting them into + // `Vec<(G1Prepared, G2Preared::EllCoeff)>`, the latter contains + // three elements of Fp2. For each pair, the coeffs.next() can at most + // be called twice, when the bit being looped over in `Config::X` is + // set. So this panic cannot happen. + // + // 3. if any of the G1Affine point is infinity. The ell() function which + // calls p.xy().unwrap(), which is when the point is infinity. This + // condition also cannot happen because when the pairs are generated, + // any pair containing a zero point is filtered. + // + // The above analysis is best effort to weed out panics from the source, + // however the algorithm is quite involved. So we cannot be 100% certain + // every panic condition has been excluded. + let mlo = Bls12_381::multi_miller_loop(vp1, vp2); + // final_exponentiation returning None means the `mlo.0.is_zero()` + Bls12_381::final_exponentiation(mlo).ok_or_else(|| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + "final_exponentiation has failed, most likely multi_miller_loop produced infinity", + &[], + ) + }) + } + + pub(crate) fn check_pairing_output( + &self, + output: &PairingOutput, + ) -> Result { + self.charge_budget(ContractCostType::MemCmp, Some(FP12_SERIALIZED_SIZE as u64))?; + match output.0.cmp(&Fq12::ONE) { + Ordering::Equal => Ok(true.into()), + _ => Ok(false.into()), + } + } + + pub(crate) fn fr_add_internal(&self, lhs: &mut Fr, rhs: &Fr) -> Result<(), HostError> { + self.charge_budget(ContractCostType::Bls12381FrAddSub, None)?; + lhs.add_assign(rhs); + Ok(()) + } + + pub(crate) fn fr_sub_internal(&self, lhs: &mut Fr, rhs: &Fr) -> Result<(), HostError> { + self.charge_budget(ContractCostType::Bls12381FrAddSub, None)?; + lhs.sub_assign(rhs); + Ok(()) + } + + pub(crate) fn fr_mul_internal(&self, lhs: &mut Fr, rhs: &Fr) -> Result<(), HostError> { + self.charge_budget(ContractCostType::Bls12381FrMul, None)?; + lhs.mul_assign(rhs); + Ok(()) + } + + pub(crate) fn fr_pow_internal(&self, lhs: &Fr, rhs: &u64) -> Result { + self.charge_budget( + ContractCostType::Bls12381FrPow, + Some(64 - rhs.leading_zeros() as u64), + )?; + Ok(lhs.pow(&[*rhs])) + } + + pub(crate) fn fr_inv_internal(&self, lhs: &Fr) -> Result { + if lhs.is_zero() { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + "scalar inversion input is zero", + &[], + )); + } + self.charge_budget(ContractCostType::Bls12381FrInv, None)?; + // `inverse()` returns `None` only if the rhs is zero, which we have + // checked upfront, so this cannot fail. + lhs.inverse().ok_or_else(|| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + "scalar inversion failed", + &[], + ) + }) + } +} diff --git a/soroban-env-host/src/host/crypto.rs b/soroban-env-host/src/crypto/mod.rs similarity index 99% rename from soroban-env-host/src/host/crypto.rs rename to soroban-env-host/src/crypto/mod.rs index 033427d49..9bf643e16 100644 --- a/soroban-env-host/src/host/crypto.rs +++ b/soroban-env-host/src/crypto/mod.rs @@ -1,4 +1,4 @@ -use super::metered_clone::MeteredContainer; +use crate::host::metered_clone::MeteredContainer; use crate::host::prng::SEED_BYTES; use crate::{ budget::AsBudget, @@ -17,6 +17,7 @@ use sha3::Keccak256; use ecdsa::{signature::hazmat::PrehashVerifier, PrimeCurve, Signature, SignatureSize}; use elliptic_curve::CurveArithmetic; use generic_array::ArrayLength; +pub(crate) mod bls12_381; impl Host { // Ed25519 functions diff --git a/soroban-env-host/src/e2e_invoke.rs b/soroban-env-host/src/e2e_invoke.rs index 2150d6bd5..b327d85fe 100644 --- a/soroban-env-host/src/e2e_invoke.rs +++ b/soroban-env-host/src/e2e_invoke.rs @@ -14,10 +14,10 @@ use crate::{ }; use crate::{ budget::{AsBudget, Budget}, + crypto::sha256_hash_from_bytes, events::Events, fees::LedgerEntryRentChange, host::{ - crypto::sha256_hash_from_bytes, metered_clone::{MeteredAlloc, MeteredClone, MeteredContainer, MeteredIterator}, metered_xdr::{metered_from_xdr_with_budget, metered_write_xdr}, TraceHook, diff --git a/soroban-env-host/src/host.rs b/soroban-env-host/src/host.rs index 549c0aeb3..c371ba460 100644 --- a/soroban-env-host/src/host.rs +++ b/soroban-env-host/src/host.rs @@ -6,8 +6,8 @@ use crate::{ budget::{AsBudget, Budget}, events::{diagnostic::DiagnosticLevel, Events, InternalEventsBuffer}, host_object::{HostMap, HostObject, HostVec}, - impl_bignum_host_fns, impl_bignum_host_fns_rhs_u32, impl_wrapping_obj_from_num, - impl_wrapping_obj_to_num, + impl_bignum_host_fns, impl_bignum_host_fns_rhs_u32, impl_bls12_381_fr_arith_host_fns, + impl_wrapping_obj_from_num, impl_wrapping_obj_to_num, num::*, storage::Storage, vm::ModuleCache, @@ -18,13 +18,12 @@ use crate::{ ScSymbol, ScVal, TimePoint, Uint256, }, AddressObject, Bool, BytesObject, Compare, ConversionError, EnvBase, Error, LedgerInfo, - MapObject, Object, StorageType, StringObject, Symbol, SymbolObject, TryFromVal, Val, VecObject, - VmCaller, VmCallerEnv, Void, + MapObject, Object, StorageType, StringObject, Symbol, SymbolObject, SymbolSmall, TryFromVal, + TryIntoVal, Val, VecObject, VmCaller, VmCallerEnv, Void, }; mod comparison; mod conversion; -pub(crate) mod crypto; mod data_helper; mod declared_size; pub(crate) mod error; @@ -38,7 +37,7 @@ pub(crate) mod metered_map; pub(crate) mod metered_vector; pub(crate) mod metered_xdr; mod num; -mod prng; +pub(crate) mod prng; pub(crate) mod trace; mod validity; @@ -61,7 +60,6 @@ pub use frame::ContractFunctionSet; pub(crate) use frame::Frame; #[cfg(any(test, feature = "recording_mode"))] use rand_chacha::ChaCha20Rng; -use soroban_env_common::SymbolSmall; #[cfg(any(test, feature = "testutils"))] #[derive(Clone, Copy)] @@ -2918,6 +2916,202 @@ impl VmCallerEnv for Host { Ok(res.into()) } + fn bls12_381_check_g1_is_in_subgroup( + &self, + _vmcaller: &mut VmCaller, + pt: BytesObject, + ) -> Result { + let pt = self.g1_affine_deserialize_from_bytesobj(pt, false)?; + self.check_point_is_in_subgroup(&pt, &ContractCostType::Bls12381G1CheckPointInSubgroup) + .map(|b| Bool::from(b)) + } + + fn bls12_381_g1_add( + &self, + _vmcaller: &mut VmCaller, + p0: BytesObject, + p1: BytesObject, + ) -> Result { + let p0 = self.g1_affine_deserialize_from_bytesobj(p0, false)?; + let p1 = self.g1_affine_deserialize_from_bytesobj(p1, false)?; + let res = self.g1_add_internal(p0, p1)?; + self.g1_projective_serialize_uncompressed(res) + } + + fn bls12_381_g1_mul( + &self, + _vmcaller: &mut VmCaller, + p0: BytesObject, + scalar: U256Val, + ) -> Result { + let p0 = self.g1_affine_deserialize_from_bytesobj(p0, true)?; + let scalar = self.fr_from_u256val(scalar)?; + let res = self.g1_mul_internal(p0, scalar)?; + self.g1_projective_serialize_uncompressed(res) + } + + fn bls12_381_g1_msm( + &self, + _vmcaller: &mut VmCaller, + vp: VecObject, + vs: VecObject, + ) -> Result { + let points = self.checked_g1_vec_from_vecobj(vp)?; + let scalars = self.fr_vec_from_vecobj(vs)?; + let res = self.msm_internal(&points, &scalars, &ContractCostType::Bls12381G1Msm, "G1")?; + self.g1_projective_serialize_uncompressed(res) + } + + fn bls12_381_map_fp_to_g1( + &self, + _vmcaller: &mut VmCaller, + fp: BytesObject, + ) -> Result { + let fp = self.fp_deserialize_from_bytesobj(fp)?; + let g1 = self.map_to_curve(fp, ContractCostType::Bls12381MapFpToG1)?; + self.g1_affine_serialize_uncompressed(&g1) + } + + fn bls12_381_hash_to_g1( + &self, + _vmcaller: &mut VmCaller, + mo: BytesObject, + dst: BytesObject, + ) -> Result { + let g1 = self.visit_obj(mo, |msg: &ScBytes| { + self.visit_obj(dst, |dst: &ScBytes| { + self.hash_to_curve( + dst.as_slice(), + msg.as_slice(), + &ContractCostType::Bls12381HashToG1, + ) + }) + })?; + self.g1_affine_serialize_uncompressed(&g1) + } + + fn bls12_381_check_g2_is_in_subgroup( + &self, + _vmcaller: &mut VmCaller, + pt: BytesObject, + ) -> Result { + let pt = self.g2_affine_deserialize_from_bytesobj(pt, false)?; + self.check_point_is_in_subgroup(&pt, &ContractCostType::Bls12381G2CheckPointInSubgroup) + .map(|b| Bool::from(b)) + } + + fn bls12_381_g2_add( + &self, + _vmcaller: &mut VmCaller, + p0: BytesObject, + p1: BytesObject, + ) -> Result { + let p0 = self.g2_affine_deserialize_from_bytesobj(p0, false)?; + let p1 = self.g2_affine_deserialize_from_bytesobj(p1, false)?; + let res = self.g2_add_internal(p0, p1)?; + self.g2_projective_serialize_uncompressed(res) + } + + fn bls12_381_g2_mul( + &self, + _vmcaller: &mut VmCaller, + p0: BytesObject, + scalar_le_bytes: U256Val, + ) -> Result { + let p0 = self.g2_affine_deserialize_from_bytesobj(p0, true)?; + let scalar = self.fr_from_u256val(scalar_le_bytes)?; + let res = self.g2_mul_internal(p0, scalar)?; + self.g2_projective_serialize_uncompressed(res) + } + + fn bls12_381_g2_msm( + &self, + _vmcaller: &mut VmCaller, + vp: VecObject, + vs: VecObject, + ) -> Result { + let points = self.checked_g2_vec_from_vecobj(vp)?; + let scalars = self.fr_vec_from_vecobj(vs)?; + let res = self.msm_internal(&points, &scalars, &ContractCostType::Bls12381G2Msm, "G2")?; + self.g2_projective_serialize_uncompressed(res) + } + + fn bls12_381_map_fp2_to_g2( + &self, + _vmcaller: &mut VmCaller, + fp2: BytesObject, + ) -> Result { + let fp2 = self.fp2_deserialize_from_bytesobj(fp2)?; + let g2 = self.map_to_curve(fp2, ContractCostType::Bls12381MapFp2ToG2)?; + self.g2_affine_serialize_uncompressed(&g2) + } + + fn bls12_381_hash_to_g2( + &self, + _vmcaller: &mut VmCaller, + msg: BytesObject, + dst: BytesObject, + ) -> Result { + let g2 = self.visit_obj(msg, |msg: &ScBytes| { + self.visit_obj(dst, |dst: &ScBytes| { + self.hash_to_curve( + dst.as_slice(), + msg.as_slice(), + &ContractCostType::Bls12381HashToG2, + ) + }) + })?; + self.g2_affine_serialize_uncompressed(&g2) + } + + fn bls12_381_multi_pairing_check( + &self, + vmcaller: &mut VmCaller, + vp1: VecObject, + vp2: VecObject, + ) -> Result { + let l1: u32 = self.vec_len(vmcaller, vp1)?.into(); + let l2: u32 = self.vec_len(vmcaller, vp2)?.into(); + if l1 != l2 || l1 == 0 { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("multi-pairing-check: invalid input vector lengths {l1} and {l2}").as_str(), + &[], + )); + } + let vp1 = self.checked_g1_vec_from_vecobj(vp1)?; + let vp2 = self.checked_g2_vec_from_vecobj(vp2)?; + let output = self.pairing_internal(&vp1, &vp2)?; + self.check_pairing_output(&output) + } + + impl_bls12_381_fr_arith_host_fns!(bls12_381_fr_add, fr_add_internal); + impl_bls12_381_fr_arith_host_fns!(bls12_381_fr_sub, fr_sub_internal); + impl_bls12_381_fr_arith_host_fns!(bls12_381_fr_mul, fr_mul_internal); + + fn bls12_381_fr_pow( + &self, + _vmcaller: &mut VmCaller, + lhs: U256Val, + rhs: U64Val, + ) -> Result { + let lhs = self.fr_from_u256val(lhs)?; + let rhs = rhs.try_into_val(self)?; + let res = self.fr_pow_internal(&lhs, &rhs)?; + self.fr_to_u256val(res) + } + + fn bls12_381_fr_inv( + &self, + _vmcaller: &mut VmCaller, + lhs: U256Val, + ) -> Result { + let lhs = self.fr_from_u256val(lhs)?; + let res = self.fr_inv_internal(&lhs)?; + self.fr_to_u256val(res) + } + // endregion: "crypto" module functions // region: "test" module functions diff --git a/soroban-env-host/src/host/data_helper.rs b/soroban-env-host/src/host/data_helper.rs index 4d6870623..62c3c0e62 100644 --- a/soroban-env-host/src/host/data_helper.rs +++ b/soroban-env-host/src/host/data_helper.rs @@ -525,7 +525,7 @@ impl Host { } #[cfg(any(test, feature = "testutils"))] -use super::crypto; +use crate::crypto; #[cfg(any(test, feature = "testutils"))] use crate::storage::{AccessType, Footprint}; diff --git a/soroban-env-host/src/host/lifecycle.rs b/soroban-env-host/src/host/lifecycle.rs index b513a3309..1b570fe94 100644 --- a/soroban-env-host/src/host/lifecycle.rs +++ b/soroban-env-host/src/host/lifecycle.rs @@ -1,5 +1,5 @@ use crate::{ - err, + crypto, err, host::{ metered_clone::{MeteredAlloc, MeteredClone}, metered_write_xdr, ContractReentryMode, @@ -307,7 +307,6 @@ impl Host { } } -use super::crypto; use super::frame::CallParams; #[cfg(any(test, feature = "testutils"))] use super::ContractFunctionSet; diff --git a/soroban-env-host/src/host/metered_xdr.rs b/soroban-env-host/src/host/metered_xdr.rs index 8221292a3..77aa77d8e 100644 --- a/soroban-env-host/src/host/metered_xdr.rs +++ b/soroban-env-host/src/host/metered_xdr.rs @@ -1,6 +1,6 @@ use crate::{ budget::Budget, - host::crypto::sha256_hash_from_bytes_raw, + crypto::sha256_hash_from_bytes_raw, xdr::{ContractCostType, Limited, ReadXdr, ScBytes, ScErrorCode, ScErrorType, WriteXdr}, BytesObject, Host, HostError, DEFAULT_XDR_RW_LIMITS, }; diff --git a/soroban-env-host/src/host/num.rs b/soroban-env-host/src/host/num.rs index fca891027..b66611e03 100644 --- a/soroban-env-host/src/host/num.rs +++ b/soroban-env-host/src/host/num.rs @@ -66,3 +66,20 @@ macro_rules! impl_bignum_host_fns_rhs_u32 { } }; } + +#[macro_export] +macro_rules! impl_bls12_381_fr_arith_host_fns { + ($host_fn: ident, $method: ident) => { + fn $host_fn( + &self, + _vmcaller: &mut VmCaller, + lhs: U256Val, + rhs: U256Val, + ) -> Result { + let mut lhs = self.fr_from_u256val(lhs)?; + let rhs = self.fr_from_u256val(rhs)?; + self.$method(&mut lhs, &rhs)?; + self.fr_to_u256val(lhs) + } + }; +} diff --git a/soroban-env-host/src/host/prng.rs b/soroban-env-host/src/host/prng.rs index 6a9bd01d5..c122fc337 100644 --- a/soroban-env-host/src/host/prng.rs +++ b/soroban-env-host/src/host/prng.rs @@ -1,10 +1,7 @@ -use super::{ - crypto::{chacha20_fill_bytes, unbias_prng_seed}, - declared_size::DeclaredSizeForMetering, - metered_clone::MeteredContainer, -}; +use super::{declared_size::DeclaredSizeForMetering, metered_clone::MeteredContainer}; use crate::{ budget::Budget, + crypto::{chacha20_fill_bytes, unbias_prng_seed}, host::metered_clone::MeteredClone, host_object::HostVec, xdr::{ContractCostType, ScBytes, ScErrorCode, ScErrorType}, diff --git a/soroban-env-host/src/lib.rs b/soroban-env-host/src/lib.rs index e5dafaea9..072fde116 100644 --- a/soroban-env-host/src/lib.rs +++ b/soroban-env-host/src/lib.rs @@ -26,11 +26,11 @@ mod macros; pub mod budget; pub mod events; pub use events::diagnostic::DiagnosticLevel; +mod builtin_contracts; +pub(crate) mod crypto; mod host; pub(crate) mod host_object; -mod builtin_contracts; - pub mod auth; pub mod vm; pub use vm::Vm; diff --git a/soroban-env-host/src/test.rs b/soroban-env-host/src/test.rs index 6d8b6433f..7a607c93c 100644 --- a/soroban-env-host/src/test.rs +++ b/soroban-env-host/src/test.rs @@ -3,6 +3,7 @@ pub(crate) mod observe; mod address; mod auth; mod basic; +mod bls12_381; mod budget_metering; mod bytes; mod complex; diff --git a/soroban-env-host/src/test/bls12_381.rs b/soroban-env-host/src/test/bls12_381.rs new file mode 100644 index 000000000..805179af2 --- /dev/null +++ b/soroban-env-host/src/test/bls12_381.rs @@ -0,0 +1,1750 @@ +use crate::{ + crypto::bls12_381::{ + FP2_SERIALIZED_SIZE, FP_SERIALIZED_SIZE, G1_SERIALIZED_SIZE, G2_SERIALIZED_SIZE, + }, + xdr::{ScErrorCode, ScErrorType}, + BytesObject, Env, EnvBase, Host, HostError, U256Val, U32Val, Val, VecObject, +}; +use ark_bls12_381::{Fq, Fq2, Fr, G1Affine, G2Affine, FQ_ONE, FQ_ZERO}; +use ark_ec::AffineRepr; +use ark_ff::UniformRand; +use ark_serialize::CanonicalSerialize; +use hex::FromHex; +use rand::{rngs::StdRng, SeedableRng}; +use serde::Deserialize; +use std::cmp::Ordering; + +const MODULUS: &str = "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"; + +impl Host { + pub(crate) fn fp_serialize_into_bytesobj(&self, fp: &Fq) -> Result { + let mut buf = [0u8; FP_SERIALIZED_SIZE]; + self.serialize_uncompressed_into_slice::(&fp, &mut buf, "Fp")?; + buf.reverse(); + self.add_host_object(self.scbytes_from_slice(&buf)?) + } + + pub(crate) fn fp2_serialize_into_bytesobj(&self, fp2: &Fq2) -> Result { + let mut buf = [0u8; FP2_SERIALIZED_SIZE]; + self.serialize_uncompressed_into_slice::(&fp2, &mut buf, "Fp")?; + buf.reverse(); + self.add_host_object(self.scbytes_from_slice(&buf)?) + } +} + +enum InvalidPointTypes { + TooManyBytes, + TooFewBytes, + CompressionFlagSet, + InfinityFlagSetBitsNotAllZero, + SortFlagSet, + PointNotOnCurve, + PointNotInSubgroup, + OutOfRange, +} + +#[allow(unused)] +#[derive(Deserialize, Debug)] +struct Field { + m: String, + p: String, +} + +#[allow(unused)] +#[derive(Deserialize, Debug)] +struct Map { + name: String, +} + +#[derive(Deserialize, Debug)] +struct Point { + x: String, + y: String, +} + +#[allow(non_snake_case)] +#[derive(Deserialize, Debug)] +struct TestCase { + P: Point, + Q0: Point, + Q1: Point, + msg: String, + u: [String; 2], +} + +#[allow(unused, non_snake_case)] +#[derive(Deserialize, Debug)] +struct HashToCurveTestSuite { + L: String, + Z: String, + ciphersuite: String, + curve: String, + dst: String, + expand: String, + field: Field, + hash: String, + k: String, + map: Map, + randomOracle: bool, + vectors: Vec, +} + +fn parse_hex(s: &str) -> Vec { + Vec::from_hex(s.trim_start_matches("0x")).unwrap() +} + +fn sample_g1(host: &Host, rng: &mut StdRng) -> Result { + host.g1_affine_serialize_uncompressed(&G1Affine::rand(rng)) +} + +fn sample_g1_not_on_curve(host: &Host, rng: &mut StdRng) -> Result { + loop { + let x = Fq::rand(rng); + let y = Fq::rand(rng); + let p = G1Affine::new_unchecked(x, y); + if !p.is_on_curve() { + return host.g1_affine_serialize_uncompressed(&p); + } + } +} + +fn sample_g1_not_in_subgroup(host: &Host, rng: &mut StdRng) -> Result { + loop { + let x = Fq::rand(rng); + if let Some(p) = G1Affine::get_point_from_x_unchecked(x, true) { + assert!(p.is_on_curve()); + if !p.is_in_correct_subgroup_assuming_on_curve() { + return host.g1_affine_serialize_uncompressed(&p); + } + } + } +} + +fn sample_g1_out_of_range(host: &Host, rng: &mut StdRng) -> Result { + let g1 = sample_g1(host, rng)?; + host.bytes_copy_from_slice(g1, U32Val::from(0), MODULUS.as_bytes()) +} + +fn g1_zero(host: &Host) -> Result { + host.g1_affine_serialize_uncompressed(&G1Affine::zero()) +} + +fn neg_g1(bo: BytesObject, host: &Host) -> Result { + let g1 = host.g1_affine_deserialize_from_bytesobj(bo, true)?; + host.g1_affine_serialize_uncompressed(&-g1) +} + +fn invalid_g1( + host: &Host, + ty: InvalidPointTypes, + rng: &mut StdRng, +) -> Result { + let affine = G1Affine::rand(rng); + assert!(!affine.is_zero()); + let bo = host.g1_affine_serialize_uncompressed(&affine)?; + match ty { + InvalidPointTypes::TooManyBytes => { + // insert an empty byte to the end + host.bytes_insert(bo, U32Val::from(G1_SERIALIZED_SIZE as u32), U32Val::from(0)) + } + InvalidPointTypes::TooFewBytes => { + // delete the last byte + host.bytes_del(bo, U32Val::from(G1_SERIALIZED_SIZE as u32 - 1)) + } + InvalidPointTypes::CompressionFlagSet => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 7)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::InfinityFlagSetBitsNotAllZero => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 6)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::SortFlagSet => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 5)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::PointNotOnCurve => sample_g1_not_on_curve(host, rng), + InvalidPointTypes::PointNotInSubgroup => sample_g1_not_in_subgroup(host, rng), + InvalidPointTypes::OutOfRange => sample_g1_out_of_range(host, rng), + } +} + +fn sample_g2(host: &Host, rng: &mut StdRng) -> Result { + host.g2_affine_serialize_uncompressed(&G2Affine::rand(rng)) +} + +fn sample_g2_not_on_curve(host: &Host, rng: &mut StdRng) -> Result { + loop { + let x = Fq2::rand(rng); + let y = Fq2::rand(rng); + let p = G2Affine::new_unchecked(x, y); + if !p.is_on_curve() { + return host.g2_affine_serialize_uncompressed(&p); + } + } +} + +fn sample_g2_not_in_subgroup(host: &Host, rng: &mut StdRng) -> Result { + loop { + let x = Fq2::rand(rng); + if let Some(p) = G2Affine::get_point_from_x_unchecked(x, true) { + assert!(p.is_on_curve()); + if !p.is_in_correct_subgroup_assuming_on_curve() { + return host.g2_affine_serialize_uncompressed(&p); + } + } + } +} + +fn g2_zero(host: &Host) -> Result { + host.g2_affine_serialize_uncompressed(&G2Affine::zero()) +} + +fn sample_g2_out_of_range(host: &Host, rng: &mut StdRng) -> Result { + let g2 = sample_g2(host, rng)?; + host.bytes_copy_from_slice(g2, U32Val::from(0), MODULUS.as_bytes()) +} + +fn neg_g2(bo: BytesObject, host: &Host) -> Result { + let g2 = host.g2_affine_deserialize_from_bytesobj(bo, true)?; + host.g2_affine_serialize_uncompressed(&-g2) +} + +fn invalid_g2( + host: &Host, + ty: InvalidPointTypes, + rng: &mut StdRng, +) -> Result { + let affine = G2Affine::rand(rng); + assert!(!affine.is_zero()); + let bo = host.g2_affine_serialize_uncompressed(&affine)?; + match ty { + InvalidPointTypes::TooManyBytes => { + // insert an empty byte to the end + host.bytes_insert(bo, U32Val::from(G2_SERIALIZED_SIZE as u32), U32Val::from(0)) + } + InvalidPointTypes::TooFewBytes => { + // delete the last byte + host.bytes_del(bo, U32Val::from(G2_SERIALIZED_SIZE as u32 - 1)) + } + InvalidPointTypes::CompressionFlagSet => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 7)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::InfinityFlagSetBitsNotAllZero => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 6)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::SortFlagSet => { + let mut first_byte: u32 = host.bytes_get(bo, U32Val::from(0))?.into(); + first_byte = ((first_byte as u8) | (1 << 5)) as u32; + host.bytes_put(bo, U32Val::from(0), U32Val::from(first_byte)) + } + InvalidPointTypes::PointNotOnCurve => sample_g2_not_on_curve(host, rng), + InvalidPointTypes::PointNotInSubgroup => sample_g2_not_in_subgroup(host, rng), + InvalidPointTypes::OutOfRange => sample_g2_out_of_range(host, rng), + } +} + +fn parse_g2_point_test_case(host: &Host, p: Point) -> Result { + let mut p_bytes = [0u8; 192]; + // the input point format in each coordinate is (c0,c1), each part + // being a hex string starting '0x'. So we need to split it by comma, + // flip the two parts, and parse each part (each part is already + // big-endian, so all we need to do is to strip the prefix) + let qx: Vec<_> = p.x.split(',').collect(); + let qy: Vec<_> = p.y.split(',').collect(); + p_bytes[0..48].copy_from_slice(&parse_hex(qx[1])); + p_bytes[48..96].copy_from_slice(&parse_hex(qx[0])); + p_bytes[96..144].copy_from_slice(&parse_hex(qy[1])); + p_bytes[144..192].copy_from_slice(&parse_hex(qy[0])); + host.bytes_new_from_slice(&p_bytes) +} + +#[allow(unused)] +fn sample_fp(host: &Host, rng: &mut StdRng) -> Result { + let fp = Fq::rand(rng); + host.fp_serialize_into_bytesobj(&fp) +} + +fn invalid_fp( + host: &Host, + ty: InvalidPointTypes, + rng: &mut StdRng, +) -> Result { + let fp = Fq::rand(rng); + match ty { + InvalidPointTypes::TooManyBytes => { + let mut buf = [0u8; FP_SERIALIZED_SIZE + 1]; // one extra zero byte + host.serialize_uncompressed_into_slice::<49, _>(&fp, &mut buf, "test")?; + host.bytes_new_from_slice(&buf) + } + InvalidPointTypes::TooFewBytes => { + let mut buf = [0u8; FP_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::(&fp, &mut buf, "test")?; + host.bytes_new_from_slice(&buf[0..FP_SERIALIZED_SIZE - 1]) // take one less byte + } + InvalidPointTypes::OutOfRange => { + // Fp can only take the range of (0, MODULUS-1) + let bytes = parse_hex(&MODULUS); + host.bytes_new_from_slice(bytes.as_slice()) + } + _ => panic!("not available"), + } +} + +#[allow(unused)] +fn sample_fp2(host: &Host, rng: &mut StdRng) -> Result { + let fp2 = Fq2::rand(rng); + host.fp2_serialize_into_bytesobj(&fp2) +} + +fn invalid_fp2( + host: &Host, + ty: InvalidPointTypes, + rng: &mut StdRng, +) -> Result { + let fp = Fq::rand(rng); + match ty { + InvalidPointTypes::TooManyBytes => { + let mut buf = [0u8; FP2_SERIALIZED_SIZE + 1]; // one extra zero byte + host.serialize_uncompressed_into_slice::<97, _>(&fp, &mut buf, "test")?; + host.bytes_new_from_slice(&buf) + } + InvalidPointTypes::TooFewBytes => { + let mut buf = [0u8; FP2_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::( + &fp, &mut buf, "test", + )?; + host.bytes_new_from_slice(&buf[0..FP2_SERIALIZED_SIZE - 1]) // take one less byte + } + InvalidPointTypes::OutOfRange => { + // Each Fp can only take the range of (0, MODULUS-1) + let bytes = parse_hex(&MODULUS); + host.bytes_new_from_slice(bytes.as_slice()) + } + _ => panic!("not available"), + } +} + +fn sample_fr(host: &Host, rng: &mut StdRng) -> Result { + let obj = host.obj_from_u256_pieces( + u64::rand(rng), + u64::rand(rng), + u64::rand(rng), + u64::rand(rng), + )?; + Ok(obj.into()) +} + +fn sample_host_vec( + host: &Host, + vec_len: usize, + rng: &mut StdRng, +) -> Result { + let vals: Vec = (0..vec_len) + .into_iter() + .map(|_| { + let t = T::rand(rng); + let mut buf = vec![0; EXPECTED_SIZE]; + host.serialize_uncompressed_into_slice::(&t, &mut buf, "test") + .unwrap(); + host.bytes_new_from_slice(&buf).unwrap().to_val() + }) + .collect(); + host.vec_new_from_slice(&vals) +} + +fn zero_g1_vec(host: &Host, vec_len: usize) -> Result { + let vals: Vec = (0..vec_len) + .into_iter() + .map(|_| g1_zero(host).unwrap().to_val()) + .collect(); + host.vec_new_from_slice(&vals) +} + +fn zero_g2_vec(host: &Host, vec_len: usize) -> Result { + let vals: Vec = (0..vec_len) + .into_iter() + .map(|_| g2_zero(host).unwrap().to_val()) + .collect(); + host.vec_new_from_slice(&vals) +} + +fn sample_fr_vec(host: &Host, vec_len: usize, rng: &mut StdRng) -> Result { + let vals: Vec = (0..vec_len) + .into_iter() + .map(|_| { + host.obj_from_u256_pieces( + u64::rand(rng), + u64::rand(rng), + u64::rand(rng), + u64::rand(rng), + ) + .unwrap() + .to_val() + }) + .collect(); + host.vec_new_from_slice(&vals) +} + +#[test] +fn check_g1_is_in_subgroup() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid point + { + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::TooManyBytes, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::TooFewBytes, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::CompressionFlagSet, + &mut rng + )?,), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )?,), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::SortFlagSet, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::PointNotOnCurve, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::OutOfRange, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // valid point in subgroup + { + for _ in 0..10 { + assert!(host + .bls12_381_check_g1_is_in_subgroup(sample_g1(&host, &mut rng)?)? + .to_val() + .is_true()) + } + } + // infinity point is in subgroup + { + assert!(host + .bls12_381_check_g1_is_in_subgroup(g1_zero(&host)?)? + .to_val() + .is_true()) + } + // out of subgroup + { + for _ in 0..10 { + assert!(host + .bls12_381_check_g1_is_in_subgroup(invalid_g1( + &host, + InvalidPointTypes::PointNotInSubgroup, + &mut rng + )?)? + .to_val() + .is_false()) + } + } + Ok(()) +} + +#[test] +fn g1_add() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid p1 + { + let p2 = sample_g1(&host, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::TooManyBytes, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::TooFewBytes, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::CompressionFlagSet, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::SortFlagSet, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::PointNotOnCurve, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + // addition does not require input points to be in the correcct subgroup + assert!(host + .bls12_381_g1_add( + invalid_g1(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)?, + p2 + ) + .is_ok()) + } + // invalid p2 + { + let p1 = sample_g1(&host, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::TooManyBytes, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::TooFewBytes, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::CompressionFlagSet, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::SortFlagSet, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::PointNotOnCurve, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + // addition does not require input points to be in the correcct subgroup + assert!(host + .bls12_381_g1_add( + p1, + invalid_g1(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)? + ) + .is_ok()); + } + // 3. lhs.add(zero) = lhs + { + let p1 = sample_g1(&host, &mut rng)?; + let res = host.bls12_381_g1_add(p1, g1_zero(&host)?)?; + assert_eq!(host.obj_cmp(p1.into(), res.into())?, Ordering::Equal as i64); + } + // 4. zero.add(rhs) = rhs + { + let p2 = sample_g1(&host, &mut rng)?; + let res = host.bls12_381_g1_add(g1_zero(&host)?, p2)?; + assert_eq!(host.obj_cmp(p2.into(), res.into())?, Ordering::Equal as i64); + } + // 5. communitive a + b = b + a + { + let a = sample_g1(&host, &mut rng)?; + let b = sample_g1(&host, &mut rng)?; + let a_plus_b = host.bls12_381_g1_add(a, b)?; + let b_plus_a = host.bls12_381_g1_add(b, a)?; + assert_eq!( + host.obj_cmp(a_plus_b.into(), b_plus_a.into())?, + Ordering::Equal as i64 + ); + } + // 6. associative (a + b) + c = a + (b + c) + { + let a = sample_g1(&host, &mut rng)?; + let b = sample_g1(&host, &mut rng)?; + let c = sample_g1(&host, &mut rng)?; + let aplusb = host.bls12_381_g1_add(a, b)?; + let aplusb_plus_c = host.bls12_381_g1_add(aplusb, c)?; + let bplusc = host.bls12_381_g1_add(b, c)?; + let a_plus_bplusc = host.bls12_381_g1_add(a, bplusc)?; + assert_eq!( + host.obj_cmp(aplusb_plus_c.into(), a_plus_bplusc.into())?, + Ordering::Equal as i64 + ); + } + // 7. a - a = zero + { + let a = sample_g1(&host, &mut rng)?; + let neg_a = neg_g1(a.clone(), &host)?; + let res = host.bls12_381_g1_add(a, neg_a)?; + let zero = g1_zero(&host)?; + assert_eq!( + host.obj_cmp(res.into(), zero.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn g1_mul() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // 2. lhs * 0 = 0 + { + let lhs = sample_g1(&host, &mut rng)?; + let rhs = host.obj_from_u256_pieces(0, 0, 0, 0)?; + let res = host.bls12_381_g1_mul(lhs, rhs.into())?; + let zero = g1_zero(&host)?; + assert_eq!( + host.obj_cmp(res.into(), zero.into())?, + Ordering::Equal as i64 + ); + } + // 3. lhs * 1 = lhs + { + let lhs = sample_g1(&host, &mut rng)?; + let rhs = U256Val::from_u32(1); + let res = host.bls12_381_g1_mul(lhs, rhs.into())?; + assert_eq!( + host.obj_cmp(res.into(), lhs.into())?, + Ordering::Equal as i64 + ); + } + // 4. associative P * a * b = P * b * a + { + let p = sample_g1(&host, &mut rng)?; + let a = sample_fr(&host, &mut rng)?; + let b = sample_fr(&host, &mut rng)?; + let pa = host.bls12_381_g1_mul(p, a)?; + let pab = host.bls12_381_g1_mul(pa, b)?; + let pb = host.bls12_381_g1_mul(p, b)?; + let pba = host.bls12_381_g1_mul(pb, a)?; + assert_eq!( + host.obj_cmp(pab.into(), pba.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn g1_msm() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // vector lengths are zero + { + let vp = host.vec_new()?; + let vs = host.vec_new()?; + assert!(HostError::result_matches_err( + host.bls12_381_g1_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector lengths not equal + { + let vp = sample_host_vec::(&host, 2, &mut rng)?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g1_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector g1 not valid + { + let vp = host.vec_new_from_slice(&[ + sample_g1(&host, &mut rng)?.to_val(), + invalid_g1(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)?.to_val(), + sample_g1(&host, &mut rng)?.to_val(), + ])?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g1_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector of zero points result zero + { + let vp = host.vec_new_from_slice(&[g1_zero(&host)?.to_val(); 3])?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + let res = host.bls12_381_g1_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g1_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // vector of zero scalars result in zero point + { + let vp = sample_host_vec::(&host, 3, &mut rng)?; + let vs = host.vec_new_from_slice(&[U256Val::from_u32(0).to_val(); 3])?; + let res = host.bls12_381_g1_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g1_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // 6. g1 * (1) + g1 (-1) = 0 + { + let pt = sample_g1(&host, &mut rng)?; + let zero = g1_zero(&host)?; + assert_ne!( + host.obj_cmp(pt.into(), zero.into())?, + Ordering::Equal as i64 + ); + let neg_pt = neg_g1(pt, &host)?; + let vp = host.vec_new_from_slice(&[pt.to_val(), neg_pt.to_val()])?; + let vs = host.vec_new_from_slice(&[U256Val::from_u32(1).to_val(); 2])?; + let res = host.bls12_381_g1_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g1_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // 7. associative: shuffle points orders results stay the same + { + host.budget_ref().reset_default()?; + let mut vp = vec![ + sample_g1(&host, &mut rng)?.to_val(), + sample_g1(&host, &mut rng)?.to_val(), + sample_g1(&host, &mut rng)?.to_val(), + sample_g1(&host, &mut rng)?.to_val(), + ]; + let mut vs = vec![ + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + ]; + let ref_res = + host.bls12_381_g1_msm(host.vec_new_from_slice(&vp)?, host.vec_new_from_slice(&vs)?)?; + let mut rng = StdRng::from_seed([0xff; 32]); + let mut shuffle_with_order = |v1: &mut Vec, v2: &mut Vec| { + use rand::seq::SliceRandom; + assert_eq!(v1.len(), v2.len()); + let mut indices: Vec = (0..v1.len()).collect(); + indices.shuffle(&mut rng); + let v1_shuffled: Vec = indices.iter().map(|&i| v1[i]).collect(); + let v2_shuffled: Vec = indices.iter().map(|&i| v2[i]).collect(); + *v1 = v1_shuffled; + *v2 = v2_shuffled; + }; + + for _ in 0..10 { + shuffle_with_order(&mut vp, &mut vs); + let vp_obj = host.vec_new_from_slice(&vp)?; + let vs_obj = host.vec_new_from_slice(&vs)?; + let res = host.bls12_381_g1_msm(vp_obj, vs_obj)?; + assert_eq!( + host.obj_cmp(res.into(), ref_res.into())?, + Ordering::Equal as i64 + ); + } + } + // 8. msm result is same as invidial mul and add + { + host.budget_ref().reset_default()?; + let vp = sample_host_vec::(&host, 10, &mut rng)?; + let vs = sample_fr_vec(&host, 10, &mut rng)?; + let ref_res = host.bls12_381_g1_msm(vp, vs)?; + let mut res = g1_zero(&host)?; + for i in 0..10 { + let p: BytesObject = host.vec_get(vp, U32Val::from(i))?.try_into()?; + let s: U256Val = host.vec_get(vs, U32Val::from(i))?.try_into()?; + let rhs = host.bls12_381_g1_mul(p, s)?; + res = host.bls12_381_g1_add(res, rhs)?; + } + assert_eq!( + host.obj_cmp(res.into(), ref_res.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn map_fp_to_g1() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid fp: wrong length + { + let p1 = invalid_fp(&host, InvalidPointTypes::TooFewBytes, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp_to_g1(p1), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + let p2 = invalid_fp(&host, InvalidPointTypes::TooManyBytes, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp_to_g1(p2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + let p3 = invalid_fp(&host, InvalidPointTypes::OutOfRange, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp_to_g1(p3), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // Test cases from https://datatracker.ietf.org/doc/html/rfc9380#name-bls12381g1_xmdsha-256_sswu_ + // To interpret the results, understand the steps it takes to hash a msg to curve + // 1. u = hash_to_field(msg, 2) + // 2. Q0 = map_to_curve(u[0]) + // 3. Q1 = map_to_curve(u[1]) + // 4. R = Q0 + Q1 # Point addition + // 5. P = clear_cofactor(R) + // 6. return P + { + host.budget_ref().reset_default()?; + let test_map_fp_to_curve_inner = |u: String, q: Point| -> Result<(), HostError> { + let mut q_bytes = [0u8; 96]; + q_bytes[0..48].copy_from_slice(&parse_hex(&q.x)); + q_bytes[48..].copy_from_slice(&parse_hex(&q.y)); + let g1 = host.bytes_new_from_slice(&q_bytes)?; + let fp = host.bytes_new_from_slice(&parse_hex(&u))?; + let res = host.bls12_381_map_fp_to_g1(fp)?; + assert_eq!(host.obj_cmp(res.into(), g1.into())?, Ordering::Equal as i64); + Ok(()) + }; + + let test_suite: HashToCurveTestSuite = serde_json::from_slice( + &std::fs::read("./src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json").unwrap(), + ) + .unwrap(); + println!("{test_suite:?}"); + for case in test_suite.vectors { + let [u0, u1] = case.u; + test_map_fp_to_curve_inner(u0, case.Q0)?; + test_map_fp_to_curve_inner(u1, case.Q1)?; + } + } + Ok(()) +} + +#[test] +fn hash_to_g1() -> Result<(), HostError> { + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // 1. invalid input dst length = 0 + { + let dst = host.bytes_new_from_slice(&[])?; + let msg = host.bytes_new_from_slice("some message".as_bytes())?; + assert!(HostError::result_matches_err( + host.bls12_381_hash_to_g1(msg, dst), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 2. invalid input dst length > 255 + { + let dst = host.bytes_new_from_slice(&[0; 256])?; + let msg = host.bytes_new_from_slice("some message".as_bytes())?; + assert!(HostError::result_matches_err( + host.bls12_381_hash_to_g1(msg, dst), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 3. test vectors from https://datatracker.ietf.org/doc/html/rfc9380#name-bls12381g1_xmdsha-256_sswu_ + { + let test_suite: HashToCurveTestSuite = serde_json::from_slice( + &std::fs::read("./src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json").unwrap(), + ) + .unwrap(); + let dst = host.bytes_new_from_slice(test_suite.dst.as_bytes())?; + let parse_g1 = |p: Point| -> Result { + let mut p_bytes = [0u8; 96]; + p_bytes[0..48].copy_from_slice(&parse_hex(&p.x)); + p_bytes[48..].copy_from_slice(&parse_hex(&p.y)); + host.bytes_new_from_slice(&p_bytes) + }; + + for case in test_suite.vectors { + let msg = host.bytes_new_from_slice(case.msg.as_bytes())?; + let g1 = host.bls12_381_hash_to_g1(msg, dst)?; + let g1_ref = parse_g1(case.P)?; + assert_eq!( + host.obj_cmp(g1.into(), g1_ref.into())?, + Ordering::Equal as i64 + ); + } + } + Ok(()) +} + +// g2 tests + +#[test] +fn check_g2_is_in_subgroup() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid point + { + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::TooManyBytes, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::TooFewBytes, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::CompressionFlagSet, + &mut rng + )?,), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )?,), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::SortFlagSet, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::PointNotOnCurve, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::OutOfRange, + &mut rng + )?), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // valid point in subgroup + { + for _ in 0..10 { + assert!(host + .bls12_381_check_g2_is_in_subgroup(sample_g2(&host, &mut rng)?)? + .to_val() + .is_true()) + } + } + // infinity point is in subgroup + { + assert!(host + .bls12_381_check_g2_is_in_subgroup(g2_zero(&host)?)? + .to_val() + .is_true()) + } + // out of subgroup + { + for _ in 0..10 { + assert!(host + .bls12_381_check_g2_is_in_subgroup(invalid_g2( + &host, + InvalidPointTypes::PointNotInSubgroup, + &mut rng + )?)? + .to_val() + .is_false()) + } + } + Ok(()) +} + +#[test] +fn g2_add() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid p1 + { + let p2 = sample_g2(&host, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::TooManyBytes, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::TooFewBytes, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::CompressionFlagSet, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::SortFlagSet, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::PointNotOnCurve, &mut rng)?, + p2 + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + // addition does not require input points to be in the correcct subgroup + assert!(host + .bls12_381_g2_add( + invalid_g2(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)?, + p2 + ) + .is_ok()); + } + // invalid p2 + { + let p1 = sample_g2(&host, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::TooManyBytes, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::TooFewBytes, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::CompressionFlagSet, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2( + &host, + InvalidPointTypes::InfinityFlagSetBitsNotAllZero, + &mut rng + )? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::SortFlagSet, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + assert!(HostError::result_matches_err( + host.bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::PointNotOnCurve, &mut rng)? + ), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + // addition does not require input points to be in the correcct subgroup + assert!(host + .bls12_381_g2_add( + p1, + invalid_g2(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)? + ) + .is_ok()); + } + // 3. lhs.add(zero) = lhs + { + let p1 = sample_g2(&host, &mut rng)?; + let res = host.bls12_381_g2_add(p1, g2_zero(&host)?)?; + assert_eq!(host.obj_cmp(p1.into(), res.into())?, Ordering::Equal as i64); + } + // 4. zero.add(rhs) = rhs + { + let p2 = sample_g2(&host, &mut rng)?; + let res = host.bls12_381_g2_add(g2_zero(&host)?, p2)?; + assert_eq!(host.obj_cmp(p2.into(), res.into())?, Ordering::Equal as i64); + } + // 5. communitive a + b = b + a + { + let a = sample_g2(&host, &mut rng)?; + let b = sample_g2(&host, &mut rng)?; + let a_plus_b = host.bls12_381_g2_add(a, b)?; + let b_plus_a = host.bls12_381_g2_add(b, a)?; + assert_eq!( + host.obj_cmp(a_plus_b.into(), b_plus_a.into())?, + Ordering::Equal as i64 + ); + } + // 6. associative (a + b) + c = a + (b + c) + { + let a = sample_g2(&host, &mut rng)?; + let b = sample_g2(&host, &mut rng)?; + let c = sample_g2(&host, &mut rng)?; + let aplusb = host.bls12_381_g2_add(a, b)?; + let aplusb_plus_c = host.bls12_381_g2_add(aplusb, c)?; + let bplusc = host.bls12_381_g2_add(b, c)?; + let a_plus_bplusc = host.bls12_381_g2_add(a, bplusc)?; + assert_eq!( + host.obj_cmp(aplusb_plus_c.into(), a_plus_bplusc.into())?, + Ordering::Equal as i64 + ); + } + // 7. a - a = zero + { + let a = sample_g2(&host, &mut rng)?; + let neg_a = neg_g2(a.clone(), &host)?; + let res = host.bls12_381_g2_add(a, neg_a)?; + let zero = g2_zero(&host)?; + assert_eq!( + host.obj_cmp(res.into(), zero.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn g2_mul() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // 2. lhs * 0 = 0 + { + let lhs = sample_g2(&host, &mut rng)?; + let rhs = host.obj_from_u256_pieces(0, 0, 0, 0)?; + let res = host.bls12_381_g2_mul(lhs, rhs.into())?; + let zero = g2_zero(&host)?; + assert_eq!( + host.obj_cmp(res.into(), zero.into())?, + Ordering::Equal as i64 + ); + } + // 3. lhs * 1 = lhs + { + let lhs = sample_g2(&host, &mut rng)?; + let rhs = U256Val::from_u32(1); + let res = host.bls12_381_g2_mul(lhs, rhs.into())?; + assert_eq!( + host.obj_cmp(res.into(), lhs.into())?, + Ordering::Equal as i64 + ); + } + // 4. associative P * a * b = P * b * a + { + let p = sample_g2(&host, &mut rng)?; + let a = sample_fr(&host, &mut rng)?; + let b = sample_fr(&host, &mut rng)?; + let pa = host.bls12_381_g2_mul(p, a)?; + let pab = host.bls12_381_g2_mul(pa, b)?; + let pb = host.bls12_381_g2_mul(p, b)?; + let pba = host.bls12_381_g2_mul(pb, a)?; + assert_eq!( + host.obj_cmp(pab.into(), pba.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn g2_msm() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // vector lengths are zero + { + let vp = host.vec_new()?; + let vs = host.vec_new()?; + assert!(HostError::result_matches_err( + host.bls12_381_g2_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector lengths not equal + { + let vp = sample_host_vec::(&host, 2, &mut rng)?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g2_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector g2 not valid + { + let vp = host.vec_new_from_slice(&[ + sample_g2(&host, &mut rng)?.to_val(), + invalid_g2(&host, InvalidPointTypes::PointNotInSubgroup, &mut rng)?.to_val(), + sample_g2(&host, &mut rng)?.to_val(), + ])?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_g2_msm(vp, vs), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // vector of zero points result zero + { + let vp = host.vec_new_from_slice(&[g2_zero(&host)?.to_val(); 3])?; + let vs = sample_fr_vec(&host, 3, &mut rng)?; + let res = host.bls12_381_g2_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g2_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // vector of zero scalars result in zero point + { + let vp = sample_host_vec::(&host, 3, &mut rng)?; + let vs = host.vec_new_from_slice(&[U256Val::from_u32(0).to_val(); 3])?; + let res = host.bls12_381_g2_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g2_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // 6. g2 * (1) + g2 (-1) = 0 + { + host.budget_ref().reset_default()?; + let pt = sample_g2(&host, &mut rng)?; + let zero = g2_zero(&host)?; + assert_ne!( + host.obj_cmp(pt.into(), zero.into())?, + Ordering::Equal as i64 + ); + let neg_pt = neg_g2(pt, &host)?; + let vp = host.vec_new_from_slice(&[pt.to_val(), neg_pt.to_val()])?; + let vs = host.vec_new_from_slice(&[U256Val::from_u32(1).to_val(); 2])?; + let res = host.bls12_381_g2_msm(vp, vs)?; + assert_eq!( + host.obj_cmp(res.into(), g2_zero(&host)?.into())?, + Ordering::Equal as i64 + ); + } + // 7. associative: shuffle points orders results stay the same + { + let mut vp = vec![ + sample_g2(&host, &mut rng)?.to_val(), + sample_g2(&host, &mut rng)?.to_val(), + sample_g2(&host, &mut rng)?.to_val(), + sample_g2(&host, &mut rng)?.to_val(), + ]; + let mut vs = vec![ + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + sample_fr(&host, &mut rng)?.to_val(), + ]; + let ref_res = + host.bls12_381_g2_msm(host.vec_new_from_slice(&vp)?, host.vec_new_from_slice(&vs)?)?; + let mut rng = StdRng::from_seed([0xff; 32]); + let mut shuffle_with_order = |v1: &mut Vec, v2: &mut Vec| { + use rand::seq::SliceRandom; + assert_eq!(v1.len(), v2.len()); + let mut indices: Vec = (0..v1.len()).collect(); + indices.shuffle(&mut rng); + let v1_shuffled: Vec = indices.iter().map(|&i| v1[i]).collect(); + let v2_shuffled: Vec = indices.iter().map(|&i| v2[i]).collect(); + *v1 = v1_shuffled; + *v2 = v2_shuffled; + }; + + for _ in 0..10 { + host.budget_ref().reset_default()?; + shuffle_with_order(&mut vp, &mut vs); + let vp_obj = host.vec_new_from_slice(&vp)?; + let vs_obj = host.vec_new_from_slice(&vs)?; + let res = host.bls12_381_g2_msm(vp_obj, vs_obj)?; + assert_eq!( + host.obj_cmp(res.into(), ref_res.into())?, + Ordering::Equal as i64 + ); + } + } + // 8. msm result is same as invidial mul and add + { + host.budget_ref().reset_default()?; + let vp = sample_host_vec::(&host, 5, &mut rng)?; + let vs = sample_fr_vec(&host, 5, &mut rng)?; + let ref_res = host.bls12_381_g2_msm(vp, vs)?; + let mut res = g2_zero(&host)?; + for i in 0..5 { + let p: BytesObject = host.vec_get(vp, U32Val::from(i))?.try_into()?; + let s: U256Val = host.vec_get(vs, U32Val::from(i))?.try_into()?; + let rhs = host.bls12_381_g2_mul(p, s)?; + res = host.bls12_381_g2_add(res, rhs)?; + } + assert_eq!( + host.obj_cmp(res.into(), ref_res.into())?, + Ordering::Equal as i64 + ); + } + Ok(()) +} + +#[test] +fn map_fp2_to_g2() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // invalid fp2: wrong length + { + let p1 = invalid_fp2(&host, InvalidPointTypes::TooFewBytes, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp2_to_g2(p1), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + let p2 = invalid_fp2(&host, InvalidPointTypes::TooManyBytes, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp2_to_g2(p2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + let p3 = invalid_fp2(&host, InvalidPointTypes::OutOfRange, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_map_fp2_to_g2(p3), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // Test cases from https://datatracker.ietf.org/doc/html/rfc9380#name-bls12381g2_xmdsha-256_sswu_ + // To interpret the results, understand the steps it takes to hash a msg to curve + // 1. u = hash_to_field(msg, 2) + // 2. Q0 = map_to_curve(u[0]) + // 3. Q1 = map_to_curve(u[1]) + // 4. R = Q0 + Q1 # Point addition + // 5. P = clear_cofactor(R) + // 6. return P + { + host.budget_ref().reset_default()?; + let test_map_fp2_to_curve_inner = |u: String, q: Point| -> Result<(), HostError> { + let g2 = parse_g2_point_test_case(&host, q)?; + let mut u_bytes = [0u8; 96]; + let uu: Vec<_> = u.split(',').collect(); + u_bytes[0..48].copy_from_slice(&parse_hex(uu[1])); + u_bytes[48..96].copy_from_slice(&parse_hex(uu[0])); + let fp2 = host.bytes_new_from_slice(&u_bytes)?; + let res = host.bls12_381_map_fp2_to_g2(fp2)?; + assert_eq!(host.obj_cmp(res.into(), g2.into())?, Ordering::Equal as i64); + Ok(()) + }; + + let test_suite: HashToCurveTestSuite = serde_json::from_slice( + &std::fs::read("./src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json").unwrap(), + ) + .unwrap(); + for case in test_suite.vectors { + let [u0, u1] = case.u; + test_map_fp2_to_curve_inner(u0, case.Q0)?; + test_map_fp2_to_curve_inner(u1, case.Q1)?; + } + } + Ok(()) +} + +#[test] +fn hash_to_g2() -> Result<(), HostError> { + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // 1. invalid input dst length = 0 + { + let dst = host.bytes_new_from_slice(&[])?; + let msg = host.bytes_new_from_slice("some message".as_bytes())?; + assert!(HostError::result_matches_err( + host.bls12_381_hash_to_g2(msg, dst), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 2. invalid input dst length > 255 + { + let dst = host.bytes_new_from_slice(&[0; 256])?; + let msg = host.bytes_new_from_slice("some message".as_bytes())?; + assert!(HostError::result_matches_err( + host.bls12_381_hash_to_g2(msg, dst), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 3. test vectors from https://datatracker.ietf.org/doc/html/rfc9380#name-bls12381g2_xmdsha-256_sswu_ + { + let test_suite: HashToCurveTestSuite = serde_json::from_slice( + &std::fs::read("./src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json").unwrap(), + ) + .unwrap(); + let dst = host.bytes_new_from_slice(test_suite.dst.as_bytes())?; + for case in test_suite.vectors { + let msg = host.bytes_new_from_slice(case.msg.as_bytes())?; + let g2 = host.bls12_381_hash_to_g2(msg, dst)?; + let g2_ref = parse_g2_point_test_case(&host, case.P)?; + assert_eq!( + host.obj_cmp(g2.into(), g2_ref.into())?, + Ordering::Equal as i64 + ); + } + } + Ok(()) +} + +// pairing checks +#[test] +fn pairing() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // 1. vector lengths don't match + { + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let vp2 = sample_host_vec::(&host, 2, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_multi_pairing_check(vp1, vp2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 2. vector length is 0 + { + let vp1 = sample_host_vec::(&host, 0, &mut rng)?; + let vp2 = sample_host_vec::(&host, 0, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_multi_pairing_check(vp1, vp2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 3. any g1 is invalid + { + let mut vp1 = sample_host_vec::(&host, 3, &mut rng)?; + vp1 = host.vec_put( + vp1, + U32Val::from(1), + sample_g1_not_in_subgroup(&host, &mut rng)?.to_val(), + )?; + let vp2 = sample_host_vec::(&host, 2, &mut rng)?; + assert!(HostError::result_matches_err( + host.bls12_381_multi_pairing_check(vp1, vp2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 4. any g2 is invalid + { + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let mut vp2 = sample_host_vec::(&host, 3, &mut rng)?; + vp2 = host.vec_put( + vp2, + U32Val::from(1), + sample_g2_not_on_curve(&host, &mut rng)?.to_val(), + )?; + assert!(HostError::result_matches_err( + host.bls12_381_multi_pairing_check(vp1, vp2), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + // 5. e(P, Q+R) = e(P, Q)*e(P, R) + { + host.budget_ref().reset_default()?; + let p = sample_g1(&host, &mut rng)?; + let neg_p = neg_g1(p, &host)?; + let q = sample_g2(&host, &mut rng)?; + let r = sample_g2(&host, &mut rng)?; + let q_plus_r = host.bls12_381_g2_add(q, r)?; + + //check e(-P, Q+R)*e(P, Q)*e(P, R) == 1 + let g1_vec = host.vec_new_from_slice(&[neg_p.to_val(), p.to_val(), p.to_val()])?; + let g2_vec = host.vec_new_from_slice(&[q_plus_r.to_val(), q.to_val(), r.to_val()])?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + assert!(res.as_val().is_true()) + } + // 6. e(P+S, R) = e(P, R)*e(S, R) + { + host.budget_ref().reset_default()?; + let p = sample_g1(&host, &mut rng)?; + let s = sample_g1(&host, &mut rng)?; + let r = sample_g2(&host, &mut rng)?; + let neg_r = neg_g2(r, &host)?; + let p_plus_s = host.bls12_381_g1_add(p, s)?; + // check e(P+S, -R) * e(P, R)*e(S, R) == 1 + let g1_vec = host.vec_new_from_slice(&[p_plus_s.to_val(), p.to_val(), s.to_val()])?; + let g2_vec = host.vec_new_from_slice(&[neg_r.to_val(), r.to_val(), r.to_val()])?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + assert!(res.as_val().is_true()) + } + + // 7. e([a]P, [b]Q) = e([b]P, [a]Q) = e([ab]P, Q)= e(P, [ab]Q) + { + host.budget_ref().reset_default()?; + let a = sample_fr(&host, &mut rng)?; + let b = sample_fr(&host, &mut rng)?; + let p = sample_g1(&host, &mut rng)?; + let neg_p = neg_g1(p, &host)?; + let q = sample_g2(&host, &mut rng)?; + let neg_q = neg_g2(q, &host)?; + let a_p = host.bls12_381_g1_mul(p, a)?; + let b_p = host.bls12_381_g1_mul(p, b)?; + let a_q = host.bls12_381_g2_mul(q, a)?; + let b_q = host.bls12_381_g2_mul(q, b)?; + let ab = host.bls12_381_fr_mul(a, b)?; + let ab_p = host.bls12_381_g1_mul(p, ab)?; + let ab_q = host.bls12_381_g2_mul(q, ab)?; + // check e([a]P, [b]Q) * e([b]P, [a]Q) * e([ab]P, -Q) * e(-P, [ab]Q) == 1 + let g1_vec = + host.vec_new_from_slice(&[a_p.to_val(), b_p.to_val(), ab_p.to_val(), neg_p.to_val()])?; + let g2_vec = + host.vec_new_from_slice(&[b_q.to_val(), a_q.to_val(), neg_q.to_val(), ab_q.to_val()])?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + assert!(res.as_val().is_true()) + } + // 8. any of g1 point is infinity + { + host.budget_ref().reset_default()?; + let mut vp1 = sample_host_vec::(&host, 3, &mut rng)?; + vp1 = host.vec_put(vp1, U32Val::from(1), g1_zero(&host)?.to_val())?; + let vp2 = sample_host_vec::(&host, 3, &mut rng)?; + assert!(host.bls12_381_multi_pairing_check(vp1, vp2).is_ok()); + } + // 9. any of g2 point is infinity + { + host.budget_ref().reset_default()?; + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let mut vp2 = sample_host_vec::(&host, 3, &mut rng)?; + vp2 = host.vec_put(vp2, U32Val::from(2), g2_zero(&host)?.to_val())?; + assert!(host.bls12_381_multi_pairing_check(vp1, vp2).is_ok()); + } + // 10. entire vector is zero + { + host.budget_ref().reset_default()?; + let vp1 = zero_g1_vec(&host, 5)?; + let vp2 = zero_g2_vec(&host, 5)?; + assert!(host.bls12_381_multi_pairing_check(vp1, vp2).is_ok()); + } + Ok(()) +} + +// fr arithmetics + +// serialization roundtrip +#[test] +fn test_serialization_roundtrip() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // g1 + { + let g1_roundtrip_check = |g1: &G1Affine, subgroup_check: bool| -> Result { + let bo = host.g1_affine_serialize_uncompressed(&g1)?; + let g1_back = host.g1_affine_deserialize_from_bytesobj(bo, subgroup_check)?; + Ok(g1.eq(&g1_back)) + }; + assert!(g1_roundtrip_check(&G1Affine::zero(), true)?); + assert!(g1_roundtrip_check(&G1Affine::generator(), true)?); + for _ in 0..20 { + // on curve and in subgroup + let g1 = G1Affine::rand(&mut rng); + assert!(g1_roundtrip_check(&g1, true)?) + } + for i in 0..10 { + // on curve and not in subgroup + let g1 = G1Affine::get_point_from_x_unchecked(Fq::rand(&mut rng), (i % 2) != 0) + .unwrap_or(G1Affine::zero()); + assert!(g1_roundtrip_check(&g1, false)?); + if !g1.is_in_correct_subgroup_assuming_on_curve() { + assert!(HostError::result_matches_err( + g1_roundtrip_check(&g1, true), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + for _ in 0..10 { + // not on curve + let g1 = G1Affine::new_unchecked(Fq::rand(&mut rng), Fq::rand(&mut rng)); + if g1.is_on_curve() { + continue; + } + assert!(HostError::result_matches_err( + g1_roundtrip_check(&g1, false), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + // g2 + { + let g2_roundtrip_check = |g2: &G2Affine, subgroup_check: bool| -> Result { + let bo = host.g2_affine_serialize_uncompressed(&g2)?; + let g2_back = host.g2_affine_deserialize_from_bytesobj(bo, subgroup_check)?; + Ok(g2.eq(&g2_back)) + }; + assert!(g2_roundtrip_check(&G2Affine::zero(), true)?); + assert!(g2_roundtrip_check(&G2Affine::generator(), true)?); + for _ in 0..20 { + // on curve and in subgroup + let g2 = G2Affine::rand(&mut rng); + assert!(g2_roundtrip_check(&g2, true)?) + } + for i in 0..10 { + // on curve and not in subgroup + let g2 = G2Affine::get_point_from_x_unchecked(Fq2::rand(&mut rng), (i % 2) != 0) + .unwrap_or(G2Affine::zero()); + assert!(g2_roundtrip_check(&g2, false)?); + if !g2.is_in_correct_subgroup_assuming_on_curve() { + assert!(HostError::result_matches_err( + g2_roundtrip_check(&g2, true), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + for _ in 0..10 { + // not on curve + let g2 = G2Affine::new_unchecked(Fq2::rand(&mut rng), Fq2::rand(&mut rng)); + if g2.is_on_curve() { + continue; + } + assert!(HostError::result_matches_err( + g2_roundtrip_check(&g2, false), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + // fp + { + let fp_roundtrip_check = |fp: &Fq| -> Result { + let mut buf = [0; FP_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::(fp, &mut buf, "Fp")?; + buf.reverse(); + let bo = host.add_host_object(host.scbytes_from_slice(&buf)?)?; + let fp_back = host.fp_deserialize_from_bytesobj(bo)?; + Ok(fp.eq(&fp_back)) + }; + assert!(fp_roundtrip_check(&FQ_ZERO)?); + assert!(fp_roundtrip_check(&FQ_ONE)?); + for _ in 0..20 { + assert!(fp_roundtrip_check(&Fq::rand(&mut rng))?) + } + } + // fp2 + { + let fp2_roundtrip_check = |fp2: &Fq2| -> Result { + let mut buf = [0; FP2_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::(fp2, &mut buf, "Fp2")?; + buf.reverse(); + let bo = host.add_host_object(host.scbytes_from_slice(&buf)?)?; + let fp2_back = host.fp2_deserialize_from_bytesobj(bo)?; + Ok(fp2.eq(&fp2_back)) + }; + for _ in 0..20 { + assert!(fp2_roundtrip_check(&Fq2::rand(&mut rng))?) + } + } + // fr + { + let fr_roundtrip_check = |fr: Fr| -> Result { + let uv = host.fr_to_u256val(fr.clone())?; + let fr_back = host.fr_from_u256val(uv)?; + Ok(fr == fr_back) + }; + for _ in 0..20 { + assert!(fr_roundtrip_check(Fr::rand(&mut rng))?) + } + } + Ok(()) +} diff --git a/soroban-env-host/src/test/budget_metering.rs b/soroban-env-host/src/test/budget_metering.rs index dd15e7708..75a70e531 100644 --- a/soroban-env-host/src/test/budget_metering.rs +++ b/soroban-env-host/src/test/budget_metering.rs @@ -396,6 +396,34 @@ fn total_amount_charged_from_random_inputs() -> Result<(), HostError> { (1, None), /* VerifyEcdsaSecp256r1Sig */ ]); + tracker.extend_from_slice(&[ + (1, None), /* Bls12381EncodeFp */ + (1, None), /* Bls12381DecodeFp */ + (1, None), /* Bls12381G1CheckPointOnCurve */ + (1, None), /* Bls12381G1CheckPointInSubgroup */ + (1, None), /* Bls12381G2CheckPointOnCurve */ + (1, None), /* Bls12381G2CheckPointInSubgroup */ + (1, None), /* Bls12381G1ProjectiveToAffine */ + (1, None), /* Bls12381G2ProjectiveToAffine */ + (1, None), /* Bls12381G1Add */ + (1, None), /* Bls12381G1Mul */ + (1, Some(1)), /* Bls12381G1Msm */ + (1, None), /* Bls12381MapFpToG1 */ + (1, Some(1)), /* Bls12381HashToG1 */ + (1, None), /* Bls12381G2Add */ + (1, None), /* Bls12381G2Mul */ + (1, Some(1)), /* Bls12381G2Msm */ + (1, None), /* Bls12381MapFp2ToG2 */ + (1, Some(1)), /* Bls12381HashToG2 */ + (1, Some(1)), /* Bls12381Pairing */ + (1, None), /* Bls12381FrFromU256 */ + (1, None), /* Bls12381FrToU256 */ + (1, None), /* Bls12381FrAddSub */ + (1, None), /* Bls12381FrMul */ + (1, Some(1)), /* Bls12381FrPow */ + (1, None), /* Bls12381FrInv */ + ]); + for (ty, &(iterations, input)) in tracker.iter().enumerate() { host.with_budget(|b| b.bulk_charge(ContractCostType::VARIANTS[ty], iterations, input))?; } @@ -409,62 +437,87 @@ fn total_amount_charged_from_random_inputs() -> Result<(), HostError> { let actual = format!("{:?}", host.as_budget()); let expected = expect![[r#" - =============================================================================================================================================================================== - Cpu limit: 100000000; used: 15313119 - Mem limit: 41943040; used: 298417 - =============================================================================================================================================================================== - CostType iterations input cpu_insns mem_bytes const_term_cpu lin_term_cpu const_term_mem lin_term_mem - WasmInsnExec 246 None 984 0 4 0 0 0 - MemAlloc 1 Some(152) 453 168 434 16 16 128 - MemCpy 1 Some(65) 50 0 42 16 0 0 - MemCmp 1 Some(74) 53 0 44 16 0 0 - DispatchHostFunction 176 None 54560 0 310 0 0 0 - VisitObject 97 None 5917 0 61 0 0 0 - ValSer 1 Some(49) 241 389 230 29 242 384 - ValDeser 1 Some(103) 62271 309 59052 4001 0 384 - ComputeSha256Hash 1 Some(193) 14310 0 3738 7012 0 0 - ComputeEd25519PubKey 226 None 9097178 0 40253 0 0 0 - VerifyEd25519Sig 1 Some(227) 384738 0 377524 4068 0 0 - VmInstantiation 1 Some(147) 97310 135880 31271 57504 130065 5064 - VmCachedInstantiation 1 Some(147) 41608 71169 40828 680 69472 1478 - InvokeVmFunction 47 None 101003 705 2149 0 15 0 - ComputeKeccak256Hash 1 Some(1) 3812 0 3766 5969 0 0 - DecodeEcdsaCurve256Sig 1 None 710 0 710 0 0 0 - RecoverEcdsaSecp256k1Key 1 None 2315295 181 2315295 0 181 0 - Int256AddSub 1 None 4404 99 4404 0 99 0 - Int256Mul 1 None 4947 99 4947 0 99 0 - Int256Div 1 None 4911 99 4911 0 99 0 - Int256Pow 1 None 4286 99 4286 0 99 0 - Int256Shift 1 None 913 99 913 0 99 0 - ChaCha20DrawBytes 1 Some(1) 1061 0 1058 501 0 0 - ParseWasmInstructions 1 Some(1) 37421 13981 37421 32 13980 215 - ParseWasmFunctions 1 Some(1) 657 180 0 84156 0 23056 - ParseWasmGlobals 1 Some(1) 1276 93 0 163415 0 11924 - ParseWasmTableEntries 1 Some(1) 231 47 0 29644 0 6121 - ParseWasmTypes 1 Some(1) 6977 387 0 893113 0 49554 - ParseWasmDataSegments 1 Some(1) 1444 43 0 184921 0 5525 - ParseWasmElemSegments 1 Some(1) 2440 367 0 312369 0 47034 - ParseWasmImports 1 Some(1) 4134 795 0 529255 0 101762 - ParseWasmExports 1 Some(1) 2825 277 0 361665 0 35491 - ParseWasmDataSegmentBytes 1 Some(1) 0 1 0 14 0 129 - InstantiateWasmInstructions 1 None 43208 70792 43208 0 70792 0 - InstantiateWasmFunctions 1 Some(1) 62 138 0 8050 0 17749 - InstantiateWasmGlobals 1 Some(1) 83 53 0 10647 0 6833 - InstantiateWasmTableEntries 1 Some(1) 15 8 0 1933 0 1025 - InstantiateWasmTypes 1 None 0 0 0 0 0 0 - InstantiateWasmDataSegments 1 Some(1) 134 1012 0 17164 0 129632 - InstantiateWasmElemSegments 1 Some(1) 267 106 0 34261 0 13665 - InstantiateWasmImports 1 Some(1) 5829 770 0 746142 0 98578 - InstantiateWasmExports 1 Some(1) 2313 71 0 296177 0 9176 - InstantiateWasmDataSegmentBytes 1 Some(1) 0 0 0 14 0 126 - Sec1DecodePointUncompressed 1 None 1882 0 1882 0 0 0 - VerifyEcdsaSecp256r1Sig 1 None 3000906 0 3000906 0 0 0 - =============================================================================================================================================================================== - Internal details (diagnostics info, does not affect fees) - Total # times meter was called: 45 - Shadow cpu limit: 100000000; used: 15313119 - Shadow mem limit: 41943040; used: 298417 - =============================================================================================================================================================================== + =============================================================================================================================================================================== + Cpu limit: 100000000; used: 71071547 + Mem limit: 41943040; used: 733666 + =============================================================================================================================================================================== + CostType iterations input cpu_insns mem_bytes const_term_cpu lin_term_cpu const_term_mem lin_term_mem + WasmInsnExec 246 None 984 0 4 0 0 0 + MemAlloc 1 Some(152) 453 168 434 16 16 128 + MemCpy 1 Some(65) 50 0 42 16 0 0 + MemCmp 1 Some(74) 53 0 44 16 0 0 + DispatchHostFunction 176 None 54560 0 310 0 0 0 + VisitObject 97 None 5917 0 61 0 0 0 + ValSer 1 Some(49) 241 389 230 29 242 384 + ValDeser 1 Some(103) 62271 309 59052 4001 0 384 + ComputeSha256Hash 1 Some(193) 14310 0 3738 7012 0 0 + ComputeEd25519PubKey 226 None 9097178 0 40253 0 0 0 + VerifyEd25519Sig 1 Some(227) 384738 0 377524 4068 0 0 + VmInstantiation 1 Some(147) 97310 135880 31271 57504 130065 5064 + VmCachedInstantiation 1 Some(147) 41608 71169 40828 680 69472 1478 + InvokeVmFunction 47 None 101003 705 2149 0 15 0 + ComputeKeccak256Hash 1 Some(1) 3812 0 3766 5969 0 0 + DecodeEcdsaCurve256Sig 1 None 710 0 710 0 0 0 + RecoverEcdsaSecp256k1Key 1 None 2315295 181 2315295 0 181 0 + Int256AddSub 1 None 4404 99 4404 0 99 0 + Int256Mul 1 None 4947 99 4947 0 99 0 + Int256Div 1 None 4911 99 4911 0 99 0 + Int256Pow 1 None 4286 99 4286 0 99 0 + Int256Shift 1 None 913 99 913 0 99 0 + ChaCha20DrawBytes 1 Some(1) 1061 0 1058 501 0 0 + ParseWasmInstructions 1 Some(1) 37421 13981 37421 32 13980 215 + ParseWasmFunctions 1 Some(1) 657 180 0 84156 0 23056 + ParseWasmGlobals 1 Some(1) 1276 93 0 163415 0 11924 + ParseWasmTableEntries 1 Some(1) 231 47 0 29644 0 6121 + ParseWasmTypes 1 Some(1) 6977 387 0 893113 0 49554 + ParseWasmDataSegments 1 Some(1) 1444 43 0 184921 0 5525 + ParseWasmElemSegments 1 Some(1) 2440 367 0 312369 0 47034 + ParseWasmImports 1 Some(1) 4134 795 0 529255 0 101762 + ParseWasmExports 1 Some(1) 2825 277 0 361665 0 35491 + ParseWasmDataSegmentBytes 1 Some(1) 0 1 0 14 0 129 + InstantiateWasmInstructions 1 None 43208 70792 43208 0 70792 0 + InstantiateWasmFunctions 1 Some(1) 62 138 0 8050 0 17749 + InstantiateWasmGlobals 1 Some(1) 83 53 0 10647 0 6833 + InstantiateWasmTableEntries 1 Some(1) 15 8 0 1933 0 1025 + InstantiateWasmTypes 1 None 0 0 0 0 0 0 + InstantiateWasmDataSegments 1 Some(1) 134 1012 0 17164 0 129632 + InstantiateWasmElemSegments 1 Some(1) 267 106 0 34261 0 13665 + InstantiateWasmImports 1 Some(1) 5829 770 0 746142 0 98578 + InstantiateWasmExports 1 Some(1) 2313 71 0 296177 0 9176 + InstantiateWasmDataSegmentBytes 1 Some(1) 0 0 0 14 0 126 + Sec1DecodePointUncompressed 1 None 1882 0 1882 0 0 0 + VerifyEcdsaSecp256r1Sig 1 None 3000906 0 3000906 0 0 0 + Bls12381EncodeFp 1 None 661 0 661 0 0 0 + Bls12381DecodeFp 1 None 985 0 985 0 0 0 + Bls12381G1CheckPointOnCurve 1 None 1934 0 1934 0 0 0 + Bls12381G1CheckPointInSubgroup 1 None 730510 0 730510 0 0 0 + Bls12381G2CheckPointOnCurve 1 None 5921 0 5921 0 0 0 + Bls12381G2CheckPointInSubgroup 1 None 1057822 0 1057822 0 0 0 + Bls12381G1ProjectiveToAffine 1 None 92642 0 92642 0 0 0 + Bls12381G2ProjectiveToAffine 1 None 100742 0 100742 0 0 0 + Bls12381G1Add 1 None 7689 0 7689 0 0 0 + Bls12381G1Mul 1 None 2458985 0 2458985 0 0 0 + Bls12381G1Msm 1 Some(1) 3179828 112264 2426722 96397671 109494 354667 + Bls12381MapFpToG1 1 None 1541554 5552 1541554 0 5552 0 + Bls12381HashToG1 1 Some(1) 3211243 9424 3211191 6713 9424 0 + Bls12381G2Add 1 None 25207 0 25207 0 0 0 + Bls12381G2Mul 1 None 7873219 0 7873219 0 0 0 + Bls12381G2Msm 1 Some(1) 10455244 222424 8035968 309667335 219654 354667 + Bls12381MapFp2ToG2 1 None 2420202 3344 2420202 0 3344 0 + Bls12381HashToG2 1 Some(1) 7050617 6816 7050564 6797 6816 0 + Bls12381Pairing 1 Some(1) 15503174 75176 10558948 632860943 2204 9340474 + Bls12381FrFromU256 1 None 1994 0 1994 0 0 0 + Bls12381FrToU256 1 None 1155 248 1155 0 248 0 + Bls12381FrAddSub 1 None 74 0 74 0 0 0 + Bls12381FrMul 1 None 332 0 332 0 0 0 + Bls12381FrPow 1 Some(1) 1273 1 691 74558 0 128 + Bls12381FrInv 1 None 35421 0 35421 0 0 0 + =============================================================================================================================================================================== + Internal details (diagnostics info, does not affect fees) + Total # times meter was called: 70 + Shadow cpu limit: 100000000; used: 71071547 + Shadow mem limit: 41943040; used: 733666 + =============================================================================================================================================================================== "#]]; expected.assert_eq(&actual); diff --git a/soroban-env-host/src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json b/soroban-env-host/src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json new file mode 100644 index 000000000..46c7574f0 --- /dev/null +++ b/soroban-env-host/src/test/data/BLS12381G1_XMD_SHA-256_SSWU_RO_.json @@ -0,0 +1,115 @@ +{ + "L": "0x40", + "Z": "0xb", + "ciphersuite": "BLS12381G1_XMD:SHA-256_SSWU_RO_", + "curve": "BLS12-381 G1", + "dst": "QUUX-V01-CS02-with-BLS12381G1_XMD:SHA-256_SSWU_RO_", + "expand": "XMD", + "field": { + "m": "0x1", + "p": "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab" + }, + "hash": "sha256", + "k": "0x80", + "map": { + "name": "SSWU" + }, + "randomOracle": true, + "vectors": [ + { + "P": { + "x": "0x052926add2207b76ca4fa57a8734416c8dc95e24501772c814278700eed6d1e4e8cf62d9c09db0fac349612b759e79a1", + "y": "0x08ba738453bfed09cb546dbb0783dbb3a5f1f566ed67bb6be0e8c67e2e81a4cc68ee29813bb7994998f3eae0c9c6a265" + }, + "Q0": { + "x": "0x11a3cce7e1d90975990066b2f2643b9540fa40d6137780df4e753a8054d07580db3b7f1f03396333d4a359d1fe3766fe", + "y": "0x0eeaf6d794e479e270da10fdaf768db4c96b650a74518fc67b04b03927754bac66f3ac720404f339ecdcc028afa091b7" + }, + "Q1": { + "x": "0x160003aaf1632b13396dbad518effa00fff532f604de1a7fc2082ff4cb0afa2d63b2c32da1bef2bf6c5ca62dc6b72f9c", + "y": "0x0d8bb2d14e20cf9f6036152ed386d79189415b6d015a20133acb4e019139b94e9c146aaad5817f866c95d609a361735e" + }, + "msg": "", + "u": [ + "0x0ba14bd907ad64a016293ee7c2d276b8eae71f25a4b941eece7b0d89f17f75cb3ae5438a614fb61d6835ad59f29c564f", + "0x019b9bd7979f12657976de2884c7cce192b82c177c80e0ec604436a7f538d231552f0d96d9f7babe5fa3b19b3ff25ac9" + ] + }, + { + "P": { + "x": "0x03567bc5ef9c690c2ab2ecdf6a96ef1c139cc0b2f284dca0a9a7943388a49a3aee664ba5379a7655d3c68900be2f6903", + "y": "0x0b9c15f3fe6e5cf4211f346271d7b01c8f3b28be689c8429c85b67af215533311f0b8dfaaa154fa6b88176c229f2885d" + }, + "Q0": { + "x": "0x125435adce8e1cbd1c803e7123f45392dc6e326d292499c2c45c5865985fd74fe8f042ecdeeec5ecac80680d04317d80", + "y": "0x0e8828948c989126595ee30e4f7c931cbd6f4570735624fd25aef2fa41d3f79cfb4b4ee7b7e55a8ce013af2a5ba20bf2" + }, + "Q1": { + "x": "0x11def93719829ecda3b46aa8c31fc3ac9c34b428982b898369608e4f042babee6c77ab9218aad5c87ba785481eff8ae4", + "y": "0x0007c9cef122ccf2efd233d6eb9bfc680aa276652b0661f4f820a653cec1db7ff69899f8e52b8e92b025a12c822a6ce6" + }, + "msg": "abc", + "u": [ + "0x0d921c33f2bad966478a03ca35d05719bdf92d347557ea166e5bba579eea9b83e9afa5c088573c2281410369fbd32951", + "0x003574a00b109ada2f26a37a91f9d1e740dffd8d69ec0c35e1e9f4652c7dba61123e9dd2e76c655d956e2b3462611139" + ] + }, + { + "P": { + "x": "0x11e0b079dea29a68f0383ee94fed1b940995272407e3bb916bbf268c263ddd57a6a27200a784cbc248e84f357ce82d98", + "y": "0x03a87ae2caf14e8ee52e51fa2ed8eefe80f02457004ba4d486d6aa1f517c0889501dc7413753f9599b099ebcbbd2d709" + }, + "Q0": { + "x": "0x08834484878c217682f6d09a4b51444802fdba3d7f2df9903a0ddadb92130ebbfa807fffa0eabf257d7b48272410afff", + "y": "0x0b318f7ecf77f45a0f038e62d7098221d2dbbca2a394164e2e3fe953dc714ac2cde412d8f2d7f0c03b259e6795a2508e" + }, + "Q1": { + "x": "0x158418ed6b27e2549f05531a8281b5822b31c3bf3144277fbb977f8d6e2694fedceb7011b3c2b192f23e2a44b2bd106e", + "y": "0x1879074f344471fac5f839e2b4920789643c075792bec5af4282c73f7941cda5aa77b00085eb10e206171b9787c4169f" + }, + "msg": "abcdef0123456789", + "u": [ + "0x062d1865eb80ebfa73dcfc45db1ad4266b9f3a93219976a3790ab8d52d3e5f1e62f3b01795e36834b17b70e7b76246d4", + "0x0cdc3e2f271f29c4ff75020857ce6c5d36008c9b48385ea2f2bf6f96f428a3deb798aa033cd482d1cdc8b30178b08e3a" + ] + }, + { + "P": { + "x": "0x15f68eaa693b95ccb85215dc65fa81038d69629f70aeee0d0f677cf22285e7bf58d7cb86eefe8f2e9bc3f8cb84fac488", + "y": "0x1807a1d50c29f430b8cafc4f8638dfeeadf51211e1602a5f184443076715f91bb90a48ba1e370edce6ae1062f5e6dd38" + }, + "Q0": { + "x": "0x0cbd7f84ad2c99643fea7a7ac8f52d63d66cefa06d9a56148e58b984b3dd25e1f41ff47154543343949c64f88d48a710", + "y": "0x052c00e4ed52d000d94881a5638ae9274d3efc8bc77bc0e5c650de04a000b2c334a9e80b85282a00f3148dfdface0865" + }, + "Q1": { + "x": "0x06493fb68f0d513af08be0372f849436a787e7b701ae31cb964d968021d6ba6bd7d26a38aaa5a68e8c21a6b17dc8b579", + "y": "0x02e98f2ccf5802b05ffaac7c20018bc0c0b2fd580216c4aa2275d2909dc0c92d0d0bdc979226adeb57a29933536b6bb4" + }, + "msg": "q128_qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", + "u": [ + "0x010476f6a060453c0b1ad0b628f3e57c23039ee16eea5e71bb87c3b5419b1255dc0e5883322e563b84a29543823c0e86", + "0x0b1a912064fb0554b180e07af7e787f1f883a0470759c03c1b6509eb8ce980d1670305ae7b928226bb58fdc0a419f46e" + ] + }, + { + "P": { + "x": "0x082aabae8b7dedb0e78aeb619ad3bfd9277a2f77ba7fad20ef6aabdc6c31d19ba5a6d12283553294c1825c4b3ca2dcfe", + "y": "0x05b84ae5a942248eea39e1d91030458c40153f3b654ab7872d779ad1e942856a20c438e8d99bc8abfbf74729ce1f7ac8" + }, + "Q0": { + "x": "0x0cf97e6dbd0947857f3e578231d07b309c622ade08f2c08b32ff372bd90db19467b2563cc997d4407968d4ac80e154f8", + "y": "0x127f0cddf2613058101a5701f4cb9d0861fd6c2a1b8e0afe194fccf586a3201a53874a2761a9ab6d7220c68661a35ab3" + }, + "Q1": { + "x": "0x092f1acfa62b05f95884c6791fba989bbe58044ee6355d100973bf9553ade52b47929264e6ae770fb264582d8dce512a", + "y": "0x028e6d0169a72cfedb737be45db6c401d3adfb12c58c619c82b93a5dfcccef12290de530b0480575ddc8397cda0bbebf" + }, + "msg": "a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "u": [ + "0x0a8ffa7447f6be1c5a2ea4b959c9454b431e29ccc0802bc052413a9c5b4f9aac67a93431bd480d15be1e057c8a08e8c6", + "0x05d487032f602c90fa7625dbafe0f4a49ef4a6b0b33d7bb349ff4cf5410d297fd6241876e3e77b651cfc8191e40a68b7" + ] + } + ] +} diff --git a/soroban-env-host/src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json b/soroban-env-host/src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json new file mode 100644 index 000000000..5807ee6f6 --- /dev/null +++ b/soroban-env-host/src/test/data/BLS12381G2_XMD_SHA-256_SSWU_RO_.json @@ -0,0 +1,115 @@ +{ + "L": "0x40", + "Z": "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaa9,0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa", + "ciphersuite": "BLS12381G2_XMD:SHA-256_SSWU_RO_", + "curve": "BLS12-381 G2", + "dst": "QUUX-V01-CS02-with-BLS12381G2_XMD:SHA-256_SSWU_RO_", + "expand": "XMD", + "field": { + "m": "0x2", + "p": "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab" + }, + "hash": "sha256", + "k": "0x80", + "map": { + "name": "SSWU" + }, + "randomOracle": true, + "vectors": [ + { + "P": { + "x": "0x0141ebfbdca40eb85b87142e130ab689c673cf60f1a3e98d69335266f30d9b8d4ac44c1038e9dcdd5393faf5c41fb78a,0x05cb8437535e20ecffaef7752baddf98034139c38452458baeefab379ba13dff5bf5dd71b72418717047f5b0f37da03d", + "y": "0x0503921d7f6a12805e72940b963c0cf3471c7b2a524950ca195d11062ee75ec076daf2d4bc358c4b190c0c98064fdd92,0x12424ac32561493f3fe3c260708a12b7c620e7be00099a974e259ddc7d1f6395c3c811cdd19f1e8dbf3e9ecfdcbab8d6" + }, + "Q0": { + "x": "0x019ad3fc9c72425a998d7ab1ea0e646a1f6093444fc6965f1cad5a3195a7b1e099c050d57f45e3fa191cc6d75ed7458c,0x171c88b0b0efb5eb2b88913a9e74fe111a4f68867b59db252ce5868af4d1254bfab77ebde5d61cd1a86fb2fe4a5a1c1d", + "y": "0x0ba10604e62bdd9eeeb4156652066167b72c8d743b050fb4c1016c31b505129374f76e03fa127d6a156213576910fef3,0x0eb22c7a543d3d376e9716a49b72e79a89c9bfe9feee8533ed931cbb5373dde1fbcd7411d8052e02693654f71e15410a" + }, + "Q1": { + "x": "0x113d2b9cd4bd98aee53470b27abc658d91b47a78a51584f3d4b950677cfb8a3e99c24222c406128c91296ef6b45608be,0x13855912321c5cb793e9d1e88f6f8d342d49c0b0dbac613ee9e17e3c0b3c97dfbb5a49cc3fb45102fdbaf65e0efe2632", + "y": "0x0fd3def0b7574a1d801be44fde617162aa2e89da47f464317d9bb5abc3a7071763ce74180883ad7ad9a723a9afafcdca,0x056f617902b3c0d0f78a9a8cbda43a26b65f602f8786540b9469b060db7b38417915b413ca65f875c130bebfaa59790c" + }, + "msg": "", + "u": [ + "0x03dbc2cce174e91ba93cbb08f26b917f98194a2ea08d1cce75b2b9cc9f21689d80bd79b594a613d0a68eb807dfdc1cf8,0x05a2acec64114845711a54199ea339abd125ba38253b70a92c876df10598bd1986b739cad67961eb94f7076511b3b39a", + "0x02f99798e8a5acdeed60d7e18e9120521ba1f47ec090984662846bc825de191b5b7641148c0dbc237726a334473eee94,0x145a81e418d4010cc027a68f14391b30074e89e60ee7a22f87217b2f6eb0c4b94c9115b436e6fa4607e95a98de30a435" + ] + }, + { + "P": { + "x": "0x02c2d18e033b960562aae3cab37a27ce00d80ccd5ba4b7fe0e7a210245129dbec7780ccc7954725f4168aff2787776e6,0x139cddbccdc5e91b9623efd38c49f81a6f83f175e80b06fc374de9eb4b41dfe4ca3a230ed250fbe3a2acf73a41177fd8", + "y": "0x1787327b68159716a37440985269cf584bcb1e621d3a7202be6ea05c4cfe244aeb197642555a0645fb87bf7466b2ba48,0x00aa65dae3c8d732d10ecd2c50f8a1baf3001578f71c694e03866e9f3d49ac1e1ce70dd94a733534f106d4cec0eddd16" + }, + "Q0": { + "x": "0x12b2e525281b5f4d2276954e84ac4f42cf4e13b6ac4228624e17760faf94ce5706d53f0ca1952f1c5ef75239aeed55ad,0x05d8a724db78e570e34100c0bc4a5fa84ad5839359b40398151f37cff5a51de945c563463c9efbdda569850ee5a53e77", + "y": "0x02eacdc556d0bdb5d18d22f23dcb086dd106cad713777c7e6407943edbe0b3d1efe391eedf11e977fac55f9b94f2489c,0x04bbe48bfd5814648d0b9e30f0717b34015d45a861425fabc1ee06fdfce36384ae2c808185e693ae97dcde118f34de41" + }, + "Q1": { + "x": "0x19f18cc5ec0c2f055e47c802acc3b0e40c337256a208001dde14b25afced146f37ea3d3ce16834c78175b3ed61f3c537,0x15b0dadc256a258b4c68ea43605dffa6d312eef215c19e6474b3e101d33b661dfee43b51abbf96fee68fc6043ac56a58", + "y": "0x05e47c1781286e61c7ade887512bd9c2cb9f640d3be9cf87ea0bad24bd0ebfe946497b48a581ab6c7d4ca74b5147287f,0x19f98db2f4a1fcdf56a9ced7b320ea9deecf57c8e59236b0dc21f6ee7229aa9705ce9ac7fe7a31c72edca0d92370c096" + }, + "msg": "abc", + "u": [ + "0x15f7c0aa8f6b296ab5ff9c2c7581ade64f4ee6f1bf18f55179ff44a2cf355fa53dd2a2158c5ecb17d7c52f63e7195771,0x01c8067bf4c0ba709aa8b9abc3d1cef589a4758e09ef53732d670fd8739a7274e111ba2fcaa71b3d33df2a3a0c8529dd", + "0x187111d5e088b6b9acfdfad078c4dacf72dcd17ca17c82be35e79f8c372a693f60a033b461d81b025864a0ad051a06e4,0x08b852331c96ed983e497ebc6dee9b75e373d923b729194af8e72a051ea586f3538a6ebb1e80881a082fa2b24df9f566" + ] + }, + { + "P": { + "x": "0x121982811d2491fde9ba7ed31ef9ca474f0e1501297f68c298e9f4c0028add35aea8bb83d53c08cfc007c1e005723cd0,0x190d119345b94fbd15497bcba94ecf7db2cbfd1e1fe7da034d26cbba169fb3968288b3fafb265f9ebd380512a71c3f2c", + "y": "0x05571a0f8d3c08d094576981f4a3b8eda0a8e771fcdcc8ecceaf1356a6acf17574518acb506e435b639353c2e14827c8,0x0bb5e7572275c567462d91807de765611490205a941a5a6af3b1691bfe596c31225d3aabdf15faff860cb4ef17c7c3be" + }, + "Q0": { + "x": "0x0f48f1ea1318ddb713697708f7327781fb39718971d72a9245b9731faaca4dbaa7cca433d6c434a820c28b18e20ea208,0x06051467c8f85da5ba2540974758f7a1e0239a5981de441fdd87680a995649c211054869c50edbac1f3a86c561ba3162", + "y": "0x168b3d6df80069dbbedb714d41b32961ad064c227355e1ce5fac8e105de5e49d77f0c64867f3834848f152497eb76333,0x134e0e8331cee8cb12f9c2d0742714ed9eee78a84d634c9a95f6a7391b37125ed48bfc6e90bf3546e99930ff67cc97bc" + }, + "Q1": { + "x": "0x004fd03968cd1c99a0dd84551f44c206c84dcbdb78076c5bfee24e89a92c8508b52b88b68a92258403cbe1ea2da3495f,0x1674338ea298281b636b2eb0fe593008d03171195fd6dcd4531e8a1ed1f02a72da238a17a635de307d7d24aa2d969a47", + "y": "0x0dc7fa13fff6b12558419e0a1e94bfc3cfaf67238009991c5f24ee94b632c3d09e27eca329989aee348a67b50d5e236c,0x169585e164c131103d85324f2d7747b23b91d66ae5d947c449c8194a347969fc6bbd967729768da485ba71868df8aed2" + }, + "msg": "abcdef0123456789", + "u": [ + "0x0313d9325081b415bfd4e5364efaef392ecf69b087496973b229303e1816d2080971470f7da112c4eb43053130b785e1,0x062f84cb21ed89406890c051a0e8b9cf6c575cf6e8e18ecf63ba86826b0ae02548d83b483b79e48512b82a6c0686df8f", + "0x1739123845406baa7be5c5dc74492051b6d42504de008c635f3535bb831d478a341420e67dcc7b46b2e8cba5379cca97,0x01897665d9cb5db16a27657760bbea7951f67ad68f8d55f7113f24ba6ddd82caef240a9bfa627972279974894701d975" + ] + }, + { + "P": { + "x": "0x19a84dd7248a1066f737cc34502ee5555bd3c19f2ecdb3c7d9e24dc65d4e25e50d83f0f77105e955d78f4762d33c17da,0x0934aba516a52d8ae479939a91998299c76d39cc0c035cd18813bec433f587e2d7a4fef038260eef0cef4d02aae3eb91", + "y": "0x14f81cd421617428bc3b9fe25afbb751d934a00493524bc4e065635b0555084dd54679df1536101b2c979c0152d09192,0x09bcccfa036b4847c9950780733633f13619994394c23ff0b32fa6b795844f4a0673e20282d07bc69641cee04f5e5662" + }, + "Q0": { + "x": "0x09eccbc53df677f0e5814e3f86e41e146422834854a224bf5a83a50e4cc0a77bfc56718e8166ad180f53526ea9194b57,0x0c3633943f91daee715277bd644fba585168a72f96ded64fc5a384cce4ec884a4c3c30f08e09cd2129335dc8f67840ec", + "y": "0x0eb6186a0457d5b12d132902d4468bfeb7315d83320b6c32f1c875f344efcba979952b4aa418589cb01af712f98cc555,0x119e3cf167e69eb16c1c7830e8df88856d48be12e3ff0a40791a5cd2f7221311d4bf13b1847f371f467357b3f3c0b4c7" + }, + "Q1": { + "x": "0x0eb3aabc1ddfce17ff18455fcc7167d15ce6b60ddc9eb9b59f8d40ab49420d35558686293d046fc1e42f864b7f60e381,0x198bdfb19d7441ebcca61e8ff774b29d17da16547d2c10c273227a635cacea3f16826322ae85717630f0867539b5ed8b", + "y": "0x0aaf1dee3adf3ed4c80e481c09b57ea4c705e1b8d25b897f0ceeec3990748716575f92abff22a1c8f4582aff7b872d52,0x0d058d9061ed27d4259848a06c96c5ca68921a5d269b078650c882cb3c2bd424a8702b7a6ee4e0ead9982baf6843e924" + }, + "msg": "q128_qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", + "u": [ + "0x025820cefc7d06fd38de7d8e370e0da8a52498be9b53cba9927b2ef5c6de1e12e12f188bbc7bc923864883c57e49e253,0x034147b77ce337a52e5948f66db0bab47a8d038e712123bb381899b6ab5ad20f02805601e6104c29df18c254b8618c7b", + "0x0930315cae1f9a6017c3f0c8f2314baa130e1cf13f6532bff0a8a1790cd70af918088c3db94bda214e896e1543629795,0x10c4df2cacf67ea3cb3108b00d4cbd0b3968031ebc8eac4b1ebcefe84d6b715fde66bef0219951ece29d1facc8a520ef" + ] + }, + { + "P": { + "x": "0x01a6ba2f9a11fa5598b2d8ace0fbe0a0eacb65deceb476fbbcb64fd24557c2f4b18ecfc5663e54ae16a84f5ab7f62534,0x11fca2ff525572795a801eed17eb12785887c7b63fb77a42be46ce4a34131d71f7a73e95fee3f812aea3de78b4d01569", + "y": "0x0b6798718c8aed24bc19cb27f866f1c9effcdbf92397ad6448b5c9db90d2b9da6cbabf48adc1adf59a1a28344e79d57e,0x03a47f8e6d1763ba0cad63d6114c0accbef65707825a511b251a660a9b3994249ae4e63fac38b23da0c398689ee2ab52" + }, + "Q0": { + "x": "0x17cadf8d04a1a170f8347d42856526a24cc466cb2ddfd506cff01191666b7f944e31244d662c904de5440516a2b09004,0x0d13ba91f2a8b0051cf3279ea0ee63a9f19bc9cb8bfcc7d78b3cbd8cc4fc43ba726774b28038213acf2b0095391c523e", + "y": "0x17ef19497d6d9246fa94d35575c0f8d06ee02f21a284dbeaa78768cb1e25abd564e3381de87bda26acd04f41181610c5,0x12c3c913ba4ed03c24f0721a81a6be7430f2971ffca8fd1729aafe496bb725807531b44b34b59b3ae5495e5a2dcbd5c8" + }, + "Q1": { + "x": "0x16ec57b7fe04c71dfe34fb5ad84dbce5a2dbbd6ee085f1d8cd17f45e8868976fc3c51ad9eeda682c7869024d24579bfd,0x13103f7aace1ae1420d208a537f7d3a9679c287208026e4e3439ab8cd534c12856284d95e27f5e1f33eec2ce656533b0", + "y": "0x0958b2c4c2c10fcef5a6c59b9e92c4a67b0fae3e2e0f1b6b5edad9c940b8f3524ba9ebbc3f2ceb3cfe377655b3163bd7,0x0ccb594ed8bd14ca64ed9cb4e0aba221be540f25dd0d6ba15a4a4be5d67bcf35df7853b2d8dad3ba245f1ea3697f66aa" + }, + "msg": "a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "u": [ + "0x190b513da3e66fc9a3587b78c76d1d132b1152174d0b83e3c1114066392579a45824c5fa17649ab89299ddd4bda54935,0x12ab625b0fe0ebd1367fe9fac57bb1168891846039b4216b9d94007b674de2d79126870e88aeef54b2ec717a887dcf39", + "0x0e6a42010cf435fb5bacc156a585e1ea3294cc81d0ceb81924d95040298380b164f702275892cedd81b62de3aba3f6b5,0x117d9a0defc57a33ed208428cb84e54c85a6840e7648480ae428838989d25d97a0af8e3255be62b25c2a85630d2dddd8" + ] + } + ] +} diff --git a/soroban-env-host/src/test/hostile.rs b/soroban-env-host/src/test/hostile.rs index a7d7081eb..7e42f2ae9 100644 --- a/soroban-env-host/src/test/hostile.rs +++ b/soroban-env-host/src/test/hostile.rs @@ -575,6 +575,31 @@ fn excessive_logging() -> Result<(), HostError> { InstantiateWasmDataSegmentBytes 0 0 Sec1DecodePointUncompressed 0 0 VerifyEcdsaSecp256r1Sig 0 0 + Bls12381EncodeFp 0 0 + Bls12381DecodeFp 0 0 + Bls12381G1CheckPointOnCurve 0 0 + Bls12381G1CheckPointInSubgroup 0 0 + Bls12381G2CheckPointOnCurve 0 0 + Bls12381G2CheckPointInSubgroup 0 0 + Bls12381G1ProjectiveToAffine 0 0 + Bls12381G2ProjectiveToAffine 0 0 + Bls12381G1Add 0 0 + Bls12381G1Mul 0 0 + Bls12381G1Msm 0 0 + Bls12381MapFpToG1 0 0 + Bls12381HashToG1 0 0 + Bls12381G2Add 0 0 + Bls12381G2Mul 0 0 + Bls12381G2Msm 0 0 + Bls12381MapFp2ToG2 0 0 + Bls12381HashToG2 0 0 + Bls12381Pairing 0 0 + Bls12381FrFromU256 0 0 + Bls12381FrToU256 0 0 + Bls12381FrAddSub 0 0 + Bls12381FrMul 0 0 + Bls12381FrPow 0 0 + Bls12381FrInv 0 0 ================================================================= "#]]; diff --git a/soroban-env-host/src/test/lifecycle.rs b/soroban-env-host/src/test/lifecycle.rs index 84c1e2bbd..e3110e269 100644 --- a/soroban-env-host/src/test/lifecycle.rs +++ b/soroban-env-host/src/test/lifecycle.rs @@ -680,7 +680,7 @@ mod cap_54_55_56 { use soroban_test_wasms::UPLOAD_CONTRACT; use crate::{ - host::crypto::sha256_hash_from_bytes, + crypto::sha256_hash_from_bytes, storage::{FootprintMap, StorageMap}, test::observe::ObservedHost, testutils::wasm::wasm_module_with_a_bit_of_everything, diff --git a/soroban-env-host/tests/bls.rs b/soroban-env-host/tests/bls.rs new file mode 100644 index 000000000..23764fa0d --- /dev/null +++ b/soroban-env-host/tests/bls.rs @@ -0,0 +1,449 @@ +mod v22 { + use ark_bls12_381::{G1Affine, G2Affine}; + use ark_ec::AffineRepr; + use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate}; + use hex::FromHex; + use serde::Deserialize; + use soroban_env_host::{ + budget::AsBudget, + xdr::{ScErrorCode, ScErrorType}, + BytesObject, Env, EnvBase, Error, Host, HostError, Val, + }; + use std::cmp::Ordering; + + pub const DST_ETHEREUM: &str = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_"; + + #[derive(Deserialize, Debug)] + struct Aggregate { + input: Vec, + output: String, + } + + #[derive(Deserialize, Debug)] + struct AggregateVerifyInput { + pubkeys: Vec, + messages: Vec, + signature: String, + } + + #[derive(Deserialize, Debug)] + struct AggregateVerify { + input: AggregateVerifyInput, + output: bool, + } + + #[derive(Deserialize, Debug)] + struct BatchVerifyInput { + pubkeys: Vec, + messages: Vec, + signatures: Vec, + } + + #[derive(Deserialize, Debug)] + struct BatchVerify { + input: BatchVerifyInput, + output: bool, + } + + #[derive(Debug, Deserialize)] + struct FastAggregateVerifyInput { + pubkeys: Vec, + message: String, + signature: String, + } + + #[derive(Debug, Deserialize)] + struct FastAggregateVerify { + input: FastAggregateVerifyInput, + output: bool, + } + + #[derive(Deserialize, Debug)] + struct VerifyInput { + pubkey: String, + message: String, + signature: String, + } + + #[derive(Debug, Deserialize)] + struct Verify { + input: VerifyInput, + output: bool, + } + + #[derive(Deserialize, Debug)] + struct SignInput { + privkey: String, + message: String, + } + + #[derive(Deserialize, Debug)] + struct Sign { + input: SignInput, + output: String, + } + + fn parse_hex(s: &str) -> Vec { + Vec::from_hex(s.trim_start_matches("0x")).unwrap() + } + + fn adapt_g1_point(host: &Host, p: &String) -> Result { + let p = parse_hex(p.as_str()); + assert_eq!(p.len(), 48); + let pt = + G1Affine::deserialize_with_mode(p.as_slice(), Compress::Yes, Validate::No).unwrap(); + let mut buf = vec![0u8; 96]; + pt.serialize_with_mode(buf.as_mut_slice(), Compress::No) + .unwrap(); + host.bytes_new_from_slice(&buf) + } + + fn neg_g1(host: &Host) -> Result { + let mut buf = [0u8; 96]; + let neg_g1 = -G1Affine::generator(); + neg_g1.serialize_uncompressed(buf.as_mut_slice()).unwrap(); + host.bytes_new_from_slice(&buf) + } + + fn adapt_g2_point(host: &Host, p: &String) -> Result { + let p = parse_hex(p.as_str()); + assert_eq!(p.len(), 96); + let pt = + G2Affine::deserialize_with_mode(p.as_slice(), Compress::Yes, Validate::No).unwrap(); + let mut buf = vec![0u8; 192]; + pt.serialize_with_mode(buf.as_mut_slice(), Compress::No) + .unwrap(); + host.bytes_new_from_slice(&buf) + } + + fn hash_msg_to_curve( + host: &Host, + msg: &String, + dst: BytesObject, + ) -> Result { + let msg = parse_hex(msg.as_str()); + let msg = host.bytes_new_from_slice(&msg)?; + host.bls12_381_hash_to_g2(msg, dst) + } + + fn aggregate_g1(host: &Host, inputs: &Vec) -> Result { + assert!(!inputs.is_empty()); + let mut agg = adapt_g1_point(&host, &inputs[0])?; + for i in 1..inputs.len() { + let pt = adapt_g1_point(&host, &inputs[i])?; + agg = host.bls12_381_g1_add(agg, pt)?; + } + match host.bls12_381_check_g1_is_in_subgroup(agg)?.into() { + true => Ok(agg), + false => Err(HostError::from(Error::from_type_and_code( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + ))), + } + } + + fn aggregate_g2(host: &Host, inputs: &Vec) -> Result { + assert!(!inputs.is_empty()); + let mut agg = adapt_g2_point(&host, &inputs[0])?; + for i in 1..inputs.len() { + let pt = adapt_g2_point(&host, &inputs[i])?; + agg = host.bls12_381_g2_add(agg, pt)?; + } + match host.bls12_381_check_g2_is_in_subgroup(agg)?.into() { + true => Ok(agg), + false => Err(HostError::from(Error::from_type_and_code( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + ))), + } + } + + fn verify_single_signature( + host: &Host, + pubkey: &String, + msg: &String, + sig: &String, + ) -> Result { + let dst = host.bytes_new_from_slice(DST_ETHEREUM.as_bytes())?; + let pk = adapt_g1_point(host, &pubkey).unwrap().to_val(); + let msg = hash_msg_to_curve(host, &msg, dst).unwrap().to_val(); + let sig = adapt_g2_point(host, &sig)?.to_val(); + let neg_g1 = neg_g1(host)?.to_val(); + let g1_vec = host.vec_new_from_slice(&[pk, neg_g1])?; + let g2_vec = host.vec_new_from_slice(&[msg, sig])?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + if res.as_val().is_false() { + return Ok(false); + } + Ok(true) + } + + // implements the CoreAggregateVerify algorithm specified in + // https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signature-05.html#section-2.9 + fn aggregate_verify( + host: &Host, + pubkeys: &Vec, + msgs: &Vec, + sig: &String, + ) -> Result { + assert_eq!(pubkeys.len(), msgs.len()); + let dst = host.bytes_new_from_slice(DST_ETHEREUM.as_bytes())?; + let mut g1_vec: Vec = pubkeys + .iter() + .map(|pk| adapt_g1_point(host, pk).unwrap().to_val()) + .collect(); + let mut g2_vec: Vec = msgs + .iter() + .map(|msg| hash_msg_to_curve(host, msg, dst).unwrap().to_val()) + .collect(); + let neg_g1 = neg_g1(host)?.to_val(); + g1_vec.push(neg_g1); + let sig = adapt_g2_point(host, sig)?.to_val(); + g2_vec.push(sig); + + let g1_vec = host.vec_new_from_slice(&g1_vec)?; + let g2_vec = host.vec_new_from_slice(&g2_vec)?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + if res.as_val().is_false() { + return Ok(false); + } + Ok(true) + } + + // we won't implement the batch verify logic for this test, we'll just verify individual signature + fn batch_verify( + host: &Host, + pubkeys: &Vec, + msgs: &Vec, + sigs: &Vec, + ) -> Result { + assert_eq!(pubkeys.len(), msgs.len()); + assert_eq!(pubkeys.len(), sigs.len()); + for i in 0..pubkeys.len() { + let res = verify_single_signature(host, &pubkeys[i], &msgs[i], &sigs[i])?; + if !res { + return Ok(false); + } + } + Ok(true) + } + + fn fast_aggregate_verify( + host: &Host, + pubkeys: &Vec, + msg: &String, + sig: &String, + ) -> Result { + assert!(!pubkeys.is_empty()); + let dst = host.bytes_new_from_slice(DST_ETHEREUM.as_bytes())?; + let agg_pk = aggregate_g1(host, &pubkeys)?.to_val(); + let msg = hash_msg_to_curve(host, msg, dst).unwrap().to_val(); + let sig = adapt_g2_point(host, &sig)?.to_val(); + let neg_g1 = neg_g1(host)?.to_val(); + let g1_vec = host.vec_new_from_slice(&[agg_pk, neg_g1])?; + let g2_vec = host.vec_new_from_slice(&[msg, sig])?; + let res = host.bls12_381_multi_pairing_check(g1_vec, g2_vec)?; + if res.as_val().is_false() { + return Ok(false); + } + Ok(true) + } + + fn sign(host: &Host, priv_key: &String, msg: &String) -> Result { + let dst = host.bytes_new_from_slice(DST_ETHEREUM.as_bytes())?; + let key_bytes = host.bytes_new_from_slice(parse_hex(&priv_key).as_slice())?; + let key_u256 = host.u256_val_from_be_bytes(key_bytes)?; + let msg = host.bytes_new_from_slice(&parse_hex(msg).as_slice())?; + let msg_g2 = host.bls12_381_hash_to_g2(msg, dst)?; + host.bls12_381_g2_mul(msg_g2, key_u256) + } + + #[test] + fn test_aggregate() -> Result<(), HostError> { + let test_files = [ + "aggregate_0x0000000000000000000000000000000000000000000000000000000000000000.json", + "aggregate_0x5656565656565656565656565656565656565656565656565656565656565656.json", + "aggregate_0xabababababababababababababababababababababababababababababababab.json", + "aggregate_infinity_signature.json", + "aggregate_single_signature.json", + ]; + let host = Host::test_host(); + for filename in test_files { + let test_suite: Aggregate = serde_json::from_slice( + &std::fs::read(format!("./tests/data/ethereum-bls/aggregate/{}", filename)) + .unwrap(), + ) + .unwrap(); + let agg = aggregate_g2(&host, &test_suite.input)?; + let res = adapt_g2_point(&host, &test_suite.output)?; + assert_eq!( + host.obj_cmp(agg.to_val(), res.to_val())?, + Ordering::Equal as i64 + ); + } + Ok(()) + } + + #[test] + fn test_aggregate_verify() -> Result<(), HostError> { + let test_files = ["aggregate_verify_valid.json"]; + + let host = Host::test_host(); + host.enable_debug()?; + for filename in test_files { + let test_suite: AggregateVerify = serde_json::from_slice( + &std::fs::read(format!( + "./tests/data/ethereum-bls/aggregate_verify/{}", + filename + )) + .unwrap(), + ) + .unwrap(); + let res = aggregate_verify( + &host, + &test_suite.input.pubkeys, + &test_suite.input.messages, + &test_suite.input.signature, + ); + assert_eq!(res?, test_suite.output) + } + Ok(()) + } + + #[test] + fn test_batch_verify() -> Result<(), HostError> { + let test_files = [ + "batch_verify_invalid_forged_signature_set.json", + "batch_verify_valid_multiple_signature_set.json", + "batch_verify_valid_simple_signature_set.json", + ]; + + let host = Host::test_host(); + host.enable_debug()?; + for filename in test_files { + host.as_budget().reset_default()?; + let test_suite: BatchVerify = serde_json::from_slice( + &std::fs::read(format!( + "./tests/data/ethereum-bls/batch_verify/{}", + filename + )) + .unwrap(), + ) + .unwrap(); + let res = batch_verify( + &host, + &test_suite.input.pubkeys, + &test_suite.input.messages, + &test_suite.input.signatures, + ); + assert_eq!(res?, test_suite.output) + } + Ok(()) + } + + #[test] + fn test_fast_aggregate_verify() -> Result<(), HostError> { + let test_files = [ + "fast_aggregate_verify_extra_pubkey_4f079f946446fabf.json", + "fast_aggregate_verify_valid_3d7576f3c0e3570a.json", + "fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd.json", + "fast_aggregate_verify_valid_5e745ad0c6199a6c.json", + "fast_aggregate_verify_extra_pubkey_a698ea45b109f303.json", + "fast_aggregate_verify_valid_652ce62f09290811.json", + ]; + let host = Host::test_host(); + host.enable_debug()?; + for filename in test_files { + host.as_budget().reset_default()?; + let test_suite: FastAggregateVerify = serde_json::from_slice( + &std::fs::read(format!( + "./tests/data/ethereum-bls/fast_aggregate_verify/{}", + filename + )) + .unwrap(), + ) + .unwrap(); + let res = fast_aggregate_verify( + &host, + &test_suite.input.pubkeys, + &test_suite.input.message, + &test_suite.input.signature, + ); + assert_eq!(res?, test_suite.output) + } + Ok(()) + } + + #[test] + fn test_verify() -> Result<(), HostError> { + let test_files = [ + "verify_valid_case_195246ee3bd3b6ec.json", + "verify_wrong_pubkey_case_2ea479adf8c40300.json", + "verify_valid_case_2ea479adf8c40300.json", + "verify_wrong_pubkey_case_2f09d443ab8a3ac2.json", + "verify_valid_case_2f09d443ab8a3ac2.json", + "verify_wrong_pubkey_case_3208262581c8fc09.json", + "verify_valid_case_3208262581c8fc09.json", + "verify_wrong_pubkey_case_6b3b17f6962a490c.json", + "verify_valid_case_6b3b17f6962a490c.json", + "verify_wrong_pubkey_case_6eeb7c52dfd9baf0.json", + "verify_valid_case_6eeb7c52dfd9baf0.json", + "verify_wrong_pubkey_case_8761a0b7e920c323.json", + "verify_valid_case_8761a0b7e920c323.json", + "verify_wrong_pubkey_case_d34885d766d5f705.json", + "verify_valid_case_d34885d766d5f705.json", + "verify_wrong_pubkey_case_e8a50c445c855360.json", + "verify_valid_case_e8a50c445c855360.json", + "verifycase_one_privkey_47117849458281be.json", + "verify_wrong_pubkey_case_195246ee3bd3b6ec.json", + ]; + let host = Host::test_host(); + host.enable_debug()?; + for filename in test_files { + host.as_budget().reset_default()?; + let test_suite: Verify = serde_json::from_slice( + &std::fs::read(format!("./tests/data/ethereum-bls/verify/{}", filename)).unwrap(), + ) + .unwrap(); + let res = verify_single_signature( + &host, + &test_suite.input.pubkey, + &test_suite.input.message, + &test_suite.input.signature, + ); + assert_eq!(res?, test_suite.output) + } + Ok(()) + } + + #[test] + fn test_sign() -> Result<(), HostError> { + let test_files = [ + "sign_case_11b8c7cad5238946.json", + "sign_case_37286e1a6d1f6eb3.json", + "sign_case_84d45c9c7cca6b92.json", + "sign_case_c82df61aa3ee60fb.json", + "sign_case_f2ae1097e7d0e18b.json", + "sign_case_142f678a8d05fcd1.json", + "sign_case_7055381f640f2c1d.json", + "sign_case_8cd3d4d0d9a5b265.json", + "sign_case_d0e28d7e76eb6e9c.json", + ]; + let host = Host::test_host(); + host.enable_debug()?; + for filename in test_files { + host.as_budget().reset_default()?; + let test_suite: Sign = serde_json::from_slice( + &std::fs::read(format!("./tests/data/ethereum-bls/sign/{}", filename)).unwrap(), + ) + .unwrap(); + let res = sign(&host, &test_suite.input.privkey, &test_suite.input.message)?; + let output = adapt_g2_point(&host, &test_suite.output)?; + assert_eq!( + host.obj_cmp(res.to_val(), output.to_val())?, + std::cmp::Ordering::Equal as i64 + ); + } + Ok(()) + } +} diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/README.md b/soroban-env-host/tests/data/ethereum-bls/aggregate/README.md new file mode 100644 index 000000000..e87c5ecbb --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/README.md @@ -0,0 +1,19 @@ +# Test format: BLS signature aggregation + +A BLS signature aggregation combines a series of signatures into a single signature. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: List[BLS Signature] -- list of input BLS signatures +output: BLS Signature -- expected output, single BLS signature or `null`. +``` + +- `BLS Signature` here is encoded as a string: hexadecimal encoding of 96 bytes (192 nibbles), prefixed with `0x`. +- output value is `null` if the input is invalid. + +## Condition + +The `aggregate` handler should aggregate the signatures in the `input`, and the result should match the expected `output`. diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x0000000000000000000000000000000000000000000000000000000000000000.json b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x0000000000000000000000000000000000000000000000000000000000000000.json new file mode 100644 index 000000000..34f0e2381 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x0000000000000000000000000000000000000000000000000000000000000000.json @@ -0,0 +1 @@ +{"input": ["0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55", "0xb23c46be3a001c63ca711f87a005c200cc550b9429d5f4eb38d74322144f1b63926da3388979e5321012fb1a0526bcd100b5ef5fe72628ce4cd5e904aeaa3279527843fae5ca9ca675f4f51ed8f83bbf7155da9ecc9663100a885d5dc6df96d9", "0x948a7cb99f76d616c2c564ce9bf4a519f1bea6b0a624a02276443c245854219fabb8d4ce061d255af5330b078d5380681751aa7053da2c98bae898edc218c75f07e24d8802a17cd1f6833b71e58f5eb5b94208b4d0bb3848cecb075ea21be115"], "output": "0x9683b3e6701f9a4b706709577963110043af78a5b41991b998475a3d3fd62abf35ce03b33908418efc95a058494a8ae504354b9f626231f6b3f3c849dfdeaf5017c4780e2aee1850ceaf4b4d9ce70971a3d2cfcd97b7e5ecf6759f8da5f76d31"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x5656565656565656565656565656565656565656565656565656565656565656.json b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x5656565656565656565656565656565656565656565656565656565656565656.json new file mode 100644 index 000000000..719703866 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0x5656565656565656565656565656565656565656565656565656565656565656.json @@ -0,0 +1 @@ +{"input": ["0x882730e5d03f6b42c3abc26d3372625034e1d871b65a8a6b900a56dae22da98abbe1b68f85e49fe7652a55ec3d0591c20767677e33e5cbb1207315c41a9ac03be39c2e7668edc043d6cb1d9fd93033caa8a1c5b0e84bedaeb6c64972503a43eb", "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe", "0xa4efa926610b8bd1c8330c918b7a5e9bf374e53435ef8b7ec186abf62e1b1f65aeaaeb365677ac1d1172a1f5b44b4e6d022c252c58486c0a759fbdc7de15a756acc4d343064035667a594b4c2a6f0b0b421975977f297dba63ee2f63ffe47bb6"], "output": "0xad38fc73846583b08d110d16ab1d026c6ea77ac2071e8ae832f56ac0cbcdeb9f5678ba5ce42bd8dce334cc47b5abcba40a58f7f1f80ab304193eb98836cc14d8183ec14cc77de0f80c4ffd49e168927a968b5cdaa4cf46b9805be84ad7efa77b"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0xabababababababababababababababababababababababababababababababab.json b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0xabababababababababababababababababababababababababababababababab.json new file mode 100644 index 000000000..8b47fc8b4 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_0xabababababababababababababababababababababababababababababababab.json @@ -0,0 +1 @@ +{"input": ["0x91347bccf740d859038fcdcaf233eeceb2a436bcaaee9b2aa3bfb70efe29dfb2677562ccbea1c8e061fb9971b0753c240622fab78489ce96768259fc01360346da5b9f579e5da0d941e4c6ba18a0e64906082375394f337fa1af2b7127b0d121", "0x9674e2228034527f4c083206032b020310face156d4a4685e2fcaec2f6f3665aa635d90347b6ce124eb879266b1e801d185de36a0a289b85e9039662634f2eea1e02e670bc7ab849d006a70b2f93b84597558a05b879c8d445f387a5d5b653df", "0xae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9"], "output": "0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfc4ff1d930"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_infinity_signature.json b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_infinity_signature.json new file mode 100644 index 000000000..487ed634f --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_infinity_signature.json @@ -0,0 +1 @@ +{"input": ["0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"], "output": "0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_single_signature.json b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_single_signature.json new file mode 100644 index 000000000..d2b4f9cb2 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate/aggregate_single_signature.json @@ -0,0 +1 @@ +{"input": ["0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"], "output": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/README.md b/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/README.md new file mode 100644 index 000000000..112927c4a --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/README.md @@ -0,0 +1,17 @@ +# Test format: BLS aggregate signature verification + +Verify the signature against the given pubkeys and messages. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: + pubkeys: List[bytes48] -- the pubkeys + messages: List[bytes32] -- the messages + signature: bytes96 -- the signature to verify against pubkeys and messages +output: bool -- VALID or INVALID +``` + +All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. diff --git a/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/aggregate_verify_valid.json b/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/aggregate_verify_valid.json new file mode 100644 index 000000000..1592941da --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/aggregate_verify/aggregate_verify_valid.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "messages": ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x5656565656565656565656565656565656565656565656565656565656565656", "0xabababababababababababababababababababababababababababababababab"], "signature": "0x9104e74b9dfd3ad502f25d6a5ef57db0ed7d9a0e00f3500586d8ce44231212542fcfaf87840539b398bf07626705cf1105d246ca1062c6c2e1a53029a0f790ed5e3cb1f52f8234dc5144c45fc847c0cd37a92d68e7c5ba7c648a8a339f171244"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/batch_verify/README.md b/soroban-env-host/tests/data/ethereum-bls/batch_verify/README.md new file mode 100644 index 000000000..94104bb50 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/batch_verify/README.md @@ -0,0 +1,17 @@ +# Test format: BLS batch signature verification + +[Batch verify](https://ethresear.ch/t/fast-verification-of-multiple-bls-signatures/5407) the signatures against the given pubkeys and messages. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: + pubkeys: List[bytes48] -- the pubkeys + messages: List[bytes32] -- the messages + signatures: List[bytes96] -- the signatures to verify against pubkeys and messages +output: bool -- VALID or INVALID +``` + +All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. diff --git a/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_invalid_forged_signature_set.json b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_invalid_forged_signature_set.json new file mode 100644 index 000000000..567a4ac78 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_invalid_forged_signature_set.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81"], "messages": ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x5656565656565656565656565656565656565656565656565656565656565656"], "signatures": ["0xa70f1f1b4bd97d182ebb55d08be3f90b1dc232bb50b44e259381a642ef0bad3629ad3542f3e8ff6a84e451fc0b595e090fc4f0e860cfc5584715ef1b6cd717b9994378f7a51b815bbf5a0d95bc3402583ad2e95a229731e539906249a5e4355c", "0xb758eb7e15c101f53be2214d2a6b65e8fe7053146dbe3c73c9fe9b5efecdf63ca06a4d5d938dbf18fe6600529c0011a7013f45ae012b02904d5c7c33316e935a0e084abead4f43f84383c52cd3b3f14024437e251a2a7c0d5147954022873a58"]}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_multiple_signature_set.json b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_multiple_signature_set.json new file mode 100644 index 000000000..bdd7df17c --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_multiple_signature_set.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81"], "messages": ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x5656565656565656565656565656565656565656565656565656565656565656"], "signatures": ["0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55", "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe"]}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_simple_signature_set.json b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_simple_signature_set.json new file mode 100644 index 000000000..e96384586 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/batch_verify/batch_verify_valid_simple_signature_set.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "messages": ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x5656565656565656565656565656565656565656565656565656565656565656", "0xabababababababababababababababababababababababababababababababab"], "signatures": ["0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55", "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe", "0xae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9"]}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/README.md b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/README.md new file mode 100644 index 000000000..eaf029bf7 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/README.md @@ -0,0 +1,17 @@ +# Test format: BLS fast aggregate signature verification + +Verify the signature against the given pubkeys and one message. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: + pubkeys: List[bytes48] -- the pubkey + message: bytes32 -- the message + signature: bytes96 -- the signature to verify against pubkeys and message +output: bool -- VALID or INVALID +``` + +All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_4f079f946446fabf.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_4f079f946446fabf.json new file mode 100644 index 000000000..d0753eb33 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_4f079f946446fabf.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0x912c3615f69575407db9392eb21fee18fff797eeb2fbe1816366ca2a08ae574d8824dbfafb4c9eaa1cf61b63c6f9b69911f269b664c42947dd1b53ef1081926c1e82bb2a465f927124b08391a5249036146d6f3f1e17ff5f162f779746d830d1"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd.json new file mode 100644 index 000000000..0e9b4d5ef --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfc4ff1d930"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_a698ea45b109f303.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_a698ea45b109f303.json new file mode 100644 index 000000000..ede402328 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_extra_pubkey_a698ea45b109f303.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_3d7576f3c0e3570a.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_3d7576f3c0e3570a.json new file mode 100644 index 000000000..2470cb287 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_3d7576f3c0e3570a.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f"], "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfc4ff1d930"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_5e745ad0c6199a6c.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_5e745ad0c6199a6c.json new file mode 100644 index 000000000..8ba653561 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_5e745ad0c6199a6c.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a"], "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_652ce62f09290811.json b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_652ce62f09290811.json new file mode 100644 index 000000000..25b0fdf2c --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/fast_aggregate_verify/fast_aggregate_verify_valid_652ce62f09290811.json @@ -0,0 +1 @@ +{"input": {"pubkeys": ["0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81"], "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0x912c3615f69575407db9392eb21fee18fff797eeb2fbe1816366ca2a08ae574d8824dbfafb4c9eaa1cf61b63c6f9b69911f269b664c42947dd1b53ef1081926c1e82bb2a465f927124b08391a5249036146d6f3f1e17ff5f162f779746d830d1"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/README.md b/soroban-env-host/tests/data/ethereum-bls/sign/README.md new file mode 100644 index 000000000..299826554 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/README.md @@ -0,0 +1,21 @@ +# Test format: BLS sign message + +Message signing with BLS should produce a signature. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: + privkey: bytes32 -- the private key used for signing + message: bytes32 -- input message to sign (a hash) +output: BLS Signature -- expected output, single BLS signature or `null`. +``` + +All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. +- output value is `null` if the input is invalid. + +## Condition + +The `sign` handler should sign `message` with `privkey`, and the resulting signature should match the expected `output`. diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_11b8c7cad5238946.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_11b8c7cad5238946.json new file mode 100644 index 000000000..00b558b08 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_11b8c7cad5238946.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", "message": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "output": "0xb23c46be3a001c63ca711f87a005c200cc550b9429d5f4eb38d74322144f1b63926da3388979e5321012fb1a0526bcd100b5ef5fe72628ce4cd5e904aeaa3279527843fae5ca9ca675f4f51ed8f83bbf7155da9ecc9663100a885d5dc6df96d9"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_142f678a8d05fcd1.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_142f678a8d05fcd1.json new file mode 100644 index 000000000..29b1c4636 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_142f678a8d05fcd1.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", "message": "0x5656565656565656565656565656565656565656565656565656565656565656"}, "output": "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_37286e1a6d1f6eb3.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_37286e1a6d1f6eb3.json new file mode 100644 index 000000000..a62d5cfb9 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_37286e1a6d1f6eb3.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", "message": "0xabababababababababababababababababababababababababababababababab"}, "output": "0x9674e2228034527f4c083206032b020310face156d4a4685e2fcaec2f6f3665aa635d90347b6ce124eb879266b1e801d185de36a0a289b85e9039662634f2eea1e02e670bc7ab849d006a70b2f93b84597558a05b879c8d445f387a5d5b653df"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_7055381f640f2c1d.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_7055381f640f2c1d.json new file mode 100644 index 000000000..62d42df9e --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_7055381f640f2c1d.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", "message": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "output": "0x948a7cb99f76d616c2c564ce9bf4a519f1bea6b0a624a02276443c245854219fabb8d4ce061d255af5330b078d5380681751aa7053da2c98bae898edc218c75f07e24d8802a17cd1f6833b71e58f5eb5b94208b4d0bb3848cecb075ea21be115"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_84d45c9c7cca6b92.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_84d45c9c7cca6b92.json new file mode 100644 index 000000000..3254f7fc8 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_84d45c9c7cca6b92.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", "message": "0xabababababababababababababababababababababababababababababababab"}, "output": "0xae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_8cd3d4d0d9a5b265.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_8cd3d4d0d9a5b265.json new file mode 100644 index 000000000..7ba74f09a --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_8cd3d4d0d9a5b265.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", "message": "0x5656565656565656565656565656565656565656565656565656565656565656"}, "output": "0xa4efa926610b8bd1c8330c918b7a5e9bf374e53435ef8b7ec186abf62e1b1f65aeaaeb365677ac1d1172a1f5b44b4e6d022c252c58486c0a759fbdc7de15a756acc4d343064035667a594b4c2a6f0b0b421975977f297dba63ee2f63ffe47bb6"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_c82df61aa3ee60fb.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_c82df61aa3ee60fb.json new file mode 100644 index 000000000..bc95a9185 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_c82df61aa3ee60fb.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", "message": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "output": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_d0e28d7e76eb6e9c.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_d0e28d7e76eb6e9c.json new file mode 100644 index 000000000..d6d5683fc --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_d0e28d7e76eb6e9c.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", "message": "0x5656565656565656565656565656565656565656565656565656565656565656"}, "output": "0x882730e5d03f6b42c3abc26d3372625034e1d871b65a8a6b900a56dae22da98abbe1b68f85e49fe7652a55ec3d0591c20767677e33e5cbb1207315c41a9ac03be39c2e7668edc043d6cb1d9fd93033caa8a1c5b0e84bedaeb6c64972503a43eb"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_f2ae1097e7d0e18b.json b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_f2ae1097e7d0e18b.json new file mode 100644 index 000000000..7def66932 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/sign/sign_case_f2ae1097e7d0e18b.json @@ -0,0 +1 @@ +{"input": {"privkey": "0x263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", "message": "0xabababababababababababababababababababababababababababababababab"}, "output": "0x91347bccf740d859038fcdcaf233eeceb2a436bcaaee9b2aa3bfb70efe29dfb2677562ccbea1c8e061fb9971b0753c240622fab78489ce96768259fc01360346da5b9f579e5da0d941e4c6ba18a0e64906082375394f337fa1af2b7127b0d121"} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/README.md b/soroban-env-host/tests/data/ethereum-bls/verify/README.md new file mode 100644 index 000000000..40500d92b --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/README.md @@ -0,0 +1,17 @@ +# Test format: BLS signature verification + +Verify the signature against the given one pubkey and one message. + +## Test case format + +The test data is declared in a `data.yaml` file: + +```yaml +input: + pubkey: bytes48 -- the pubkey + message: bytes32 -- the message + signature: bytes96 -- the signature to verify against pubkey and message +output: bool -- VALID or INVALID +``` + +All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_195246ee3bd3b6ec.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_195246ee3bd3b6ec.json new file mode 100644 index 000000000..36515d84f --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_195246ee3bd3b6ec.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0xae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2ea479adf8c40300.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2ea479adf8c40300.json new file mode 100644 index 000000000..a1a009f89 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2ea479adf8c40300.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0x882730e5d03f6b42c3abc26d3372625034e1d871b65a8a6b900a56dae22da98abbe1b68f85e49fe7652a55ec3d0591c20767677e33e5cbb1207315c41a9ac03be39c2e7668edc043d6cb1d9fd93033caa8a1c5b0e84bedaeb6c64972503a43eb"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2f09d443ab8a3ac2.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2f09d443ab8a3ac2.json new file mode 100644 index 000000000..e48e5cdfc --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_2f09d443ab8a3ac2.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb23c46be3a001c63ca711f87a005c200cc550b9429d5f4eb38d74322144f1b63926da3388979e5321012fb1a0526bcd100b5ef5fe72628ce4cd5e904aeaa3279527843fae5ca9ca675f4f51ed8f83bbf7155da9ecc9663100a885d5dc6df96d9"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_3208262581c8fc09.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_3208262581c8fc09.json new file mode 100644 index 000000000..202923aeb --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_3208262581c8fc09.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6b3b17f6962a490c.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6b3b17f6962a490c.json new file mode 100644 index 000000000..f904137e1 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6b3b17f6962a490c.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0xa4efa926610b8bd1c8330c918b7a5e9bf374e53435ef8b7ec186abf62e1b1f65aeaaeb365677ac1d1172a1f5b44b4e6d022c252c58486c0a759fbdc7de15a756acc4d343064035667a594b4c2a6f0b0b421975977f297dba63ee2f63ffe47bb6"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6eeb7c52dfd9baf0.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6eeb7c52dfd9baf0.json new file mode 100644 index 000000000..b94b289cb --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_6eeb7c52dfd9baf0.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x9674e2228034527f4c083206032b020310face156d4a4685e2fcaec2f6f3665aa635d90347b6ce124eb879266b1e801d185de36a0a289b85e9039662634f2eea1e02e670bc7ab849d006a70b2f93b84597558a05b879c8d445f387a5d5b653df"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_8761a0b7e920c323.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_8761a0b7e920c323.json new file mode 100644 index 000000000..66cdc7f53 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_8761a0b7e920c323.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x91347bccf740d859038fcdcaf233eeceb2a436bcaaee9b2aa3bfb70efe29dfb2677562ccbea1c8e061fb9971b0753c240622fab78489ce96768259fc01360346da5b9f579e5da0d941e4c6ba18a0e64906082375394f337fa1af2b7127b0d121"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_d34885d766d5f705.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_d34885d766d5f705.json new file mode 100644 index 000000000..1ef2ea487 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_d34885d766d5f705.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0x948a7cb99f76d616c2c564ce9bf4a519f1bea6b0a624a02276443c245854219fabb8d4ce061d255af5330b078d5380681751aa7053da2c98bae898edc218c75f07e24d8802a17cd1f6833b71e58f5eb5b94208b4d0bb3848cecb075ea21be115"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_e8a50c445c855360.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_e8a50c445c855360.json new file mode 100644 index 000000000..d94718d39 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_valid_case_e8a50c445c855360.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"}, "output": true} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_195246ee3bd3b6ec.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_195246ee3bd3b6ec.json new file mode 100644 index 000000000..37c53ead9 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_195246ee3bd3b6ec.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x9674e2228034527f4c083206032b020310face156d4a4685e2fcaec2f6f3665aa635d90347b6ce124eb879266b1e801d185de36a0a289b85e9039662634f2eea1e02e670bc7ab849d006a70b2f93b84597558a05b879c8d445f387a5d5b653df"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2ea479adf8c40300.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2ea479adf8c40300.json new file mode 100644 index 000000000..a8da83ab3 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2ea479adf8c40300.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0xa4efa926610b8bd1c8330c918b7a5e9bf374e53435ef8b7ec186abf62e1b1f65aeaaeb365677ac1d1172a1f5b44b4e6d022c252c58486c0a759fbdc7de15a756acc4d343064035667a594b4c2a6f0b0b421975977f297dba63ee2f63ffe47bb6"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2f09d443ab8a3ac2.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2f09d443ab8a3ac2.json new file mode 100644 index 000000000..11e7e89c6 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_2f09d443ab8a3ac2.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_3208262581c8fc09.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_3208262581c8fc09.json new file mode 100644 index 000000000..c73077460 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_3208262581c8fc09.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0x882730e5d03f6b42c3abc26d3372625034e1d871b65a8a6b900a56dae22da98abbe1b68f85e49fe7652a55ec3d0591c20767677e33e5cbb1207315c41a9ac03be39c2e7668edc043d6cb1d9fd93033caa8a1c5b0e84bedaeb6c64972503a43eb"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6b3b17f6962a490c.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6b3b17f6962a490c.json new file mode 100644 index 000000000..205a89fed --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6b3b17f6962a490c.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0x5656565656565656565656565656565656565656565656565656565656565656", "signature": "0xaf1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6eeb7c52dfd9baf0.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6eeb7c52dfd9baf0.json new file mode 100644 index 000000000..a6b207c19 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_6eeb7c52dfd9baf0.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0x91347bccf740d859038fcdcaf233eeceb2a436bcaaee9b2aa3bfb70efe29dfb2677562ccbea1c8e061fb9971b0753c240622fab78489ce96768259fc01360346da5b9f579e5da0d941e4c6ba18a0e64906082375394f337fa1af2b7127b0d121"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_8761a0b7e920c323.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_8761a0b7e920c323.json new file mode 100644 index 000000000..7ed97782c --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_8761a0b7e920c323.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0xabababababababababababababababababababababababababababababababab", "signature": "0xae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_d34885d766d5f705.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_d34885d766d5f705.json new file mode 100644 index 000000000..a9c10e084 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_d34885d766d5f705.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0xb23c46be3a001c63ca711f87a005c200cc550b9429d5f4eb38d74322144f1b63926da3388979e5321012fb1a0526bcd100b5ef5fe72628ce4cd5e904aeaa3279527843fae5ca9ca675f4f51ed8f83bbf7155da9ecc9663100a885d5dc6df96d9"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_e8a50c445c855360.json b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_e8a50c445c855360.json new file mode 100644 index 000000000..bf24f57b9 --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verify_wrong_pubkey_case_e8a50c445c855360.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a", "message": "0x0000000000000000000000000000000000000000000000000000000000000000", "signature": "0x948a7cb99f76d616c2c564ce9bf4a519f1bea6b0a624a02276443c245854219fabb8d4ce061d255af5330b078d5380681751aa7053da2c98bae898edc218c75f07e24d8802a17cd1f6833b71e58f5eb5b94208b4d0bb3848cecb075ea21be115"}, "output": false} \ No newline at end of file diff --git a/soroban-env-host/tests/data/ethereum-bls/verify/verifycase_one_privkey_47117849458281be.json b/soroban-env-host/tests/data/ethereum-bls/verify/verifycase_one_privkey_47117849458281be.json new file mode 100644 index 000000000..11c9373eb --- /dev/null +++ b/soroban-env-host/tests/data/ethereum-bls/verify/verifycase_one_privkey_47117849458281be.json @@ -0,0 +1 @@ +{"input": {"pubkey": "0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb", "message": "0x1212121212121212121212121212121212121212121212121212121212121212", "signature": "0xa42ae16f1c2a5fa69c04cb5998d2add790764ce8dd45bf25b29b4700829232052b52352dcff1cf255b3a7810ad7269601810f03b2bc8b68cf289cf295b206770605a190b6842583e47c3d1c0f73c54907bfb2a602157d46a4353a20283018763"}, "output": true} \ No newline at end of file diff --git a/soroban-env-macros/Cargo.toml b/soroban-env-macros/Cargo.toml index 3ebabc2c2..d4ad528d1 100644 --- a/soroban-env-macros/Cargo.toml +++ b/soroban-env-macros/Cargo.toml @@ -17,7 +17,7 @@ stellar-xdr = { workspace = true, features = ["curr", "std"] } syn = {version="2.0.39",features=["full"]} quote = "1.0.33" proc-macro2 = "1.0.69" -itertools = "0.11.0" +itertools = "0.10.5" serde = { version = "1.0.192", features = ["derive"] } serde_json = "1.0.108"