Stop using "legally-Identifiable" signatures for the notary protocol, as notary nodes will use their service identity to sign (and not the legal one). It also doesn't make sense to attach an identity on the signature if it's a group identity and the signer holds only 1 out of many keys.

This commit is contained in:
Andrius Dagys 2016-11-14 16:02:20 +00:00
parent d855b10817
commit d00163e29d
6 changed files with 18 additions and 20 deletions

View File

@ -105,7 +105,7 @@ abstract class AbstractStateReplacementProtocol<T> {
} }
@Suspendable @Suspendable
private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.LegallyIdentifiable { private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.WithKey {
progressTracker.currentStep = NOTARY progressTracker.currentStep = NOTARY
return subProtocol(NotaryProtocol.Client(stx)) return subProtocol(NotaryProtocol.Client(stx))
} }

View File

@ -22,7 +22,7 @@ object NotaryProtocol {
* by another transaction or the timestamp is invalid. * by another transaction or the timestamp is invalid.
*/ */
open class Client(private val stx: SignedTransaction, open class Client(private val stx: SignedTransaction,
override val progressTracker: ProgressTracker = Client.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() { override val progressTracker: ProgressTracker = Client.tracker()) : ProtocolLogic<DigitalSignature.WithKey>() {
companion object { companion object {
@ -36,7 +36,7 @@ object NotaryProtocol {
lateinit var notaryParty: Party lateinit var notaryParty: Party
@Suspendable @Suspendable
override fun call(): DigitalSignature.LegallyIdentifiable { override fun call(): DigitalSignature.WithKey {
progressTracker.currentStep = REQUESTING progressTracker.currentStep = REQUESTING
val wtx = stx.tx val wtx = stx.tx
notaryParty = wtx.notary ?: throw IllegalStateException("Transaction does not specify a Notary") notaryParty = wtx.notary ?: throw IllegalStateException("Transaction does not specify a Notary")
@ -56,7 +56,7 @@ object NotaryProtocol {
} }
@Throws(NotaryException::class, IllegalStateException::class) @Throws(NotaryException::class, IllegalStateException::class)
private fun validateResponse(response: UntrustworthyData<Result>): DigitalSignature.LegallyIdentifiable { private fun validateResponse(response: UntrustworthyData<Result>): DigitalSignature.WithKey {
return response.unwrap { notaryResult -> return response.unwrap { notaryResult ->
progressTracker.currentStep = VALIDATING progressTracker.currentStep = VALIDATING
when (notaryResult) { when (notaryResult) {
@ -74,8 +74,8 @@ object NotaryProtocol {
} }
} }
private fun validateSignature(sig: DigitalSignature.LegallyIdentifiable, data: ByteArray) { private fun validateSignature(sig: DigitalSignature.WithKey, data: ByteArray) {
check(sig.signer == notaryParty) { "Notary result not signed by the correct service" } check(sig.by in notaryParty.owningKey.keys) { "Invalid signer for the notary result" }
sig.verifyWithECDSA(data) sig.verifyWithECDSA(data)
} }
} }
@ -140,11 +140,9 @@ object NotaryProtocol {
} }
} }
private fun sign(bits: ByteArray): DigitalSignature.LegallyIdentifiable { private fun sign(bits: ByteArray): DigitalSignature.WithKey {
val myNodeInfo = serviceHub.myInfo
val myIdentity = myNodeInfo.notaryIdentity
val mySigningKey = serviceHub.notaryIdentityKey val mySigningKey = serviceHub.notaryIdentityKey
return mySigningKey.signWithECDSA(bits, myIdentity) return mySigningKey.signWithECDSA(bits)
} }
} }
@ -153,7 +151,7 @@ object NotaryProtocol {
sealed class Result { sealed class Result {
class Error(val error: NotaryError): Result() class Error(val error: NotaryError): Result()
class Success(val sig: DigitalSignature.LegallyIdentifiable) : Result() class Success(val sig: DigitalSignature.WithKey) : Result()
} }
} }

View File

@ -41,7 +41,7 @@ object TwoPartyDealProtocol {
// This object is serialised to the network and is the first protocol message the seller sends to the buyer. // This object is serialised to the network and is the first protocol message the seller sends to the buyer.
data class Handshake<out T>(val payload: T, val publicKey: PublicKeyTree) data class Handshake<out T>(val payload: T, val publicKey: PublicKeyTree)
class SignaturesFromPrimary(val sellerSig: DigitalSignature.WithKey, val notarySig: DigitalSignature.LegallyIdentifiable) class SignaturesFromPrimary(val sellerSig: DigitalSignature.WithKey, val notarySig: DigitalSignature.WithKey)
/** /**
* [Primary] at the end sends the signed tx to all the regulator parties. This a seperate workflow which needs a * [Primary] at the end sends the signed tx to all the regulator parties. This a seperate workflow which needs a
@ -160,7 +160,7 @@ object TwoPartyDealProtocol {
} }
@Suspendable @Suspendable
private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.LegallyIdentifiable { private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.WithKey {
progressTracker.currentStep = NOTARY progressTracker.currentStep = NOTARY
return subProtocol(NotaryProtocol.Client(stx)) return subProtocol(NotaryProtocol.Client(stx))
} }
@ -172,7 +172,7 @@ object TwoPartyDealProtocol {
@Suspendable @Suspendable
private fun sendSignatures(allPartySignedTx: SignedTransaction, ourSignature: DigitalSignature.WithKey, private fun sendSignatures(allPartySignedTx: SignedTransaction, ourSignature: DigitalSignature.WithKey,
notarySignature: DigitalSignature.LegallyIdentifiable): SignedTransaction { notarySignature: DigitalSignature.WithKey): SignedTransaction {
progressTracker.currentStep = SENDING_SIGS progressTracker.currentStep = SENDING_SIGS
val fullySigned = allPartySignedTx + notarySignature val fullySigned = allPartySignedTx + notarySignature

View File

@ -55,7 +55,7 @@ object TwoPartyTradeProtocol {
) )
data class SignaturesFromSeller(val sellerSig: DigitalSignature.WithKey, data class SignaturesFromSeller(val sellerSig: DigitalSignature.WithKey,
val notarySig: DigitalSignature.LegallyIdentifiable) val notarySig: DigitalSignature.WithKey)
open class Seller(val otherParty: Party, open class Seller(val otherParty: Party,
val notaryNode: NodeInfo, val notaryNode: NodeInfo,
@ -90,7 +90,7 @@ object TwoPartyTradeProtocol {
} }
@Suspendable @Suspendable
private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.LegallyIdentifiable { private fun getNotarySignature(stx: SignedTransaction): DigitalSignature.WithKey {
progressTracker.currentStep = NOTARY progressTracker.currentStep = NOTARY
return subProtocol(NotaryProtocol.Client(stx)) return subProtocol(NotaryProtocol.Client(stx))
} }
@ -142,7 +142,7 @@ object TwoPartyTradeProtocol {
@Suspendable @Suspendable
private fun sendSignatures(allPartySignedTx: SignedTransaction, ourSignature: DigitalSignature.WithKey, private fun sendSignatures(allPartySignedTx: SignedTransaction, ourSignature: DigitalSignature.WithKey,
notarySignature: DigitalSignature.LegallyIdentifiable): SignedTransaction { notarySignature: DigitalSignature.WithKey): SignedTransaction {
progressTracker.currentStep = SENDING_SIGS progressTracker.currentStep = SENDING_SIGS
val fullySigned = allPartySignedTx + notarySignature val fullySigned = allPartySignedTx + notarySignature

View File

@ -5,8 +5,8 @@ import net.corda.core.contracts.DummyContract
import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.StateAndRef
import net.corda.core.contracts.StateRef import net.corda.core.contracts.StateRef
import net.corda.core.contracts.TransactionType import net.corda.core.contracts.TransactionType
import net.corda.core.node.services.ServiceInfo
import net.corda.core.crypto.DigitalSignature import net.corda.core.crypto.DigitalSignature
import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
@ -108,7 +108,7 @@ class NotaryServiceTests {
} }
private fun runNotaryClient(stx: SignedTransaction): ListenableFuture<DigitalSignature.LegallyIdentifiable> { private fun runNotaryClient(stx: SignedTransaction): ListenableFuture<DigitalSignature.WithKey> {
val protocol = NotaryProtocol.Client(stx) val protocol = NotaryProtocol.Client(stx)
val future = clientNode.services.startProtocol(protocol) val future = clientNode.services.startProtocol(protocol)
net.runNetwork() net.runNetwork()

View File

@ -78,7 +78,7 @@ class ValidatingNotaryServiceTests {
assertEquals(setOf(expectedMissingKey), missingKeys) assertEquals(setOf(expectedMissingKey), missingKeys)
} }
private fun runClient(stx: SignedTransaction): ListenableFuture<DigitalSignature.LegallyIdentifiable> { private fun runClient(stx: SignedTransaction): ListenableFuture<DigitalSignature.WithKey> {
val protocol = NotaryProtocol.Client(stx) val protocol = NotaryProtocol.Client(stx)
val future = clientNode.services.startProtocol(protocol) val future = clientNode.services.startProtocol(protocol)
net.runNetwork() net.runNetwork()