Code Monkey home page Code Monkey logo

solidity-ed-on-bn254's Introduction

Solidity EdOnBN254 (Baby JubJub)

Solidity implementation of a twisted Edwards curve on scalar field of BN254, also known as Baby-Jubjub.

This repo was modified from:

Curve Information

Base Field

$$ q = 21888242871839275222246405745257275088548364400416034343698204186575808495617 $$

Twisted edwards curve

$$ ax^2+y^2=1+dx^2y^2 $$

Where

$$ a=1, d=168696/168700;mod;q=9706598848417545097372247223557719406784115219466060233080913168975159366771 $$

Usage

First, install this package as dependency.

forge install https://github.com/Tetration-Lab/solidity-ed-on-bn254
forge remappings

Then use it in library or smart contract.

import {EdOnBN254} from "solidity-ed-on-bn254/EdOnBN254.sol";

contract X {
 function x() public {
  EdOnBN254.Affine g = EdOnBN254.primeSubgroupGenerator(); // Prime subgroup generator
  EdOnBN254.Affine x = EdOnBN254.mul(g, 3); // Scalar multiplication
  EdOnBN254.Affine y = EdOnBN254.add(g, x); // Affine addition
  EdOnBN254.Affine z = EdOnBN254.neg(y); // Affine negation
 }
}

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.