From a13878e0b10b02803dfd585dc1267b9aaf5f8558 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 30 Aug 2023 18:19:46 -0600 Subject: [PATCH] HOUSEKEEPING: vdk_aecrypt package installs Blake was being stupid so I copied the contents of this package directly into the source of JR, but really this should be its own package. So now doing that refactoring. --- libs/vdk_aecrypt/src/vdk_aecrypt.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/libs/vdk_aecrypt/src/vdk_aecrypt.ts b/libs/vdk_aecrypt/src/vdk_aecrypt.ts index 7fbfe2e..2d0adf6 100644 --- a/libs/vdk_aecrypt/src/vdk_aecrypt.ts +++ b/libs/vdk_aecrypt/src/vdk_aecrypt.ts @@ -11,12 +11,14 @@ */ -import * as blakejs from './jex_include/local-blakejs-1.2.1/dist/index.js'; +// @ts-ignore FIXME yes blake2b sucks +import * as blake2b from './jex_include/local-blakejs-1.2.1/dist/blake2b.js'; import * as vdk_binary from './jex_include/local-vdk_binary-0.1.0/dist/vdk_binary.js'; export { hash_and_salt_msg, + hash, salt_msg, btc_varuint_encode } @@ -103,12 +105,27 @@ hash_and_salt_msg : Uint8Array { let message_bytes : Uint8Array = vdk_binary.encode_utf8(message_str); - return blakejs.blake2b(salt_msg(message_bytes), // bytes to hash - undefined, // key (optional) - 32); // resulting byte length + let salted_bytes : Uint8Array = salt_msg(message_bytes); + return hash(salted_bytes); } + +/** + * Blake2 hash of data + */ +function +hash + (data_bytes : Uint8Array) + : Uint8Array +{ + return blake2b.blake2b(data_bytes, // bytes to hash + undefined, // key (optional) + 32); // resulting byte length +} + + + /** * salt the message *