mirror of
https://github.com/corda/corda.git
synced 2024-12-23 14:52:29 +00:00
Remove CompositeSignaturesWithKeys
Remove CompositeSignaturesWithKeys class, as other refactors mean it is now superfluous. Instead serialization of the TransactionSignature can be used directly.
This commit is contained in:
parent
472ecc65c6
commit
9b3cad30b2
@ -1,6 +1,7 @@
|
||||
package net.corda.core.crypto.composite
|
||||
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.crypto.TransactionSignature
|
||||
import net.corda.core.serialization.deserialize
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.security.*
|
||||
@ -27,6 +28,7 @@ class CompositeSignature : Signature(SIGNATURE_ALGORITHM) {
|
||||
return signatureState!!
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in inherited API")
|
||||
@Throws(InvalidAlgorithmParameterException::class)
|
||||
override fun engineGetParameter(param: String?): Any {
|
||||
throw InvalidAlgorithmParameterException("Composite signatures do not support any parameters")
|
||||
@ -46,6 +48,7 @@ class CompositeSignature : Signature(SIGNATURE_ALGORITHM) {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in inherited API")
|
||||
@Throws(InvalidAlgorithmParameterException::class)
|
||||
override fun engineSetParameter(param: String?, value: Any?) {
|
||||
throw InvalidAlgorithmParameterException("Composite signatures do not support any parameters")
|
||||
@ -74,10 +77,10 @@ class CompositeSignature : Signature(SIGNATURE_ALGORITHM) {
|
||||
|
||||
data class State(val buffer: ByteArrayOutputStream, val verifyKey: CompositeKey) {
|
||||
fun engineVerify(sigBytes: ByteArray): Boolean {
|
||||
val sig = sigBytes.deserialize<CompositeSignaturesWithKeys>()
|
||||
return if (verifyKey.isFulfilledBy(sig.sigs.map { it.by })) {
|
||||
val sigs = sigBytes.deserialize<List<TransactionSignature>>()
|
||||
return if (verifyKey.isFulfilledBy(sigs.map { it.by })) {
|
||||
val clearData = SecureHash.SHA256(buffer.toByteArray())
|
||||
sig.sigs.all { it.isValid(clearData) }
|
||||
sigs.all { it.isValid(clearData) }
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
package net.corda.core.crypto.composite
|
||||
|
||||
import net.corda.core.crypto.TransactionSignature
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
|
||||
/**
|
||||
* Custom class for holding signature data. This exists for later extension work to provide a standardised cross-platform
|
||||
* serialization format.
|
||||
*/
|
||||
@CordaSerializable
|
||||
data class CompositeSignaturesWithKeys(val sigs: List<TransactionSignature>) {
|
||||
companion object {
|
||||
val EMPTY = CompositeSignaturesWithKeys(emptyList())
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package net.corda.core.crypto
|
||||
import net.corda.core.crypto.composite.CompositeKey
|
||||
import net.corda.core.crypto.composite.CompositeKey.NodeAndWeight
|
||||
import net.corda.core.crypto.composite.CompositeSignature
|
||||
import net.corda.core.crypto.composite.CompositeSignaturesWithKeys
|
||||
import net.corda.core.internal.declaredField
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.serialization.serialize
|
||||
@ -161,17 +160,17 @@ class CompositeKeyTests : TestDependencyInjectionBase() {
|
||||
engine.initVerify(twoOfThree)
|
||||
engine.update(secureHash.bytes)
|
||||
|
||||
assertFalse { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature)).serialize().bytes) }
|
||||
assertFalse { engine.verify(CompositeSignaturesWithKeys(listOf(bobSignature)).serialize().bytes) }
|
||||
assertFalse { engine.verify(CompositeSignaturesWithKeys(listOf(charlieSignature)).serialize().bytes) }
|
||||
assertTrue { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature, bobSignature)).serialize().bytes) }
|
||||
assertTrue { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature, charlieSignature)).serialize().bytes) }
|
||||
assertTrue { engine.verify(CompositeSignaturesWithKeys(listOf(bobSignature, charlieSignature)).serialize().bytes) }
|
||||
assertTrue { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature, bobSignature, charlieSignature)).serialize().bytes) }
|
||||
assertFalse { engine.verify(listOf(aliceSignature).serialize().bytes) }
|
||||
assertFalse { engine.verify(listOf(bobSignature).serialize().bytes) }
|
||||
assertFalse { engine.verify(listOf(charlieSignature).serialize().bytes) }
|
||||
assertTrue { engine.verify(listOf(aliceSignature, bobSignature).serialize().bytes) }
|
||||
assertTrue { engine.verify(listOf(aliceSignature, charlieSignature).serialize().bytes) }
|
||||
assertTrue { engine.verify(listOf(bobSignature, charlieSignature).serialize().bytes) }
|
||||
assertTrue { engine.verify(listOf(aliceSignature, bobSignature, charlieSignature).serialize().bytes) }
|
||||
|
||||
// Check the underlying signature is validated
|
||||
val brokenBobSignature = TransactionSignature(aliceSignature.bytes, bobSignature.by, SignatureMetadata(1, Crypto.findSignatureScheme(bobSignature.by).schemeNumberID))
|
||||
assertFalse { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature, brokenBobSignature)).serialize().bytes) }
|
||||
assertFalse { engine.verify(listOf(aliceSignature, brokenBobSignature).serialize().bytes) }
|
||||
}
|
||||
|
||||
@Test()
|
||||
|
Loading…
Reference in New Issue
Block a user