Change package, add additional key test
This commit is contained in:
parent
b0fb634507
commit
07d713c437
13
package-lock.json
generated
13
package-lock.json
generated
@ -13,6 +13,7 @@
|
|||||||
"@alexaltea/capstone-js": "^3.0.5",
|
"@alexaltea/capstone-js": "^3.0.5",
|
||||||
"@astronautlabs/amf": "^0.0.6",
|
"@astronautlabs/amf": "^0.0.6",
|
||||||
"@blu3r4y/lzma": "^2.3.3",
|
"@blu3r4y/lzma": "^2.3.3",
|
||||||
|
"@noble/hashes": "2.2.0",
|
||||||
"@wavesenterprise/crypto-gost-js": "^2.1.0-RC1",
|
"@wavesenterprise/crypto-gost-js": "^2.1.0-RC1",
|
||||||
"@xmldom/xmldom": "^0.8.13",
|
"@xmldom/xmldom": "^0.8.13",
|
||||||
"argon2-browser": "^1.18.0",
|
"argon2-browser": "^1.18.0",
|
||||||
@ -49,7 +50,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",
|
||||||
"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",
|
||||||
@ -11028,17 +11028,6 @@
|
|||||||
"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,7 +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",
|
"@noble/hashes": "2.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",
|
||||||
|
|||||||
@ -7,8 +7,9 @@
|
|||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import Utils from "../Utils.mjs";
|
import Utils from "../Utils.mjs";
|
||||||
import { blake3 } from "hashes-grs/blake3";
|
import { blake3 } from "@noble/hashes/blake3.js";
|
||||||
import { bytesToHex } from "hashes-grs/utils";
|
import { bytesToHex } from "@noble/hashes/utils.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BLAKE3 operation
|
* BLAKE3 operation
|
||||||
*/
|
*/
|
||||||
@ -47,6 +48,7 @@ class BLAKE3 extends Operation {
|
|||||||
const key = args[1];
|
const key = args[1];
|
||||||
const size = args[0];
|
const size = args[0];
|
||||||
const opts = { dkLen: size };
|
const opts = { dkLen: size };
|
||||||
|
const inputBytes = new Uint8Array(Utils.strToArrayBuffer(input));
|
||||||
if (key !== "") {
|
if (key !== "") {
|
||||||
const keyBytes = new Uint8Array(Utils.strToArrayBuffer(key));
|
const keyBytes = new Uint8Array(Utils.strToArrayBuffer(key));
|
||||||
if (keyBytes.length !== 32) {
|
if (keyBytes.length !== 32) {
|
||||||
@ -54,7 +56,7 @@ class BLAKE3 extends Operation {
|
|||||||
}
|
}
|
||||||
opts.key = keyBytes;
|
opts.key = keyBytes;
|
||||||
}
|
}
|
||||||
return bytesToHex(blake3(input, opts));
|
return bytesToHex(blake3(inputBytes, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,5 +60,15 @@ TestRegister.addTests([
|
|||||||
{ "op": "BLAKE3",
|
{ "op": "BLAKE3",
|
||||||
"args": [16390, ""] }
|
"args": [16390, ""] }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "BLAKE3: 16390 - key test",
|
||||||
|
input: "test",
|
||||||
|
expectedMatch: /a8d0.{32760}19ccd9b9726b46ae/,
|
||||||
|
recipeConfig: [
|
||||||
|
{ "op": "BLAKE3",
|
||||||
|
"args": [16390, "ThiskeyisexactlythirtytwoBytesLo"] }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user