keccak unit tests
This commit is contained in:
@ -146,27 +146,26 @@ function Keccak(rate, capacity, inputBytes, delimitedSuffix, outputByteLen) {
|
||||
return new Uint8Array(output);
|
||||
}
|
||||
|
||||
// SHAKE and SHA3 functions
|
||||
function SHAKE128(inputBytes, outputByteLen) {
|
||||
return Keccak(1344, 256, inputBytes, 0x1f, outputByteLen);
|
||||
const keccak = {
|
||||
// SHAKE and SHA3 functions
|
||||
SHAKE128: (inputBytes, outputByteLen) => {
|
||||
return Keccak(1344, 256, inputBytes, 0x1f, outputByteLen);
|
||||
},
|
||||
SHAKE256: (inputBytes, outputByteLen) => {
|
||||
return Keccak(1088, 512, inputBytes, 0x1f, outputByteLen);
|
||||
},
|
||||
SHA3_224: (inputBytes) => {
|
||||
return Keccak(1152, 448, inputBytes, 0x06, 224 / 8);
|
||||
},
|
||||
SHA3_256: (inputBytes) => {
|
||||
return Keccak(1088, 512, inputBytes, 0x06, 256 / 8);
|
||||
},
|
||||
SHA3_384: (inputBytes) => {
|
||||
return Keccak(832, 768, inputBytes, 0x06, 384 / 8);
|
||||
},
|
||||
SHA3_512: (inputBytes) => {
|
||||
return Keccak(576, 1024, inputBytes, 0x06, 512 / 8);
|
||||
}
|
||||
}
|
||||
|
||||
function SHAKE256(inputBytes, outputByteLen) {
|
||||
return Keccak(1088, 512, inputBytes, 0x1f, outputByteLen);
|
||||
}
|
||||
|
||||
function SHA3_224(inputBytes) {
|
||||
return Keccak(1152, 448, inputBytes, 0x06, 224 / 8);
|
||||
}
|
||||
|
||||
function SHA3_256(inputBytes) {
|
||||
return Keccak(1088, 512, inputBytes, 0x06, 256 / 8);
|
||||
}
|
||||
|
||||
function SHA3_384(inputBytes) {
|
||||
return Keccak(832, 768, inputBytes, 0x06, 384 / 8);
|
||||
}
|
||||
|
||||
function SHA3_512(inputBytes) {
|
||||
return Keccak(576, 1024, inputBytes, 0x06, 512 / 8);
|
||||
}
|
||||
module.exports = keccak;
|
||||
|
9
src/stringutils.js
Normal file
9
src/stringutils.js
Normal file
@ -0,0 +1,9 @@
|
||||
const stringutils = {
|
||||
hexToArray: (hexString) => {
|
||||
return Uint8Array.from(Buffer.from(hexString, 'hex'));
|
||||
},
|
||||
arrayToHex: (hex) => {
|
||||
return Buffer.from(hex).toString('hex');
|
||||
}
|
||||
}
|
||||
module.exports = stringutils;
|
Reference in New Issue
Block a user