Replace ripemd160 dependencies with @noble/hashes

This commit is contained in:
Simon Warta
2022-01-26 21:32:30 +01:00
parent b17e519524
commit 4a6253f16b
6 changed files with 30 additions and 36 deletions
+1 -2
View File
@@ -44,12 +44,12 @@
"@cosmjs/encoding": "workspace:packages/encoding",
"@cosmjs/math": "workspace:packages/math",
"@cosmjs/utils": "workspace:packages/utils",
"@noble/hashes": "^1",
"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",
+4 -4
View File
@@ -1,11 +1,11 @@
import RIPEMD160 from "ripemd160";
import { ripemd160 as nobleRipemd160 } from "@noble/hashes/ripemd160";
import { HashFunction } from "./hash";
export class Ripemd160 implements HashFunction {
public readonly blockSize = 512 / 8;
private readonly impl = new RIPEMD160();
private readonly impl = nobleRipemd160.create();
public constructor(firstData?: Uint8Array) {
if (firstData) {
@@ -14,12 +14,12 @@ export class Ripemd160 implements HashFunction {
}
public update(data: Uint8Array): Ripemd160 {
this.impl.update(Buffer.from(data));
this.impl.update(data);
return this;
}
public digest(): Uint8Array {
return Uint8Array.from(this.impl.digest());
return this.impl.digest();
}
}