Coder Social home page Coder Social logo

laplacekorea / solidity-bn256g2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from musalbas/solidity-bn256g2

0.0 1.0 0.0 67 KB

Implementation of elliptic curve operations on G2 for alt_bn128 in Solidity.

License: GNU Lesser General Public License v3.0

Solidity 68.65% Python 31.35%

solidity-bn256g2's Introduction

solidity-BN256G2

Implementation of elliptic curve operations on G2 for alt_bn128 in Solidity.

Build Status

Functions

ECTwistAdd

/**
 * @notice Add two twist points
 * @param pt1xx Coefficient 1 of x on point 1
 * @param pt1xy Coefficient 2 of x on point 1
 * @param pt1yx Coefficient 1 of y on point 1
 * @param pt1yy Coefficient 2 of y on point 1
 * @param pt2xx Coefficient 1 of x on point 2
 * @param pt2xy Coefficient 2 of x on point 2
 * @param pt2yx Coefficient 1 of y on point 2
 * @param pt2yy Coefficient 2 of y on point 2
 * @return (pt3xx, pt3xy, pt3yx, pt3yy)
 */
function ECTwistAdd(
    uint256 pt1xx, uint256 pt1xy,
    uint256 pt1yx, uint256 pt1yy,
    uint256 pt2xx, uint256 pt2xy,
    uint256 pt2yx, uint256 pt2yy
) public view returns (
    uint256, uint256,
    uint256, uint256
)

ECTwistMul

/**
 * @notice Multiply a twist point by a scalar
 * @param s     Scalar to multiply by
 * @param pt1xx Coefficient 1 of x
 * @param pt1xy Coefficient 2 of x
 * @param pt1yx Coefficient 1 of y
 * @param pt1yy Coefficient 2 of y
 * @return (pt2xx, pt2xy, pt2yx, pt2yy)
 */
function ECTwistMul(
    uint256 s,
    uint256 pt1xx, uint256 pt1xy,
    uint256 pt1yx, uint256 pt1yy
) public view returns (
    uint256, uint256,
    uint256, uint256
)

Gas costs

Function Gas cost
ECTwistAdd ~30,000
ECTwistMul ~2,000,000 for a 256-bit scalar

solidity-bn256g2's People

Contributors

musalbas avatar 0xashish avatar schaeff avatar

Watchers

 avatar

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.