Skip to content

Commit

Permalink
Fix: EIP-2539 (polkadot-evm#1207)
Browse files Browse the repository at this point in the history
* Fix: map_fp2_to_g2 input length check

* Add clear_cofactor to mapping operation
  • Loading branch information
hujw77 authored Sep 22, 2023
1 parent 5d86b28 commit 789fa51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frame/evm/precompile/bls12377/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ impl Precompile for Bls12377MapG1 {

let fq = read_fq(input, 0)?;
let g1 = match map_to_curve_g1(fq) {
Ok(point) => point,
Ok(point) => point.clear_cofactor(),
Err(_) => {
return Err(PrecompileFailure::Error {
exit_status: ExitError::Other("map to curve failed".into()),
Expand Down Expand Up @@ -635,15 +635,15 @@ impl Precompile for Bls12377MapG2 {
handle.record_cost(Bls12377MapG2::GAS_COST)?;

let input = handle.input();
if input.len() != 64 {
if input.len() != 128 {
return Err(PrecompileFailure::Error {
exit_status: ExitError::Other("invalid input length".into()),
});
}

let fq2 = read_fq2(input, 0)?;
let g2 = match map_to_curve_g2(fq2) {
Ok(point) => point,
Ok(point) => point.clear_cofactor(),
Err(_) => {
return Err(PrecompileFailure::Error {
exit_status: ExitError::Other("map to curve failed".into()),
Expand Down

0 comments on commit 789fa51

Please sign in to comment.