mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Use Sha2 from @noble/hashes
This commit is contained in:
parent
218c341f67
commit
3c7d886eee
16
.pnp.cjs
generated
16
.pnp.cjs
generated
@ -594,10 +594,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||||||
"@types/serve-static",
|
"@types/serve-static",
|
||||||
"npm:1.13.9"
|
"npm:1.13.9"
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"@types/sha.js",
|
|
||||||
"npm:2.4.0"
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"@types/ws",
|
"@types/ws",
|
||||||
"npm:6.0.4"
|
"npm:6.0.4"
|
||||||
@ -3378,7 +3374,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||||||
["@types/karma-jasmine-html-reporter", "npm:1.5.1"],
|
["@types/karma-jasmine-html-reporter", "npm:1.5.1"],
|
||||||
["@types/libsodium-wrappers", "npm:0.7.9"],
|
["@types/libsodium-wrappers", "npm:0.7.9"],
|
||||||
["@types/node", "npm:15.3.1"],
|
["@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/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:4.28.4"],
|
||||||
["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:4.28.4"],
|
["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:4.28.4"],
|
||||||
["bip39", "npm:3.0.4"],
|
["bip39", "npm:3.0.4"],
|
||||||
@ -3405,7 +3400,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||||||
["nyc", "npm:15.1.0"],
|
["nyc", "npm:15.1.0"],
|
||||||
["prettier", "npm:2.4.1"],
|
["prettier", "npm:2.4.1"],
|
||||||
["ses", "npm:0.11.1"],
|
["ses", "npm:0.11.1"],
|
||||||
["sha.js", "npm:2.4.11"],
|
|
||||||
["source-map-support", "npm:0.5.19"],
|
["source-map-support", "npm:0.5.19"],
|
||||||
["stream-browserify", "npm:3.0.0"],
|
["stream-browserify", "npm:3.0.0"],
|
||||||
["ts-node", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.10.2"],
|
["ts-node", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.10.2"],
|
||||||
@ -4870,16 +4864,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||||||
"linkType": "HARD",
|
"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", [
|
["@types/ws", [
|
||||||
["npm:6.0.4", {
|
["npm:6.0.4", {
|
||||||
"packageLocation": "./.yarn/cache/@types-ws-npm-6.0.4-4b7cc6a57b-b2656a76bf.zip/node_modules/@types/ws/",
|
"packageLocation": "./.yarn/cache/@types-ws-npm-6.0.4-4b7cc6a57b-b2656a76bf.zip/node_modules/@types/ws/",
|
||||||
|
BIN
.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/@types-sha.js-npm-2.4.0-844623a8de-0e1bd1a98d.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -48,8 +48,7 @@
|
|||||||
"bip39": "^3.0.2",
|
"bip39": "^3.0.2",
|
||||||
"bn.js": "^5.2.0",
|
"bn.js": "^5.2.0",
|
||||||
"elliptic": "^6.5.3",
|
"elliptic": "^6.5.3",
|
||||||
"libsodium-wrappers": "^0.7.6",
|
"libsodium-wrappers": "^0.7.6"
|
||||||
"sha.js": "^2.4.11"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||||
@ -62,7 +61,6 @@
|
|||||||
"@types/karma-jasmine-html-reporter": "^1",
|
"@types/karma-jasmine-html-reporter": "^1",
|
||||||
"@types/libsodium-wrappers": "^0.7.7",
|
"@types/libsodium-wrappers": "^0.7.7",
|
||||||
"@types/node": "^15.0.1",
|
"@types/node": "^15.0.1",
|
||||||
"@types/sha.js": "^2.4.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28",
|
"@typescript-eslint/eslint-plugin": "^4.28",
|
||||||
"@typescript-eslint/parser": "^4.28",
|
"@typescript-eslint/parser": "^4.28",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
import { Hash } from "crypto";
|
import { sha256 as nobleSha256 } from "@noble/hashes/sha256";
|
||||||
import shajs from "sha.js";
|
import { sha512 as nobleSha512 } from "@noble/hashes/sha512";
|
||||||
|
|
||||||
import { HashFunction } from "./hash";
|
import { HashFunction } from "./hash";
|
||||||
|
|
||||||
export class Sha256 implements HashFunction {
|
export class Sha256 implements HashFunction {
|
||||||
public readonly blockSize = 512 / 8;
|
public readonly blockSize = 512 / 8;
|
||||||
|
|
||||||
private readonly impl: Hash;
|
private readonly impl = nobleSha256.create();
|
||||||
|
|
||||||
public constructor(firstData?: Uint8Array) {
|
public constructor(firstData?: Uint8Array) {
|
||||||
this.impl = shajs("sha256");
|
|
||||||
|
|
||||||
if (firstData) {
|
if (firstData) {
|
||||||
this.update(firstData);
|
this.update(firstData);
|
||||||
}
|
}
|
||||||
@ -22,7 +20,7 @@ export class Sha256 implements HashFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public digest(): Uint8Array {
|
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 {
|
export class Sha512 implements HashFunction {
|
||||||
public readonly blockSize = 1024 / 8;
|
public readonly blockSize = 1024 / 8;
|
||||||
|
|
||||||
private readonly impl: Hash;
|
private readonly impl = nobleSha512.create();
|
||||||
|
|
||||||
public constructor(firstData?: Uint8Array) {
|
public constructor(firstData?: Uint8Array) {
|
||||||
this.impl = shajs("sha512");
|
|
||||||
|
|
||||||
if (firstData) {
|
if (firstData) {
|
||||||
this.update(firstData);
|
this.update(firstData);
|
||||||
}
|
}
|
||||||
@ -50,7 +46,7 @@ export class Sha512 implements HashFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public digest(): Uint8Array {
|
public digest(): Uint8Array {
|
||||||
return new Uint8Array(this.impl.digest());
|
return this.impl.digest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
yarn.lock
11
yarn.lock
@ -465,7 +465,6 @@ __metadata:
|
|||||||
"@types/karma-jasmine-html-reporter": ^1
|
"@types/karma-jasmine-html-reporter": ^1
|
||||||
"@types/libsodium-wrappers": ^0.7.7
|
"@types/libsodium-wrappers": ^0.7.7
|
||||||
"@types/node": ^15.0.1
|
"@types/node": ^15.0.1
|
||||||
"@types/sha.js": ^2.4.0
|
|
||||||
"@typescript-eslint/eslint-plugin": ^4.28
|
"@typescript-eslint/eslint-plugin": ^4.28
|
||||||
"@typescript-eslint/parser": ^4.28
|
"@typescript-eslint/parser": ^4.28
|
||||||
bip39: ^3.0.2
|
bip39: ^3.0.2
|
||||||
@ -492,7 +491,6 @@ __metadata:
|
|||||||
nyc: ^15.1.0
|
nyc: ^15.1.0
|
||||||
prettier: ^2.4.1
|
prettier: ^2.4.1
|
||||||
ses: ^0.11.0
|
ses: ^0.11.0
|
||||||
sha.js: ^2.4.11
|
|
||||||
source-map-support: ^0.5.19
|
source-map-support: ^0.5.19
|
||||||
stream-browserify: ^3.0.0
|
stream-browserify: ^3.0.0
|
||||||
ts-node: ^8
|
ts-node: ^8
|
||||||
@ -1801,15 +1799,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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":
|
"@types/ws@npm:^6.0.1":
|
||||||
version: 6.0.4
|
version: 6.0.4
|
||||||
resolution: "@types/ws@npm:6.0.4"
|
resolution: "@types/ws@npm:6.0.4"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user