2019-07-26 07:17:29 +00:00
|
|
|
package peer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/crypto"
|
2019-07-26 07:17:29 +00:00
|
|
|
|
|
|
|
"github.com/vacp2p/mvds/state"
|
|
|
|
)
|
|
|
|
|
|
|
|
func PublicKeyToPeerID(k ecdsa.PublicKey) state.PeerID {
|
|
|
|
var p state.PeerID
|
|
|
|
copy(p[:], crypto.FromECDSAPub(&k))
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func PeerIDToPublicKey(p state.PeerID) (*ecdsa.PublicKey, error) {
|
|
|
|
return crypto.UnmarshalPubkey(p[:])
|
|
|
|
}
|