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