use of org.whispersystems.libsignal.IdentityKeyPair in project Signal-Android by WhisperSystems.
the class ProfileUtil method getSelfPaymentsAddressProtobuf.
@Nullable
private static SignalServiceProtos.PaymentAddress getSelfPaymentsAddressProtobuf() {
if (!SignalStore.paymentsValues().mobileCoinPaymentsEnabled()) {
return null;
} else {
IdentityKeyPair identityKeyPair = SignalStore.account().getAciIdentityKey();
MobileCoinPublicAddress publicAddress = ApplicationDependencies.getPayments().getWallet().getMobileCoinPublicAddress();
return MobileCoinPublicAddressProfileUtil.signPaymentsAddress(publicAddress.serialize(), identityKeyPair);
}
}
use of org.whispersystems.libsignal.IdentityKeyPair in project Signal-Android by WhisperSystems.
the class MobileCoinPublicAddressProfileUtilTest method can_not_verify_a_tampered_address.
@Test
public void can_not_verify_a_tampered_address() {
IdentityKeyPair identityKeyPair = IdentityKeyUtil.generateIdentityKeyPair();
byte[] addressBytes = Util.getSecretBytes(100);
SignalServiceProtos.PaymentAddress signedPaymentAddress = MobileCoinPublicAddressProfileUtil.signPaymentsAddress(addressBytes, identityKeyPair);
byte[] address = signedPaymentAddress.getMobileCoinAddress().getAddress().toByteArray();
address[0] = (byte) (address[0] ^ 0x01);
SignalServiceProtos.PaymentAddress tamperedAddress = signedPaymentAddress.toBuilder().setMobileCoinAddress(signedPaymentAddress.getMobileCoinAddress().toBuilder().setAddress(ByteString.copyFrom(address))).build();
assertThatThrownBy(() -> MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(tamperedAddress, identityKeyPair.getPublicKey())).isInstanceOf(PaymentsAddressException.class).hasMessage("Invalid MobileCoin address signature on payments address proto");
}
use of org.whispersystems.libsignal.IdentityKeyPair in project Signal-Android by WhisperSystems.
the class MobileCoinPublicAddressProfileUtilTest method can_not_verify_a_missing_signature.
@Test
public void can_not_verify_a_missing_signature() {
IdentityKeyPair identityKeyPair = IdentityKeyUtil.generateIdentityKeyPair();
byte[] address = Util.getSecretBytes(100);
SignalServiceProtos.PaymentAddress signedPaymentAddress = MobileCoinPublicAddressProfileUtil.signPaymentsAddress(address, identityKeyPair);
SignalServiceProtos.PaymentAddress removedSignature = signedPaymentAddress.toBuilder().setMobileCoinAddress(signedPaymentAddress.getMobileCoinAddress().toBuilder().clearSignature()).build();
assertThatThrownBy(() -> MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(removedSignature, identityKeyPair.getPublicKey())).isInstanceOf(PaymentsAddressException.class).hasMessage("Invalid MobileCoin address signature on payments address proto");
}
use of org.whispersystems.libsignal.IdentityKeyPair in project Signal-Android by WhisperSystems.
the class MobileCoinPublicAddressProfileUtilTest method can_not_verify_an_address_with_the_wrong_key.
@Test
public void can_not_verify_an_address_with_the_wrong_key() {
IdentityKeyPair identityKeyPair = IdentityKeyUtil.generateIdentityKeyPair();
IdentityKey wrongPublicKey = IdentityKeyUtil.generateIdentityKeyPair().getPublicKey();
byte[] address = Util.getSecretBytes(100);
SignalServiceProtos.PaymentAddress signedPaymentAddress = MobileCoinPublicAddressProfileUtil.signPaymentsAddress(address, identityKeyPair);
assertThatThrownBy(() -> MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(signedPaymentAddress, wrongPublicKey)).isInstanceOf(PaymentsAddressException.class).hasMessage("Invalid MobileCoin address signature on payments address proto");
}
use of org.whispersystems.libsignal.IdentityKeyPair in project Signal-Android by WhisperSystems.
the class MobileCoinPublicAddressProfileUtilTest method can_not_verify_a_missing_address.
@Test
public void can_not_verify_a_missing_address() {
IdentityKeyPair identityKeyPair = IdentityKeyUtil.generateIdentityKeyPair();
byte[] address = Util.getSecretBytes(100);
SignalServiceProtos.PaymentAddress signedPaymentAddress = MobileCoinPublicAddressProfileUtil.signPaymentsAddress(address, identityKeyPair);
SignalServiceProtos.PaymentAddress removedAddress = signedPaymentAddress.toBuilder().setMobileCoinAddress(signedPaymentAddress.getMobileCoinAddress().toBuilder().clearAddress()).build();
assertThatThrownBy(() -> MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(removedAddress, identityKeyPair.getPublicKey())).isInstanceOf(PaymentsAddressException.class).hasMessage("Invalid MobileCoin address signature on payments address proto");
}
Aggregations