diff --git a/.pnp.cjs b/.pnp.cjs index 510fa80b7f..d9b6ef3063 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -342,6 +342,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "@ledgerhq/logs", "npm:5.50.0" ], + [ + "@noble/hashes", + "npm:0.4.3" + ], [ "@nodelib/fs.scandir", "npm:2.1.4" @@ -582,10 +586,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "@types/range-parser", "npm:1.2.3" ], - [ - "@types/ripemd160", - "npm:2.0.0" - ], [ "@types/semver", "npm:7.3.6" @@ -3372,6 +3372,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@cosmjs/math", "workspace:packages/math"], ["@cosmjs/utils", "workspace:packages/utils"], ["@istanbuljs/nyc-config-typescript", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.0.1"], + ["@noble/hashes", "npm:0.4.3"], ["@types/bn.js", "npm:5.1.0"], ["@types/elliptic", "npm:6.4.12"], ["@types/eslint-plugin-prettier", "npm:3.1.0"], @@ -3381,7 +3382,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/ripemd160", "npm:2.0.0"], ["@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"], @@ -3409,7 +3409,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["libsodium-wrappers", "npm:0.7.9"], ["nyc", "npm:15.1.0"], ["prettier", "npm:2.4.1"], - ["ripemd160", "npm:2.0.2"], ["ses", "npm:0.11.1"], ["sha.js", "npm:2.4.11"], ["source-map-support", "npm:0.5.19"], @@ -4224,6 +4223,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], + ["@noble/hashes", [ + ["npm:0.4.3", { + "packageLocation": "./.yarn/cache/@noble-hashes-npm-0.4.3-fdd24c531c-d477167bf4.zip/node_modules/@noble/hashes/", + "packageDependencies": [ + ["@noble/hashes", "npm:0.4.3"] + ], + "linkType": "HARD", + }] + ]], ["@nodelib/fs.scandir", [ ["npm:2.1.4", { "packageLocation": "./.yarn/cache/@nodelib-fs.scandir-npm-2.1.4-6f6ddb2372-18c2150ab5.zip/node_modules/@nodelib/fs.scandir/", @@ -4847,16 +4855,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], - ["@types/ripemd160", [ - ["npm:2.0.0", { - "packageLocation": "./.yarn/cache/@types-ripemd160-npm-2.0.0-0e635eba3e-eb0eb2d380.zip/node_modules/@types/ripemd160/", - "packageDependencies": [ - ["@types/ripemd160", "npm:2.0.0"], - ["@types/node", "npm:15.3.1"] - ], - "linkType": "HARD", - }] - ]], ["@types/semver", [ ["npm:7.3.6", { "packageLocation": "./.yarn/cache/@types-semver-npm-7.3.6-4add0df8f9-933b115a59.zip/node_modules/@types/semver/", diff --git a/.yarn/cache/@noble-hashes-npm-0.4.3-fdd24c531c-d477167bf4.zip b/.yarn/cache/@noble-hashes-npm-0.4.3-fdd24c531c-d477167bf4.zip new file mode 100644 index 0000000000..f3d2abb710 --- /dev/null +++ b/.yarn/cache/@noble-hashes-npm-0.4.3-fdd24c531c-d477167bf4.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c0c3d758b12794db6e252c41c7c5686eab752eb6d61fd18381972618b83b6a4 +size 87118 diff --git a/.yarn/cache/@types-ripemd160-npm-2.0.0-0e635eba3e-eb0eb2d380.zip b/.yarn/cache/@types-ripemd160-npm-2.0.0-0e635eba3e-eb0eb2d380.zip deleted file mode 100644 index 8404bdd625..0000000000 --- a/.yarn/cache/@types-ripemd160-npm-2.0.0-0e635eba3e-eb0eb2d380.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:48fa2838edad2eae418762a057ea6c816e1f82a9976c1c93447d2fbe827a2dc3 -size 2531 diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 14becd2237..e38b9a005c 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -44,12 +44,12 @@ "@cosmjs/encoding": "workspace:packages/encoding", "@cosmjs/math": "workspace:packages/math", "@cosmjs/utils": "workspace:packages/utils", + "@noble/hashes": "^0.4.3", "bip39": "^3.0.2", "bn.js": "^5.2.0", "elliptic": "^6.5.3", "js-sha3": "^0.8.0", "libsodium-wrappers": "^0.7.6", - "ripemd160": "^2.0.2", "sha.js": "^2.4.11" }, "devDependencies": { @@ -63,7 +63,6 @@ "@types/karma-jasmine-html-reporter": "^1", "@types/libsodium-wrappers": "^0.7.7", "@types/node": "^15.0.1", - "@types/ripemd160": "^2.0.0", "@types/sha.js": "^2.4.0", "@typescript-eslint/eslint-plugin": "^4.28", "@typescript-eslint/parser": "^4.28", diff --git a/packages/crypto/src/ripemd.ts b/packages/crypto/src/ripemd.ts index 258a43e014..10eccb9586 100644 --- a/packages/crypto/src/ripemd.ts +++ b/packages/crypto/src/ripemd.ts @@ -1,11 +1,11 @@ -import RIPEMD160 from "ripemd160"; +import { ripemd160 as libRipemd160 } from "@noble/hashes/lib/ripemd160"; import { HashFunction } from "./hash"; export class Ripemd160 implements HashFunction { public readonly blockSize = 512 / 8; - private readonly impl = new RIPEMD160(); + private readonly impl = libRipemd160.create(); public constructor(firstData?: Uint8Array) { if (firstData) { @@ -14,7 +14,7 @@ export class Ripemd160 implements HashFunction { } public update(data: Uint8Array): Ripemd160 { - this.impl.update(Buffer.from(data)); + this.impl.update(data); return this; } diff --git a/yarn.lock b/yarn.lock index 974881f2ab..24356ccb66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -455,6 +455,7 @@ __metadata: "@cosmjs/math": "workspace:packages/math" "@cosmjs/utils": "workspace:packages/utils" "@istanbuljs/nyc-config-typescript": ^1.0.1 + "@noble/hashes": ^0.4.3 "@types/bn.js": ^5 "@types/elliptic": ^6.4.12 "@types/eslint-plugin-prettier": ^3 @@ -464,7 +465,6 @@ __metadata: "@types/karma-jasmine-html-reporter": ^1 "@types/libsodium-wrappers": ^0.7.7 "@types/node": ^15.0.1 - "@types/ripemd160": ^2.0.0 "@types/sha.js": ^2.4.0 "@typescript-eslint/eslint-plugin": ^4.28 "@typescript-eslint/parser": ^4.28 @@ -492,7 +492,6 @@ __metadata: libsodium-wrappers: ^0.7.6 nyc: ^15.1.0 prettier: ^2.4.1 - ripemd160: ^2.0.2 ses: ^0.11.0 sha.js: ^2.4.11 source-map-support: ^0.5.19 @@ -1248,6 +1247,13 @@ __metadata: languageName: node linkType: hard +"@noble/hashes@npm:^0.4.3": + version: 0.4.3 + resolution: "@noble/hashes@npm:0.4.3" + checksum: d477167bf45273bfc0927b7325b10b33050600dfe9c713cf70f83d5dde61c6d9118e8802164a58eb4c936c52d694609d41b597d10d534e72bb4bddc158b38396 + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.4": version: 2.1.4 resolution: "@nodelib/fs.scandir@npm:2.1.4" @@ -1779,15 +1785,6 @@ __metadata: languageName: node linkType: hard -"@types/ripemd160@npm:^2.0.0": - version: 2.0.0 - resolution: "@types/ripemd160@npm:2.0.0" - dependencies: - "@types/node": "*" - checksum: eb0eb2d380734a957a1e584f22af874552fe2ce1b28bc079ea5e361dec4bfcee5285d34dc6acdbce31616ac93210343a6c92809a45e18e3b3fd7f462c65b5166 - languageName: node - linkType: hard - "@types/semver@npm:^7.3.4": version: 7.3.6 resolution: "@types/semver@npm:7.3.6"