1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00
any-sync/util/crypto/peer.go
2023-03-28 21:29:12 +02:00

18 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)
}