github.com/annchain/OG@v0.0.9/consensus/dkg/dkg_model.go (about) 1 package dkg 2 3 import ( 4 "github.com/annchain/OG/common" 5 "github.com/annchain/OG/common/crypto" 6 "github.com/annchain/OG/common/hexutil" 7 "github.com/annchain/kyber/v3" 8 ) 9 10 type DkgPeer struct { 11 Id int 12 PublicKey crypto.PublicKey `json:"-"` 13 Address common.Address `json:"address"` 14 PublicKeyBytes hexutil.Bytes `json:"public_key"` 15 } 16 17 type PartPub struct { 18 Point kyber.Point 19 Peer DkgPeer 20 } 21 22 type PartSec struct { 23 PartPub 24 Scalar kyber.Scalar 25 PrivateKey crypto.PrivateKey 26 } 27 28 type PartPubs []PartPub 29 30 func (p PartPubs) Points() []kyber.Point { 31 var points []kyber.Point 32 for _, v := range p { 33 points = append(points, v.Point) 34 } 35 return points 36 } 37 38 func (p PartPubs) Peers() []DkgPeer { 39 var peers []DkgPeer 40 for _, v := range p { 41 peers = append(peers, v.Peer) 42 } 43 return peers 44 } 45 46 func (h PartPubs) Len() int { 47 return len(h) 48 } 49 50 // 51 //func (h PartPubs) Less(i, j int) bool { 52 // return h[i].PublicKey.String() < h[j].PublicKey.String() 53 //} 54 // 55 //func (h PartPubs) Swap(i, j int) { 56 // h[i], h[j] = h[j], h[i] 57 //} 58 // 59 //type DkgPeer struct { 60 // MyIndex int 61 // PublicKey ogcrypto.PublicKey `json:"-"` 62 // 63 // Part kyber.Point 64 //}