Last active
December 29, 2015 12:19
-
-
Save rev22/7669930 to your computer and use it in GitHub Desktop.
Testing curve255js...
This file contains hidden or 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
// Converts key from plain hexadecimal to inverted-byte hexadecimal | |
function hex2ibh(x) { | |
x = new Array(64 + 1 - x.length).join("0") + x; // Pad with '0' at the front | |
// Invert bytes | |
return x.split(/(..)/).reverse().join(""); | |
} | |
function ibh2hex(x) { | |
//assert(length(x) == 64); | |
// Invert bytes | |
return x.split(/(..)/).reverse().join(""); | |
} | |
priv=ibh2hex('0300000000000000000000000000000000000000000000000000000000000000'); | |
base=ibh2hex('0900000000000000000000000000000000000000000000000000000000000000'); | |
console.log(priv); | |
pub = hex2ibh(c255lhexencode(curve25519(c255lhexdecode(priv), c255lhexdecode(base)))); | |
expect='123c71fbaf030ac059081c62674e82f864ba1bc2914d5345e6ab576d1abc121c'; | |
assert(pub == expect); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment