Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIP-31 - BLS12-381 Precompiles #1279

Closed
wants to merge 6 commits into from
Closed

CIP-31 - BLS12-381 Precompiles #1279

wants to merge 6 commits into from

Conversation

kilic
Copy link
Contributor

@kilic kilic commented Dec 28, 2020

Description

This PR adds BLS12-381 elliptic curve precompiles as defined in EIP-2537.

Other changes

  • added BLS12-381 elliptic curve library added to ./crypto/bls12381
  • added precompile runners with addresses and gas schedule.
  • created new set of precompiles named PrecompiledContractsDonut
  • added test vectors generated with https://github.com/matter-labs/eip1962

Tested

Underlying elliptic curve library is heavily tested in terms of mathematical properties.

Original library BLS12-381 is subjected to the security audit under drand project and also made its way to be backend of EIP-2537 go-ethereum precompiles.

@kilic kilic requested a review from kobigurk as a code owner December 28, 2020 04:32
@kilic kilic marked this pull request as draft December 28, 2020 04:32
@kilic kilic marked this pull request as ready for review December 28, 2020 06:24
@prestwich
Copy link
Contributor

hey @kilic, I'm starting to shephard client integration. :) Can you please do the following:

  1. once tests: change precompile tests to use Donut block #1286 is merged, rebase onto latest master
  2. Remove your current address declarations
  3. Remove any activation logic (including any rows in the istanbul precompile block)
  4. Fill in the rows in the Donut Precompile block

Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

First pass, generally looks good, but do remember to charge gas. This also applies to the PR for BLS12-377

}

func (c *bls12381G1Add) Run(input []byte, caller common.Address, evm *EVM, gas uint64) ([]byte, uint64, error) {
// Implements EIP-2537 G1Add precompile.
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the first step of any pre-compile function should be to debit the gas
Example code:

	gas, err := debitRequiredGas(c, input, gas)
	if err != nil {
		return nil, gas, err
	}

@trianglesphere trianglesphere self-assigned this Jan 29, 2021
@mcortesi mcortesi added the donut label Jan 29, 2021
@mcortesi mcortesi changed the title BLS12-381 Precompiles CIP-31 - BLS12-381 Precompiles Jan 29, 2021
@mcortesi
Copy link
Contributor

mcortesi commented Feb 8, 2021

Closed in favor of #1340

@mcortesi mcortesi closed this Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants