]> nmode's Git Repositories - signal-cli/commitdiff
Add additional logging for payment address parsing
authorAsamK <asamk@gmx.de>
Wed, 8 Jun 2022 13:21:24 +0000 (15:21 +0200)
committerAsamK <asamk@gmx.de>
Wed, 8 Jun 2022 13:21:24 +0000 (15:21 +0200)
lib/src/main/java/org/asamk/signal/manager/util/PaymentUtils.java
lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java

index 6c34d9c9d0fdc012d4741967e589de40f4873870..1471d8fed0bd153a1c3c8e87105c1cd3f2d9d09e 100644 (file)
@@ -6,10 +6,14 @@ import org.signal.libsignal.protocol.IdentityKey;
 import org.signal.libsignal.protocol.IdentityKeyPair;
 import org.signal.libsignal.protocol.ecc.ECPrivateKey;
 import org.signal.libsignal.protocol.ecc.ECPublicKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
 
 public class PaymentUtils {
 
+    private final static Logger logger = LoggerFactory.getLogger(PaymentUtils.class);
+
     private PaymentUtils() {
     }
 
@@ -37,6 +41,7 @@ public class PaymentUtils {
             SignalServiceProtos.PaymentAddress paymentAddress, ECPublicKey publicKey
     ) {
         if (!paymentAddress.hasMobileCoinAddress()) {
+            logger.debug("Got payment address without mobile coin address, ignoring.");
             return null;
         }
 
@@ -44,6 +49,7 @@ public class PaymentUtils {
         byte[] signature = paymentAddress.getMobileCoinAddress().getSignature().toByteArray();
 
         if (signature.length != 64 || !publicKey.verifySignature(bytes, signature)) {
+            logger.debug("Got mobile coin address with invalid signature, ignoring.");
             return null;
         }
 
index e202f70af56f227d6f7b6bf61ce93af5cb14238b..5d61cab3b2f0ccd81e7b68863967e33e63e6c684 100644 (file)
@@ -30,7 +30,8 @@ public class ProfileUtils {
         IdentityKey identityKey = null;
         try {
             identityKey = new IdentityKey(Base64.getDecoder().decode(encryptedProfile.getIdentityKey()), 0);
-        } catch (InvalidKeyException ignored) {
+        } catch (InvalidKeyException e) {
+            logger.debug("Failed to decode identity key in profile, can't verify payment address", e);
         }
 
         try {
@@ -112,6 +113,7 @@ public class ProfileUtils {
         try {
             decrypted = profileCipher.decryptWithLength(encryptedPaymentAddress);
         } catch (IOException e) {
+            logger.debug("Failed to decrypt payment address", e);
             return null;
         }
 
@@ -119,6 +121,7 @@ public class ProfileUtils {
         try {
             paymentAddress = SignalServiceProtos.PaymentAddress.parseFrom(decrypted);
         } catch (InvalidProtocolBufferException e) {
+            logger.debug("Failed to parse payment address", e);
             return null;
         }