Class AbstractSignatureService<P extends PrivateKeyable>

java.lang.Object
org.xrpl.xrpl4j.crypto.signing.AbstractSignatureService<P>
All Implemented Interfaces:
SignatureService<P>, TransactionSigner<P>, TransactionVerifier
Direct Known Subclasses:
BcSignatureService

public abstract class AbstractSignatureService<P extends PrivateKeyable> extends Object implements SignatureService<P>
An abstract implementation of SignatureService with common functionality that subclasses can utilize.
  • Constructor Details

  • Method Details

    • sign

      public <T extends Transaction> SingleSignedTransaction<T> sign(P privateKeyable, T transaction)
      Description copied from interface: TransactionSigner
      Get a transaction with a single-sig using privateKeyable.
      Specified by:
      sign in interface TransactionSigner<P extends PrivateKeyable>
      Type Parameters:
      T - The type Transaction to be signed.
      Parameters:
      privateKeyable - The TransactionSigner used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A SingleSignedTransaction of type TransactionSigner containing everything related to a signed transaction.
    • sign

      public Signature sign(P privateKeyable, Attestation attestation)
      Description copied from interface: TransactionSigner
      Sign attestations for cross-chain account creation or transfers.

      This method will be marked Beta until the featureXChainBridge amendment is enabled on mainnet. Its API is subject to change.

      Specified by:
      sign in interface TransactionSigner<P extends PrivateKeyable>
      Parameters:
      privateKeyable - The TransactionSigner used to sign attestation.
      attestation - An Attestation to sign.
      Returns:
      A Signature.
    • sign

      public Signature sign(P privateKeyable, UnsignedClaim unsignedClaim)
      Description copied from interface: TransactionSigner
      Signs a claim for usage in a Payment Channel.
      Specified by:
      sign in interface TransactionSigner<P extends PrivateKeyable>
      Parameters:
      privateKeyable - A TransactionSigner used for signing.
      unsignedClaim - An UnsignedClaim.
      Returns:
      A Signature.
    • signInner

      public Signature signInner(P privateKeyable, Batch batchTransaction)
      Description copied from interface: TransactionSigner
      Get a signature for a batch transaction using the supplied TransactionSigner.

      Per XLS-0056, BatchSigners sign a specific format: HashPrefix::batch + flags + count + inner tx IDs. This differs from both single-signing and multi-signing.

      This method will be marked Beta until the featureBatch amendment is enabled on mainnet. Its API is subject to change.

      Specified by:
      signInner in interface TransactionSigner<P extends PrivateKeyable>
      Parameters:
      privateKeyable - The TransactionSigner used to sign batchTransaction.
      batchTransaction - The Batch transaction to sign.
      Returns:
      A Signature for the batch transaction.
    • multiSign

      public <T extends Transaction> Signature multiSign(P privateKeyable, T transaction)
      Description copied from interface: TransactionSigner
      Get a signature for the supplied unsigned transaction using the supplied TransactionSigner. The primary reason this method's signature diverges from TransactionSigner.sign(PrivateKeyable, Transaction) is that for multi-sign scenarios, the interstitially signed transaction is always discarded. Instead, a quorum of signatures is needed, and then that quorum is submitted to the ledger with the unsigned transaction. Thus, getting a multi-signed transaction here is not useful and is not returned from this interface. Note that SignatureUtils can be used to assemble and obtain the bytes for a multi-signed transaction (these diverge slightly from the bytes of a single-signed transaction).
      Specified by:
      multiSign in interface TransactionSigner<P extends PrivateKeyable>
      Type Parameters:
      T - The type of the transaction to be signed.
      Parameters:
      privateKeyable - The TransactionSigner used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A Signature for the transaction.
    • multiSignInner

      public Signature multiSignInner(P privateKeyable, Batch batchTransaction)
      Description copied from interface: TransactionSigner
      Obtain a multi-signature for a batch transaction using the supplied TransactionSigner.

      This is used when a multi-sig account acts as a BatchSigner with nested Signers. Per rippled's checkBatchMultiSign, this uses batch serialization (HashPrefix::batch + flags + count + tx IDs) followed by appending the signer's account ID.

      This method will be marked Beta until the featureBatch amendment is enabled on mainnet. Its API is subject to change.

      Specified by:
      multiSignInner in interface TransactionSigner<P extends PrivateKeyable>
      Parameters:
      privateKeyable - The TransactionSigner used to sign batchTransaction.
      batchTransaction - The Batch transaction to sign.
      Returns:
      A Signature for the batch transaction with multi-sig format.
    • verify

      public <T extends Transaction> boolean verify(Signer signer, 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:
      signer - A Signer used for verification.
      unsignedTransaction - The Transaction of type TransactionVerifier that was signed.
      Returns:
      true if the signature is valid and verified; false otherwise.
    • verifyMultiSigned

      public <T extends Transaction> boolean verifyMultiSigned(Set<Signer> signerSet, 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:
      verifyMultiSigned in interface TransactionVerifier
      Type Parameters:
      T - The actual type of Transaction.
      Parameters:
      signerSet - A Set of Signer objects 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(P privateKey, UnsignedByteArray signableTransactionBytes)
      Does the actual work of computing a signature using a ed25519 private-key, as locatable using privateKey.
      Parameters:
      privateKey - A AbstractSignatureService used for signing.
      signableTransactionBytes - A 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(P privateKey, UnsignedByteArray signableTransactionBytes)
      Does the actual work of computing a signature using a secp256k1 private-key, as locatable using privateKey.
      Parameters:
      privateKey - A AbstractSignatureService used for signing.
      signableTransactionBytes - A 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

      public abstract PublicKey derivePublicKey(P privateKey)
      Helper method to derive a public key from a private key.
      Specified by:
      derivePublicKey in interface TransactionSigner<P extends PrivateKeyable>
      Parameters:
      privateKey - An instance of PrivateKey.
      Returns:
      A corresponding PublicKey.