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() {
}
SignalServiceProtos.PaymentAddress paymentAddress, ECPublicKey publicKey
) {
if (!paymentAddress.hasMobileCoinAddress()) {
+ logger.debug("Got payment address without mobile coin address, ignoring.");
return null;
}
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;
}
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 {
try {
decrypted = profileCipher.decryptWithLength(encryptedPaymentAddress);
} catch (IOException e) {
+ logger.debug("Failed to decrypt payment address", e);
return null;
}
try {
paymentAddress = SignalServiceProtos.PaymentAddress.parseFrom(decrypted);
} catch (InvalidProtocolBufferException e) {
+ logger.debug("Failed to parse payment address", e);
return null;
}