mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
Address review comments
This commit is contained in:
parent
fa4b503f81
commit
8a9350fc93
@ -55,8 +55,7 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
|
|||||||
@Throws(SignatureException::class)
|
@Throws(SignatureException::class)
|
||||||
fun verifySignatures(vararg allowedToBeMissing: PublicKey): WireTransaction {
|
fun verifySignatures(vararg allowedToBeMissing: PublicKey): WireTransaction {
|
||||||
// Embedded WireTransaction is not deserialised until after we check the signatures.
|
// Embedded WireTransaction is not deserialised until after we check the signatures.
|
||||||
for (sig in sigs)
|
checkSignaturesAreValid()
|
||||||
sig.verifyWithECDSA(txBits.bits)
|
|
||||||
|
|
||||||
val missing = getMissingSignatures()
|
val missing = getMissingSignatures()
|
||||||
if (missing.isNotEmpty()) {
|
if (missing.isNotEmpty()) {
|
||||||
@ -68,6 +67,20 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
|
|||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mathematically validates the signatures that are present on this transaction. This does not imply that
|
||||||
|
* the signatures are by the right keys, or that there are sufficient signatures, just that they aren't
|
||||||
|
* corrupt. If you use this function directly you'll need to do the other checks yourself. Probably you
|
||||||
|
* want [verifySignatures] instead.
|
||||||
|
*
|
||||||
|
* @throws SignatureException if a signature fails to verify.
|
||||||
|
*/
|
||||||
|
@Throws(SignatureException::class)
|
||||||
|
fun checkSignaturesAreValid() {
|
||||||
|
for (sig in sigs)
|
||||||
|
sig.verifyWithECDSA(txBits.bits)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getMissingSignatures(): Set<PublicKey> {
|
private fun getMissingSignatures(): Set<PublicKey> {
|
||||||
val requiredKeys = tx.mustSign.toSet()
|
val requiredKeys = tx.mustSign.toSet()
|
||||||
val sigKeys = sigs.map { it.by }.toSet()
|
val sigKeys = sigs.map { it.by }.toSet()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user