Class AbstractSignatureService<P extends PrivateKeyable>
- All Implemented Interfaces:
SignatureService<P>,TransactionSigner<P>,TransactionVerifier
- Direct Known Subclasses:
BcSignatureService
SignatureService with common functionality that subclasses can utilize.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSignatureService(AbstractTransactionSigner<P> abstractTransactionSigner, AbstractTransactionVerifier abstractTransactionVerifier) Required-args Constructor, for testing.AbstractSignatureService(SignatureUtils signatureUtils) Required-args Constructor. -
Method Summary
Modifier and TypeMethodDescriptionabstract PublicKeyderivePublicKey(P privateKey) Helper method to derive a public key from a private key.protected abstract SignatureecDsaSign(P privateKey, UnsignedByteArray signableTransactionBytes) Does the actual work of computing a signature using a secp256k1 private-key, as locatable usingprivateKey.protected abstract booleanecDsaVerify(PublicKey publicKey, UnsignedByteArray transactionBytes, Signature signature) Verify a signature.protected abstract SignatureedDsaSign(P privateKey, UnsignedByteArray signableTransactionBytes) Does the actual work of computing a signature using a ed25519 private-key, as locatable usingprivateKey.protected abstract booleanedDsaVerify(PublicKey publicKey, UnsignedByteArray transactionBytes, Signature signature) Verify a signature.<T extends Transaction>
SignatureGet a signature for the supplied unsigned transaction using the suppliedTransactionSigner.multiSignInner(P privateKeyable, Batch batchTransaction) Obtain a multi-signature for a batch transaction using the suppliedTransactionSigner.sign(P privateKeyable, UnsignedClaim unsignedClaim) Signs a claim for usage in a Payment Channel.sign(P privateKeyable, Attestation attestation) Sign attestations for cross-chain account creation or transfers.<T extends Transaction>
SingleSignedTransaction<T> Get a transaction with a single-sig usingprivateKeyable.Get a signature for a batch transaction using the suppliedTransactionSigner.<T extends Transaction>
booleanVerify the supplied digital-signature to ensure that it was constructed using the private-key corresponding tosignerPublicKey.<T extends Transaction>
booleanverifyMultiSigned(Set<Signer> signerSet, T unsignedTransaction, int minSigners) Verify thatminSignersfrom the collection of public keys have supplied signatures for a given signed transaction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xrpl.xrpl4j.crypto.signing.TransactionSigner
multiSignToSignerMethods inherited from interface org.xrpl.xrpl4j.crypto.signing.TransactionVerifier
verifyMultiSigned
-
Constructor Details
-
AbstractSignatureService
Required-args Constructor.- Parameters:
signatureUtils- ASignatureUtils.
-
AbstractSignatureService
protected AbstractSignatureService(AbstractTransactionSigner<P> abstractTransactionSigner, AbstractTransactionVerifier abstractTransactionVerifier) Required-args Constructor, for testing.- Parameters:
abstractTransactionSigner- AAbstractTransactionSigner.abstractTransactionVerifier- AAbstractTransactionVerifier.
-
-
Method Details
-
sign
Description copied from interface:TransactionSignerGet a transaction with a single-sig usingprivateKeyable.- Specified by:
signin interfaceTransactionSigner<P extends PrivateKeyable>- Type Parameters:
T- The typeTransactionto be signed.- Parameters:
privateKeyable- TheTransactionSignerused to signtransaction.transaction- TheTransactionto sign.- Returns:
- A
SingleSignedTransactionof typeTransactionSignercontaining everything related to a signed transaction.
-
sign
Description copied from interface:TransactionSignerSign attestations for cross-chain account creation or transfers.This method will be marked
Betauntil the featureXChainBridge amendment is enabled on mainnet. Its API is subject to change.- Specified by:
signin interfaceTransactionSigner<P extends PrivateKeyable>- Parameters:
privateKeyable- TheTransactionSignerused to signattestation.attestation- AnAttestationto sign.- Returns:
- A
Signature.
-
sign
Description copied from interface:TransactionSignerSigns a claim for usage in a Payment Channel.- Specified by:
signin interfaceTransactionSigner<P extends PrivateKeyable>- Parameters:
privateKeyable- ATransactionSignerused for signing.unsignedClaim- AnUnsignedClaim.- Returns:
- A
Signature.
-
signInner
Description copied from interface:TransactionSignerGet a signature for a batch transaction using the suppliedTransactionSigner.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
Betauntil the featureBatch amendment is enabled on mainnet. Its API is subject to change.- Specified by:
signInnerin interfaceTransactionSigner<P extends PrivateKeyable>- Parameters:
privateKeyable- TheTransactionSignerused to signbatchTransaction.batchTransaction- TheBatchtransaction to sign.- Returns:
- A
Signaturefor the batch transaction.
-
multiSign
Description copied from interface:TransactionSignerGet a signature for the supplied unsigned transaction using the suppliedTransactionSigner. The primary reason this method's signature diverges fromTransactionSigner.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 thatSignatureUtilscan 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:
multiSignin interfaceTransactionSigner<P extends PrivateKeyable>- Type Parameters:
T- The type of the transaction to be signed.- Parameters:
privateKeyable- TheTransactionSignerused to signtransaction.transaction- TheTransactionto sign.- Returns:
- A
Signaturefor the transaction.
-
multiSignInner
Description copied from interface:TransactionSignerObtain a multi-signature for a batch transaction using the suppliedTransactionSigner.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
Betauntil the featureBatch amendment is enabled on mainnet. Its API is subject to change.- Specified by:
multiSignInnerin interfaceTransactionSigner<P extends PrivateKeyable>- Parameters:
privateKeyable- TheTransactionSignerused to signbatchTransaction.batchTransaction- TheBatchtransaction to sign.- Returns:
- A
Signaturefor the batch transaction with multi-sig format.
-
verify
Description copied from interface:TransactionVerifierVerify the supplied digital-signature to ensure that it was constructed using the private-key corresponding tosignerPublicKey.- Specified by:
verifyin interfaceTransactionVerifier- Type Parameters:
T- The actual type ofTransaction.- Parameters:
signer- ASignerused for verification.unsignedTransaction- TheTransactionof typeTransactionVerifierthat was signed.- Returns:
trueif the signature is valid and verified;falseotherwise.
-
verifyMultiSigned
public <T extends Transaction> boolean verifyMultiSigned(Set<Signer> signerSet, T unsignedTransaction, int minSigners) Description copied from interface:TransactionVerifierVerify thatminSignersfrom the collection of public keys have supplied signatures for a given signed transaction.- Specified by:
verifyMultiSignedin interfaceTransactionVerifier- Type Parameters:
T- The actual type ofTransaction.- Parameters:
signerSet- ASetofSignerobjects used for verification.unsignedTransaction- The transaction of typeTransactionVerifierthat was signed.minSigners- The minimum number of signatures required to form a quorum.- Returns:
trueif a minimum number of signatures are valid for the supplied transaction;falseotherwise.
-
edDsaSign
Does the actual work of computing a signature using a ed25519 private-key, as locatable usingprivateKey.- Parameters:
privateKey- AAbstractSignatureServiceused for signing.signableTransactionBytes- AUnsignedByteArrayto sign.- Returns:
- A
Signaturewith data that can be used to submit a transaction to the XRP Ledger.
-
ecDsaSign
Does the actual work of computing a signature using a secp256k1 private-key, as locatable usingprivateKey.- Parameters:
privateKey- AAbstractSignatureServiceused for signing.signableTransactionBytes- AUnsignedByteArrayto sign.- Returns:
- A
Signaturewith 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- ThePublicKeyused to verify the signed transaction.transactionBytes- AnUnsignedByteArraycontaining the bytes of the transaction that was signed.signature- ASignatureover the transaction.- Returns:
trueif the signature is valid;falseotherwise.
-
ecDsaVerify
protected abstract boolean ecDsaVerify(PublicKey publicKey, UnsignedByteArray transactionBytes, Signature signature) Verify a signature.- Parameters:
publicKey- APublicKey.transactionBytes- AnUnsignedByteArraycontaining the bytes of the transaction that was signed.signature- ASignatureover the transaction.- Returns:
trueif the signature is valid;falseotherwise.
-
derivePublicKey
Helper method to derive a public key from a private key.- Specified by:
derivePublicKeyin interfaceTransactionSigner<P extends PrivateKeyable>- Parameters:
privateKey- An instance ofPrivateKey.- Returns:
- A corresponding
PublicKey.
-