Class BcDerivedKeySignatureService
- All Implemented Interfaces:
SignatureService<PrivateKeyReference>,TransactionSigner<PrivateKeyReference>,TransactionVerifier
SignatureService that uses an in-memory secret value to deterministically create a seed
value that can then be used to generate XRPL private keys. This implementation keeps a cache of instances of
SignatureService that it delegates to based upon the PrivateKeyReference supplied on each call.
WARNING: This implementation stores private seed-generation material in-memory. Depending on your security
requirements, consider a different implementation of SignatureService.
-
Constructor Summary
ConstructorsConstructorDescriptionBcDerivedKeySignatureService(ServerSecretSupplier serverSecretSupplier) Required-args Constructor.BcDerivedKeySignatureService(ServerSecretSupplier serverSecretSupplier, com.github.benmanes.caffeine.cache.CaffeineSpec caffeineSpec) Required-args Constructor. -
Method Summary
Modifier and TypeMethodDescriptionderivePublicKey(PrivateKeyReference privateKeyable) Accessor for the public-key corresponding to the supplied key meta-data.<T extends Transaction>
SignaturemultiSign(PrivateKeyReference privateKeyReference, T transaction) Get a signature for the supplied unsigned transaction using the suppliedTransactionSigner.multiSignInner(PrivateKeyReference privateKeyable, Batch batchTransaction) Obtain a multi-signature for a batch transaction using the suppliedTransactionSigner.<T extends Transaction>
SignermultiSignToSigner(PrivateKeyReference privateKeyable, T transaction) Obtain a signature for the supplied unsigned transaction using the suppliedTransactionSigner.sign(PrivateKeyReference privateKeyReference, UnsignedClaim unsignedClaim) Signs a claim for usage in a Payment Channel.sign(PrivateKeyReference privateKeyReference, Attestation attestation) Sign attestations for cross-chain account creation or transfers.<T extends Transaction>
SingleSignedTransaction<T> sign(PrivateKeyReference privateKeyReference, T transaction) Get a transaction with a single-sig usingprivateKeyable.signInner(PrivateKeyReference privateKeyable, Batch batchTransaction) 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.TransactionVerifier
verifyMultiSigned
-
Constructor Details
-
BcDerivedKeySignatureService
Required-args Constructor.- Parameters:
serverSecretSupplier- AServerSecretSupplierthat can be used to generate seed values, which can
-
BcDerivedKeySignatureService
public BcDerivedKeySignatureService(ServerSecretSupplier serverSecretSupplier, com.github.benmanes.caffeine.cache.CaffeineSpec caffeineSpec) Required-args Constructor.- Parameters:
serverSecretSupplier- AServerSecretSupplierthat can be used to generate seed values, which cancaffeineSpec- ACaffeineSpecthat can be initialized externally to configure the Caffeine cache constructed by this service.
-
-
Method Details
-
derivePublicKey
Description copied from interface:TransactionSignerAccessor 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:
derivePublicKeyin interfaceTransactionSigner<PrivateKeyReference>- Parameters:
privateKeyable- APrivateKeyableto derive a public key from.- Returns:
- A
PublicKey.
-
sign
public <T extends Transaction> SingleSignedTransaction<T> sign(PrivateKeyReference privateKeyReference, T transaction) Description copied from interface:TransactionSignerGet a transaction with a single-sig usingprivateKeyable.- Specified by:
signin interfaceTransactionSigner<PrivateKeyReference>- Type Parameters:
T- The typeTransactionto be signed.- Parameters:
privateKeyReference- TheTransactionSignerused to signtransaction.transaction- TheTransactionto sign.- Returns:
- A
SingleSignedTransactionof typeTransactionSignercontaining everything related to a signed transaction.
-
sign
Description copied from interface:TransactionSignerSigns a claim for usage in a Payment Channel.- Specified by:
signin interfaceTransactionSigner<PrivateKeyReference>- Parameters:
privateKeyReference- ATransactionSignerused for signing.unsignedClaim- AnUnsignedClaim.- Returns:
- A
Signature.
-
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<PrivateKeyReference>- Parameters:
privateKeyReference- TheTransactionSignerused to signattestation.attestation- AnAttestationto sign.- Returns:
- A
Signature.
-
multiSign
public <T extends Transaction> Signature multiSign(PrivateKeyReference privateKeyReference, T transaction) 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<PrivateKeyReference>- Type Parameters:
T- The type of the transaction to be signed.- Parameters:
privateKeyReference- TheTransactionSignerused to signtransaction.transaction- TheTransactionto sign.- Returns:
- A
Signaturefor the transaction.
-
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<PrivateKeyReference>- Parameters:
privateKeyable- TheTransactionSignerused to signbatchTransaction.batchTransaction- TheBatchtransaction to sign.- Returns:
- A
Signaturefor the batch 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<PrivateKeyReference>- Parameters:
privateKeyable- TheTransactionSignerused to signbatchTransaction.batchTransaction- TheBatchtransaction to sign.- Returns:
- A
Signaturefor the batch transaction with multi-sig format.
-
multiSignToSigner
public <T extends Transaction> Signer multiSignToSigner(PrivateKeyReference privateKeyable, T transaction) Description copied from interface:TransactionSignerObtain a signature for the supplied unsigned transaction using the suppliedTransactionSigner.As is the case with
TransactionSigner.multiSign(PrivateKeyable, Transaction), 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 need and then that quorum is submitted to the ledger with the unsigned transaction. Thus, obtaining 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).This method is nearly identical to
TransactionSigner.multiSign(PrivateKeyable, Transaction)except that its return-type is aSigner, which is more convenient for submitting transactions to the XRP Ledger. Note however that this method internally callsTransactionSigner.derivePublicKey(PrivateKeyable), which in certain remote-key configurations (e.g., storing keys in a remote HSM) involves a potentially expensive remote call to the HSM. In most scenarios, the public key will already be available, so callers of this method should consider usingTransactionSigner.multiSign(PrivateKeyable, Transaction)instead if public-key derivation is a performance concern.- Specified by:
multiSignToSignerin interfaceTransactionSigner<PrivateKeyReference>- Type Parameters:
T- The type of the transaction to be signed.- Parameters:
privateKeyable- TheTransactionSignerused to signtransaction.transaction- TheTransactionto sign.- Returns:
- A
Signaturefor the transaction.
-
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.
-