mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 12:32:28 +00:00
15 lines
385 B
TypeScript
15 lines
385 B
TypeScript
import {keys} from 'libp2p-crypto';
|
|
import {KeyPair} from "../src/@types/libp2p";
|
|
import PeerId from "peer-id";
|
|
|
|
export async function generateEd25519Keys() {
|
|
return await keys.generateKeyPair('ed25519');
|
|
}
|
|
|
|
export function getKeyPairFromPeerId(peerId: PeerId): KeyPair {
|
|
return {
|
|
privateKey: peerId.privKey.marshal().slice(0, 32),
|
|
publicKey: peerId.marshalPubKey(),
|
|
}
|
|
}
|