forked from CODeRUS/libaxolotl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identitykeypair.cpp
34 lines (28 loc) · 948 Bytes
/
identitykeypair.cpp
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
#include "identitykeypair.h"
#include "ecc/curve.h"
#include "state/sessionstate.h"
IdentityKeyPair::IdentityKeyPair()
{
}
IdentityKeyPair::IdentityKeyPair(const IdentityKey &publicKey, const DjbECPrivateKey &privateKey)
{
this->publicKey = publicKey;
this->privateKey = privateKey;
}
IdentityKeyPair::IdentityKeyPair(const QByteArray &serialized)
{
textsecure::IdentityKeyPairStructure structure;
structure.ParseFromArray(serialized.constData(), serialized.size());
::std::string publickey = structure.publickey();
this->publicKey = IdentityKey(QByteArray(publickey.data(), publickey.length()), 0);
::std::string privatekey = structure.privatekey();
this->privateKey = Curve::decodePrivatePoint(QByteArray(privatekey.data(), privatekey.length()));
}
IdentityKey IdentityKeyPair::getPublicKey() const
{
return publicKey;
}
DjbECPrivateKey IdentityKeyPair::getPrivateKey() const
{
return privateKey;
}