mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-10 17:12:16 +02:00
Implement IdentityKeyPair Deserialize
This commit is contained in:
@@ -96,6 +96,7 @@ public final class Native {
|
||||
|
||||
public static native byte[] HKDF_DeriveSecrets(int version, byte[] inputKeyMaterial, byte[] salt, byte[] info, int outputLength);
|
||||
|
||||
public static native long[] IdentityKeyPair_Deserialize(byte[] data);
|
||||
public static native byte[] IdentityKeyPair_Serialize(long publicKeyHandle, long privateKeyHandle);
|
||||
|
||||
public static native void NumericFingerprintGenerator_Destroy(long handle);
|
||||
|
||||
@@ -32,6 +32,10 @@ public class IdentityKey {
|
||||
this.publicKey = Curve.decodePoint(bytes, 0);
|
||||
}
|
||||
|
||||
public IdentityKey(long nativeHandle) {
|
||||
this.publicKey = new ECPublicKey(nativeHandle);
|
||||
}
|
||||
|
||||
public ECPublicKey getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,15 @@ public class IdentityKeyPair {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public IdentityKeyPair(byte[] serialized) {
|
||||
long[] tuple = Native.IdentityKeyPair_Deserialize(serialized);
|
||||
long publicKeyHandle = tuple[0];
|
||||
long privateKeyHandle = tuple[1];
|
||||
|
||||
this.publicKey = new IdentityKey(publicKeyHandle);
|
||||
this.privateKey = new ECPrivateKey(privateKeyHandle);
|
||||
}
|
||||
|
||||
public IdentityKey getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
@@ -31,7 +40,7 @@ public class IdentityKeyPair {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
byte[] serialize() {
|
||||
public byte[] serialize() {
|
||||
return Native.IdentityKeyPair_Serialize(this.publicKey.nativeHandle(), this.privateKey.nativeHandle());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user