* Revert "Remove ed2curve dependency (#1265)"
This reverts commit 7e9b2770b6.
* Adjust
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { convertPublicKeyToX25519, convertSecretKeyToX25519 } from '@stablelib/ed25519';
|
||||
import ed2curve from 'ed2curve';
|
||||
|
||||
export function convertPublicKeyToCurve25519 (publicKey: Uint8Array): Uint8Array {
|
||||
return convertPublicKeyToX25519(publicKey);
|
||||
}
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
export function convertSecretKeyToCurve25519 (secretKey: Uint8Array): Uint8Array {
|
||||
return convertSecretKeyToX25519(secretKey);
|
||||
return ed2curve.convertSecretKey(secretKey);
|
||||
}
|
||||
|
||||
export function convertPublicKeyToCurve25519 (publicKey: Uint8Array): Uint8Array {
|
||||
return assertReturn(ed2curve.convertPublicKey(publicKey), 'Unable to convert publicKey to ed25519');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
import { blake2AsU8a } from '../../blake2/asU8a';
|
||||
import { ed25519PairFromSeed } from './fromSeed';
|
||||
|
||||
@@ -22,6 +24,8 @@ import { ed25519PairFromSeed } from './fromSeed';
|
||||
*/
|
||||
export function ed25519PairFromString (value: string): Keypair {
|
||||
return ed25519PairFromSeed(
|
||||
blake2AsU8a(value)
|
||||
blake2AsU8a(
|
||||
stringToU8a(value)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user