diff --git a/src/lib/crypto_utils.ts b/src/lib/crypto_utils.ts index 330c30f..2611c9c 100644 --- a/src/lib/crypto_utils.ts +++ b/src/lib/crypto_utils.ts @@ -1,6 +1,6 @@ import { box, randomBytes } from 'tweetnacl'; import { createHmac, createCipheriv, createDecipheriv } from 'crypto'; -import { createHash as createBlake2Hash } from 'blake2'; +import { blake2b } from '@noble/hashes/blake2b'; import { x25519 } from '@noble/curves/ed25519'; // import { encodeBase64, decodeBase64 } from 'tweetnacl-util'; // import { BLAKE2b } from '@stablelib/blake2b'; @@ -40,9 +40,7 @@ function deriveKey(sharedSecret: Uint8Array, salt: Uint8Array): Uint8Array { * @returns A 32-byte hash */ export function calculateHash(data: Uint8Array): Uint8Array { - const hash = createBlake2Hash('blake2b', { digestLength: 32 }); // Use BLAKE2b with 32-byte digest - hash.update(data); - return new Uint8Array(hash.digest()); + return blake2b(data, { dkLen: 32 }); // 32 bytes = 256 bits } /** diff --git a/src/types/blake2.d.ts b/src/types/blake2.d.ts deleted file mode 100644 index b554c12..0000000 --- a/src/types/blake2.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare module 'blake2' { - interface HashOptions { - digestLength?: number; - } - - interface Hash { - update(data: Buffer | Uint8Array): void; - digest(): Buffer; - } - - export function createHash(algorithm: string, options?: HashOptions): Hash; -} \ No newline at end of file