@@ -162,8 +162,8 @@ PrecompileAnalysis bls12_g1add_analyze(bytes_view, evmc_revision) noexcept
162
162
163
163
PrecompileAnalysis bls12_g1mul_analyze (bytes_view, evmc_revision) noexcept
164
164
{
165
- // TODO: Implement
166
- return {GasCostMax, 0 };
165
+ static constexpr auto BLS12_G1MUL_PRECOMPILE_GAS = 12000 ;
166
+ return {BLS12_G1MUL_PRECOMPILE_GAS, 128 };
167
167
}
168
168
169
169
PrecompileAnalysis bls12_g1msm_analyze (bytes_view, evmc_revision) noexcept
@@ -361,9 +361,18 @@ ExecutionResult bls12_g1add_execute(const uint8_t* input, size_t input_size, uin
361
361
return {EVMC_SUCCESS, 128 };
362
362
}
363
363
364
- ExecutionResult bls12_g1mul_execute (const uint8_t *, size_t , uint8_t *, size_t ) noexcept
364
+ ExecutionResult bls12_g1mul_execute (const uint8_t * input, size_t input_size, uint8_t * output,
365
+ [[maybe_unused]] size_t output_size) noexcept
365
366
{
366
- return {EVMC_PRECOMPILE_FAILURE, 0 };
367
+ if (input_size != 160 )
368
+ return {EVMC_PRECOMPILE_FAILURE, 0 };
369
+
370
+ assert (output_size == 128 );
371
+
372
+ if (!crypto::bls::g1_mul (output, &output[64 ], input, &input[64 ], &input[128 ]))
373
+ return {EVMC_PRECOMPILE_FAILURE, 0 };
374
+
375
+ return {EVMC_SUCCESS, 128 };
367
376
}
368
377
369
378
ExecutionResult bls12_g1msm_execute (const uint8_t *, size_t , uint8_t *, size_t ) noexcept
0 commit comments