UNPKG

669 BJavaScriptView Raw
1// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3
4import { u8aToU8a } from '@polkadot/util';
5import { sr25519KeypairFromSeed } from '@polkadot/wasm-crypto';
6import { sr25519PairFromU8a } from "./fromU8a.js";
7
8/**
9 * @name sr25519PairFromSeed
10 * @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
11 */
12export function sr25519PairFromSeed(seed) {
13 const seedU8a = u8aToU8a(seed);
14 if (seedU8a.length !== 32) {
15 throw new Error(`Expected a seed matching 32 bytes, found ${seedU8a.length}`);
16 }
17 return sr25519PairFromU8a(sr25519KeypairFromSeed(seedU8a));
18}
\No newline at end of file