private PreKeyBundle CreateBobPreKeyBundle(ISignalProtocolStore bobStore) { EcKeyPair bobUnsignedPreKey = Curve.GenerateKeyPair(); int bobUnsignedPreKeyId = new Random().Next((int)Medium.MaxValue); byte[] bobSignature = Curve.CalculateSignature(bobStore.GetIdentityKeyPair().GetPrivateKey(), BobSignedPreKey.GetPublicKey().Serialize()); PreKeyBundle bobPreKeyBundle = new PreKeyBundle(1, 1, (uint)bobUnsignedPreKeyId, bobUnsignedPreKey.GetPublicKey(), BobSignedPreKeyId, BobSignedPreKey.GetPublicKey(), bobSignature, bobStore.GetIdentityKeyPair().GetPublicKey()); bobStore.StoreSignedPreKey(BobSignedPreKeyId, new SignedPreKeyRecord(BobSignedPreKeyId, (ulong)DateTime.UtcNow.Ticks, BobSignedPreKey, bobSignature)); bobStore.StorePreKey((uint)bobUnsignedPreKeyId, new PreKeyRecord((uint)bobUnsignedPreKeyId, bobUnsignedPreKey)); return(bobPreKeyBundle); }
private PreKeyBundle CreateAlicePreKeyBundle(ISignalProtocolStore aliceStore) { EcKeyPair aliceUnsignedPreKey = Curve.GenerateKeyPair(); int aliceUnsignedPreKeyId = new Random().Next((int)Medium.MaxValue); byte[] aliceSignature = Curve.CalculateSignature(aliceStore.GetIdentityKeyPair().GetPrivateKey(), AliceSignedPreKey.GetPublicKey().Serialize()); PreKeyBundle alicePreKeyBundle = new PreKeyBundle(1, 1, (uint)aliceUnsignedPreKeyId, aliceUnsignedPreKey.GetPublicKey(), AliceSignedPreKeyId, AliceSignedPreKey.GetPublicKey(), aliceSignature, aliceStore.GetIdentityKeyPair().GetPublicKey()); aliceStore.StoreSignedPreKey(AliceSignedPreKeyId, new SignedPreKeyRecord(AliceSignedPreKeyId, (ulong)DateTime.UtcNow.Ticks, AliceSignedPreKey, aliceSignature)); aliceStore.StorePreKey((uint)aliceUnsignedPreKeyId, new PreKeyRecord((uint)aliceUnsignedPreKeyId, aliceUnsignedPreKey)); return(alicePreKeyBundle); }