diff options
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/crypto/dkg/dkg.go | 27 |
1 files changed, 27 insertions, 0 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 f6b3e0e1b..425d96b95 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 @@ -131,6 +131,33 @@ func (prvs *PrivateKeyShares) Equal(other *PrivateKeyShares) bool { return true } +// EncodeRLP implements rlp.Encoder +func (prvs *PrivateKeyShares) EncodeRLP(w io.Writer) error { + mpks := make([][]byte, len(prvs.masterPrivateKey)) + for i, m := range prvs.masterPrivateKey { + mpks[i] = m.GetLittleEndian() + } + return rlp.Encode(w, mpks) +} + +// DecodeRLP implements rlp.Decoder +func (prvs *PrivateKeyShares) DecodeRLP(s *rlp.Stream) error { + var dec [][]byte + if err := s.Decode(&dec); err != nil { + return err + } + + for _, k := range dec { + var key bls.SecretKey + if err := key.SetLittleEndian(k); err != nil { + return err + } + prvs.masterPrivateKey = append(prvs.masterPrivateKey, key) + } + + return nil +} + // PublicKeyShares represents a public key shares for DKG protocol. type PublicKeyShares struct { shareCaches []PublicKey |