Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed Mar 29, 2021
1 parent 8a3985b commit 8a4d4dc
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,13 @@ public String decryptFilePairwise(String senderId, String filePath, String ciphe
public JSONObject getEncryptingSenderKey(String userId, String stickId, Boolean isSticky) {
try {
SenderKeyStore senderKeyStore = new MySenderKeyStore(context);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(userId, isSticky ? 1 : 0);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(userId, 0);
SenderKeyName senderKeyName = new SenderKeyName(stickId, signalProtocolAddress);
GroupSessionBuilder groupSessionBuilder = new GroupSessionBuilder(senderKeyStore);
SenderKeyDistributionMessage senderKeyDistributionMessage = groupSessionBuilder.create(senderKeyName);
DatabaseFactory.getStickyKeyDatabase(context).insertStickyKey(stickId, Base64.encodeBytes(senderKeyDistributionMessage.serialize()));
SenderKeyState senderKeyState = senderKeyStore.loadSenderKey(senderKeyName).getSenderKeyState();
String cipher = encryptTextPairwise(userId, isSticky ? 1 : 0, Base64.encodeBytes(senderKeyState.getSigningKeyPrivate().serialize()));
String cipher = encryptTextPairwise(userId, 0, Base64.encodeBytes(senderKeyState.getSigningKeyPrivate().serialize()));
JSONObject map = new JSONObject();
map.put("id", senderKeyState.getKeyId());
map.put("chainKey", Base64.encodeBytes(senderKeyState.getSenderChainKey().getSeed()));
Expand All @@ -544,7 +544,7 @@ public String getSenderKey(String senderId, String targetId, String stickId, Boo
GroupSessionBuilder groupSessionBuilder = new GroupSessionBuilder(senderKeyStore);
senderKeyDistributionMessage = groupSessionBuilder.create(senderKeyName);
}
return encryptTextPairwise(targetId, isSticky ? 1 : 0, Base64.encodeBytes(senderKeyDistributionMessage.serialize()));
return encryptTextPairwise(targetId, 0, Base64.encodeBytes(senderKeyDistributionMessage.serialize()));
}

public String decryptStickyKey(String senderId, String cipher, int identityKeyId) {
Expand Down Expand Up @@ -617,7 +617,7 @@ public int getChainStep(String userId, String stickId) {
public String encryptText(String userId, String stickId, String text, Boolean isSticky) {
try {
SenderKeyStore senderKeyStore = new MySenderKeyStore(context);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(userId, isSticky ? 1 : 0);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(userId, 0);
SenderKeyName senderKeyName = new SenderKeyName(stickId, signalProtocolAddress);
GroupCipher groupCipher = new GroupCipher(senderKeyStore, senderKeyName);
byte[] cipherText;
Expand All @@ -632,7 +632,7 @@ public String encryptText(String userId, String stickId, String text, Boolean is

public Boolean sessionExists(String senderId, String stickId, Boolean isSticky) {
SenderKeyStore mySenderKeyStore = new MySenderKeyStore(context);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, isSticky ? 1 : 0);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, 0);
SenderKeyName senderKeyName = new SenderKeyName(stickId, signalProtocolAddress);
SenderKeyRecord record = mySenderKeyStore.loadSenderKey(senderKeyName);
return !record.isEmpty();
Expand All @@ -650,7 +650,7 @@ public void initSession(String senderId, String stickId, String cipherSenderKey,
try {
if (cipherSenderKey != null) {
SenderKeyStore senderKeyStore = new MySenderKeyStore(context);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, isSticky ? 1 : 0);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, 0);
SenderKeyName senderKeyName = new SenderKeyName(stickId, signalProtocolAddress);
GroupSessionBuilder groupSessionBuilder = new GroupSessionBuilder(senderKeyStore);
String senderKey = decryptStickyKey(senderId, cipherSenderKey, identityKeyId);
Expand All @@ -670,7 +670,7 @@ public String decryptText(String senderId, String stickId, String cipher, Boolea
try {
Boolean isSelf = senderId.equals(PreferenceManager.getDefaultSharedPreferences(context).getString("userId", ""));
SenderKeyStore mySenderKeyStore = new MySenderKeyStore(context);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, isSticky ? 1 : 0);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(senderId, 0);
SenderKeyName senderKeyName = new SenderKeyName(stickId, signalProtocolAddress);
GroupCipher groupCipher = new GroupCipher(mySenderKeyStore, senderKeyName);
byte[] decryptedCipher;
Expand Down

0 comments on commit 8a4d4dc

Please sign in to comment.