19 lines
693 B
JavaScript
19 lines
693 B
JavaScript
import {createRSAPeerId, createEd25519PeerId, createSecp256k1PeerId, createFromJSON, exportToProtobuf} from "@libp2p/peer-id-factory";
|
|
import {fromString as uint8ArrayFromString, toString as uint8ArrayToString} from "uint8arrays";
|
|
import fs from "fs";
|
|
|
|
async function run() {
|
|
//var id = await createEd25519PeerId({bits: 1024});
|
|
var id = await createRSAPeerId();
|
|
var json = {
|
|
id: id.toString(),
|
|
privKey: uint8ArrayToString(id.privateKey, "base64pad"),
|
|
pubKey: uint8ArrayToString(id.publicKey, "base64pad")
|
|
}
|
|
console.log(json);
|
|
console.log("peerId.json has been saved in the current folder");
|
|
fs.writeFileSync("./peerId.json", JSON.stringify(json, null, 2));
|
|
}
|
|
|
|
run();
|