ENT-12401: Fixed compilation errors and changed alias from 4.12 variant.

This commit is contained in:
Adel El-Beik 2024-11-06 15:17:23 +00:00
parent d54f1e2eeb
commit 4524c6522f
3 changed files with 7 additions and 3 deletions

View File

@ -74,6 +74,8 @@ data class RotatedKeys(val rotatedSigningKeys: List<List<SecureHash>> = emptyLis
}
}
fun rotateToHash(key: PublicKey) = rotate(key.hash.sha256())
private fun rotate(key: SecureHash): SecureHash {
return rotateMap[key] ?: key
}

View File

@ -658,7 +658,7 @@ open class TransactionBuilder(
// TODO, we don't currently support mixing signature constraints with different signers. This will change once we introduce third party signers.
(constraints.count { it is SignatureAttachmentConstraint } > 1) &&
(constraints.filterIsInstance<SignatureAttachmentConstraint>().map { serviceHub?.toVerifyingServiceHub()?.rotatedKeys?.rotateToHash(it.key) ?: it.key}.toSet().size > 1)
(constraints.filterIsInstance<SignatureAttachmentConstraint>().map { serviceHub?.retrieveRotatedKeys()?.rotateToHash(it.key) ?: it.key}.toSet().size > 1)
->
throw IllegalArgumentException("Cannot mix SignatureAttachmentConstraints signed by different parties in the same transaction.")

View File

@ -79,6 +79,7 @@ class ContractWithRotatedKeyTest {
val keyStoreDir1 = SelfCleaningDir()
val keyStoreDir2 = SelfCleaningDir()
// Note the alias below is different in 4.12 and above and it needs to match the alias used internally
val packageOwnerKey1 = keyStoreDir1.path.generateKey(alias="alias1")
val packageOwnerKey2 = keyStoreDir2.path.generateKey(alias="alias1")
@ -142,8 +143,9 @@ class ContractWithRotatedKeyTest {
val keyStoreDir1 = SelfCleaningDir()
val keyStoreDir2 = SelfCleaningDir()
val packageOwnerKey1 = keyStoreDir1.path.generateKey(alias="1-testcordapp-rsa")
val packageOwnerKey2 = keyStoreDir2.path.generateKey(alias="1-testcordapp-rsa")
// Note the alias below is different in 4.12 and above and it needs to match the alias used internally
val packageOwnerKey1 = keyStoreDir1.path.generateKey(alias="alias1")
val packageOwnerKey2 = keyStoreDir2.path.generateKey(alias="alias1")
val unsignedFinanceCorDapp1 = cordappWithPackages("net.corda.finance", "migration", "META-INF.services")
val unsignedFinanceCorDapp2 = cordappWithPackages("net.corda.finance", "migration", "META-INF.services").copy(versionId = 2)