github.com/status-im/status-go@v1.1.0/protocol/datasync/peer/utils.go (about) 1 package peer 2 3 import ( 4 "crypto/ecdsa" 5 6 "github.com/status-im/mvds/state" 7 8 "github.com/status-im/status-go/eth-node/crypto" 9 ) 10 11 func PublicKeyToPeerID(k ecdsa.PublicKey) state.PeerID { 12 var p state.PeerID 13 copy(p[:], crypto.FromECDSAPub(&k)) 14 return p 15 } 16 17 func IDToPublicKey(p state.PeerID) (*ecdsa.PublicKey, error) { 18 return crypto.UnmarshalPubkey(p[:]) 19 }