@@ -180,8 +180,8 @@ PrecompileAnalysis bls12_g2add_analyze(bytes_view, evmc_revision) noexcept
180
180
181
181
PrecompileAnalysis bls12_g2mul_analyze (bytes_view, evmc_revision) noexcept
182
182
{
183
- // TODO: Implement
184
- return {GasCostMax, 0 };
183
+ static constexpr auto BLS12_G2MUL_PRECOMPILE_GAS = 45000 ;
184
+ return {BLS12_G2MUL_PRECOMPILE_GAS, 256 };
185
185
}
186
186
187
187
PrecompileAnalysis 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
394
394
return {EVMC_SUCCESS, 256 };
395
395
}
396
396
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
398
399
{
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 };
400
409
}
401
410
402
411
ExecutionResult bls12_g2msm_execute (const uint8_t *, size_t , uint8_t *, size_t ) noexcept
0 commit comments