This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
forked from barryWhiteHat/semaphore
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from HarryR/jubjub-eddsa-tests
Jubjub EdDSA + Tests + solidity cleanups
- Loading branch information
Showing
23 changed files
with
808 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ __pycache__ | |
.coverage.* | ||
/node_modules | ||
package-lock.json | ||
lextab.py | ||
yacctab.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "default", | ||
"rules": { | ||
"indent": false, | ||
"var-name-mixedcase": false, | ||
"func-name-mixedcase": false, | ||
"func-param-name-mixedcase": false, | ||
"not-rely-on-time": false, | ||
"bracket-align": false, | ||
"expression-indent": false, | ||
"max-line-length": false, | ||
"two-lines-top-level-separator": false, | ||
"separate-by-one-line-in-contract": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2018 @HarryR | ||
// License: LGPL-3.0+ | ||
|
||
pragma solidity 0.4.24; | ||
|
||
import "./JubJub.sol"; | ||
|
||
|
||
contract EdDSA | ||
{ | ||
function HashToInt( bytes data ) | ||
public pure returns (uint256) | ||
{ | ||
uint256 hashed = uint256(sha256(data)); | ||
|
||
// (2<<249) - 1 | ||
uint256 mask = 1809251394333065553493296640760748560207343510400633813116524750123642650623; | ||
|
||
return hashed & mask; | ||
} | ||
|
||
function Verify( uint256[2] pubkey, uint256 hashed_msg, uint256[2] R, uint256 s ) | ||
public view returns (bool) | ||
{ | ||
uint256[2] memory B = JubJub.Generator(); | ||
uint256[2] memory lhs; | ||
uint256[2] memory rhs; | ||
|
||
(lhs[0], lhs[1]) = JubJub.scalarMult(B[0], B[1], s); | ||
|
||
uint256 t = HashToInt(abi.encodePacked( | ||
R[0], R[1], | ||
pubkey[0], pubkey[1], | ||
hashed_msg | ||
)); | ||
|
||
(rhs[0], rhs[1]) = JubJub.scalarMult(pubkey[0], pubkey[1], t); | ||
|
||
return lhs[0] == rhs[0] && lhs[1] == rhs[1]; | ||
} | ||
} |
Oops, something went wrong.