UNPKG

523 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { assert, isU8a } from '@polkadot/util';
4import { sr25519PairFromU8a } from "./pair/fromU8a.js";
5import { sr25519KeypairToU8a } from "./pair/toU8a.js";
6export function createDeriveFn(derive) {
7 return (keypair, chainCode) => {
8 assert(isU8a(chainCode) && chainCode.length === 32, 'Invalid chainCode passed to derive');
9 return sr25519PairFromU8a(derive(sr25519KeypairToU8a(keypair), chainCode));
10 };
11}
\No newline at end of file