Class AbstractSignatureService

java.lang.Object
org.xrpl.xrpl4j.crypto.core.signing.AbstractSignatureService
All Implemented Interfaces:
SignatureService, TransactionSigner, TransactionVerifier

public abstract class AbstractSignatureService extends Object implements SignatureService
An abstract implementation of SignatureService with common functionality that sub-classes can utilize.
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

  • Method Details

    • sign

      public <T extends Transaction> SingleSingedTransaction<T> sign(PrivateKey privateKey, T transaction)
      Description copied from interface: TransactionSigner
      Obtain a signature for the supplied transaction using privateKey.
      Specified by:
      sign in interface TransactionSigner
      Type Parameters:
      T - The type Transaction to be signed.
      Parameters:
      privateKey - The PrivateKey used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A SingleSingedTransaction of type TransactionSigner containing everything related to a signed transaction.
    • sign

      public Signature sign(PrivateKey privateKey, UnsignedClaim unsignedClaim)
      Description copied from interface: TransactionSigner
      Signs a claim for usage in a Payment Channel.
      Specified by:
      sign in interface TransactionSigner
      Parameters:
      privateKey - A PrivateKey used for signing.
      unsignedClaim - An UnsignedClaim.
      Returns:
      A Signature.
    • multiSign

      public <T extends Transaction> Signature multiSign(PrivateKey privateKey, T transaction)
      Description copied from interface: TransactionSigner
      Obtain a signature for the supplied unsigned transaction using the supplied PrivateKey. The primary reason this method's signature diverges from TransactionSigner.sign(PrivateKey, Transaction) is that for multi-sign scenarios, the interstitially signed transaction is always discarded. Instead, a quorum of signatures is need and then that quorum is submitted to the ledger with the unsigned transaction. Thus, obtaining a multi-signed transaction here is not useful (instead, see TransactionUtils to construct a multisigned transaction).
      Specified by:
      multiSign in interface TransactionSigner
      Type Parameters:
      T - The type of the transaction to be signed.
      Parameters:
      privateKey - The PrivateKey used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A Signature for the transaction.
    • verify

      public <T extends Transaction> boolean verify(SignatureWithPublicKey signatureWithPublicKey, T unsignedTransaction)
      Description copied from interface: TransactionVerifier
      Verify the supplied digital-signature to ensure that it was constructed using the private-key corresponding to signerPublicKey.
      Specified by:
      verify in interface TransactionVerifier
      Type Parameters:
      T - The actual type of Transaction.
      Parameters:
      signatureWithPublicKey - A SignatureWithPublicKey used for verification.
      unsignedTransaction - The Transaction of type TransactionVerifier that was signed.
      Returns:
      true if the signature is valid and verified; false otherwise.
    • verify

      public <T extends Transaction> boolean verify(Set<SignatureWithPublicKey> signatureWithPublicKeys, T unsignedTransaction, int minSigners)
      Description copied from interface: TransactionVerifier
      Verify that minSigners from the collection of public keys have supplied signatures for a given signed transaction.
      Specified by:
      verify in interface TransactionVerifier
      Type Parameters:
      T - The actual type of Transaction.
      Parameters:
      signatureWithPublicKeys - A Set of SignatureWithPublicKey used for verification.
      unsignedTransaction - The transaction of type TransactionVerifier that was signed.
      minSigners - The minimum number of signatures required to form a quorum.
      Returns:
      true if a minimum number of signatures are valid for the supplied transaction; false otherwise.
    • edDsaSign

      protected abstract Signature edDsaSign(PrivateKey privateKey, UnsignedByteArray signableTransactionBytes)
      Does the actual work of computing a signature using an Ed25519 private-key, as locatable using privateKey.
      Parameters:
      privateKey - The PrivateKey to use for signing.
      signableTransactionBytes - The UnsignedByteArray to sign.
      Returns:
      A Signature with data that can be used to submit a transaction to the XRP Ledger.
    • ecDsaSign

      protected abstract Signature ecDsaSign(PrivateKey privateKey, UnsignedByteArray signableTransactionBytes)
      Does the actual work of computing a signature using a secp256k1 private-key, as locatable using privateKeyMetadata.
      Parameters:
      privateKey - The PrivateKey to use for signing.
      signableTransactionBytes - The UnsignedByteArray to sign.
      Returns:
      A Signature with data that can be used to submit a transaction to the XRP Ledger.
    • edDsaVerify

      protected abstract boolean edDsaVerify(PublicKey publicKey, UnsignedByteArray transactionBytes, Signature signature)
      Verify a signature.
      Parameters:
      publicKey - The PublicKey used to verify the signed transaction.
      transactionBytes - An UnsignedByteArray containing the bytes of the transaction that was signed.
      signature - A Signature over the transaction.
      Returns:
      true if the signature is valid; false otherwise.
    • ecDsaVerify

      protected abstract boolean ecDsaVerify(PublicKey publicKey, UnsignedByteArray transactionBytes, Signature signature)
      Verify a signature.
      Parameters:
      publicKey - A PublicKey.
      transactionBytes - An UnsignedByteArray containing the bytes of the transaction that was signed.
      signature - A Signature over the transaction.
      Returns:
      true if the signature is valid; false otherwise.
    • derivePublicKey

      protected abstract PublicKey derivePublicKey(PrivateKey privateKey)
      Helper method to derive a public key from a private key.
      Parameters:
      privateKey - An instance of PrivateKey.
      Returns:
      A corresponding PublicKey.
    • getSignatureUtils

      public SignatureUtils getSignatureUtils()
      Accessor for the SignatureUtils used by this class.
      Returns:
      A SignatureUtils used by this class.