aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-19 14:35:20 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitb69f7b9987d0e373c34a1bf7bfd7fa93e1dc5b88 (patch)
treeea243290f14acceb9cd106c0ddda14900ab50f15 /dex
parent1a26392d20f4d3d3d7c7af6b6f04d8d7760b8036 (diff)
downloaddexon-b69f7b9987d0e373c34a1bf7bfd7fa93e1dc5b88.tar.gz
dexon-b69f7b9987d0e373c34a1bf7bfd7fa93e1dc5b88.tar.zst
dexon-b69f7b9987d0e373c34a1bf7bfd7fa93e1dc5b88.zip
dex: fix public key parsing due to changes in consensus core
Diffstat (limited to 'dex')
-rw-r--r--dex/governance.go20
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