diff --git a/.pnp.cjs b/.pnp.cjs index 17fa78972e..d462e57f9d 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -594,10 +594,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "@types/serve-static", "npm:1.13.9" ], - [ - "@types/sha.js", - "npm:2.4.0" - ], [ "@types/ws", "npm:6.0.4" @@ -3378,7 +3374,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/karma-jasmine-html-reporter", "npm:1.5.1"], ["@types/libsodium-wrappers", "npm:0.7.9"], ["@types/node", "npm:15.3.1"], - ["@types/sha.js", "npm:2.4.0"], ["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:4.28.4"], ["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:4.28.4"], ["bip39", "npm:3.0.4"], @@ -3405,7 +3400,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["nyc", "npm:15.1.0"], ["prettier", "npm:2.4.1"], ["ses", "npm:0.11.1"], - ["sha.js", "npm:2.4.11"], ["source-map-support", "npm:0.5.19"], ["stream-browserify", "npm:3.0.0"], ["ts-node", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.10.2"], @@ -4870,16 +4864,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], - ["@types/sha.js", [ - ["npm:2.4.0", { - "packageLocation": "./.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip/node_modules/@types/sha.js/", - "packageDependencies": [ - ["@types/sha.js", "npm:2.4.0"], - ["@types/node", "npm:15.3.1"] - ], - "linkType": "HARD", - }] - ]], ["@types/ws", [ ["npm:6.0.4", { "packageLocation": "./.yarn/cache/@types-ws-npm-6.0.4-4b7cc6a57b-b2656a76bf.zip/node_modules/@types/ws/", diff --git a/.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip b/.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip deleted file mode 100644 index 5b0a9b8951..0000000000 --- a/.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eab162464749baa1a5eddd5d3f11a297572577d1dc4366e382c459efc7bee1b4 -size 2570 diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 6547faf83b..6330c3b0e8 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -48,8 +48,7 @@ "bip39": "^3.0.2", "bn.js": "^5.2.0", "elliptic": "^6.5.3", - "libsodium-wrappers": "^0.7.6", - "sha.js": "^2.4.11" + "libsodium-wrappers": "^0.7.6" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", @@ -62,7 +61,6 @@ "@types/karma-jasmine-html-reporter": "^1", "@types/libsodium-wrappers": "^0.7.7", "@types/node": "^15.0.1", - "@types/sha.js": "^2.4.0", "@typescript-eslint/eslint-plugin": "^4.28", "@typescript-eslint/parser": "^4.28", "buffer": "^6.0.3", diff --git a/packages/crypto/src/sha.ts b/packages/crypto/src/sha.ts index 47a3df01f8..25656aed11 100644 --- a/packages/crypto/src/sha.ts +++ b/packages/crypto/src/sha.ts @@ -1,16 +1,14 @@ -import { Hash } from "crypto"; -import shajs from "sha.js"; +import { sha256 as nobleSha256 } from "@noble/hashes/sha256"; +import { sha512 as nobleSha512 } from "@noble/hashes/sha512"; import { HashFunction } from "./hash"; export class Sha256 implements HashFunction { public readonly blockSize = 512 / 8; - private readonly impl: Hash; + private readonly impl = nobleSha256.create(); public constructor(firstData?: Uint8Array) { - this.impl = shajs("sha256"); - if (firstData) { this.update(firstData); } @@ -22,7 +20,7 @@ export class Sha256 implements HashFunction { } public digest(): Uint8Array { - return new Uint8Array(this.impl.digest()); + return this.impl.digest(); } } @@ -34,11 +32,9 @@ export function sha256(data: Uint8Array): Uint8Array { export class Sha512 implements HashFunction { public readonly blockSize = 1024 / 8; - private readonly impl: Hash; + private readonly impl = nobleSha512.create(); public constructor(firstData?: Uint8Array) { - this.impl = shajs("sha512"); - if (firstData) { this.update(firstData); } @@ -50,7 +46,7 @@ export class Sha512 implements HashFunction { } public digest(): Uint8Array { - return new Uint8Array(this.impl.digest()); + return this.impl.digest(); } } diff --git a/yarn.lock b/yarn.lock index 53006282a8..af9095f817 100644 --- a/yarn.lock +++ b/yarn.lock @@ -465,7 +465,6 @@ __metadata: "@types/karma-jasmine-html-reporter": ^1 "@types/libsodium-wrappers": ^0.7.7 "@types/node": ^15.0.1 - "@types/sha.js": ^2.4.0 "@typescript-eslint/eslint-plugin": ^4.28 "@typescript-eslint/parser": ^4.28 bip39: ^3.0.2 @@ -492,7 +491,6 @@ __metadata: nyc: ^15.1.0 prettier: ^2.4.1 ses: ^0.11.0 - sha.js: ^2.4.11 source-map-support: ^0.5.19 stream-browserify: ^3.0.0 ts-node: ^8 @@ -1801,15 +1799,6 @@ __metadata: languageName: node linkType: hard -"@types/sha.js@npm:^2.4.0": - version: 2.4.0 - resolution: "@types/sha.js@npm:2.4.0" - dependencies: - "@types/node": "*" - checksum: 0e1bd1a98d88dbbf87180b8ef81ab2bf8c2bd066a99858c76299fb599fd912df807072a55a6f484077498dd972a1b55eaa03aae6ea2654027a4dd0331db7e201 - languageName: node - linkType: hard - "@types/ws@npm:^6.0.1": version: 6.0.4 resolution: "@types/ws@npm:6.0.4"