mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 05:52:29 +00:00
14 lines
363 B
TypeScript
14 lines
363 B
TypeScript
import {keys} from 'libp2p-crypto';
|
|
import {KeyPair, PeerId} from "../src/@types/libp2p";
|
|
|
|
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(),
|
|
}
|
|
}
|