feat: add deriveChildKey function

This commit is contained in:
Derrick Hammer 2023-06-21 04:32:21 -04:00
parent 0aff93d064
commit d7cdaaf316
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 12 additions and 0 deletions

View File

@ -9,4 +9,5 @@ export * from "./stringifyJSON.js";
export * from "./types.js"; export * from "./types.js";
export * from "./cid.js"; export * from "./cid.js";
export * from "./encoding.js"; export * from "./encoding.js";
export * from "./keys.js";
export { ed25519, sha512 }; export { ed25519, sha512 };

11
src/keys.ts Normal file
View File

@ -0,0 +1,11 @@
import { blake3 } from "@noble/hashes/blake3";
import { concatBytes } from "@noble/hashes/utils";
export function deriveChildKey(
parentKey: Uint8Array,
tweak: string,
): Uint8Array {
const tweakHash = blake3(tweak);
return blake3(concatBytes(parentKey, tweakHash));
}