15 lines
385 B
TypeScript
Raw Normal View History

2020-04-03 09:24:58 +02:00
import {keys} from 'libp2p-crypto';
import {KeyPair} from "../src/@types/libp2p";
import PeerId from "peer-id";
2019-11-07 10:55:18 +01:00
export async function generateEd25519Keys() {
2020-04-03 09:24:58 +02:00
return await keys.generateKeyPair('ed25519');
2019-11-07 10:55:18 +01:00
}
2019-12-03 13:52:44 +01:00
export function getKeyPairFromPeerId(peerId: PeerId): KeyPair {
return {
privateKey: peerId.privKey.marshal().slice(0, 32),
publicKey: peerId.marshalPubKey(),
}
}