-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
49 lines (39 loc) · 1.09 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"github.com/nmohnblatt/contact_discovery2/crypto"
"github.com/nmohnblatt/contact_discovery2/crypto/blindtbls"
"go.dedis.ch/kyber/v3/pairing"
"go.dedis.ch/kyber/v3/share"
)
type server struct {
ID int
keys crypto.MasterSecretShares
Comms chan keysInTransport
}
func (s server) sign(suite pairing.Suite, userPublic keysInTransport) ([]byte, []byte, error) {
buf1, err := blindtbls.Sign(suite, suite.G1(), s.keys[0], userPublic.Left)
if err != nil {
return nil, nil, err
}
buf2, _ := blindtbls.Sign(suite, suite.G2(), s.keys[1], userPublic.Right)
if err != nil {
return nil, nil, err
}
return buf1, buf2, nil
}
func (s server) runServer(parameters publicParameters) {
for {
toSign := <-s.Comms
left, right, _ := s.sign(parameters.Suite, toSign)
outputMessage := keysInTransport{left, right, nil}
s.Comms <- outputMessage
}
}
// NewServer creates an instance of a server
func newServer(id int, key1, key2 *share.PriShare, comms chan keysInTransport) *server {
return &server{
ID: id,
keys: [2]*share.PriShare{key1, key2},
Comms: comms,
}
}