-
Notifications
You must be signed in to change notification settings - Fork 4
/
identitykey.cpp
46 lines (38 loc) · 933 Bytes
/
identitykey.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
35
36
37
38
39
40
41
42
43
44
45
46
#include "identitykey.h"
#include "ecc/curve.h"
IdentityKey::IdentityKey()
{
}
IdentityKey::IdentityKey(const DjbECPublicKey &publicKey, int offset)
{
if (offset == 0) {
this->publicKey = publicKey;
}
else {
this->publicKey = Curve::decodePoint(publicKey.serialize(), offset);
}
}
IdentityKey::IdentityKey(const QByteArray &publicKey, int offset)
{
this->publicKey = Curve::decodePoint(publicKey, offset);
}
DjbECPublicKey IdentityKey::getPublicKey() const
{
return publicKey;
}
QByteArray IdentityKey::serialize() const
{
return publicKey.serialize();
}
QByteArray IdentityKey::getFingerprint() const
{
return publicKey.serialize().toHex();
}
QByteArray IdentityKey::hashCode() const
{
return publicKey.serialize().mid(0, 4); // TODO
}
bool IdentityKey::operator ==(const IdentityKey &otherKey)
{
return publicKey.serialize() == otherKey.getPublicKey().serialize();
}