diff --git a/core/src/main/kotlin/net/corda/core/conclave/common/CordaEnclaveClient.kt b/core/src/main/kotlin/net/corda/core/conclave/common/CordaEnclaveClient.kt index b548850b20..a346ad2cc8 100644 --- a/core/src/main/kotlin/net/corda/core/conclave/common/CordaEnclaveClient.kt +++ b/core/src/main/kotlin/net/corda/core/conclave/common/CordaEnclaveClient.kt @@ -16,7 +16,7 @@ import java.util.* * data to arrive in a single ByteArray */ -abstract class CordaEnclaveClient(val x500: CordaX500Name, val keyManagementService: KeyManagementService? = null, val identityService: IdentityService? = null): SingletonSerializeAsToken() { +abstract class CordaEnclaveClient(val x500: CordaX500Name, val keyManagementService: KeyManagementService? = null, val identityService: IdentityService? = null) { // Some exceptions we could throw [TBD - do we want this?] class RemoteAttestationException(description: String) : FlowException(description) diff --git a/core/src/main/kotlin/net/corda/core/node/services/EncryptedTransactionService.kt b/core/src/main/kotlin/net/corda/core/node/services/EncryptedTransactionService.kt index c8b595167c..07d6213802 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/EncryptedTransactionService.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/EncryptedTransactionService.kt @@ -15,7 +15,7 @@ import net.corda.core.transactions.EncryptedTransaction import java.util.* import java.util.concurrent.ConcurrentHashMap -class EncryptedTransactionService(val enclaveClient: CordaEnclaveClient = DummyCordaEnclaveClient(CordaX500Name("PartyDummy", "London", "GB" ))) : SingletonSerializeAsToken() { +class EncryptedTransactionService(val enclaveClient: CordaEnclaveClient = DummyCordaEnclaveClient(CordaX500Name("PartyDummy", "London", "GB" ))) { private val attestationCache = ConcurrentHashMap() diff --git a/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt index 3075fdb619..3bf669c6a5 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt @@ -22,6 +22,7 @@ import net.corda.core.serialization.deserialize import net.corda.core.serialization.internal.AttachmentsClassLoaderCache import net.corda.core.serialization.serialize import net.corda.core.utilities.OpaqueBytes +import net.corda.core.utilities.SgxSupport import java.security.PublicKey import java.security.SignatureException import java.util.function.Predicate @@ -425,6 +426,7 @@ constructor(componentGroups: List, val privacySalt: PrivacySalt, val paramsHash = coreTransaction?.networkParametersHash ?: services.networkParametersService.defaultHash val params = services.networkParametersService.lookup(paramsHash) ?: throw IllegalStateException("Should have been able to fetch parameters by this point: $paramsHash") + @Suppress("UNCHECKED_CAST") when (coreTransaction) { is WireTransaction -> coreTransaction.componentGroups @@ -433,10 +435,12 @@ constructor(componentGroups: List, val privacySalt: PrivacySalt, ?.get(stateRef.index) as SerializedBytes>? is ContractUpgradeWireTransaction -> coreTransaction.resolveOutputComponent(services, stateRef, params) is NotaryChangeWireTransaction -> coreTransaction.resolveOutputComponent(services, stateRef, params) - else -> { + else -> if(SgxSupport.isInsideEnclave) { services.validatedTransactions.getEncryptedTransaction(stateRef.txhash)?.let { encryptedTx -> - services.encryptedTransactionService.decryptInputAndRefsForNode(encryptedTx).inputs.single { it.ref == stateRef }.serialize() as SerializedBytes>? - } ?: throw UnsupportedOperationException("Attempting to resolve input ${stateRef.index} of a ${coreTransaction?.let { it.javaClass } ?: null} transaction. This is not supported.") + services.encryptedTransactionService.decryptInputAndRefsForNode(encryptedTx).inputs.singleOrNull { it.ref == stateRef }?.state?.serialize() + } ?: throw UnsupportedOperationException("Attempting to resolve input ${stateRef.index} of a ${coreTransaction?.javaClass ?: "null"} transaction. This is not supported.") + } else { + throw UnsupportedOperationException("Attempting to resolve input ${stateRef.index} of a ${coreTransaction?.javaClass ?: "null"} transaction. This is not supported.") } } } else {