File: aliceaxolotlparameters.py

package info (click to toggle)
python-axolotl 0.2.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 592 kB
  • sloc: python: 2,962; makefile: 3
file content (83 lines) | stat: -rw-r--r-- 2,826 bytes parent folder | download | duplicates (3)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -*- coding: utf-8 -*-


class AliceAxolotlParameters:
    def __init__(self, ourIdentityKey, ourBaseKey, theirIdentityKey, theirSignedPreKey,
                 theirRatchetKey, theirOneTimePreKey):
        """
        :type ourBaseKey: ECKeyPair
        :type theirSignedPreKey: ECKeyPair
        :type ourIdentityKey: IdentityKeyPair
        :type theirOneTimePreKey: ECPublicKey
        :type theirRatchetKey: ECKeyPair
        :type theirIdentityKey: IdentityKey
        """
        self.ourBaseKey = ourBaseKey
        self.ourIdentityKey = ourIdentityKey
        self.theirSignedPreKey = theirSignedPreKey
        self.theirRatchetKey = theirRatchetKey
        self.theirIdentityKey = theirIdentityKey
        self.theirOneTimePreKey = theirOneTimePreKey

        if ourBaseKey is None or ourIdentityKey is None or theirSignedPreKey is None \
                or theirRatchetKey is None or theirIdentityKey is None or theirSignedPreKey is None:
            raise ValueError("Null value!")

    def getOurIdentityKey(self):
        return self.ourIdentityKey

    def getOurBaseKey(self):
        return self.ourBaseKey

    def getTheirIdentityKey(self):
        return self.theirIdentityKey

    def getTheirSignedPreKey(self):
        return self.theirSignedPreKey

    def getTheirOneTimePreKey(self):
        return self.theirOneTimePreKey

    def getTheirRatchetKey(self):
        return self.theirRatchetKey

    @staticmethod
    def newBuilder():
        return AliceAxolotlParameters.Builder()

    class Builder:
        def __init__(self):
            self.ourIdentityKey = None
            self.ourBaseKey = None
            self.theirIdentityKey = None
            self.theirSignedPreKey = None
            self.theirRatchetKey = None
            self.theirOneTimePreKey = None

        def setOurIdentityKey(self, ourIdentityKey):
            self.ourIdentityKey = ourIdentityKey
            return self

        def setOurBaseKey(self, ourBaseKey):
            self.ourBaseKey = ourBaseKey
            return self

        def setTheirRatchetKey(self, theirRatchetKey):
            self.theirRatchetKey = theirRatchetKey
            return self

        def setTheirIdentityKey(self, theirIdentityKey):
            self.theirIdentityKey = theirIdentityKey
            return self

        def setTheirSignedPreKey(self, theirSignedPreKey):
            self.theirSignedPreKey = theirSignedPreKey
            return self

        def setTheirOneTimePreKey(self, theirOneTimePreKey):
            self.theirOneTimePreKey = theirOneTimePreKey
            return self

        def create(self):
            return AliceAxolotlParameters(self.ourIdentityKey, self.ourBaseKey, self.theirIdentityKey,
                                          self.theirSignedPreKey, self.theirRatchetKey, self.theirOneTimePreKey)