any-sync/util/crypto/peer.go
2023-03-28 21:29:12 +02:00

19 lines
384 B
Go

package crypto
import (
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
)
func IdFromSigningPubKey(pubKey PubKey) (peer.ID, error) {
rawSigning, err := pubKey.Raw()
if err != nil {
return "", err
}
libp2pKey, err := crypto.UnmarshalEd25519PublicKey(rawSigning)
if err != nil {
return "", err
}
return peer.IDFromPublicKey(libp2pKey)
}