From 89d8a1e1b46a0acf4df94aee02c90883493e5583 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Mon, 9 Sep 2024 21:38:42 +0300 Subject: [PATCH] fixes --- .eslintrc.js | 17 ++++++++++++++++- package.json | 4 ++-- src/ff/f1field.ts | 6 +++--- src/ff/scalar.ts | 4 ++-- tests/sha256.test.ts | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 40def64..03a522d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,22 @@ module.exports = { ...spellcheckerRule, cspell: { ...cspellConfig, - ignoreWords: ['dtau', 'escalar', 'pleft', 'pright'] + ignoreWords: [ + 'dtau', + 'escalar', + 'pleft', + 'pright', + 'unstringify', + 'bxor', + 'nullt', + 'msglen', + 'negone', + 'tonelli', + 'nres', + 'idiv', + 'newr', + 'bnot' + ] } } ] diff --git a/package.json b/package.json index 75af603..a5a4fc4 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "build:esm": "tsc -p config/tsconfig.esm.json", "clean": "rimraf ./dist", "test": "jest", - "lint": "eslint --fix --ext .ts src/** tests/**", - "lint:check": "eslint --ext .ts src/** tests/**", + "lint": "eslint --fix --ext .js,.ts src/** tests/**", + "lint:check": "eslint --ext .js,.ts src/** tests/**", "format": "prettier --config .prettierrc './**/*.ts' --write", "format:check": "prettier --config .prettierrc './**/*.ts' --check" }, diff --git a/src/ff/f1field.ts b/src/ff/f1field.ts index edad9a6..858316a 100644 --- a/src/ff/f1field.ts +++ b/src/ff/f1field.ts @@ -327,12 +327,12 @@ export class F1Field { return this.toRprLE(buff, o, this.mul(this.R, e)); } - // Pases a buffer with Little Endian Representation + // Passes a buffer with Little Endian Representation fromRprLE(buff: Uint8Array, o: number) { return Scalar.fromRprLE(buff, o, this.n8); } - // Pases a buffer with Big Endian Representation + // Passes a buffer with Big Endian Representation fromRprBE(buff: Uint8Array, o: number) { return Scalar.fromRprBE(buff, o, this.n8); } @@ -425,7 +425,7 @@ export function mulScalar(F: F1Field, base: bigint, e: bigint): bigint { } else if (n[n.length - 1] == -1) { res = F.neg(base); } else { - throw new Error('invlaud NAF'); + throw new Error('invalid NAF'); } for (let i = n.length - 2; i >= 0; i--) { diff --git a/src/ff/scalar.ts b/src/ff/scalar.ts index 0ddd5f5..dac1224 100644 --- a/src/ff/scalar.ts +++ b/src/ff/scalar.ts @@ -213,7 +213,7 @@ export const toRprBE = (buff: Uint8Array, o: number, e: bigint, n8: number): voi for (let i = 0; i < n8 / 4 - l; i++) v.setInt32(0, 0, false); }; -// Pases a buffer with Little Endian Representation +// Passes a buffer with Little Endian Representation export const fromRprLE = (buff: Uint8Array, o: number, n8?: number): bigint => { n8 = n8 || buff.byteLength; o = o || 0; @@ -223,7 +223,7 @@ export const fromRprLE = (buff: Uint8Array, o: number, n8?: number): bigint => { return fromString(a.join(''), 16); }; -// Pases a buffer with Big Endian Representation +// Passes a buffer with Big Endian Representation export const fromRprBE = (buff: Uint8Array, o: number, n8: number): bigint => { n8 = n8 || buff.byteLength; o = o || 0; diff --git a/tests/sha256.test.ts b/tests/sha256.test.ts index a546a3c..c87cb13 100644 --- a/tests/sha256.test.ts +++ b/tests/sha256.test.ts @@ -41,7 +41,7 @@ describe('SHA-256 Hashing', () => { it('should hash different inputs to different values', () => { const input1 = 'Hello, World!'; - const input2 = 'Hello, Goodbay!'; + const input2 = 'Hello, Good bay!'; const hash1 = sha256(encoder.encode(input1)); const hash2 = sha256(encoder.encode(input2));