UNPKG

733 BJavaScriptView Raw
1import { stringToU8a } from '@polkadot/util';
2import { blake2AsU8a } from '../../blake2/asU8a.js';
3import { ed25519PairFromSeed } from './fromSeed.js';
4/**
5 * @name ed25519PairFromString
6 * @summary Creates a new public/secret keypair from a string.
7 * @description
8 * Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import { ed25519PairFromString } from '@polkadot/util-crypto';
14 *
15 * ed25519PairFromString('test'); // => { secretKey: [...], publicKey: [...] }
16 * ```
17 */
18export function ed25519PairFromString(value) {
19 return ed25519PairFromSeed(blake2AsU8a(stringToU8a(value)));
20}