diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-06 16:53:15 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 920c88803eaa5e1c67cd4cef752d9d6f11ccbd02 (patch) | |
tree | f654fe7e87154ea8388e3127e7107cf06d9b03c5 /vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg | |
parent | ccb4258f1abdea547e1ae4357c4be14043e315ca (diff) | |
download | go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar.gz go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar.bz2 go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar.lz go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar.xz go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.tar.zst go-tangerine-920c88803eaa5e1c67cd4cef752d9d6f11ccbd02.zip |
vendor: sync to latest core (#225)
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go index e43ebc806..f6b3e0e1b 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go @@ -138,13 +138,6 @@ type PublicKeyShares struct { masterPublicKey []bls.PublicKey } -type rlpPublicKeyShares struct { - ShareCaches [][]byte - ShareCacheIndexK [][]byte - ShareCacheIndexV []uint32 - MasterPublicKey [][]byte -} - // Equal checks equality of two PublicKeyShares instance. func (pubs *PublicKeyShares) Equal(other *PublicKeyShares) bool { // Check shares. @@ -172,53 +165,22 @@ func (pubs *PublicKeyShares) Equal(other *PublicKeyShares) bool { // EncodeRLP implements rlp.Encoder func (pubs *PublicKeyShares) EncodeRLP(w io.Writer) error { - var rps rlpPublicKeyShares - for _, share := range pubs.shareCaches { - rps.ShareCaches = append(rps.ShareCaches, share.Serialize()) + mpks := make([][]byte, len(pubs.masterPublicKey)) + for i, m := range pubs.masterPublicKey { + mpks[i] = m.Serialize() } - - for id, v := range pubs.shareCacheIndex { - rps.ShareCacheIndexK = append( - rps.ShareCacheIndexK, id.GetLittleEndian()) - rps.ShareCacheIndexV = append(rps.ShareCacheIndexV, uint32(v)) - } - - for _, m := range pubs.masterPublicKey { - rps.MasterPublicKey = append(rps.MasterPublicKey, m.Serialize()) - } - - return rlp.Encode(w, rps) + return rlp.Encode(w, mpks) } // DecodeRLP implements rlp.Decoder func (pubs *PublicKeyShares) DecodeRLP(s *rlp.Stream) error { - var dec rlpPublicKeyShares + var dec [][]byte if err := s.Decode(&dec); err != nil { return err } - if len(dec.ShareCacheIndexK) != len(dec.ShareCacheIndexV) { - return fmt.Errorf("invalid shareIndex") - } - ps := NewEmptyPublicKeyShares() - for _, share := range dec.ShareCaches { - var publicKey PublicKey - if err := publicKey.Deserialize(share); err != nil { - return err - } - ps.shareCaches = append(ps.shareCaches, publicKey) - } - - for i, k := range dec.ShareCacheIndexK { - id, err := BytesID(k) - if err != nil { - return err - } - ps.shareCacheIndex[id] = int(dec.ShareCacheIndexV[i]) - } - - for _, k := range dec.MasterPublicKey { + for _, k := range dec { var key bls.PublicKey if err := key.Deserialize(k); err != nil { return err |