Refactor: Rename KeyRingVo to KeyRing

This commit is contained in:
Manfred Karrer 2017-03-27 16:11:08 -05:00
parent 3f53dd3fd8
commit 242f816b4e
50 changed files with 300 additions and 254 deletions

View file

@ -15,12 +15,9 @@
* along with bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bisq.vo.crypto;
package io.bisq.common.crypto;
import io.bisq.common.crypto.Encryption;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.crypto.PGP;
import io.bisq.common.crypto.Sig;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import lombok.Setter;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
@ -35,7 +32,7 @@ import java.security.KeyPair;
@Value
@Slf4j
@Immutable
public class KeyRingVO {
public class KeyRing {
private final KeyPair signatureKeyPair;
private final KeyPair encryptionKeyPair;
private final PubKeyRingVO pubKeyRingVO;
@ -48,7 +45,7 @@ public class KeyRingVO {
private PGPKeyPair pgpKeyPair;
@Inject
public KeyRingVO(KeyStorage keyStorage) {
public KeyRing(KeyStorage keyStorage) {
if (keyStorage.allKeyFilesExist()) {
signatureKeyPair = keyStorage.loadKeyPair(KeyStorage.KeyEntry.MSG_SIGNATURE);
encryptionKeyPair = keyStorage.loadKeyPair(KeyStorage.KeyEntry.MSG_ENCRYPTION);

View file

@ -20,7 +20,6 @@ package io.bisq.common.crypto;
import com.google.inject.Inject;
import io.bisq.common.storage.FileUtil;
import io.bisq.vo.crypto.KeyRingVO;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
@ -147,9 +146,9 @@ public class KeyStorage {
}
}
public void saveKeyRing(KeyRingVO keyRingVO) {
savePrivateKey(keyRingVO.getSignatureKeyPair().getPrivate(), KeyEntry.MSG_SIGNATURE.getFileName());
savePrivateKey(keyRingVO.getEncryptionKeyPair().getPrivate(), KeyEntry.MSG_ENCRYPTION.getFileName());
public void saveKeyRing(KeyRing keyRing) {
savePrivateKey(keyRing.getSignatureKeyPair().getPrivate(), KeyEntry.MSG_SIGNATURE.getFileName());
savePrivateKey(keyRing.getEncryptionKeyPair().getPrivate(), KeyEntry.MSG_ENCRYPTION.getFileName());
}
private void savePrivateKey(PrivateKey privateKey, String name) {

View file

@ -15,12 +15,12 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bisq.vo.crypto;
package io.bisq.common.crypto.vo;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.Encryption;
import io.bisq.common.crypto.PGP;
import io.bisq.common.crypto.Sig;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.openpgp.PGPException;
@ -30,7 +30,6 @@ import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
@ -38,29 +37,28 @@ import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.Arrays;
/**
* Same as KeyRing but with public keys only.
* Used to send public keys over the wire to other peer.
*/
// TODO remove Serializable, apply final and Value , serialVersionUID
@Getter
@EqualsAndHashCode
@Slf4j
// TODO remove Serializable/serialVersionUID after PB refactoring
public final class PubKeyRingVO implements Serializable {
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
@Getter
private final byte[] signaturePubKeyBytes;
@Getter
private final byte[] encryptionPubKeyBytes;
@Getter
private final String pgpPubKeyAsPem;
@Nullable
private PublicKey signaturePubKey;
@Nullable
private PublicKey encryptionPubKey;
@Nullable
// TODO remove Nullable once impl.
private PGPPublicKey pgpPubKey;
public PubKeyRingVO(PublicKey signaturePubKey, PublicKey encryptionPubKey, @Nullable PGPPublicKey pgpPubKey) {
public PubKeyRingVO(@NotNull PublicKey signaturePubKey, @NotNull PublicKey encryptionPubKey, @Nullable PGPPublicKey pgpPubKey) {
this.signaturePubKey = signaturePubKey;
this.encryptionPubKey = encryptionPubKey;
this.pgpPubKey = pgpPubKey;
@ -76,36 +74,72 @@ public final class PubKeyRingVO implements Serializable {
this.signaturePubKeyBytes = signaturePubKeyBytes;
this.encryptionPubKeyBytes = encryptionPubKeyBytes;
this.pgpPubKeyAsPem = pgpPubKeyAsPem;
init();
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
try {
in.defaultReadObject();
init();
} catch (Throwable t) {
log.warn("Cannot be deserialized." + t.getMessage());
}
}
private void init() {
try {
signaturePubKey = KeyFactory.getInstance(Sig.KEY_ALGO, "BC")
.generatePublic(new X509EncodedKeySpec(signaturePubKeyBytes));
encryptionPubKey = KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO, "BC")
.generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes));
@NotNull
public PublicKey getSignaturePubKey() {
if (signaturePubKey == null) {
try {
this.pgpPubKey = io.bisq.common.crypto.PGP.getPubKeyFromPEM(pgpPubKeyAsPem);
} catch (IOException | PGPException e) {
log.error(e.toString());
signaturePubKey = KeyFactory.getInstance(Sig.KEY_ALGO, "BC")
.generatePublic(new X509EncodedKeySpec(getSignaturePubKeyBytes()));
} catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) {
e.printStackTrace();
log.error(e.getMessage());
throw new RuntimeException(e);
}
} catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) {
e.printStackTrace();
log.error(e.getMessage());
}
return signaturePubKey;
}
@NotNull
public PublicKey getEncryptionPubKey() {
if (encryptionPubKey == null) {
try {
encryptionPubKey = KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO, "BC")
.generatePublic(new X509EncodedKeySpec(getEncryptionPubKeyBytes()));
} catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) {
e.printStackTrace();
log.error(e.getMessage());
throw new RuntimeException(e);
}
}
return encryptionPubKey;
}
@Nullable
public PGPPublicKey getPgpPubKey() {
if (pgpPubKey == null) {
try {
pgpPubKey = PGP.getPubKeyFromPEM(getPgpPubKeyAsPem());
} catch (InvalidKeySpecException | NoSuchAlgorithmException | IOException | PGPException e) {
e.printStackTrace();
log.error(e.getMessage());
throw new RuntimeException(e);
}
}
return pgpPubKey;
}
// Only use the raw data
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PubKeyRingVO that = (PubKeyRingVO) o;
if (!Arrays.equals(signaturePubKeyBytes, that.signaturePubKeyBytes)) return false;
if (!Arrays.equals(encryptionPubKeyBytes, that.encryptionPubKeyBytes)) return false;
return !(pgpPubKeyAsPem != null ? !pgpPubKeyAsPem.equals(that.pgpPubKeyAsPem) : that.pgpPubKeyAsPem != null);
}
@Override
public int hashCode() {
int result = signaturePubKeyBytes != null ? Arrays.hashCode(signaturePubKeyBytes) : 0;
result = 31 * result + (encryptionPubKeyBytes != null ? Arrays.hashCode(encryptionPubKeyBytes) : 0);
result = 31 * result + (pgpPubKeyAsPem != null ? pgpPubKeyAsPem.hashCode() : 0);
return result;
}
// Hex

View file

@ -1,7 +1,6 @@
package io.bisq.common.crypto;
import io.bisq.common.storage.FileUtil;
import io.bisq.vo.crypto.KeyRingVO;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.After;
import org.junit.Before;
@ -17,7 +16,7 @@ import java.security.cert.CertificateException;
public class EncryptionTest {
private static final Logger log = LoggerFactory.getLogger(EncryptionTest.class);
private KeyRingVO keyRingVO;
private KeyRing keyRing;
private File dir;
@Before
@ -27,7 +26,7 @@ public class EncryptionTest {
dir.delete();
dir.mkdir();
KeyStorage keyStorage = new KeyStorage(dir);
keyRingVO = new KeyRingVO(keyStorage);
keyRing = new KeyRing(keyStorage);
}
@After

View file

@ -1,7 +1,6 @@
package io.bisq.common.crypto;
import io.bisq.common.storage.FileUtil;
import io.bisq.vo.crypto.KeyRingVO;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.After;
import org.junit.Before;
@ -21,7 +20,7 @@ import static org.junit.Assert.assertTrue;
public class SigTest {
private static final Logger log = LoggerFactory.getLogger(SigTest.class);
private KeyRingVO keyRingVO;
private KeyRing keyRing;
private File dir;
@Before
@ -31,7 +30,7 @@ public class SigTest {
dir.delete();
dir.mkdir();
KeyStorage keyStorage = new KeyStorage(dir);
keyRingVO = new KeyRingVO(keyStorage);
keyRing = new KeyRing(keyStorage);
}
@After
@ -48,14 +47,14 @@ public class SigTest {
String msg = String.valueOf(new Random().nextInt());
String sig = null;
try {
sig = Sig.sign(keyRingVO.getSignatureKeyPair().getPrivate(), msg);
sig = Sig.sign(keyRing.getSignatureKeyPair().getPrivate(), msg);
} catch (CryptoException e) {
log.error("sign failed");
e.printStackTrace();
assertTrue(false);
}
try {
assertTrue(Sig.verify(keyRingVO.getSignatureKeyPair().getPublic(), msg, sig));
assertTrue(Sig.verify(keyRing.getSignatureKeyPair().getPublic(), msg, sig));
} catch (CryptoException e) {
log.error("verify failed");
e.printStackTrace();

View file

@ -20,6 +20,7 @@ package io.bisq.core.alert;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.KeyRing;
import io.bisq.core.app.AppOptionKeys;
import io.bisq.core.user.User;
import io.bisq.network.p2p.storage.HashMapChangedListener;
@ -27,7 +28,6 @@ import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.StoragePayload;
import io.bisq.protobuffer.payload.alert.AlertPayload;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
@ -45,7 +45,7 @@ public class AlertManager {
private static final Logger log = LoggerFactory.getLogger(AlertManager.class);
private final P2PService p2PService;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final User user;
private final ObjectProperty<Alert> alertMessageProperty = new SimpleObjectProperty<>();
@ -61,9 +61,9 @@ public class AlertManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public AlertManager(P2PService p2PService, KeyRingVO keyRingVO, User user, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
public AlertManager(P2PService p2PService, KeyRing keyRing, User user, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.user = user;
if (!ignoreDevMsg) {
@ -143,7 +143,7 @@ public class AlertManager {
private void signAndAddSignatureToAlertMessage(Alert alert) {
String alertMessageAsHex = Utils.HEX.encode(alert.getMessage().getBytes());
String signatureAsBase64 = alertSigningKey.signMessage(alertMessageAsHex);
alert.setSigAndPubKey(signatureAsBase64, keyRingVO.getSignatureKeyPair().getPublic());
alert.setSigAndPubKey(signatureAsBase64, keyRing.getSignatureKeyPair().getPublic());
}
private boolean verifySignature(Alert alert) {

View file

@ -20,6 +20,8 @@ package io.bisq.core.alert;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.core.app.AppOptionKeys;
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
import io.bisq.network.p2p.SendMailboxMessageListener;
@ -28,8 +30,6 @@ import io.bisq.protobuffer.message.Message;
import io.bisq.protobuffer.message.alert.PrivateNotificationMessage;
import io.bisq.protobuffer.payload.alert.PrivateNotificationPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
@ -48,7 +48,7 @@ public class PrivateNotificationManager {
private static final Logger log = LoggerFactory.getLogger(PrivateNotificationManager.class);
private final P2PService p2PService;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final ObjectProperty<PrivateNotificationPayload> privateNotificationMessageProperty = new SimpleObjectProperty<>();
// Pub key for developer global privateNotification message
@ -65,9 +65,9 @@ public class PrivateNotificationManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public PrivateNotificationManager(P2PService p2PService, KeyRingVO keyRingVO, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
public PrivateNotificationManager(P2PService p2PService, KeyRing keyRing, @Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
if (!ignoreDevMsg) {
this.p2PService.addDecryptedDirectMessageListener(this::handleMessage);
@ -132,7 +132,7 @@ public class PrivateNotificationManager {
private void signAndAddSignatureToPrivateNotificationMessage(PrivateNotificationPayload privateNotification) {
String privateNotificationMessageAsHex = Utils.HEX.encode(privateNotification.message.getBytes());
String signatureAsBase64 = privateNotificationSigningKey.signMessage(privateNotificationMessageAsHex);
privateNotification.setSigAndPubKey(signatureAsBase64, keyRingVO.getSignatureKeyPair().getPublic());
privateNotification.setSigAndPubKey(signatureAsBase64, keyRing.getSignatureKeyPair().getPublic());
}
private boolean verifySignature(PrivateNotificationPayload privateNotification) {

View file

@ -21,6 +21,7 @@ import com.google.inject.Inject;
import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.core.user.Preferences;
@ -32,7 +33,6 @@ import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.arbitration.Mediator;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;
import org.bitcoinj.core.ECKey;
@ -88,7 +88,7 @@ public class ArbitratorManager {
// Instance fields
///////////////////////////////////////////////////////////////////////////////////////////
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final ArbitratorService arbitratorService;
private final User user;
private final Preferences preferences;
@ -102,8 +102,8 @@ public class ArbitratorManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public ArbitratorManager(KeyRingVO keyRingVO, ArbitratorService arbitratorService, User user, Preferences preferences) {
this.keyRingVO = keyRingVO;
public ArbitratorManager(KeyRing keyRing, ArbitratorService arbitratorService, User user, Preferences preferences) {
this.keyRing = keyRing;
this.arbitratorService = arbitratorService;
this.user = user;
this.preferences = preferences;
@ -256,7 +256,7 @@ public class ArbitratorManager {
// An invited arbitrator will sign at registration his storageSignaturePubKey with that private key and attach the signature and pubKey to his data.
// Other users will check the signature with the list of public keys hardcoded in the app.
public String signStorageSignaturePubKey(ECKey key) {
String keyToSignAsHex = Utils.HEX.encode(keyRingVO.getPubKeyRingVO().getSignaturePubKey().getEncoded());
String keyToSignAsHex = Utils.HEX.encode(keyRing.getPubKeyRingVO().getSignaturePubKey().getEncoded());
return key.signMessage(keyToSignAsHex);
}

View file

@ -22,6 +22,7 @@ import com.google.inject.Inject;
import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.app.Log;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.FaultHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.common.locale.Res;
@ -50,7 +51,6 @@ import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.trade.Contract;
import io.bisq.protobuffer.persistence.arbitration.DisputeList;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.bitcoinj.core.AddressFormatException;
@ -76,7 +76,7 @@ public class DisputeManager {
private final ClosedTradableManager closedTradableManager;
private final OpenOfferManager openOfferManager;
private final P2PService p2PService;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final Storage<DisputeList<Dispute>> disputeStorage;
private final DisputeList<Dispute> disputes;
transient private final ObservableList<Dispute> disputesObservableList;
@ -99,7 +99,7 @@ public class DisputeManager {
TradeManager tradeManager,
ClosedTradableManager closedTradableManager,
OpenOfferManager openOfferManager,
KeyRingVO keyRingVO,
KeyRing keyRing,
@Named(Storage.DIR_KEY) File storageDir) {
this.p2PService = p2PService;
this.tradeWalletService = tradeWalletService;
@ -107,7 +107,7 @@ public class DisputeManager {
this.tradeManager = tradeManager;
this.closedTradableManager = closedTradableManager;
this.openOfferManager = openOfferManager;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
disputeStorage = new Storage<>(storageDir);
disputes = new DisputeList<>(disputeStorage);
@ -221,7 +221,7 @@ public class DisputeManager {
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
dispute.getTradeId(),
keyRingVO.getPubKeyRingVO().hashCode(),
keyRing.getPubKeyRingVO().hashCode(),
false,
Res.get("support.systemMsg", sysMsg),
null,
@ -307,7 +307,7 @@ public class DisputeManager {
: Res.get("support.peerOpenedDispute", disputeInfo);
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
dispute.getTradeId(),
keyRingVO.getPubKeyRingVO().hashCode(),
keyRing.getPubKeyRingVO().hashCode(),
false,
Res.get("support.systemMsg", sysMsg),
null,
@ -608,7 +608,7 @@ public class DisputeManager {
// more BTC as he has deposited
final Contract contract = dispute.getContract();
boolean isBuyer = keyRingVO.getPubKeyRingVO().equals(contract.getBuyerPubKeyRingPayload().get());
boolean isBuyer = keyRing.getPubKeyRingVO().equals(contract.getBuyerPubKeyRingPayload().get());
DisputeResult.Winner publisher = disputeResult.getWinner();
// Sometimes the user who receives the trade amount is never online, so we might want to
@ -759,11 +759,11 @@ public class DisputeManager {
}
public boolean isTrader(Dispute dispute) {
return keyRingVO.getPubKeyRingVO().equals(dispute.getTraderPubKeyRingPayload().get());
return keyRing.getPubKeyRingVO().equals(dispute.getTraderPubKeyRingPayload().get());
}
private boolean isArbitrator(Dispute dispute) {
return keyRingVO.getPubKeyRingVO().equals(dispute.getArbitratorPubKeyRingPayload().get());
return keyRing.getPubKeyRingVO().equals(dispute.getArbitratorPubKeyRingPayload().get());
}
private boolean isArbitrator(DisputeResult disputeResult) {

View file

@ -20,6 +20,7 @@ package io.bisq.core.filter;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.KeyRing;
import io.bisq.core.app.AppOptionKeys;
import io.bisq.core.user.User;
import io.bisq.generated.protobuffer.PB;
@ -28,7 +29,6 @@ import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.filter.Filter;
import io.bisq.protobuffer.payload.filter.PaymentAccountFilter;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
@ -48,7 +48,7 @@ public class FilterManager {
private static final Logger log = LoggerFactory.getLogger(FilterManager.class);
private final P2PService p2PService;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final User user;
private final ObjectProperty<Filter> filterProperty = new SimpleObjectProperty<>();
@ -63,10 +63,10 @@ public class FilterManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public FilterManager(P2PService p2PService, KeyRingVO keyRingVO, User user,
public FilterManager(P2PService p2PService, KeyRing keyRing, User user,
@Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.user = user;
if (!ignoreDevMsg) {
@ -150,7 +150,7 @@ public class FilterManager {
}
private void signAndAddSignatureToFilter(Filter filter) {
filter.setSigAndPubKey(filterSigningKey.signMessage(getHexFromData(filter)), keyRingVO.getSignatureKeyPair().getPublic());
filter.setSigAndPubKey(filterSigningKey.signMessage(getHexFromData(filter)), keyRing.getSignatureKeyPair().getPublic());
}
private boolean verifySignature(Filter filter) {

View file

@ -1,5 +1,7 @@
package io.bisq.core.offer;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.common.locale.CurrencyUtil;
@ -17,8 +19,6 @@ import io.bisq.core.provider.price.PriceFeedService;
import io.bisq.protobuffer.payload.offer.OfferPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.payment.PaymentMethod;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.beans.property.*;
import lombok.Getter;
import lombok.Setter;
@ -300,8 +300,8 @@ public class Offer implements Serializable {
return getDirection() == Offer.Direction.BUY ? Offer.Direction.SELL : Offer.Direction.BUY;
}
public boolean isMyOffer(KeyRingVO keyRingVO) {
return getPubKeyRingVO().equals(keyRingVO.getPubKeyRingVO());
public boolean isMyOffer(KeyRing keyRing) {
return getPubKeyRingVO().equals(keyRing.getPubKeyRingVO());
}

View file

@ -22,6 +22,7 @@ import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Log;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.common.storage.Storage;
@ -49,7 +50,6 @@ import io.bisq.protobuffer.message.offer.OfferAvailabilityRequest;
import io.bisq.protobuffer.message.offer.OfferAvailabilityResponse;
import io.bisq.protobuffer.payload.offer.AvailabilityResult;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.ObservableList;
import org.bitcoinj.core.Coin;
import org.slf4j.Logger;
@ -74,7 +74,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
private static final long REPUBLISH_INTERVAL_MS = TimeUnit.MINUTES.toMillis(DevEnv.STRESS_TEST_MODE ? 20 : 20);
private static final long REFRESH_INTERVAL_MS = TimeUnit.MINUTES.toMillis(DevEnv.STRESS_TEST_MODE ? 4 : 4);
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final User user;
private final P2PService p2PService;
private final BtcWalletService walletService;
@ -94,7 +94,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public OpenOfferManager(KeyRingVO keyRingVO,
public OpenOfferManager(KeyRing keyRing,
User user,
P2PService p2PService,
BtcWalletService walletService,
@ -104,7 +104,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
PriceFeedService priceFeedService,
Preferences preferences,
@Named(Storage.DIR_KEY) File storageDir) {
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.user = user;
this.p2PService = p2PService;
this.walletService = walletService;
@ -332,7 +332,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
///////////////////////////////////////////////////////////////////////////////////////////
public boolean isMyOffer(Offer offer) {
return offer.isMyOffer(keyRingVO);
return offer.isMyOffer(keyRing);
}
public ObservableList<OpenOffer> getOpenOffers() {

View file

@ -17,12 +17,12 @@
package io.bisq.core.offer.availability;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.taskrunner.Model;
import io.bisq.core.offer.Offer;
import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.message.offer.OfferAvailabilityResponse;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.PubKeyRingVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -24,6 +24,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Log;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.monetary.Price;
import io.bisq.common.monetary.Volume;
import io.bisq.common.storage.Storage;
@ -43,7 +44,6 @@ import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.arbitration.Mediator;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.trade.Contract;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.*;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
@ -284,7 +284,7 @@ public abstract class Trade implements Tradable, Model {
OpenOfferManager openOfferManager,
User user,
FilterManager filterManager,
KeyRingVO keyRingVO,
KeyRing keyRing,
boolean useSavingsWallet,
Coin fundsNeededForTrade) {
Log.traceCall();
@ -297,7 +297,7 @@ public abstract class Trade implements Tradable, Model {
arbitratorManager,
user,
filterManager,
keyRingVO,
keyRing,
useSavingsWallet,
fundsNeededForTrade);

View file

@ -20,6 +20,7 @@ package io.bisq.core.trade;
import com.google.common.util.concurrent.FutureCallback;
import io.bisq.common.UserThread;
import io.bisq.common.app.Log;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.FaultHandler;
import io.bisq.common.handlers.ResultHandler;
@ -52,7 +53,6 @@ import io.bisq.protobuffer.message.trade.TradeMessage;
import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.trade.statistics.TradeStatistics;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ObservableList;
@ -82,7 +82,7 @@ public class TradeManager {
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
private final User user;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final BtcWalletService walletService;
private final TradeWalletService tradeWalletService;
private final OpenOfferManager openOfferManager;
@ -106,7 +106,7 @@ public class TradeManager {
@Inject
public TradeManager(User user,
KeyRingVO keyRingVO,
KeyRing keyRing,
BtcWalletService walletService,
TradeWalletService tradeWalletService,
OpenOfferManager openOfferManager,
@ -119,7 +119,7 @@ public class TradeManager {
TradeStatisticsManager tradeStatisticsManager,
@Named(Storage.DIR_KEY) File storageDir) {
this.user = user;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.walletService = walletService;
this.tradeWalletService = tradeWalletService;
this.openOfferManager = openOfferManager;
@ -235,7 +235,7 @@ public class TradeManager {
trade.getTradeAmount(),
trade.getDate(),
(trade.getDepositTx() != null ? trade.getDepositTx().getHashAsString() : ""),
new PubKeyRingPayload(keyRingVO.getPubKeyRingVO()));
new PubKeyRingPayload(keyRing.getPubKeyRingVO()));
tradeStatisticsManager.add(tradeStatistics, true);
// We only republish trades from last 10 days
@ -299,7 +299,7 @@ public class TradeManager {
openOfferManager,
user,
filterManager,
keyRingVO,
keyRing,
useSavingsWallet,
fundsNeededForTrade);
}
@ -376,7 +376,7 @@ public class TradeManager {
private OfferAvailabilityModel getOfferAvailabilityModel(Offer offer) {
return new OfferAvailabilityModel(
offer,
keyRingVO.getPubKeyRingVO(),
keyRing.getPubKeyRingVO(),
p2PService);
}
@ -470,7 +470,7 @@ public class TradeManager {
}
public boolean isMyOffer(Offer offer) {
return offer.isMyOffer(keyRingVO);
return offer.isMyOffer(keyRing);
}
public boolean isBuyer(Offer offer) {

View file

@ -18,12 +18,12 @@
package io.bisq.core.trade.closed;
import com.google.inject.Inject;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.storage.Storage;
import io.bisq.core.offer.Offer;
import io.bisq.core.provider.price.PriceFeedService;
import io.bisq.core.trade.Tradable;
import io.bisq.core.trade.TradableList;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.ObservableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,11 +35,11 @@ import java.util.Optional;
public class ClosedTradableManager {
private static final Logger log = LoggerFactory.getLogger(ClosedTradableManager.class);
private final TradableList<Tradable> closedTrades;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
@Inject
public ClosedTradableManager(KeyRingVO keyRingVO, PriceFeedService priceFeedService, @Named(Storage.DIR_KEY) File storageDir) {
this.keyRingVO = keyRingVO;
public ClosedTradableManager(KeyRing keyRing, PriceFeedService priceFeedService, @Named(Storage.DIR_KEY) File storageDir) {
this.keyRing = keyRing;
final Storage<TradableList<Tradable>> tradableListStorage = new Storage<>(storageDir);
// The ClosedTrades object can become a few MB so we don't keep so many backups
tradableListStorage.setNumMaxBackupFiles(3);
@ -52,7 +52,7 @@ public class ClosedTradableManager {
}
public boolean wasMyOffer(Offer offer) {
return offer.isMyOffer(keyRingVO);
return offer.isMyOffer(keyRing);
}
public ObservableList<Tradable> getClosedTrades() {

View file

@ -18,12 +18,12 @@
package io.bisq.core.trade.failed;
import com.google.inject.Inject;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.storage.Storage;
import io.bisq.core.offer.Offer;
import io.bisq.core.provider.price.PriceFeedService;
import io.bisq.core.trade.TradableList;
import io.bisq.core.trade.Trade;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.ObservableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,11 +35,11 @@ import java.util.Optional;
public class FailedTradesManager {
private static final Logger log = LoggerFactory.getLogger(FailedTradesManager.class);
private final TradableList<Trade> failedTrades;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
@Inject
public FailedTradesManager(KeyRingVO keyRingVO, PriceFeedService priceFeedService, @Named(Storage.DIR_KEY) File storageDir) {
this.keyRingVO = keyRingVO;
public FailedTradesManager(KeyRing keyRing, PriceFeedService priceFeedService, @Named(Storage.DIR_KEY) File storageDir) {
this.keyRing = keyRing;
this.failedTrades = new TradableList<>(new Storage<>(storageDir), "FailedTrades");
failedTrades.forEach(e -> e.getOffer().setPriceFeedService(priceFeedService));
}
@ -50,7 +50,7 @@ public class FailedTradesManager {
}
public boolean wasMyOffer(Offer offer) {
return offer.isMyOffer(keyRingVO);
return offer.isMyOffer(keyRing);
}
public ObservableList<Trade> getFailedTrades() {

View file

@ -18,6 +18,8 @@
package io.bisq.core.trade.protocol;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.taskrunner.Model;
import io.bisq.core.arbitration.ArbitratorManager;
import io.bisq.core.btc.wallet.BtcWalletService;
@ -36,8 +38,6 @@ import io.bisq.protobuffer.payload.btc.RawTransactionInput;
import io.bisq.protobuffer.payload.filter.PaymentAccountFilter;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.payment.PaymentAccountPayload;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
@ -64,7 +64,7 @@ public class ProcessModel implements Model, Serializable {
transient private Offer offer;
transient private User user;
transient private FilterManager filterManager;
transient private KeyRingVO keyRingVO;
transient private KeyRing keyRing;
transient private P2PService p2PService;
// Mutable
@ -109,7 +109,7 @@ public class ProcessModel implements Model, Serializable {
ArbitratorManager arbitratorManager,
User user,
FilterManager filterManager,
KeyRingVO keyRingVO,
KeyRing keyRing,
boolean useSavingsWallet,
Coin fundsNeededForTrade) {
this.offer = offer;
@ -120,7 +120,7 @@ public class ProcessModel implements Model, Serializable {
this.arbitratorManager = arbitratorManager;
this.user = user;
this.filterManager = filterManager;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.p2PService = p2PService;
this.useSavingsWallet = useSavingsWallet;
this.fundsNeededForTrade = fundsNeededForTrade;
@ -217,11 +217,11 @@ public class ProcessModel implements Model, Serializable {
}
public PubKeyRingVO getPubKeyRing() {
return keyRingVO.getPubKeyRingVO();
return keyRing.getPubKeyRingVO();
}
public KeyRingVO getKeyRingVO() {
return keyRingVO;
public KeyRing getKeyRing() {
return keyRing;
}
public void setTakerAcceptedArbitratorNodeAddresses(List<NodeAddress> takerAcceptedArbitratorNodeAddresses) {

View file

@ -19,6 +19,7 @@ package io.bisq.core.trade.protocol;
import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.core.trade.MakerTrade;
import io.bisq.core.trade.Trade;
import io.bisq.core.trade.TradeManager;
@ -27,7 +28,6 @@ import io.bisq.network.p2p.DecryptedMsgWithPubKey;
import io.bisq.protobuffer.message.Message;
import io.bisq.protobuffer.message.trade.TradeMessage;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.beans.value.ChangeListener;
import lombok.extern.slf4j.Slf4j;

View file

@ -18,11 +18,11 @@
package io.bisq.core.trade.protocol;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.persistance.Persistable;
import io.bisq.protobuffer.payload.btc.RawTransactionInput;
import io.bisq.protobuffer.payload.payment.PaymentAccountPayload;
import io.bisq.protobuffer.persistence.crypto.PubKeyRingPersistable;
import io.bisq.vo.crypto.PubKeyRingVO;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;

View file

@ -88,7 +88,7 @@ public class MakerCreateAndSignContract extends TradeTask {
taker.getMultiSigPubKey()
);
String contractAsJson = Utilities.objectToJson(contract);
String signature = Sig.sign(processModel.getKeyRingVO().getSignatureKeyPair().getPrivate(), contractAsJson);
String signature = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), contractAsJson);
trade.setContract(contract);
trade.setContractAsJson(contractAsJson);

View file

@ -97,7 +97,7 @@ public class TakerVerifyAndSignContract extends TradeTask {
takerMultiSigPubKey
);
String contractAsJson = Utilities.objectToJson(contract);
String signature = Sig.sign(processModel.getKeyRingVO().getSignatureKeyPair().getPrivate(), contractAsJson);
String signature = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), contractAsJson);
trade.setContract(contract);
trade.setContractAsJson(contractAsJson);
trade.setTakerContractSignature(signature);

View file

@ -18,6 +18,7 @@
package io.bisq.core.user;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.LanguageUtil;
import io.bisq.common.locale.TradeCurrency;
import io.bisq.common.persistance.Persistable;
@ -29,7 +30,6 @@ import io.bisq.protobuffer.payload.arbitration.Mediator;
import io.bisq.protobuffer.payload.filter.Filter;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.persistence.alert.AlertPersistable;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
@ -87,7 +87,7 @@ public final class User implements Persistable {
@Inject
public User(Storage<User> storage, KeyRingVO keyRingVO) throws NoSuchAlgorithmException {
public User(Storage<User> storage, KeyRing keyRing) throws NoSuchAlgorithmException {
this.storage = storage;
User persisted = storage.initAndGetPersisted(this);
@ -116,7 +116,7 @@ public final class User implements Persistable {
displayedPersistableAlert = persisted.getDisplayedPersistableAlert();
developersFilter = persisted.getDevelopersFilter();
} else {
accountID = String.valueOf(Math.abs(keyRingVO.getPubKeyRingVO().hashCode()));
accountID = String.valueOf(Math.abs(keyRing.getPubKeyRingVO().hashCode()));
acceptedLanguageLocaleCodes.add(LanguageUtil.getDefaultLanguageLocaleAsCode(Preferences.getDefaultLocale()));
String english = LanguageUtil.getEnglishLanguageLocaleCode();

View file

@ -20,6 +20,7 @@ package io.bisq.gui.app;
import com.google.inject.Singleton;
import io.bisq.common.Clock;
import io.bisq.common.app.AppModule;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.storage.Storage;
import io.bisq.core.alert.AlertModule;
@ -37,7 +38,6 @@ import io.bisq.gui.common.view.CachingViewLoader;
import io.bisq.gui.main.overlays.notifications.NotificationCenter;
import io.bisq.network.crypto.EncryptionServiceModule;
import io.bisq.network.p2p.P2PModule;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -61,7 +61,7 @@ class BisqAppModule extends AppModule {
protected void configure() {
bind(CachingViewLoader.class).in(Singleton.class);
bind(KeyStorage.class).in(Singleton.class);
bind(KeyRingVO.class).in(Singleton.class);
bind(KeyRing.class).in(Singleton.class);
bind(User.class).in(Singleton.class);
bind(Preferences.class).in(Singleton.class);
bind(NotificationCenter.class).in(Singleton.class);

View file

@ -25,6 +25,7 @@ import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Log;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.CurrencyUtil;
import io.bisq.common.locale.Res;
import io.bisq.common.locale.TradeCurrency;
@ -72,7 +73,6 @@ import io.bisq.protobuffer.crypto.DecryptedDataTuple;
import io.bisq.protobuffer.message.p2p.peers.keepalive.Ping;
import io.bisq.protobuffer.payload.alert.PrivateNotificationPayload;
import io.bisq.protobuffer.payload.arbitration.Dispute;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.SealedAndSignedVO;
import javafx.beans.property.*;
import javafx.beans.value.ChangeListener;
@ -119,7 +119,7 @@ public class MainViewModel implements ViewModel {
private final Clock clock;
private final FeeService feeService;
private final DaoManager daoManager;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final BSFormatter formatter;
// BTC network
@ -184,7 +184,7 @@ public class MainViewModel implements ViewModel {
FilterManager filterManager, WalletPasswordWindow walletPasswordWindow,
NotificationCenter notificationCenter, TacWindow tacWindow, Clock clock, FeeService feeService,
DaoManager daoManager,
KeyRingVO keyRingVO,
KeyRing keyRing,
BSFormatter formatter) {
this.walletsManager = walletsManager;
this.walletsSetup = walletsSetup;
@ -206,7 +206,7 @@ public class MainViewModel implements ViewModel {
this.clock = clock;
this.feeService = feeService;
this.daoManager = daoManager;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.formatter = formatter;
btcNetworkAsString = Res.get(preferences.getBitcoinNetwork().name()) +
@ -580,8 +580,8 @@ public class MainViewModel implements ViewModel {
// just use any simple dummy msg
Ping payload = new Ping(1, 1);
SealedAndSignedVO sealedAndSignedVO = NetworkCryptoUtils.encryptHybridWithSignature(payload,
keyRingVO.getSignatureKeyPair(), keyRingVO.getPubKeyRingVO().getEncryptionPubKey());
DecryptedDataTuple tuple = NetworkCryptoUtils.decryptHybridWithSignature(sealedAndSignedVO, keyRingVO.getEncryptionKeyPair().getPrivate());
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRingVO().getEncryptionPubKey());
DecryptedDataTuple tuple = NetworkCryptoUtils.decryptHybridWithSignature(sealedAndSignedVO, keyRing.getEncryptionKeyPair().getPrivate());
if (tuple.payload instanceof Ping &&
((Ping) tuple.payload).nonce == payload.nonce &&
((Ping) tuple.payload).lastRoundTripTime == payload.lastRoundTripTime) {

View file

@ -18,6 +18,7 @@
package io.bisq.gui.main.account.arbitratorregistration;
import com.google.inject.Inject;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.ResultHandler;
import io.bisq.common.locale.LanguageUtil;
@ -31,7 +32,6 @@ import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
@ -47,7 +47,7 @@ class ArbitratorRegistrationViewModel extends ActivatableViewModel {
private final User user;
private final P2PService p2PService;
private final BtcWalletService walletService;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
final BooleanProperty registrationEditDisabled = new SimpleBooleanProperty(true);
final BooleanProperty revokeButtonDisabled = new SimpleBooleanProperty(true);
@ -70,12 +70,12 @@ class ArbitratorRegistrationViewModel extends ActivatableViewModel {
User user,
P2PService p2PService,
BtcWalletService walletService,
KeyRingVO keyRingVO) {
KeyRing keyRing) {
this.arbitratorManager = arbitratorManager;
this.user = user;
this.p2PService = p2PService;
this.walletService = walletService;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
arbitratorMapChangeListener = new MapChangeListener<NodeAddress, Arbitrator>() {
@Override
@ -153,7 +153,7 @@ class ArbitratorRegistrationViewModel extends ActivatableViewModel {
p2PService.getAddress(),
arbitratorDepositAddressEntry.getPubKey(),
arbitratorDepositAddressEntry.getAddressString(),
new PubKeyRingPayload(keyRingVO.getPubKeyRingVO()),
new PubKeyRingPayload(keyRing.getPubKeyRingVO()),
new ArrayList<>(languageCodes),
new Date(),
registrationKey.getPubKey(),

View file

@ -18,6 +18,7 @@
package io.bisq.gui.main.account.content.arbitratorselection;
import com.google.inject.Inject;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.LanguageUtil;
import io.bisq.core.arbitration.ArbitratorManager;
import io.bisq.core.user.Preferences;
@ -26,7 +27,6 @@ import io.bisq.gui.common.model.ActivatableDataModel;
import io.bisq.gui.util.BSFormatter;
import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableList;
@ -37,7 +37,7 @@ class ArbitratorSelectionViewModel extends ActivatableDataModel {
private final User user;
private final ArbitratorManager arbitratorManager;
private final Preferences preferences;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final BSFormatter formatter;
final ObservableList<String> languageCodes = FXCollections.observableArrayList();
final ObservableList<ArbitratorListItem> arbitratorListItems = FXCollections.observableArrayList();
@ -46,11 +46,11 @@ class ArbitratorSelectionViewModel extends ActivatableDataModel {
@Inject
public ArbitratorSelectionViewModel(User user, ArbitratorManager arbitratorManager, Preferences preferences,
KeyRingVO keyRingVO, BSFormatter formatter) {
KeyRing keyRing, BSFormatter formatter) {
this.user = user;
this.arbitratorManager = arbitratorManager;
this.preferences = preferences;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.formatter = formatter;
arbitratorMapChangeListener = change -> applyArbitratorMap();
@ -129,7 +129,7 @@ class ArbitratorSelectionViewModel extends ActivatableDataModel {
}
public boolean arbitratorIsTrader(Arbitrator arbitrator) {
return keyRingVO.getPubKeyRingVO().equals(arbitrator.getPubKeyRingPayload().get());
return keyRing.getPubKeyRingVO().equals(arbitrator.getPubKeyRingPayload().get());
}
public boolean hasMatchingLanguage(Arbitrator arbitrator) {

View file

@ -19,6 +19,7 @@ package io.bisq.gui.main.dao.compensation.create;
import com.google.common.util.concurrent.FutureCallback;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Utilities;
import io.bisq.core.btc.InsufficientFundsException;
@ -38,7 +39,6 @@ import io.bisq.gui.util.BSFormatter;
import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.dao.compensation.CompensationRequestPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import org.apache.commons.lang3.StringUtils;
@ -81,7 +81,7 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
@Inject
private CreateCompensationRequestView(BsqWalletService bsqWalletService, BtcWalletService btcWalletService, FeeService feeService,
CompensationRequestManager compensationRequestManager, P2PService p2PService, KeyRingVO keyRingVO, BSFormatter btcFormatter) {
CompensationRequestManager compensationRequestManager, P2PService p2PService, KeyRing keyRing, BSFormatter btcFormatter) {
this.bsqWalletService = bsqWalletService;
this.btcWalletService = btcWalletService;
this.feeService = feeService;
@ -89,7 +89,7 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
this.p2PService = p2PService;
this.btcFormatter = btcFormatter;
p2pStorageSignaturePubKey = keyRingVO.getPubKeyRingVO().getSignaturePubKey();
p2pStorageSignaturePubKey = keyRing.getPubKeyRingVO().getSignaturePubKey();
}

View file

@ -18,6 +18,7 @@
package io.bisq.gui.main.disputes;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.Res;
import io.bisq.core.arbitration.ArbitratorManager;
import io.bisq.core.arbitration.DisputeManager;
@ -33,7 +34,6 @@ import io.bisq.gui.main.portfolio.PortfolioView;
import io.bisq.gui.main.portfolio.pendingtrades.PendingTradesView;
import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.value.ChangeListener;
import javafx.collections.MapChangeListener;
import javafx.fxml.FXML;
@ -54,7 +54,7 @@ public class DisputesView extends ActivatableViewAndModel<TabPane, Activatable>
private final Navigation navigation;
private final ArbitratorManager arbitratorManager;
private final DisputeManager disputeManager;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final Preferences preferences;
private Navigation.Listener navigationListener;
@ -66,12 +66,12 @@ public class DisputesView extends ActivatableViewAndModel<TabPane, Activatable>
@Inject
public DisputesView(CachingViewLoader viewLoader, Navigation navigation,
ArbitratorManager arbitratorManager, DisputeManager disputeManager,
KeyRingVO keyRingVO, Preferences preferences) {
KeyRing keyRing, Preferences preferences) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.arbitratorManager = arbitratorManager;
this.disputeManager = disputeManager;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.preferences = preferences;
}
@ -96,11 +96,11 @@ public class DisputesView extends ActivatableViewAndModel<TabPane, Activatable>
private void updateArbitratorsDisputesTabDisableState() {
boolean isActiveArbitrator = arbitratorManager.getArbitratorsObservableMap().values().stream()
.filter(e -> e.getPubKeyRingPayload() != null && e.getPubKeyRingPayload().get().equals(keyRingVO.getPubKeyRingVO()))
.filter(e -> e.getPubKeyRingPayload() != null && e.getPubKeyRingPayload().get().equals(keyRing.getPubKeyRingVO()))
.findAny().isPresent();
boolean hasDisputesAsArbitrator = disputeManager.getDisputesAsObservableList().stream()
.filter(d -> d.getArbitratorPubKeyRingPayload().get().equals(keyRingVO.getPubKeyRingVO()))
.filter(d -> d.getArbitratorPubKeyRingPayload().get().equals(keyRing.getPubKeyRingVO()))
.findAny().isPresent();
if (arbitratorsDisputesTab == null && (isActiveArbitrator || hasDisputesAsArbitrator)) {

View file

@ -17,6 +17,7 @@
package io.bisq.gui.main.disputes.arbitrator;
import io.bisq.common.crypto.KeyRing;
import io.bisq.core.alert.PrivateNotificationManager;
import io.bisq.core.arbitration.DisputeManager;
import io.bisq.core.trade.TradeManager;
@ -27,7 +28,6 @@ import io.bisq.gui.main.overlays.windows.DisputeSummaryWindow;
import io.bisq.gui.main.overlays.windows.TradeDetailsWindow;
import io.bisq.gui.util.BSFormatter;
import io.bisq.network.p2p.storage.P2PService;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.stage.Stage;
import javax.inject.Inject;
@ -37,10 +37,10 @@ import javax.inject.Inject;
public class ArbitratorDisputeView extends TraderDisputeView {
@Inject
public ArbitratorDisputeView(DisputeManager disputeManager, KeyRingVO keyRingVO, TradeManager tradeManager, Stage stage,
public ArbitratorDisputeView(DisputeManager disputeManager, KeyRing keyRing, TradeManager tradeManager, Stage stage,
BSFormatter formatter, DisputeSummaryWindow disputeSummaryWindow, PrivateNotificationManager privateNotificationManager,
ContractWindow contractWindow, TradeDetailsWindow tradeDetailsWindow, P2PService p2PService) {
super(disputeManager, keyRingVO, tradeManager, stage, formatter,
super(disputeManager, keyRing, tradeManager, stage, formatter,
disputeSummaryWindow, privateNotificationManager, contractWindow, tradeDetailsWindow, p2PService);
}
@ -56,7 +56,7 @@ public class ArbitratorDisputeView extends TraderDisputeView {
protected void applyFilteredListPredicate(String filterString) {
// If in arbitrator view we must only display disputes where we are selected as arbitrator (must not receive others anyway)
filteredList.setPredicate(dispute ->
dispute.getArbitratorPubKeyRingPayload().get().equals(keyRingVO.getPubKeyRingVO()) &&
dispute.getArbitratorPubKeyRingPayload().get().equals(keyRing.getPubKeyRingVO()) &&
(filterString.isEmpty() ||
(dispute.getId().contains(filterString) ||
(!dispute.isClosed() && filterString.toLowerCase().equals("open")) ||

View file

@ -24,6 +24,7 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bisq.common.Timer;
import io.bisq.common.UserThread;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Utilities;
import io.bisq.core.alert.PrivateNotificationManager;
@ -52,7 +53,6 @@ import io.bisq.protobuffer.payload.arbitration.Dispute;
import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.trade.Contract;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
@ -97,7 +97,7 @@ import java.util.concurrent.TimeUnit;
public class TraderDisputeView extends ActivatableView<VBox, Void> {
private final DisputeManager disputeManager;
protected final KeyRingVO keyRingVO;
protected final KeyRing keyRing;
private final TradeManager tradeManager;
private final Stage stage;
protected final BSFormatter formatter;
@ -143,11 +143,14 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TraderDisputeView(DisputeManager disputeManager, KeyRingVO keyRingVO, TradeManager tradeManager, Stage stage,
BSFormatter formatter, DisputeSummaryWindow disputeSummaryWindow, PrivateNotificationManager privateNotificationManager,
ContractWindow contractWindow, TradeDetailsWindow tradeDetailsWindow, P2PService p2PService) {
public TraderDisputeView(DisputeManager disputeManager, KeyRing keyRing,
TradeManager tradeManager, Stage stage,
BSFormatter formatter, DisputeSummaryWindow disputeSummaryWindow,
PrivateNotificationManager privateNotificationManager,
ContractWindow contractWindow, TradeDetailsWindow tradeDetailsWindow,
P2PService p2PService) {
this.disputeManager = disputeManager;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.tradeManager = tradeManager;
this.stage = stage;
this.formatter = formatter;
@ -409,7 +412,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
protected void applyFilteredListPredicate(String filterString) {
// If in trader view we must not display arbitrators own disputes as trader (must not happen anyway)
filteredList.setPredicate(dispute -> !dispute.getArbitratorPubKeyRingPayload().equals(keyRingVO.getPubKeyRingVO()));
filteredList.setPredicate(dispute -> !dispute.getArbitratorPubKeyRingPayload().equals(keyRing.getPubKeyRingVO()));
}

View file

@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
import com.google.inject.Inject;
import io.bisq.common.app.DevEnv;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.CurrencyUtil;
import io.bisq.common.locale.Res;
import io.bisq.common.locale.TradeCurrency;
@ -47,7 +48,6 @@ import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.offer.OfferPayload;
import io.bisq.protobuffer.payload.payment.BankAccountPayload;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@ -71,7 +71,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
private final BtcWalletService walletService;
private final Preferences preferences;
private final User user;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final P2PService p2PService;
private final PriceFeedService priceFeedService;
final String shortOfferId;
@ -122,14 +122,20 @@ class CreateOfferDataModel extends ActivatableDataModel {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
CreateOfferDataModel(OpenOfferManager openOfferManager, BtcWalletService walletService,
Preferences preferences, User user, KeyRingVO keyRingVO, P2PService p2PService, PriceFeedService priceFeedService,
FeeService feeService, BSFormatter formatter) {
CreateOfferDataModel(OpenOfferManager openOfferManager,
BtcWalletService walletService,
Preferences preferences,
User user,
KeyRing keyRing,
P2PService p2PService,
PriceFeedService priceFeedService,
FeeService feeService,
BSFormatter formatter) {
this.openOfferManager = openOfferManager;
this.walletService = walletService;
this.preferences = preferences;
this.user = user;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.p2PService = p2PService;
this.priceFeedService = priceFeedService;
this.feeService = feeService;
@ -345,7 +351,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
OfferPayload offerPayload = new OfferPayload(offerId,
new Date().getTime(),
p2PService.getAddress(),
new PubKeyRingPayload(keyRingVO.getPubKeyRingVO()),
new PubKeyRingPayload(keyRing.getPubKeyRingVO()),
OfferPayload.Direction.valueOf(direction.name()),
priceAsLong,
marketPriceMarginParam,

View file

@ -18,6 +18,7 @@
package io.bisq.gui.main.overlays.windows;
import com.google.common.base.Joiner;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.locale.BankUtil;
import io.bisq.common.locale.CountryUtil;
import io.bisq.common.locale.Res;
@ -38,7 +39,6 @@ import io.bisq.gui.main.overlays.popups.Popup;
import io.bisq.gui.util.BSFormatter;
import io.bisq.gui.util.Layout;
import io.bisq.protobuffer.payload.payment.PaymentMethod;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
@ -61,7 +61,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
private final BSFormatter formatter;
protected final Preferences preferences;
private final User user;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
private final Navigation navigation;
private Offer offer;
private Coin tradeAmount;
@ -76,11 +76,11 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public OfferDetailsWindow(BSFormatter formatter, Preferences preferences, User user, KeyRingVO keyRingVO, Navigation navigation) {
public OfferDetailsWindow(BSFormatter formatter, Preferences preferences, User user, KeyRing keyRing, Navigation navigation) {
this.formatter = formatter;
this.preferences = preferences;
this.user = user;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.navigation = navigation;
type = Type.Confirmation;
}
@ -221,7 +221,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
final boolean isSpecificBanks = paymentMethod.equals(PaymentMethod.SPECIFIC_BANKS);
final boolean isNationalBanks = paymentMethod.equals(PaymentMethod.NATIONAL_BANK);
final boolean isSepa = paymentMethod.equals(PaymentMethod.SEPA);
if (offer.isMyOffer(keyRingVO) && makerPaymentAccountId != null && paymentAccount != null) {
if (offer.isMyOffer(keyRing) && makerPaymentAccountId != null && paymentAccount != null) {
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.myTradingAccount"), paymentAccount.getAccountName());
} else {
final String method = Res.get(paymentMethod.getId());

View file

@ -18,6 +18,7 @@
package io.bisq.gui.main.overlays.windows;
import io.bisq.common.app.DevEnv;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Tuple2;
import io.bisq.gui.components.InputTextField;
@ -26,7 +27,6 @@ import io.bisq.gui.main.overlays.popups.Popup;
import io.bisq.network.p2p.SendMailboxMessageListener;
import io.bisq.protobuffer.payload.alert.PrivateNotificationPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;

View file

@ -19,6 +19,7 @@ package io.bisq.gui.main.portfolio.pendingtrades;
import com.google.inject.Inject;
import io.bisq.common.app.Log;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.handlers.ErrorMessageHandler;
import io.bisq.common.handlers.FaultHandler;
import io.bisq.common.handlers.ResultHandler;
@ -48,7 +49,6 @@ import io.bisq.protobuffer.payload.arbitration.Arbitrator;
import io.bisq.protobuffer.payload.arbitration.Dispute;
import io.bisq.protobuffer.payload.crypto.PubKeyRingPayload;
import io.bisq.protobuffer.payload.payment.PaymentAccountPayload;
import io.bisq.vo.crypto.KeyRingVO;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
@ -75,7 +75,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
private final TradeWalletService tradeWalletService;
private final FeeService feeService;
private final User user;
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
public final DisputeManager disputeManager;
private final P2PService p2PService;
public final Navigation navigation;
@ -99,15 +99,24 @@ public class PendingTradesDataModel extends ActivatableDataModel {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public PendingTradesDataModel(TradeManager tradeManager, BtcWalletService btcWalletService, TradeWalletService tradeWalletService, FeeService feeService,
User user, KeyRingVO keyRingVO, DisputeManager disputeManager, Preferences preferences, P2PService p2PService,
Navigation navigation, WalletPasswordWindow walletPasswordWindow, NotificationCenter notificationCenter) {
public PendingTradesDataModel(TradeManager tradeManager,
BtcWalletService btcWalletService,
TradeWalletService tradeWalletService,
FeeService feeService,
User user,
KeyRing keyRing,
DisputeManager disputeManager,
Preferences preferences,
P2PService p2PService,
Navigation navigation,
WalletPasswordWindow walletPasswordWindow,
NotificationCenter notificationCenter) {
this.tradeManager = tradeManager;
this.btcWalletService = btcWalletService;
this.tradeWalletService = tradeWalletService;
this.feeService = feeService;
this.user = user;
this.keyRingVO = keyRingVO;
this.keyRing = keyRing;
this.disputeManager = disputeManager;
this.preferences = preferences;
this.p2PService = p2PService;
@ -384,10 +393,10 @@ public class PendingTradesDataModel extends ActivatableDataModel {
checkNotNull(acceptedArbitratorByAddress, "acceptedArbitratorByAddress must no tbe null");
Dispute dispute = new Dispute(disputeManager.getDisputeStorage(),
trade.getId(),
keyRingVO.getPubKeyRingVO().hashCode(), // traderId
keyRing.getPubKeyRingVO().hashCode(), // traderId
trade.getOffer().getDirection() == Offer.Direction.BUY ? isMaker : !isMaker,
isMaker,
new PubKeyRingPayload(keyRingVO.getPubKeyRingVO()),
new PubKeyRingPayload(keyRing.getPubKeyRingVO()),
trade.getDate(),
trade.getContract(),
trade.getContractHash(),

View file

@ -18,30 +18,30 @@
package io.bisq.network.crypto;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
import io.bisq.protobuffer.crypto.DecryptedDataTuple;
import io.bisq.protobuffer.message.Message;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import io.bisq.vo.crypto.SealedAndSignedVO;
import javax.inject.Inject;
public class EncryptionService {
private final KeyRingVO keyRingVO;
private final KeyRing keyRing;
@Inject
public EncryptionService(KeyRingVO keyRingVO) {
this.keyRingVO = keyRingVO;
public EncryptionService(KeyRing keyRing) {
this.keyRing = keyRing;
}
public SealedAndSignedVO encryptAndSign(PubKeyRingVO pubKeyRingVO, Message message) throws CryptoException {
return NetworkCryptoUtils.encryptHybridWithSignature(message, keyRingVO.getSignatureKeyPair(), pubKeyRingVO.getEncryptionPubKey());
return NetworkCryptoUtils.encryptHybridWithSignature(message, keyRing.getSignatureKeyPair(), pubKeyRingVO.getEncryptionPubKey());
}
public DecryptedMsgWithPubKey decryptAndVerify(SealedAndSignedVO sealedAndSignedVO) throws CryptoException {
DecryptedDataTuple decryptedDataTuple = NetworkCryptoUtils.decryptHybridWithSignature(sealedAndSignedVO,
keyRingVO.getEncryptionKeyPair().getPrivate());
keyRing.getEncryptionKeyPair().getPrivate());
return new DecryptedMsgWithPubKey(decryptedDataTuple.payload,
decryptedDataTuple.sigPublicKey);
}

View file

@ -10,6 +10,8 @@ import io.bisq.common.Clock;
import io.bisq.common.UserThread;
import io.bisq.common.app.Log;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.storage.FileUtil;
import io.bisq.common.storage.Storage;
import io.bisq.common.util.Utilities;
@ -40,8 +42,6 @@ import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.p2p.storage.MailboxStoragePayload;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedMailboxStorageEntry;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.beans.property.*;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
@ -73,7 +73,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
private final Clock clock;
//TODO optional can be removed as seednode are created with those objects now
private final Optional<EncryptionService> optionalEncryptionService;
private final Optional<KeyRingVO> optionalKeyRingVO;
private final Optional<KeyRing> optionalKeyRingVO;
// set in init
private NetworkNode networkNode;
@ -121,7 +121,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
Clock clock,
Socks5ProxyProvider socks5ProxyProvider,
@Nullable EncryptionService encryptionService,
@Nullable KeyRingVO keyRingVO) {
@Nullable KeyRing keyRing) {
this(
seedNodesRepository,
port,
@ -136,7 +136,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
clock,
socks5ProxyProvider,
encryptionService,
keyRingVO
keyRing
);
}
@ -153,7 +153,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
Clock clock,
Socks5ProxyProvider socks5ProxyProvider,
@Nullable EncryptionService encryptionService,
@Nullable KeyRingVO keyRingVO) {
@Nullable KeyRing keyRing) {
this.seedNodesRepository = seedNodesRepository;
this.port = port;
this.maxConnections = maxConnections;
@ -162,7 +162,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
this.socks5ProxyProvider = socks5ProxyProvider;
optionalEncryptionService = Optional.ofNullable(encryptionService);
optionalKeyRingVO = Optional.ofNullable(keyRingVO);
optionalKeyRingVO = Optional.ofNullable(keyRing);
init(useLocalhostForP2P,
networkId,
@ -877,7 +877,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
@VisibleForTesting
@Nullable
public KeyRingVO getKeyRing() {
public KeyRing getKeyRing() {
return optionalKeyRingVO.isPresent() ? optionalKeyRingVO.get() : null;
}

View file

@ -21,7 +21,9 @@ package io.bisq.network.crypto;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.Hash;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.storage.FileUtil;
import io.bisq.generated.protobuffer.PB;
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
@ -34,8 +36,6 @@ import io.bisq.protobuffer.message.p2p.peers.keepalive.Ping;
import io.bisq.protobuffer.payload.alert.PrivateNotificationPayload;
import io.bisq.protobuffer.payload.crypto.SealedAndSignedPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import io.bisq.vo.crypto.SealedAndSignedVO;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.After;
@ -67,7 +67,7 @@ public class EncryptionServiceTests {
public ExpectedException thrown = ExpectedException.none();
private PubKeyRingVO pubKeyRingVO;
private KeyRingVO keyRingVO;
private KeyRing keyRing;
private File dir;
@Before
@ -77,8 +77,8 @@ public class EncryptionServiceTests {
dir.delete();
dir.mkdir();
KeyStorage keyStorage = new KeyStorage(dir);
keyRingVO = new KeyRingVO(keyStorage);
pubKeyRingVO = keyRingVO.getPubKeyRingVO();
keyRing = new KeyRing(keyStorage);
pubKeyRingVO = keyRing.getPubKeyRingVO();
}
@After
@ -88,7 +88,7 @@ public class EncryptionServiceTests {
@Test
public void testDecryptAndVerifyMessage() throws CryptoException {
EncryptionService encryptionService = new EncryptionService(keyRingVO);
EncryptionService encryptionService = new EncryptionService(keyRing);
final PrivateNotificationPayload privateNotification = new PrivateNotificationPayload("test");
privateNotification.setSigAndPubKey("", pubKeyRingVO.getSignaturePubKey());
final NodeAddress nodeAddress = new NodeAddress("localhost", 2222);
@ -114,14 +114,14 @@ public class EncryptionServiceTests {
SealedAndSignedVO sealedAndSignedVO = null;
try {
sealedAndSignedVO = NetworkCryptoUtils.encryptHybridWithSignature(payload,
keyRingVO.getSignatureKeyPair(), keyRingVO.getPubKeyRingVO().getEncryptionPubKey());
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRingVO().getEncryptionPubKey());
} catch (CryptoException e) {
log.error("encryptHybridWithSignature failed");
e.printStackTrace();
assertTrue(false);
}
try {
DecryptedDataTuple tuple = decryptHybridWithSignature(sealedAndSignedVO, keyRingVO.getEncryptionKeyPair().getPrivate());
DecryptedDataTuple tuple = decryptHybridWithSignature(sealedAndSignedVO, keyRing.getEncryptionKeyPair().getPrivate());
assertEquals(((Ping) tuple.payload).nonce, payload.nonce);
} catch (CryptoException e) {
log.error("decryptHybridWithSignature failed");

View file

@ -1,11 +1,11 @@
package io.bisq.network.p2p;
import io.bisq.common.Clock;
import io.bisq.common.crypto.KeyRing;
import io.bisq.network.crypto.EncryptionService;
import io.bisq.network.p2p.seed.SeedNodesRepository;
import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -119,7 +119,7 @@ public class TestUtils {
return seedNode;
}
public static P2PService getAndAuthenticateP2PService(int port, EncryptionService encryptionService, KeyRingVO keyRingVO,
public static P2PService getAndAuthenticateP2PService(int port, EncryptionService encryptionService, KeyRing keyRing,
boolean useLocalhostForP2P, Set<NodeAddress> seedNodes)
throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
@ -132,7 +132,7 @@ public class TestUtils {
}
P2PService p2PService = new P2PService(seedNodesRepository, port, new File("seed_node_" + port), useLocalhostForP2P,
2, P2PService.MAX_CONNECTIONS_DEFAULT, new File("dummy"), null, null, null, new Clock(), null, encryptionService, keyRingVO);
2, P2PService.MAX_CONNECTIONS_DEFAULT, new File("dummy"), null, null, null, new Clock(), null, encryptionService, keyRing);
p2PService.start(new P2PServiceListener() {
@Override
public void onRequestingDataCompleted() {

View file

@ -3,7 +3,9 @@ package io.bisq.network.p2p.network;
import io.bisq.common.Clock;
import io.bisq.common.UserThread;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.util.Tuple3;
import io.bisq.generated.protobuffer.PB;
import io.bisq.network.crypto.EncryptionService;
@ -14,8 +16,6 @@ import io.bisq.network.p2p.storage.P2PService;
import io.bisq.protobuffer.message.p2p.DirectMessage;
import io.bisq.protobuffer.message.p2p.MailboxMessage;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@ -382,11 +382,11 @@ public class NetworkStressTest {
// peer keys
final KeyStorage peerKeyStorage = new KeyStorage(peerKeysDir);
final KeyRingVO peerKeyRingVO = new KeyRingVO(peerKeyStorage);
final EncryptionService peerEncryptionService = new EncryptionService(peerKeyRingVO);
final KeyRing peerKeyRing = new KeyRing(peerKeyStorage);
final EncryptionService peerEncryptionService = new EncryptionService(peerKeyRing);
return new P2PService(seedNodesRepository, port, peerTorDir, useLocalhostForP2P,
REGTEST_NETWORK_ID, P2PService.MAX_CONNECTIONS_DEFAULT, peerStorageDir, null, null, null, new Clock(), null, peerEncryptionService, peerKeyRingVO);
REGTEST_NETWORK_ID, P2PService.MAX_CONNECTIONS_DEFAULT, peerStorageDir, null, null, null, new Clock(), null, peerEncryptionService, peerKeyRing);
}
// ## TEST SETUP: P2P service listener classes

View file

@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.crypto.Sig;
import io.bisq.common.storage.FileUtil;
@ -21,7 +22,6 @@ import io.bisq.protobuffer.payload.offer.OfferPayload;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.alert.AlertVO;
import io.bisq.vo.crypto.KeyRingVO;
import lombok.extern.slf4j.Slf4j;
import mockit.Mocked;
import mockit.integration.junit4.JMockit;
@ -53,7 +53,7 @@ public class P2PDataStorageTest {
private EncryptionService encryptionService1, encryptionService2;
private P2PDataStorage dataStorage1;
private KeyPair storageSignatureKeyPair1, storageSignatureKeyPair2;
private KeyRingVO keyRingVO1, keyRingVO2;
private KeyRing keyRing1, keyRing2;
private StoragePayload storagePayload;
private File dir1;
private File dir2;
@ -73,14 +73,14 @@ public class P2PDataStorageTest {
dir2.delete();
dir2.mkdir();
keyRingVO1 = new KeyRingVO(new KeyStorage(dir1));
storageSignatureKeyPair1 = keyRingVO1.getSignatureKeyPair();
encryptionService1 = new EncryptionService(keyRingVO1);
keyRing1 = new KeyRing(new KeyStorage(dir1));
storageSignatureKeyPair1 = keyRing1.getSignatureKeyPair();
encryptionService1 = new EncryptionService(keyRing1);
// for mailbox
keyRingVO2 = new KeyRingVO(new KeyStorage(dir2));
storageSignatureKeyPair2 = keyRingVO2.getSignatureKeyPair();
encryptionService2 = new EncryptionService(keyRingVO2);
keyRing2 = new KeyRing(new KeyStorage(dir2));
storageSignatureKeyPair2 = keyRing2.getSignatureKeyPair();
encryptionService2 = new EncryptionService(keyRing2);
dataStorage1 = new P2PDataStorage(broadcaster, networkNode, dir1);
}
@ -156,7 +156,7 @@ public class P2PDataStorageTest {
return new OfferPayload("id",
System.currentTimeMillis(),
nodeAddress4,
new PubKeyRingPayload(keyRingVO1.getPubKeyRingVO()),
new PubKeyRingPayload(keyRing1.getPubKeyRingVO()),
OfferPayload.Direction.BUY,
1200,
1.5,

View file

@ -2,6 +2,7 @@ package io.bisq.network.p2p.storage;
import io.bisq.common.UserThread;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.crypto.Sig;
import io.bisq.common.storage.FileUtil;
@ -14,7 +15,6 @@ import io.bisq.network.p2p.storage.mocks.MockData;
import io.bisq.protobuffer.message.p2p.storage.RefreshTTLMessage;
import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.*;
import org.slf4j.Logger;
@ -42,7 +42,7 @@ public class ProtectedDataStorageTest {
private EncryptionService encryptionService1, encryptionService2;
private P2PDataStorage dataStorage1;
private KeyPair storageSignatureKeyPair1, storageSignatureKeyPair2;
private KeyRingVO keyRingVO1, keyRingVO2;
private KeyRing keyRing1, keyRing2;
private MockData mockData;
private final int sleepTime = 100;
private File dir1;
@ -61,21 +61,21 @@ public class ProtectedDataStorageTest {
UserThread.setExecutor(Executors.newSingleThreadExecutor());
P2PDataStorage.CHECK_TTL_INTERVAL_SEC = 500;
keyRingVO1 = new KeyRingVO(new KeyStorage(dir1));
keyRing1 = new KeyRing(new KeyStorage(dir1));
storageSignatureKeyPair1 = keyRingVO1.getSignatureKeyPair();
encryptionService1 = new EncryptionService(keyRingVO1);
storageSignatureKeyPair1 = keyRing1.getSignatureKeyPair();
encryptionService1 = new EncryptionService(keyRing1);
P2PService p2PService = TestUtils.getAndStartSeedNode(8001, useClearNet, seedNodes).getSeedNodeP2PService();
networkNode1 = p2PService.getNetworkNode();
peerManager1 = p2PService.getPeerManager();
dataStorage1 = p2PService.getP2PDataStorage();
// for mailbox
keyRingVO2 = new KeyRingVO(new KeyStorage(dir2));
storageSignatureKeyPair2 = keyRingVO2.getSignatureKeyPair();
encryptionService2 = new EncryptionService(keyRingVO2);
keyRing2 = new KeyRing(new KeyStorage(dir2));
storageSignatureKeyPair2 = keyRing2.getSignatureKeyPair();
encryptionService2 = new EncryptionService(keyRing2);
mockData = new MockData("mockData", keyRingVO1.getSignatureKeyPair().getPublic());
mockData = new MockData("mockData", keyRing1.getSignatureKeyPair().getPublic());
Thread.sleep(sleepTime);
}

View file

@ -1,6 +1,7 @@
package io.bisq.network.p2p.storage.messages;
import io.bisq.common.crypto.CryptoException;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.generated.protobuffer.PB;
import io.bisq.protobuffer.ProtoBufferUtilities;
@ -11,7 +12,6 @@ import io.bisq.protobuffer.payload.p2p.NodeAddress;
import io.bisq.protobuffer.payload.p2p.storage.MailboxStoragePayload;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedMailboxStorageEntry;
import io.bisq.protobuffer.payload.p2p.storage.ProtectedStorageEntry;
import io.bisq.vo.crypto.KeyRingVO;
import io.bisq.vo.crypto.SealedAndSignedVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue;
@Slf4j
public class AddDataMessageTest {
private KeyRingVO keyRingVO1;
private KeyRing keyRing1;
private File dir1;
@ -39,21 +39,21 @@ public class AddDataMessageTest {
dir1 = File.createTempFile("temp_tests1", "");
dir1.delete();
dir1.mkdir();
keyRingVO1 = new KeyRingVO(new KeyStorage(dir1));
keyRing1 = new KeyRing(new KeyStorage(dir1));
}
@Test
public void toProtoBuf() throws Exception {
SealedAndSignedVO sealedAndSignedVO = new SealedAndSignedVO(RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), keyRingVO1.getPubKeyRingVO().getSignaturePubKey());
SealedAndSignedVO sealedAndSignedVO = new SealedAndSignedVO(RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), keyRing1.getPubKeyRingVO().getSignaturePubKey());
PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage = new PrefixedSealedAndSignedMessage(
new NodeAddress("host", 1000),
new SealedAndSignedPayload(sealedAndSignedVO),
RandomUtils.nextBytes(10),
UUID.randomUUID().toString());
MailboxStoragePayload mailboxStoragePayload = new MailboxStoragePayload(prefixedSealedAndSignedMessage,
keyRingVO1.getPubKeyRingVO().getSignaturePubKey(), keyRingVO1.getPubKeyRingVO().getSignaturePubKey());
keyRing1.getPubKeyRingVO().getSignaturePubKey(), keyRing1.getPubKeyRingVO().getSignaturePubKey());
ProtectedStorageEntry protectedStorageEntry = new ProtectedMailboxStorageEntry(mailboxStoragePayload,
keyRingVO1.getSignatureKeyPair().getPublic(), 1, RandomUtils.nextBytes(10), keyRingVO1.getPubKeyRingVO().getSignaturePubKey());
keyRing1.getSignatureKeyPair().getPublic(), 1, RandomUtils.nextBytes(10), keyRing1.getPubKeyRingVO().getSignaturePubKey());
AddDataMessage dataMessage1 = new AddDataMessage(protectedStorageEntry);
PB.Envelope envelope = dataMessage1.toProto();
AddDataMessage dataMessage2 = (AddDataMessage) ProtoBufferUtilities.getAddDataMessage(envelope);

View file

@ -1,6 +1,7 @@
package io.bisq.protobuffer;
import com.google.protobuf.ByteString;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.common.locale.CountryUtil;
import io.bisq.common.locale.CurrencyUtil;
import io.bisq.common.monetary.Price;
@ -45,7 +46,6 @@ import io.bisq.protobuffer.payload.payment.*;
import io.bisq.protobuffer.payload.trade.Contract;
import io.bisq.protobuffer.payload.trade.statistics.TradeStatistics;
import io.bisq.vo.alert.AlertVO;
import io.bisq.vo.crypto.PubKeyRingVO;
import io.bisq.vo.crypto.SealedAndSignedVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.output.WriterOutputStream;

View file

@ -18,9 +18,9 @@
package io.bisq.protobuffer.crypto;
import com.google.protobuf.ByteString;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.generated.protobuffer.PB;
import io.bisq.protobuffer.Marshaller;
import io.bisq.vo.crypto.PubKeyRingVO;
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import lombok.extern.slf4j.Slf4j;
@ -31,7 +31,7 @@ import lombok.extern.slf4j.Slf4j;
public abstract class PubKeyRingProto implements Marshaller {
@Delegate
private PubKeyRingVO pubKeyRingVO;
protected PubKeyRingVO pubKeyRingVO;
public PubKeyRingVO get() {
return pubKeyRingVO;

View file

@ -17,9 +17,9 @@
package io.bisq.protobuffer.payload.crypto;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.protobuffer.crypto.PubKeyRingProto;
import io.bisq.protobuffer.payload.Payload;
import io.bisq.vo.crypto.PubKeyRingVO;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

View file

@ -18,9 +18,9 @@
package io.bisq.protobuffer.persistence.crypto;
import io.bisq.common.app.Version;
import io.bisq.common.crypto.vo.PubKeyRingVO;
import io.bisq.protobuffer.crypto.PubKeyRingProto;
import io.bisq.protobuffer.persistence.PersistableNew;
import io.bisq.vo.crypto.PubKeyRingVO;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

View file

@ -20,6 +20,7 @@ package io.bisq.seednode;
import com.google.inject.Singleton;
import io.bisq.common.Clock;
import io.bisq.common.app.AppModule;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.storage.Storage;
import io.bisq.core.alert.AlertModule;
@ -34,7 +35,6 @@ import io.bisq.core.user.Preferences;
import io.bisq.core.user.User;
import io.bisq.network.crypto.EncryptionServiceModule;
import io.bisq.network.p2p.P2PModule;
import io.bisq.vo.crypto.KeyRingVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
@ -53,7 +53,7 @@ class SeedNodeModule extends AppModule {
@Override
protected void configure() {
bind(KeyStorage.class).in(Singleton.class);
bind(KeyRingVO.class).in(Singleton.class);
bind(KeyRing.class).in(Singleton.class);
bind(User.class).in(Singleton.class);
bind(Preferences.class).in(Singleton.class);
bind(Clock.class).in(Singleton.class);

View file

@ -20,6 +20,7 @@ package io.bisq.statistics;
import com.google.inject.Singleton;
import io.bisq.common.Clock;
import io.bisq.common.app.AppModule;
import io.bisq.common.crypto.KeyRing;
import io.bisq.common.crypto.KeyStorage;
import io.bisq.common.storage.Storage;
import io.bisq.core.alert.AlertModule;
@ -34,7 +35,6 @@ import io.bisq.core.user.Preferences;
import io.bisq.core.user.User;
import io.bisq.network.crypto.EncryptionServiceModule;
import io.bisq.network.p2p.P2PModule;
import io.bisq.vo.crypto.KeyRingVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
@ -53,7 +53,7 @@ class StatisticsModule extends AppModule {
@Override
protected void configure() {
bind(KeyStorage.class).in(Singleton.class);
bind(KeyRingVO.class).in(Singleton.class);
bind(KeyRing.class).in(Singleton.class);
bind(User.class).in(Singleton.class);
bind(Preferences.class).in(Singleton.class);
bind(Clock.class).in(Singleton.class);