-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpre_key_bundle.go
43 lines (37 loc) · 1.05 KB
/
pre_key_bundle.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
package x3dh
// the PreKeyBundle holds information
// about the person you would like to
// start chatting with. You need to implement
// this interface your self.
type PreKeyBundle interface {
IdentityKey() PublicKey
SignedPreKey() PublicKey
OneTimePreKey() *PublicKey
// this is actually the method in which
// you need to check if the signature
// of the PreKey is valid. YOU HAVE
// TO DO this your self. In case this
// method returns false the process of
// creating an shared secret will be aborted.
ValidSignature() (bool, error)
}
// ONLY FOR TESTING
type TestPreKeyBundle struct {
identityKey PublicKey
signedPreKey PublicKey
preKeySignature []byte
oneTimePreKey *PublicKey
validSignature func() (bool, error)
}
func (b TestPreKeyBundle) IdentityKey() PublicKey {
return b.identityKey
}
func (b TestPreKeyBundle) SignedPreKey() PublicKey {
return b.signedPreKey
}
func (b TestPreKeyBundle) OneTimePreKey() *PublicKey {
return b.oneTimePreKey
}
func (b TestPreKeyBundle) ValidSignature() (bool, error) {
return b.validSignature()
}