Skip to content

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

Notifications You must be signed in to change notification settings

Tetration-Lab/solidity-ed-on-bn254

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
 }
}

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published