From 7fefaf0818417f1cc4ae0c9f360e5b08734d68f3 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 20 Aug 2023 02:35:17 -0400 Subject: [PATCH] feat: change deriveChildKey to hkdf sha256 and create deriveBlakeChildKey that hashes based on the initial blake3 route used by s5 --- src/keys.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/keys.ts b/src/keys.ts index 83e3e25..e5f30ad 100644 --- a/src/keys.ts +++ b/src/keys.ts @@ -1,9 +1,18 @@ import { blake3 } from "@noble/hashes/blake3"; import { concatBytes } from "@noble/hashes/utils"; +import { hkdf } from "@noble/hashes/hkdf"; +import { sha256 } from "@noble/hashes/sha256"; export function deriveChildKey( parentKey: Uint8Array, tweak: string, +): Uint8Array { + return hkdf(sha256, parentKey, undefined, tweak, 32); +} + +export function deriveBlakeChildKey( + parentKey: Uint8Array, + tweak: string, ): Uint8Array { const tweakHash = blake3(tweak);