Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiating CreateLibp2p function with Proper Assessment to PeerIds #226

Open
peterkim2014 opened this issue Feb 13, 2024 · 0 comments
Open

Comments

@peterkim2014
Copy link

peterkim2014 commented Feb 13, 2024

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

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant