Replace ripemd160 dependencies with @noble/hashes
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user