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.
class DigitalSignature.WithKey
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.
by
- PublicKey of the signer.signatureMetadata
- attached class SignatureMetadata
for this signature.partialMerkleTree
- required when multi-transaction signing is utilised.class DigitalSignature.WithKey
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.
class TransactionSignature
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.
txId
- transaction's id (Merkle root), which along with signatureMetadata will be used to construct the class SignableData
object to be signed.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.class SignableData
,
class SignableData
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.
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).verify
public boolean equals(@Nullable java.lang.Object other)
public int hashCode()
@NotNull public SignatureMetadata getSignatureMetadata()
attached
class SignatureMetadata
for this signature.
class SignatureMetadata
@Nullable public PartialMerkleTree getPartialMerkleTree()
required when multi-transaction signing is utilised.