feat: add deriveBlakeChildKeyInt

This commit is contained in:
Derrick Hammer 2023-09-08 05:38:22 -04:00
parent 68cb638086
commit 282c431021
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 0 deletions

View File

@ -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)));
}