mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-22 06:38:55 -04:00
Remove pubkey storage, remove duplicate sig keys
This commit is contained in:
parent
4883c90030
commit
07a9c7fd52
13 changed files with 101 additions and 139 deletions
|
@ -128,7 +128,7 @@ public class AlertManager {
|
|||
private void signAndAddSignatureToAlertMessage(Alert alert) {
|
||||
String alertMessageAsHex = Utils.HEX.encode(alert.message.getBytes());
|
||||
String signatureAsBase64 = alertSigningKey.signMessage(alertMessageAsHex);
|
||||
alert.setSigAndStoragePubKey(signatureAsBase64, keyRing.getStorageSignatureKeyPair().getPublic());
|
||||
alert.setSigAndStoragePubKey(signatureAsBase64, keyRing.getSignatureKeyPair().getPublic());
|
||||
}
|
||||
|
||||
private boolean verifySignature(Alert alert) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public final class Arbitrator implements PubKeyProtectedExpirablePayload {
|
|||
|
||||
@Override
|
||||
public PublicKey getPubKey() {
|
||||
return pubKeyRing.getStorageSignaturePubKey();
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
}
|
||||
|
||||
public byte[] getBtcPubKey() {
|
||||
|
|
|
@ -169,7 +169,7 @@ public class ArbitratorManager {
|
|||
arbitratorsObservableMap.clear();
|
||||
Map<Address, Arbitrator> filtered = map.values().stream()
|
||||
.filter(e -> isPublicKeyInList(Utils.HEX.encode(e.getRegistrationPubKey()))
|
||||
&& verifySignature(e.getPubKeyRing().getStorageSignaturePubKey(), e.getRegistrationPubKey(), e.getRegistrationSignature()))
|
||||
&& verifySignature(e.getPubKeyRing().getSignaturePubKey(), e.getRegistrationPubKey(), e.getRegistrationSignature()))
|
||||
.collect(Collectors.toMap(Arbitrator::getArbitratorAddress, Function.identity()));
|
||||
|
||||
arbitratorsObservableMap.putAll(filtered);
|
||||
|
@ -233,7 +233,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(keyRing.getPubKeyRing().getStorageSignaturePubKey().getEncoded());
|
||||
String keyToSignAsHex = Utils.HEX.encode(keyRing.getPubKeyRing().getSignaturePubKey().getEncoded());
|
||||
return key.signMessage(keyToSignAsHex);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
|
|||
|
||||
@Override
|
||||
public PublicKey getPubKey() {
|
||||
return pubKeyRing.getStorageSignaturePubKey();
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class TradeProtocol {
|
|||
// We check the sig only as soon we have stored the peers pubKeyRing.
|
||||
PubKeyRing tradingPeerPubKeyRing = processModel.tradingPeer.getPubKeyRing();
|
||||
PublicKey signaturePubKey = decryptedMessageWithPubKey.signaturePubKey;
|
||||
if (tradingPeerPubKeyRing != null && signaturePubKey.equals(tradingPeerPubKeyRing.getMsgSignaturePubKey())) {
|
||||
if (tradingPeerPubKeyRing != null && signaturePubKey.equals(tradingPeerPubKeyRing.getSignaturePubKey())) {
|
||||
Message message = decryptedMessageWithPubKey.message;
|
||||
log.trace("handleNewMessage: message = " + message.getClass().getSimpleName() + " from " + peerAddress);
|
||||
if (message instanceof TradeMessage) {
|
||||
|
@ -75,7 +75,7 @@ public abstract class TradeProtocol {
|
|||
if (arbitratorOptional.isPresent())
|
||||
arbitratorPubKeyRing = arbitratorOptional.get().getPubKeyRing();
|
||||
|
||||
if ((arbitratorPubKeyRing != null && !signaturePubKey.equals(arbitratorPubKeyRing.getMsgSignaturePubKey())))
|
||||
if ((arbitratorPubKeyRing != null && !signaturePubKey.equals(arbitratorPubKeyRing.getSignaturePubKey())))
|
||||
log.error("Signature used in seal message does not match the one stored with that trade for the trading peer or arbitrator.");
|
||||
}
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ public abstract class TradeProtocol {
|
|||
|
||||
public void applyMailboxMessage(DecryptedMessageWithPubKey decryptedMessageWithPubKey, Trade trade) {
|
||||
log.debug("applyMailboxMessage " + decryptedMessageWithPubKey.message);
|
||||
if (decryptedMessageWithPubKey.signaturePubKey.equals(processModel.tradingPeer.getPubKeyRing().getMsgSignaturePubKey()))
|
||||
if (decryptedMessageWithPubKey.signaturePubKey.equals(processModel.tradingPeer.getPubKeyRing().getSignaturePubKey()))
|
||||
doApplyMailboxMessage(decryptedMessageWithPubKey.message, trade);
|
||||
else
|
||||
log.error("SignaturePubKey in message does not match the SignaturePubKey we have stored to that trading peer.");
|
||||
|
|
|
@ -80,7 +80,7 @@ public class VerifyAndSignContract extends TradeTask {
|
|||
trade.setTakerContractSignature(signature);
|
||||
|
||||
try {
|
||||
Sig.verify(offerer.getPubKeyRing().getMsgSignaturePubKey(),
|
||||
Sig.verify(offerer.getPubKeyRing().getSignaturePubKey(),
|
||||
contractAsJson,
|
||||
offerer.getContractSignature());
|
||||
} catch (Throwable t) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue