libp2p / js-peer-id

peer-id implementation in JavaScript. Deprecated; use https://github.com/libp2p/js-libp2p-peer-id instead.
https://github.com/libp2p/js-libp2p-peer-id
MIT License
80 stars 44 forks source link

Instantiating CreateLibp2p function with Proper Assessment to PeerIds #226

Open peterkim2014 opened 5 months ago

peterkim2014 commented 5 months ago

Current Method

  1. Made a peerId using the createEd25519PeerId. const peerId = await createEd25519PeerId({ privateKey: privateKey });

  2. Store into json, which eliminates the formats of ed25519, converts the values into string.

  3. Retrieving the data of peerId to instantiate the CreateLibp2p.


Process

Error

TypeError: Cannot read properties of undefined (reading 'length')


The pasted details below is the data structure of the peer.meta that I'm using, in order to retrieve the peerId.

CodeBase const peerIdForm = await createFromPrivKey(peer.meta); "meta": { "id": { "code": 0, "size": 36, "digest": "0x080112202a43350be8249d8a381f85da2e7b0ca661ceb2b3d727ad967cd4903ac3fa5341", "bytes": "0x0024080112202a43350be8249d8a381f85da2e7b0ca661ceb2b3d727ad967cd4903ac3fa5341" }, "key": "0x080112401330d9b33b2f6de93088ab2424a36394fa8dc67c706b2f1cac5df80eb66c2a6b2a43350be8249d8a381f85da2e7b0ca661ceb2b3d727ad967cd4903ac3fa5341", "public": "0x080112202a43350be8249d8a381f85da2e7b0ca661ceb2b3d727ad967cd4903ac3fa5341", "CID": { "/": "bafzaajaiaejcaksdguf6qje5ri4b7bo2fz5qzjtbz2zlhvzhvwlhzveqhlb7uu2b" }, "type": "Ed25519" },

If I'm missing any details that could help figure out this issue, please let me know. Thank you.