From 282c43102196426834f81253511ae7083756380f Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 8 Sep 2023 05:38:22 -0400 Subject: [PATCH] feat: add deriveBlakeChildKeyInt --- src/keys.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/keys.ts b/src/keys.ts index e5f30ad..5650db7 100644 --- a/src/keys.ts +++ b/src/keys.ts @@ -2,6 +2,7 @@ import { blake3 } from "@noble/hashes/blake3"; import { concatBytes } from "@noble/hashes/utils"; import { hkdf } from "@noble/hashes/hkdf"; import { sha256 } from "@noble/hashes/sha256"; +import { encodeEndian } from "@lumeweb/libs5"; export function deriveChildKey( parentKey: Uint8Array, @@ -18,3 +19,10 @@ export function deriveBlakeChildKey( return blake3(concatBytes(parentKey, tweakHash)); } + +export function deriveBlakeChildKeyInt( + parentKey: Uint8Array, + tweak: number, +): Uint8Array { + return blake3(concatBytes(parentKey, encodeEndian(tweak, 32))); +}