Skip to content

Commit

Permalink
Replace ripemd160 dependencies with @noble/hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Dec 6, 2021
1 parent 700cac8 commit ce93955
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
30 changes: 14 additions & 16 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .yarn/cache/@noble-hashes-npm-0.4.3-fdd24c531c-d477167bf4.zip
Git LFS file not shown

This file was deleted.

3 changes: 1 addition & 2 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/crypto/src/ripemd.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;
}

Expand Down
19 changes: 8 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit ce93955

Please sign in to comment.