From 137927b0b7e71e26070be0308af0f42c6573b712 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 30 Nov 2024 23:26:51 -0800 Subject: [PATCH] Formatting. --- lib/ed25519.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/ed25519.ts b/lib/ed25519.ts index 12f6903..3cc1fd0 100644 --- a/lib/ed25519.ts +++ b/lib/ed25519.ts @@ -12,14 +12,14 @@ export default class Ed25519 { 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(), @@ -31,7 +31,7 @@ export default class Ed25519 { 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 @@ -61,7 +61,7 @@ export default class Ed25519 { } } - reduce(r: Uint8Array): void { + reduce (r: Uint8Array): void { const x = new Uint32Array(64) for (let i = 0; i < 64; i++) { x[i] = r[i] @@ -70,7 +70,7 @@ export default class Ed25519 { 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) @@ -85,7 +85,7 @@ export default class Ed25519 { } } - 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) @@ -100,7 +100,7 @@ export default class Ed25519 { * @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) @@ -124,7 +124,7 @@ export default class Ed25519 { * @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 @@ -142,7 +142,7 @@ export default class Ed25519 { * @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) @@ -160,7 +160,7 @@ export default class Ed25519 { * @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()] @@ -191,7 +191,7 @@ export default class Ed25519 { 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') } @@ -202,7 +202,7 @@ export default class Ed25519 { 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) -- 2.34.1