mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
18 lines
384 B
Go
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)
|
|
}
|