From 60800e155612bea797eed93c67046a23d26054cc Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 24 Nov 2014 12:54:30 -0800 Subject: Break out into separate repo. --- .../protocol/SenderKeyDistributionMessage.java | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java (limited to 'src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java') diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java b/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java new file mode 100644 index 00000000..424dd87c --- /dev/null +++ b/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java @@ -0,0 +1,56 @@ +package org.whispersystems.libaxolotl.protocol; + +import com.google.protobuf.ByteString; + +import org.whispersystems.libaxolotl.ecc.ECPublicKey; +import org.whispersystems.libaxolotl.util.ByteUtil; + +public class SenderKeyDistributionMessage implements CiphertextMessage { + + private final int id; + private final int iteration; + private final byte[] chainKey; + private final ECPublicKey signatureKey; + private final byte[] serialized; + + public SenderKeyDistributionMessage(int id, int iteration, byte[] chainKey, ECPublicKey signatureKey) { + byte[] version = {ByteUtil.intsToByteHighAndLow(CURRENT_VERSION, CURRENT_VERSION)}; + + this.id = id; + this.iteration = iteration; + this.chainKey = chainKey; + this.signatureKey = signatureKey; + this.serialized = WhisperProtos.SenderKeyDistributionMessage.newBuilder() + .setId(id) + .setIteration(iteration) + .setChainKey(ByteString.copyFrom(chainKey)) + .setSigningKey(ByteString.copyFrom(signatureKey.serialize())) + .build().toByteArray(); + } + + @Override + public byte[] serialize() { + return serialized; + } + + @Override + public int getType() { + return SENDERKEY_DISTRIBUTION_TYPE; + } + + public int getIteration() { + return iteration; + } + + public byte[] getChainKey() { + return chainKey; + } + + public ECPublicKey getSignatureKey() { + return signatureKey; + } + + public int getId() { + return id; + } +} -- cgit v1.2.3