js-peer-id
js-peer-id copied to clipboard
Instantiating CreateLibp2p function with Proper Assessment to PeerIds
Current Method
-
Made a peerId using the createEd25519PeerId. const peerId = await createEd25519PeerId({ privateKey: privateKey });
-
Store into json, which eliminates the formats of ed25519, converts the values into string.
-
Retrieving the data of peerId to instantiate the CreateLibp2p.
Process
- When I store the data as hex values, because Uint8Array doesn't store the format, only the values, I'm trying to revert the hex values into a Uint8Array to extract the same peerId using the public and private key.
Error
- CreateLibp2p doesn't instantiate the node. Instead, I'm given these error messages: if (publicKey.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) { ^
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.
- Before inputting the meta into createFromPrivKey function, I'm converting the hex values into Uint8Array
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.