UNPKG

526 BJavaScriptView Raw
1// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3
4import { compactAddLength, isU8a, stringToU8a, u8aConcat } from '@polkadot/util';
5import { blake2AsU8a } from "../blake2/asU8a.js";
6const HDKD = compactAddLength(stringToU8a('Ed25519HDKD'));
7export function ed25519DeriveHard(seed, chainCode) {
8 if (!isU8a(chainCode) || chainCode.length !== 32) {
9 throw new Error('Invalid chainCode passed to derive');
10 }
11 return blake2AsU8a(u8aConcat(HDKD, seed, chainCode));
12}
\No newline at end of file