@@ -180,8 +180,8 @@ PrecompileAnalysis bls12_g2add_analyze(bytes_view, evmc_revision) noexcept
180180
181181PrecompileAnalysis bls12_g2mul_analyze (bytes_view, evmc_revision) noexcept
182182{
183- // TODO: Implement
184- return {GasCostMax, 0 };
183+ static constexpr auto BLS12_G2MUL_PRECOMPILE_GAS = 45000 ;
184+ return {BLS12_G2MUL_PRECOMPILE_GAS , 256 };
185185}
186186
187187PrecompileAnalysis bls12_g2msm_analyze (bytes_view, evmc_revision) noexcept
@@ -394,9 +394,18 @@ ExecutionResult bls12_g2add_execute(const uint8_t* input, size_t input_size, uin
394394 return {EVMC_SUCCESS , 256 };
395395}
396396
397- ExecutionResult bls12_g2mul_execute (const uint8_t *, size_t , uint8_t *, size_t ) noexcept
397+ ExecutionResult bls12_g2mul_execute (const uint8_t * input, size_t input_size, uint8_t * output,
398+ [[maybe_unused]] size_t output_size) noexcept
398399{
399- return {EVMC_PRECOMPILE_FAILURE , 0 };
400+ if (input_size != 288 )
401+ return {EVMC_PRECOMPILE_FAILURE , 0 };
402+
403+ assert (output_size == 256 );
404+
405+ if (!crypto::bls::g2_mul (output, &output[128 ], input, &input[128 ], &input[256 ]))
406+ return {EVMC_PRECOMPILE_FAILURE , 0 };
407+
408+ return {EVMC_SUCCESS , 256 };
400409}
401410
402411ExecutionResult bls12_g2msm_execute (const uint8_t *, size_t , uint8_t *, size_t ) noexcept
0 commit comments