diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-19 14:35:20 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:50 +0800 |
commit | 7febfae8bba63f6b7e1326b22437dee38989c400 (patch) | |
tree | fc9610537d2f3be3776a1e1c3b5fc4849a8587e4 /dex | |
parent | 17fb63161b6672c0e8101e5fde709b1b7ab2df23 (diff) | |
download | dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar.gz dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar.bz2 dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar.lz dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar.xz dexon-7febfae8bba63f6b7e1326b22437dee38989c400.tar.zst dexon-7febfae8bba63f6b7e1326b22437dee38989c400.zip |
dex: fix public key parsing due to changes in consensus core
Diffstat (limited to 'dex')
-rw-r--r-- | dex/governance.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/dex/governance.go b/dex/governance.go index 9235ffce1..4ec69c2d6 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -3,6 +3,7 @@ package dex import ( "context" "crypto/ecdsa" + "encoding/hex" "encoding/json" "math/big" "time" @@ -18,7 +19,6 @@ import ( "github.com/dexon-foundation/dexon/core/vm" "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/log" - "github.com/dexon-foundation/dexon/p2p/discover" "github.com/dexon-foundation/dexon/params" "github.com/dexon-foundation/dexon/rlp" "github.com/dexon-foundation/dexon/rpc" @@ -164,7 +164,11 @@ func (d *DexconGovernance) NodeSet(round uint64) []coreCrypto.PublicKey { var pks []coreCrypto.PublicKey for _, n := range s.Nodes() { - pks = append(pks, coreEcdsa.NewPublicKeyFromByteSlice(n.PublicKey)) + pk, err := coreEcdsa.NewPublicKeyFromByteSlice(n.PublicKey) + if err != nil { + panic(err) + } + pks = append(pks, pk) } return pks } @@ -306,11 +310,7 @@ func (d *DexconGovernance) NotarySet( r := make(map[string]struct{}, len(notarySet)) for id := range notarySet { if key, exists := d.nodeSetCache.GetPublicKey(id); exists { - uncompressedKey, err := crypto.DecompressPubkey(key.Bytes()) - if err != nil { - log.Error("decompress key fail", "err", err) - } - r[discover.PubkeyID(uncompressedKey).String()] = struct{}{} + r[hex.EncodeToString(key.Bytes()[1:])] = struct{}{} } } return r, nil @@ -325,11 +325,7 @@ func (d *DexconGovernance) DKGSet(round uint64) (map[string]struct{}, error) { r := make(map[string]struct{}, len(dkgSet)) for id := range dkgSet { if key, exists := d.nodeSetCache.GetPublicKey(id); exists { - uncompressedKey, err := crypto.DecompressPubkey(key.Bytes()) - if err != nil { - log.Error("decompress key fail", "err", err) - } - r[discover.PubkeyID(uncompressedKey).String()] = struct{}{} + r[hex.EncodeToString(key.Bytes()[1:])] = struct{}{} } } return r, nil |