Add additional logging for payment address parsing

This commit is contained in:
AsamK 2022-06-08 15:21:24 +02:00
parent 8236696492
commit 936a68433d
2 changed files with 10 additions and 1 deletions

View 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;
}

View 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;
}