Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tetration-lab/solidity-ed-on-bn254
Solidity implementation of a twisted Edwards curve on scalar field of BN254, also known as Baby-Jubjub.
https://github.com/tetration-lab/solidity-ed-on-bn254
babyjubjub bn254 cryptography ethereum smart-contract solidity
Last synced: 18 days ago
JSON representation
Solidity implementation of a twisted Edwards curve on scalar field of BN254, also known as Baby-Jubjub.
- Host: GitHub
- URL: https://github.com/tetration-lab/solidity-ed-on-bn254
- Owner: Tetration-Lab
- Created: 2022-12-30T08:30:50.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T17:35:07.000Z (about 1 year ago)
- Last Synced: 2024-04-14T02:01:48.394Z (8 months ago)
- Topics: babyjubjub, bn254, cryptography, ethereum, smart-contract, solidity
- Language: Solidity
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Solidity EdOnBN254 (Baby JubJub)
Solidity implementation of a twisted Edwards curve on scalar field of BN254, also known as [Baby-Jubjub](https://github.com/barryWhiteHat/baby_jubjub).
This repo was modified from:
- Another Solidity implementation:
- Arkwork Rust implementation:## 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.
```bash
forge install https://github.com/Tetration-Lab/solidity-ed-on-bn254
forge remappings
```Then use it in library or smart contract.
```solidity
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
}
}
```