Created
March 12, 2025 12:28
-
-
Save alanshaw/a0540b3e956a3a50cdf4d48829bef285 to your computer and use it in GitHub Desktop.
Ucanto private key to libp2p Peer ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/libp2p/go-libp2p/core/crypto" | |
"github.com/libp2p/go-libp2p/core/peer" | |
ed25519 "github.com/storacha/go-ucanto/principal/ed25519/signer" | |
) | |
var priv = "" | |
func main() { | |
id, _ := ed25519.Parse(priv) | |
priv, _ := crypto.UnmarshalEd25519PrivateKey(id.Raw()) | |
peerID, _ := peer.IDFromPrivateKey(priv) | |
fmt.Println(peerID.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment