TransactionSignature
Keywords: net.corda.core.crypto.TransactionSignature class
Date: 2023-09-18

net.corda.core.crypto

## Class TransactionSignature

- net.corda.core.utilities.ByteSequence
- - net.corda.core.utilities.OpaqueBytes
  - - net.corda.core.crypto.DigitalSignature
    - - net.corda.core.crypto.TransactionSignature

-     public class TransactionSignature
      extends DigitalSignature

  A wrapper over the signature output accompanied by signer's public key and signature metadata. This is similar to `class DigitalSignature.WithKey`, but targeted to DLT transaction (or block of transactions) signatures.

  See Also:
    `class DigitalSignature.WithKey`

- - ### Constructor Detail

    - #### TransactionSignature

          public TransactionSignature(@NotNull
                                      kotlin.Array[] bytes,
                                      @NotNull
                                      java.security.PublicKey by,
                                      @NotNull
                                      SignatureMetadata signatureMetadata,
                                      @Nullable
                                      PartialMerkleTree partialMerkleTree)

      A wrapper over the signature output accompanied by signer's public key and signature metadata. This is similar to `class DigitalSignature.WithKey`, but targeted to DLT transaction (or block of transactions) signatures.

      Parameters:
        `by` - PublicKey of the signer.
        `signatureMetadata` - attached `class SignatureMetadata` for this signature.
        `partialMerkleTree` - required when multi-transaction signing is utilised.
      See Also:
        `class DigitalSignature.WithKey`

    - #### TransactionSignature

          public TransactionSignature(@NotNull
                                      kotlin.Array[] bytes,
                                      @NotNull
                                      java.security.PublicKey by,
                                      @NotNull
                                      SignatureMetadata signatureMetadata)

      Construct a `class TransactionSignature` with partialMerkleTree set to null. This is the recommended constructor when signing over a single transaction.

      See Also:
        `class TransactionSignature`

  - ### Method Detail

    - #### verify

          public boolean verify(@NotNull
                                SecureHash txId)

      Function to verify a `class SignableData` object's signature. Note that `class SignableData` contains the id of the transaction and extra metadata, such as DLT's platform version. A non-null partialMerkleTree implies multi-transaction signing and the signature is over the root of this tree.

      Parameters:
        `txId` - transaction's id (Merkle root), which along with signatureMetadata will be used to construct the `class SignableData` object to be signed.
      Throws:
        `InvalidKeyException` - if the key is invalid.
        `SignatureException` - if this signatureData object is not initialized properly, the passed-in signatureData is improperly encoded or of the wrong type, if this signatureData algorithm is unable to process the input data provided, etc.
        `IllegalArgumentException` - if the signature scheme is not supported for this private key or if any of the clear or signature data is empty.
      See Also:
        `class SignableData`, `class SignableData`

    - #### isValid

          public boolean isValid(@NotNull
                                 SecureHash txId)

      Utility to simplify the act of verifying a signature. In comparison to `verify` doesn't throw an exception, making it more suitable where a boolean is required, but normally you should use the function which throws, as it avoids the risk of failing to test the result.

      Returns:
        whether the signature is correct for this key.
      Throws:
        `InvalidKeyException` - if the key to verify the signature with is not valid (i.e. wrong key type for the signature).
        `SignatureException` - if the signature is invalid (i.e. damaged).
      See Also:
        `verify`

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object other)

    - #### hashCode

          public int hashCode()

    - #### getBy

          @NotNull
          public java.security.PublicKey getBy()

      PublicKey

      of the signer.

      See Also:
        PublicKey

    - #### getSignatureMetadata

          @NotNull
          public SignatureMetadata getSignatureMetadata()

      attached

      `class SignatureMetadata` for this signature.

      See Also:
        `class SignatureMetadata`

    - #### getPartialMerkleTree

          @Nullable
          public PartialMerkleTree getPartialMerkleTree()

      required when multi-transaction signing is utilised.