From: Chris Duncan Date: Thu, 14 Aug 2025 13:56:24 +0000 (-0700) Subject: Explicitly type function variables to ensure type safety. Use const where possible. X-Git-Tag: v0.10.5~41^2~99 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d7b330547fcc6a5f491218650d44c97c2bd7430f;p=libnemo.git Explicitly type function variables to ensure type safety. Use const where possible. --- diff --git a/src/lib/crypto/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts index c2c4d1d..b00a017 100644 --- a/src/lib/crypto/nano-nacl.ts +++ b/src/lib/crypto/nano-nacl.ts @@ -27,7 +27,7 @@ export class NanoNaCl { static XY: BigInt64Array = new BigInt64Array([0xdd90n, 0xa5b7n, 0x8ab3n, 0x6dden, 0x52f5n, 0x7751n, 0x9f80n, 0x20f0n, 0xe37dn, 0x64abn, 0x4e8en, 0x66ean, 0x7665n, 0xd78bn, 0x5f0fn, 0xe787n]) static #vn (x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number): number { - let d = 0 + let d: number = 0 for (let i = 0; i < n; i++) { d |= x[xi + i] ^ y[yi + i] } @@ -48,7 +48,8 @@ export class NanoNaCl { } static car25519 (out: BigInt64Array): void { - let v, c, s = 1n << 16n + let v: bigint, c: bigint + const s: bigint = 1n << 16n c = 0n for (let i = 0; i < 16; i++) { v = out[i] + c + s @@ -71,8 +72,8 @@ export class NanoNaCl { } static neq25519 (a: BigInt64Array, b: BigInt64Array): number { - const c = new Uint8Array(32) - const d = new Uint8Array(32) + const c: Uint8Array = new Uint8Array(32) + const d: Uint8Array = new Uint8Array(32) this.pack25519(c, a) this.pack25519(d, b) return this.#vn(c, 0, d, 0, 32) @@ -104,7 +105,7 @@ export class NanoNaCl { } static par25519 (a: BigInt64Array): number { - const d = new Uint8Array(32) + const d: Uint8Array = new Uint8Array(32) this.pack25519(d, a) return d[0] & 1 } @@ -139,7 +140,8 @@ export class NanoNaCl { } static Multiply (out: BigInt64Array, a: BigInt64Array, b: BigInt64Array): void { - let v, c, s: bigint = 1n << 16n + let v: bigint, c: bigint + const s: bigint = 1n << 16n const t: BigInt64Array = new BigInt64Array(31) t.fill(0n) @@ -178,7 +180,8 @@ export class NanoNaCl { } static Square (out: BigInt64Array, a: BigInt64Array): void { - let v, c, s: bigint = 1n << 16n + let v: bigint, c: bigint + const s: bigint = 1n << 16n const t: BigInt64Array = new BigInt64Array(31) t.fill(0n) @@ -324,7 +327,7 @@ export class NanoNaCl { } static reduce (r: Uint8Array): void { - const x = new BigInt64Array(64) + const x: BigInt64Array = new BigInt64Array(64) for (let i = 0; i < 64; i++) { x[i] = BigInt(r[i]) }