Y: Int32Array
L: Uint8Array
- constructor() {
+ constructor () {
this.curve = new Curve25519()
this.X = this.curve.gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169])
this.Y = this.curve.gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666])
this.L = new Uint8Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10])
}
- pack(r: Uint8Array, p: Int32Array[]): void {
+ pack (r: Uint8Array, p: Int32Array[]): void {
const CURVE = this.curve
const tx = CURVE.gf(),
ty = CURVE.gf(),
r[31] ^= CURVE.par25519(tx) << 7
}
- modL(r: Uint8Array, x: Uint32Array | Float64Array): void {
+ modL (r: Uint8Array, x: Uint32Array | Float64Array): void {
let carry, i, j, k
for (i = 63; i >= 32; --i) {
carry = 0
}
}
- reduce(r: Uint8Array): void {
+ reduce (r: Uint8Array): void {
const x = new Uint32Array(64)
for (let i = 0; i < 64; i++) {
x[i] = r[i]
this.modL(r, x)
}
- scalarmult(p: Int32Array[], q: Int32Array[], s: Uint8Array): void {
+ scalarmult (p: Int32Array[], q: Int32Array[], s: Uint8Array): void {
const CURVE = this.curve
CURVE.set25519(p[0], CURVE.gf0)
CURVE.set25519(p[1], CURVE.gf1)
}
}
- scalarbase(p: Int32Array[], s: Uint8Array): void {
+ scalarbase (p: Int32Array[], s: Uint8Array): void {
const CURVE = this.curve
const q = [CURVE.gf(), CURVE.gf(), CURVE.gf(), CURVE.gf()]
CURVE.set25519(q[0], this.X)
* @param {String} seed A 32 byte cryptographic secure random hexadecimal string. This is basically the secret key
* @param {Object} Returns sk (Secret key) and pk (Public key) as 32 byte hexadecimal strings
*/
- generateKeys(seed: string): KeyPair {
+ generateKeys (seed: string): KeyPair {
const pk = new Uint8Array(32)
const p = [this.curve.gf(), this.curve.gf(), this.curve.gf(), this.curve.gf()]
const h = blake2b(Convert.hex2ab(seed), undefined, 64).slice(0, 32)
* @param {KeyPair} keyPair ed25519 keypair
* @returns {KeyPair} keyPair Curve25519 keypair
*/
- convertKeys(keyPair: KeyPair): KeyPair {
+ convertKeys (keyPair: KeyPair): KeyPair {
const publicKey = Convert.ab2hex(this.curve.convertEd25519PublicKeyToCurve25519(Convert.hex2ab(keyPair.publicKey)))
if (!publicKey) {
return null
* @param {Uint8Array} privateKey Secret key as byte array
* @param {Uint8Array} Returns the signature as 64 byte typed array
*/
- sign(msg: Uint8Array, privateKey: Uint8Array): Uint8Array {
+ sign (msg: Uint8Array, privateKey: Uint8Array): Uint8Array {
const signedMsg = this.naclSign(msg, privateKey)
const sig = new Uint8Array(64)
* @param {Uint8Array} signature Signature as byte array
* @param {Uint8Array} Returns the signature as 64 byte typed array
*/
- verify(msg: Uint8Array, publicKey: Uint8Array, signature: Uint8Array): boolean {
+ verify (msg: Uint8Array, publicKey: Uint8Array, signature: Uint8Array): boolean {
const CURVE = this.curve
const p = [CURVE.gf(), CURVE.gf(), CURVE.gf(), CURVE.gf()]
const q = [CURVE.gf(), CURVE.gf(), CURVE.gf(), CURVE.gf()]
return Util.compare(signature.subarray(0, 32), t)
}
- private naclSign(msg: Uint8Array, secretKey: Uint8Array): Uint8Array {
+ private naclSign (msg: Uint8Array, secretKey: Uint8Array): Uint8Array {
if (secretKey.length !== 32) {
throw new Error('bad secret key size')
}
return signedMsg
}
- private cryptoSign(sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array): number {
+ private cryptoSign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array): number {
const CURVE = this.curve
const d = new Uint8Array(64)
const h = new Uint8Array(64)