Code Monkey home page Code Monkey logo

b12-sol's Introduction

B12.sol

This library provides simply solidity wrappers for the hash function, BLS12-381 and BLS12-377 precompiles found in CIP-20, 30, and 31. These EIPs are not active on mainnet at time of writing, and require specialized client software to execute.

Building

  • $ npm i
  • $ npm compile

Tests

Connect a node an RPC with the Donut hard fork active. Ensure that your node has an unlocked funded account. The tests will deploy contracts and then run the test vectors.

  • $ npm run test

Status

These libraries are in a very early state and should be considered unreliable.

Design notes

This work builds largely on prior work here. We take advantage of Solidity's memory layout for fixed-size arrays to set up the input ranges for the precompile calls. We prep the inputs for the precompile by copying struct attributes to specific elemets of the array.

To avoid unnecessary memory growth, we explicitly de-allocate memory. However, we do not currently 0 it. This leaves dirty memory in the input slots, which may interfere with code that assumes struct members or arrays elements in memory are 0-initialized.

b12-sol's People

Contributors

mrsmkl avatar prestwich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

b12-sol's Issues

BLS 12 381 Precompile

Hi James!!
Thanks for this implementation!!

Is it possible to perform BLS 12 381 signature verification using solidity smart contract you have provided ?

Map to G1 and G2

I have a problem with using map to g1 and map to g2 functions.
I've tried to call mapToG1 function with this input:

[26919105267321020734406576177800653871,44705956066366415409607097651358312499203321806734079377348087001704912294736]

which is correspond to the first element of the test vector at test/12381/blsMapG1.json:

{
    "Input": "0000000000000000000000000000000014406e5bfb9209256a3820879a29ac2f62d6aca82324bf3ae2aa7d3c54792043bd8c791fccdb080c1a52dc68b8b69350",
    "Expected": "000000000000000000000000000000000d7721bcdb7ce1047557776eb2659a444166dc6dd55c7ca6e240e21ae9aa18f529f04ac31d861b54faf3307692545db700000000000000000000000000000000108286acbdf4384f67659a8abe89e712a504cb3ce1cba07a716869025d60d499a00d1da8cdc92958918c222ea93d87f0",
    "Name": "matter_fp_to_g1_0",
    "Gas": 5500,
    "NoBenchmark": false
  }

but the transaction was reverted by error "gas uint64 overflow".
this is the txid of the transaction:
https://celoscan.io/tx/0xfadb5ef471db20c33a89fa43b4b6401dcdf53993978f73521d7335ab7f746ca4

I couldn't find any test for these two functions in your code. can you help me with this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.