-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_profile.go
38 lines (33 loc) · 1003 Bytes
/
client_profile.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
package gotra
import (
"time"
"github.com/coyim/gotrax"
)
func (c *conversation) getKeypair() *gotrax.Keypair {
// TODO: this should be implemented correctly later
if c.longTerm == nil {
c.longTerm = gotrax.GenerateKeypair(c)
}
return c.longTerm
}
func (c *conversation) getClientProfileExpiration() time.Time {
// TODO: obviously implement this correctly
return time.Now().Add(time.Duration(2 * 7 * 24 * time.Hour))
}
func (c *conversation) getValidClientProfile() *gotrax.ClientProfile {
// TODO: implement correctly
if c.currentClientProfile == nil {
kp := c.getKeypair()
cp := &gotrax.ClientProfile{
InstanceTag: c.getInstanceTag(),
PublicKey: kp.Pub,
Versions: c.getVersions(),
Expiration: c.getClientProfileExpiration(),
DsaKey: nil,
TransitionalSignature: nil,
}
cp.Sig = gotrax.CreateEddsaSignature(cp.GenerateSignature(kp))
c.currentClientProfile = cp
}
return c.currentClientProfile
}