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