forked from cerc-io/ipld-eth-server
128d20c9bf
* Upgrade geth from 1.8.15 to 1.8.18 * Update vat_tune to use shared repository methods * Query blockchain by block hash instead of block number range * Remove hash validation from repositories * Fix vow flog integration test * Update README Travis build sticker * Update constants formatting per go fmt * Update EthPublicKeyParser.ParsePublicKey to use discv5.PubkeyID method * Address PR comments
22 lines
467 B
Go
22 lines
467 B
Go
package crypto
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
"github.com/ethereum/go-ethereum/p2p/discv5"
|
|
)
|
|
|
|
type PublicKeyParser interface {
|
|
ParsePublicKey(privateKey string) (string, error)
|
|
}
|
|
|
|
type EthPublicKeyParser struct{}
|
|
|
|
func (EthPublicKeyParser) ParsePublicKey(privateKey string) (string, error) {
|
|
np, err := crypto.HexToECDSA(privateKey)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
pubKey := discv5.PubkeyID(&np.PublicKey)
|
|
return pubKey.String(), nil
|
|
}
|