Fix all zeros after 16384 bytes with Blake3
This commit is contained in:
parent
8de0ded56c
commit
a862c62187
19
package-lock.json
generated
19
package-lock.json
generated
@ -49,7 +49,7 @@
|
|||||||
"flat": "^6.0.1",
|
"flat": "^6.0.1",
|
||||||
"geodesy": "1.1.3",
|
"geodesy": "1.1.3",
|
||||||
"handlebars": "^4.7.9",
|
"handlebars": "^4.7.9",
|
||||||
"hash-wasm": "^4.12.0",
|
"hashes-grs": "1.2.0",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"ieee754": "^1.2.1",
|
"ieee754": "^1.2.1",
|
||||||
"jimp": "1.6.0",
|
"jimp": "1.6.0",
|
||||||
@ -11018,12 +11018,6 @@
|
|||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hash-wasm": {
|
|
||||||
"version": "4.12.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/hash-wasm/-/hash-wasm-4.12.0.tgz",
|
|
||||||
"integrity": "sha512-+/2B2rYLb48I/evdOIhP+K/DD2ca2fgBjp6O+GBEnCDk2e4rpeXIK8GvIyRPjTezgmWn9gmKwkQjjx6BtqDHVQ==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/hash.js": {
|
"node_modules/hash.js": {
|
||||||
"version": "1.1.7",
|
"version": "1.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
|
||||||
@ -11034,6 +11028,17 @@
|
|||||||
"minimalistic-assert": "^1.0.1"
|
"minimalistic-assert": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/hashes-grs": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/hashes-grs/-/hashes-grs-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-CR6j5GrgbniTkgpuCUgYMkOlppWsDkBIodCspcU+9Nq4nvKfhxQ5dpN6dL22iqiCgDYi+417uknOGcD8ksj/0A==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.groestlcoin.org/donations/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/hasown": {
|
"node_modules/hasown": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||||
|
|||||||
@ -104,6 +104,7 @@
|
|||||||
"avsc": "^5.7.9",
|
"avsc": "^5.7.9",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"bignumber.js": "^9.3.1",
|
"bignumber.js": "^9.3.1",
|
||||||
|
"hashes-grs": "1.2.0",
|
||||||
"blakejs": "^1.2.1",
|
"blakejs": "^1.2.1",
|
||||||
"bootstrap": "4.6.2",
|
"bootstrap": "4.6.2",
|
||||||
"bootstrap-colorpicker": "^3.4.0",
|
"bootstrap-colorpicker": "^3.4.0",
|
||||||
@ -132,7 +133,6 @@
|
|||||||
"flat": "^6.0.1",
|
"flat": "^6.0.1",
|
||||||
"geodesy": "1.1.3",
|
"geodesy": "1.1.3",
|
||||||
"handlebars": "^4.7.9",
|
"handlebars": "^4.7.9",
|
||||||
"hash-wasm": "^4.12.0",
|
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"ieee754": "^1.2.1",
|
"ieee754": "^1.2.1",
|
||||||
"jimp": "1.6.0",
|
"jimp": "1.6.0",
|
||||||
|
|||||||
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import { blake3 } from "hash-wasm";
|
import Utils from "../Utils.mjs";
|
||||||
|
import { blake3 } from "hashes-grs/blake3";
|
||||||
|
import { bytesToHex } from "hashes-grs/utils";
|
||||||
/**
|
/**
|
||||||
* BLAKE3 operation
|
* BLAKE3 operation
|
||||||
*/
|
*/
|
||||||
@ -44,13 +46,15 @@ class BLAKE3 extends Operation {
|
|||||||
run(input, args) {
|
run(input, args) {
|
||||||
const key = args[1];
|
const key = args[1];
|
||||||
const size = args[0];
|
const size = args[0];
|
||||||
// Check if the user want a key hash or not
|
const opts = { dkLen: size };
|
||||||
if (key === "") {
|
if (key !== "") {
|
||||||
return blake3(input, size*8);
|
const keyBytes = new Uint8Array(Utils.strToArrayBuffer(key));
|
||||||
} if (key.length !== 32) {
|
if (keyBytes.length !== 32) {
|
||||||
throw new OperationError("The key must be exactly 32 bytes long");
|
throw new OperationError("The key must be exactly 32 bytes long");
|
||||||
}
|
}
|
||||||
return blake3(input, size*8, key);
|
opts.key = keyBytes;
|
||||||
|
}
|
||||||
|
return bytesToHex(blake3(input, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user