diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-19 14:35:20 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:23:39 +0800 |
commit | 9ec8fa02e86e992f8dc6a1f230b2e406178f24de (patch) | |
tree | 6de6de362852ddb41ad4fd9cb5ae5651dfbbb502 /dex | |
parent | 7d53965dce0013f8c75a3ae556f57b8a22a484e6 (diff) | |
download | go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar.gz go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar.bz2 go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar.lz go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar.xz go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.tar.zst go-tangerine-9ec8fa02e86e992f8dc6a1f230b2e406178f24de.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 |