Skip to content

Conversation

@MariusVanDerWijden
Copy link
Member

Adds the subgroup checks as required by the current spec: https://github.com/ethereum/EIPs/pull/8456/files

}
// 'point is on curve' check already done,
// Here we need to apply subgroup checks.
if !p.IsInSubGroup() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this seems un-optimal to me (all these cases). We perform both these calls, with IsOnCurve done from inside decodePointGX.

// IsOnCurve returns true if p in on the curve
func (p *G1Affine) IsOnCurve() bool {
	var point G1Jac
	point.FromAffine(p)
	return point.IsOnCurve() // call this function to handle infinity point
}

// IsInSubGroup returns true if p is in the correct subgroup, false otherwise
func (p *G1Affine) IsInSubGroup() bool {
	var _p G1Jac
	_p.FromAffine(p)
	return _p.IsInSubGroup()
}

Seems like it should be faster to do

func (p *G1Affine) IsOnCurveAndInSubGroup() bool {
	var point G1Jac
	point.FromAffine(p)
	point.IsOnCurve() && point.IsInSubGroup()
}

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe (probably?) it doesn't make any difference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes very little difference I think. The subgroup check is the heaviest, moving from affine to jac is very quick and the curve checks are very quick as well

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman added this to the 1.14.1 milestone Apr 24, 2024
@fjl fjl merged commit bd6bc37 into ethereum:master Apr 30, 2024
jorgemmsilva pushed a commit to iotaledger/go-ethereum that referenced this pull request Jun 17, 2024
sonhv0212 added a commit to sonhv0212/ronin that referenced this pull request Mar 18, 2025
sonhv0212 added a commit to sonhv0212/ronin that referenced this pull request May 20, 2025
sonhv0212 added a commit to sonhv0212/ronin that referenced this pull request May 21, 2025
sonhv0212 added a commit to ronin-chain/ronin that referenced this pull request May 21, 2025
* core/vm: add precompiled contracts, addresses Prague

reference: ethereum/EIPs#8945

* core/vm: remove redundant MUL precompiles in tests

reference: ethereum/EIPs#8945

* params: adjust gas of BLS precompiled address

References:
- ethereum/EIPs#9097
- ethereum/EIPs#9098

* core/vm,params: update DiscountTable for Bls12381G1 and Bls12381G2

reference: ethereum/EIPs#9116

* core/vm: add subgroup checks for mulexp for G1/G2

Reference:
- PR: ethereum/go-ethereum#29637
- spec: ethereum/EIPs#8456

* core/vm/testdata/precompiles: update precompile tests EIP-2537

* core/vm: fix wrong addresses of precompiled contracts Prague

* core/vm: use gnark BLS12-381 instead of the older

PR: ethereum/go-ethereum#29441

* core/vm,tests/fuzzers/bls12381: Remove unused tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants