Skip to content

Commit

Permalink
Merge pull request #529 from dedis/service_aggregate
Browse files Browse the repository at this point in the history
Service Aggregate calculation
  • Loading branch information
Gilthoniel committed Mar 21, 2019
2 parents 8102cea + 6a4ebac commit 15ad2f8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ func (o *Overlay) TransmitMsg(onetMsg *ProtocolMsg, io MessageProxy) error {
defer func() {
if r := recover(); r != nil {
svc := ServiceFactory.Name(tni.Token().ServiceID)
log.Errorf("Panic in %v %s.Dispatch(): %v", svc, o.server.ServerIdentity, r)
log.Errorf("Panic in call to protocol <%s>.Dispatch() from service <%s> at address %s: %v",
tni.ProtocolName(), svc, o.server.ServerIdentity, r)
}
}()

Expand Down
2 changes: 1 addition & 1 deletion overlay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestOverlayCatastrophicFailure(t *testing.T) {

stderr := log.GetStdErr()
assert.Contains(t, stderr, "Start(): start panic")
assert.Contains(t, stderr, "Dispatch(): dispatch panic")
assert.Contains(t, stderr, "Panic in call to protocol")
assert.Contains(t, stderr, "Dispatch(): root dispatch panic")
}

Expand Down
18 changes: 17 additions & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"go.dedis.ch/kyber/v3"
"go.dedis.ch/onet/v3/log"
"go.dedis.ch/onet/v3/network"
uuid "gopkg.in/satori/go.uuid.v1"
"gopkg.in/satori/go.uuid.v1"
)

// In this file we define the main structures used for a running protocol
Expand Down Expand Up @@ -517,6 +517,22 @@ func (ro *Roster) ServicePublics(name string) []kyber.Point {
return res
}

// ServiceAggregate returns the sum of all public keys of a given service. This
// is often used as the aggregate public key.
// If one or more of the service public keys are not present, it will return an error.
func (ro Roster) ServiceAggregate(name string) (kyber.Point, error) {
for _, si := range ro.List {
if !si.HasServiceKeyPair(name) {
return nil, errors.New("not all nodes have this service keypair")
}
}
aggregate := ro.List[0].ServicePublic(name).Clone().Null()
for _, p := range ro.ServicePublics(name) {
aggregate.Add(aggregate, p)
}
return aggregate, nil
}

// GenerateBigNaryTree creates a tree where each node has N children.
// It will make a tree with exactly 'nodes' elements, regardless of the
// size of the Roster. If 'nodes' is bigger than the number of elements
Expand Down
12 changes: 12 additions & 0 deletions treenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,18 @@ func (n *TreeNodeInstance) Public() kyber.Point {
return n.Host().ServerIdentity.ServicePublic(serviceName)
}

// Aggregate returns the sum of all public key of the roster for this TreeNodeInstance, either the specific
// or the default if one or more of the nodes don't have the service-public key available.
func (n *TreeNodeInstance) Aggregate() kyber.Point {
serviceName := ServiceFactory.Name(n.token.ServiceID)

agg, err := n.Roster().ServiceAggregate(serviceName)
if err != nil {
return n.Roster().Aggregate
}
return agg
}

// Publics makes a list of public keys for the service
// associated with the instance
func (n *TreeNodeInstance) Publics() []kyber.Point {
Expand Down

0 comments on commit 15ad2f8

Please sign in to comment.