From b498928f751be2ca38dbe3accd9d3920f5f4aac1 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Thu, 7 Jul 2016 13:22:30 +0100 Subject: [PATCH] Remove the "verify correct notary has signed" check. This is no longed necessary as the required notary key is added to the "signers" list during transaction construction. We have general validation rules that check the correct notary was included in the signers list, and that we have signatures for all "signers". --- .../kotlin/com/r3corda/protocols/TwoPartyTradeProtocol.kt | 8 -------- .../kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt | 7 ------- .../r3corda/node/messaging/TwoPartyTradeProtocolTests.kt | 4 +--- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/contracts/src/main/kotlin/com/r3corda/protocols/TwoPartyTradeProtocol.kt b/contracts/src/main/kotlin/com/r3corda/protocols/TwoPartyTradeProtocol.kt index 514f230675..c755d4acd7 100644 --- a/contracts/src/main/kotlin/com/r3corda/protocols/TwoPartyTradeProtocol.kt +++ b/contracts/src/main/kotlin/com/r3corda/protocols/TwoPartyTradeProtocol.kt @@ -202,9 +202,6 @@ object TwoPartyTradeProtocol { logger.trace { "Got signatures from seller, verifying ... " } - // TODO: figure out a way to do Notary verification along with other command signatures in SignedTransaction.verify() - verifyCorrectNotary(stx.tx, signatures.notarySig) - val fullySigned = stx + signatures.sellerSig + signatures.notarySig fullySigned.verify() @@ -260,11 +257,6 @@ object TwoPartyTradeProtocol { return ptx.toSignedTransaction(checkSufficientSignatures = false) } - private fun verifyCorrectNotary(wtx: WireTransaction, sig: DigitalSignature.LegallyIdentifiable) { - val notary = serviceHub.loadState(wtx.inputs.first()).notary - check(sig.signer == notary) { "Transaction not signed by the required Notary" } - } - private fun assembleSharedTX(tradeRequest: SellerTradeInfo): Pair> { val ptx = TransactionType.General.Builder() // Add input and output states for the movement of cash, by using the Cash contract to generate the states. diff --git a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt index d78fe77fef..cf6004881b 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt @@ -218,7 +218,6 @@ object TwoPartyDealProtocol { logger.trace { "Got signatures from other party, verifying ... " } - verifyCorrectNotary(stx.tx, signatures.notarySig) val fullySigned = stx + signatures.sellerSig + signatures.notarySig fullySigned.verify() @@ -263,12 +262,6 @@ object TwoPartyDealProtocol { return ptx.toSignedTransaction(checkSufficientSignatures = false) } - private fun verifyCorrectNotary(wtx: WireTransaction, sig: DigitalSignature.LegallyIdentifiable) { - if (wtx.inputs.isEmpty()) return // Can choose any Notary if there are no inputs - val notary = serviceHub.loadState(wtx.inputs.first()).notary - check(sig.signer == notary) { "Transaction not signed by the required Notary" } - } - @Suspendable protected abstract fun validateHandshake(handshake: Handshake): Handshake @Suspendable protected abstract fun assembleSharedTX(handshake: Handshake): Pair> } diff --git a/node/src/test/kotlin/com/r3corda/node/messaging/TwoPartyTradeProtocolTests.kt b/node/src/test/kotlin/com/r3corda/node/messaging/TwoPartyTradeProtocolTests.kt index 7975972f8b..6a50e60717 100644 --- a/node/src/test/kotlin/com/r3corda/node/messaging/TwoPartyTradeProtocolTests.kt +++ b/node/src/test/kotlin/com/r3corda/node/messaging/TwoPartyTradeProtocolTests.kt @@ -305,9 +305,7 @@ class TwoPartyTradeProtocolTests { TxRecord.Get(bobsFakeCash[1].id), TxRecord.Get(bobsFakeCash[2].id), // Alice notices that Bob's cash txns depend on a third tx she also doesn't know. She asks, Bob answers. - TxRecord.Get(bobsFakeCash[0].id), - // Bob wants to verify that the tx has been signed by the correct Notary, which requires looking up an input state - TxRecord.Get(bobsFakeCash[1].id) + TxRecord.Get(bobsFakeCash[0].id) ) // Bob has downloaded the attachment.