From b291fdae73332777a482186ebb6e139be7ebebce Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 18 Aug 2022 09:52:48 -0400 Subject: [PATCH] fix pub key validation error --- .../core/trade/protocol/TradeProtocol.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java index 1fad03d706..40d5cc275e 100644 --- a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java @@ -583,18 +583,30 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D } private boolean isPubKeyValid(DecryptedMessageWithPubKey message, NodeAddress sender) { + if (this instanceof ArbitratorProtocol) { - // valid if arbitrator's pub key ring - if (trade.getArbitratorPubKeyRing() != null && message.getSignaturePubKey().equals(trade.getArbitratorPubKeyRing().getSignaturePubKey())) return true; + // valid if traders unknown + if (trade.getMaker().getPubKeyRing() == null || trade.getTakerPubKeyRing() == null) return true; + + // valid if maker pub key + if (message.getSignaturePubKey().equals(trade.getMaker().getPubKeyRing().getSignaturePubKey())) return true; + + // valid if taker pub key + if (message.getSignaturePubKey().equals(trade.getTaker().getPubKeyRing().getSignaturePubKey())) return true; + } else { + + // valid if arbitrator or peer unknown + if (trade.getArbitratorPubKeyRing() == null || (trade.getTradingPeer() == null || trade.getTradingPeer().getPubKeyRing() == null)) return true; + + // valid if arbitrator's pub key ring + if (message.getSignaturePubKey().equals(trade.getArbitratorPubKeyRing().getSignaturePubKey())) return true; + + // valid if peer's pub key ring + if (message.getSignaturePubKey().equals(trade.getTradingPeer().getPubKeyRing().getSignaturePubKey())) return true; + } - // not invalid if pub key rings are unknown - if ((trade.getTradingPeer() == null || trade.getTradingPeer().getPubKeyRing() == null) && trade.getArbitratorPubKeyRing() == null) return true; - - // valid if peer's pub key ring - if (trade.getTradingPeer() != null && trade.getTradingPeer().getPubKeyRing() != null && message.getSignaturePubKey().equals(trade.getTradingPeer().getPubKeyRing().getSignaturePubKey())) return true; - // invalid - log.error("SignaturePubKey in message does not match the SignaturePubKey we have set for our trading peer and arbitrator."); + log.error("SignaturePubKey in message does not match the SignaturePubKey we have set for our arbitrator or trading peer."); return false; }