Class AbstractDelegatedSignatureService
java.lang.Object
org.xrpl.xrpl4j.crypto.core.signing.AbstractDelegatedSignatureService
- All Implemented Interfaces:
DelegatedPublicKeyProvider
,DelegatedSignatureService
,DelegatedTransactionSigner
,DelegatedTransactionVerifier
public abstract class AbstractDelegatedSignatureService
extends Object
implements DelegatedSignatureService
An abstract implementation of
DelegatedSignatureService
with common functionality that sub-classes can
utilize.-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractDelegatedSignatureService
(DelegatedTransactionSigner delegatedTransactionSigner, DelegatedTransactionVerifier delegatedTransactionVerifier) Required-args constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetPublicKey
(KeyMetadata keyMetadata) Accessor for the public-key corresponding to the supplied key meta-data.<T extends Transaction>
SignaturemultiSign
(KeyMetadata keyMetadata, T transaction) Obtain a multi-sig signature for the supplied transaction usingkeyMetadata
.sign
(KeyMetadata keyMetadata, UnsignedClaim unsignedClaim) Obtain a signature for the supplied unsigned payment channel claim using the private-key that corresponds tokeyMetadata
.<T extends Transaction>
SingleSingedTransaction<T>sign
(KeyMetadata keyMetadata, T transaction) Obtain a signature for the supplied transaction using the private-key that corresponds tokeyMetadata
.<T extends Transaction>
booleanverifyMultiSigned
(Set<SignatureWithKeyMetadata> signatureWithKeyMetadataSet, T unsignedTransaction) Verify that all signers have properly signed theunsignedTransaction
.<T extends Transaction>
booleanverifyMultiSigned
(Set<SignatureWithKeyMetadata> signatureWithKeyMetadataSet, T unsignedTransaction, int minSigners) Verify thatminSigners
from the collection of public keys have supplied signatures for the given theunsignedTransaction
.<T extends Transaction>
booleanverifySingleSigned
(SignatureWithKeyMetadata signatureWithKeyMetadata, T unsignedTransaction) TransactionVerifier the supplied digital-signature to ensure that it was constructed using the private-key corresponding topublicKey
.
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
AbstractDelegatedSignatureService
public AbstractDelegatedSignatureService(DelegatedTransactionSigner delegatedTransactionSigner, DelegatedTransactionVerifier delegatedTransactionVerifier) Required-args constructor.- Parameters:
delegatedTransactionSigner
- ADelegatedTransactionSigner
to sign transactions.delegatedTransactionVerifier
- ADelegatedTransactionVerifier
to verify signatures.
-
-
Method Details
-
getPublicKey
Description copied from interface:DelegatedPublicKeyProvider
Accessor for the public-key corresponding to the supplied key meta-data. This method exists to support implementations that hold private-key material internally, yet need a way for external callers to determine the actual public key for signature verification or other purposes.- Specified by:
getPublicKey
in interfaceDelegatedPublicKeyProvider
- Parameters:
keyMetadata
- AKeyMetadata
for a key-pair.- Returns:
- A
PublicKey
.
-
sign
public <T extends Transaction> SingleSingedTransaction<T> sign(KeyMetadata keyMetadata, T transaction) Description copied from interface:DelegatedTransactionSigner
Obtain a signature for the supplied transaction using the private-key that corresponds tokeyMetadata
.- Specified by:
sign
in interfaceDelegatedTransactionSigner
- Type Parameters:
T
- The type of the transaction to be signed.- Parameters:
keyMetadata
- AKeyMetadata
that describes the public/private Keypair to use for signing operations.transaction
- TheTransaction
to sign.- Returns:
- A
SingleSingedTransaction
containing binary data that can be submitted to the XRP Ledger in order to effect a transaction.
-
sign
Description copied from interface:DelegatedTransactionSigner
Obtain a signature for the supplied unsigned payment channel claim using the private-key that corresponds tokeyMetadata
.- Specified by:
sign
in interfaceDelegatedTransactionSigner
- Parameters:
keyMetadata
- AKeyMetadata
that describes the public/private Keypair to use for signing operations.unsignedClaim
- TheUnsignedClaim
to sign.- Returns:
- A
SingleSingedTransaction
containing binary data that can be submitted to the XRP Ledger in order to effect a transaction.
-
multiSign
Description copied from interface:DelegatedTransactionSigner
Obtain a multi-sig signature for the supplied transaction usingkeyMetadata
.- Specified by:
multiSign
in interfaceDelegatedTransactionSigner
- Type Parameters:
T
- The typeTransaction
to be signed.- Parameters:
keyMetadata
- AKeyMetadata
that refers to a private key that can be used to signtransaction
.transaction
- TheTransaction
to sign.- Returns:
- A
SingleSingedTransaction
of typeDelegatedTransactionSigner
containing everything related to a signed transaction.
-
verifySingleSigned
public <T extends Transaction> boolean verifySingleSigned(SignatureWithKeyMetadata signatureWithKeyMetadata, T unsignedTransaction) Description copied from interface:DelegatedTransactionVerifier
TransactionVerifier the supplied digital-signature to ensure that it was constructed using the private-key corresponding topublicKey
.- Specified by:
verifySingleSigned
in interfaceDelegatedTransactionVerifier
- Type Parameters:
T
- ATransaction
.- Parameters:
signatureWithKeyMetadata
- ASignatureWithKeyMetadata
that contains a signature and a public key that can be used to verify the transaction signature.unsignedTransaction
- ADelegatedTransactionVerifier
that was signed.- Returns:
true
if the signature is valid and verified;false
otherwise.
-
verifyMultiSigned
public <T extends Transaction> boolean verifyMultiSigned(Set<SignatureWithKeyMetadata> signatureWithKeyMetadataSet, T unsignedTransaction) Description copied from interface:DelegatedTransactionVerifier
Verify that all signers have properly signed theunsignedTransaction
.- Specified by:
verifyMultiSigned
in interfaceDelegatedTransactionVerifier
- Type Parameters:
T
- The actual type ofTransaction
.- Parameters:
signatureWithKeyMetadataSet
- ASet
ofSignatureWithKeyMetadata
used for verification.unsignedTransaction
- TheTransaction
of typeDelegatedTransactionVerifier
that was signed.- Returns:
true
if a minimum number of signatures are valid for the supplied transaction;false
otherwise.
-
verifyMultiSigned
public <T extends Transaction> boolean verifyMultiSigned(Set<SignatureWithKeyMetadata> signatureWithKeyMetadataSet, T unsignedTransaction, int minSigners) Description copied from interface:DelegatedTransactionVerifier
Verify thatminSigners
from the collection of public keys have supplied signatures for the given theunsignedTransaction
.- Specified by:
verifyMultiSigned
in interfaceDelegatedTransactionVerifier
- Type Parameters:
T
- The actual type ofTransaction
.- Parameters:
signatureWithKeyMetadataSet
- ASet
ofSignatureWithKeyMetadata
used for verification.unsignedTransaction
- The transaction of typeDelegatedTransactionVerifier
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.
-