diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 13:48:49 -0800 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 14:09:01 -0800 |
commit | 6445ea5f13850f42c3952bd06a2369317683ed88 (patch) | |
tree | f2bb37c8cf4710ff6a6a37a3e7e702c5a21ca504 /src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java | |
parent | a4d8f7f6a4c4e9e89db35f299e558dceee2362a1 (diff) |
Break project up into Java and Android build/test.
Diffstat (limited to 'src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java')
-rw-r--r-- | src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java b/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java deleted file mode 100644 index 0ea905f4..00000000 --- a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.whispersystems.libaxolotl.state; - -import com.google.protobuf.ByteString; - -import org.whispersystems.libaxolotl.InvalidKeyException; -import org.whispersystems.libaxolotl.ecc.Curve; -import org.whispersystems.libaxolotl.ecc.ECKeyPair; -import org.whispersystems.libaxolotl.ecc.ECPrivateKey; -import org.whispersystems.libaxolotl.ecc.ECPublicKey; - -import java.io.IOException; - -import static org.whispersystems.libaxolotl.state.StorageProtos.PreKeyRecordStructure; - -public class PreKeyRecord { - - private PreKeyRecordStructure structure; - - public PreKeyRecord(int id, ECKeyPair keyPair) { - this.structure = PreKeyRecordStructure.newBuilder() - .setId(id) - .setPublicKey(ByteString.copyFrom(keyPair.getPublicKey() - .serialize())) - .setPrivateKey(ByteString.copyFrom(keyPair.getPrivateKey() - .serialize())) - .build(); - } - - public PreKeyRecord(byte[] serialized) throws IOException { - this.structure = PreKeyRecordStructure.parseFrom(serialized); - } - - public int getId() { - return this.structure.getId(); - } - - public ECKeyPair getKeyPair() { - try { - ECPublicKey publicKey = Curve.decodePoint(this.structure.getPublicKey().toByteArray(), 0); - ECPrivateKey privateKey = Curve.decodePrivatePoint(this.structure.getPrivateKey().toByteArray()); - - return new ECKeyPair(publicKey, privateKey); - } catch (InvalidKeyException e) { - throw new AssertionError(e); - } - } - - public byte[] serialize() { - return this.structure.toByteArray(); - } -} |