Package org.xrpl.xrpl4j.keypairs
Class DefaultKeyPairService
- java.lang.Object
-
- org.xrpl.xrpl4j.keypairs.AbstractKeyPairService
-
- org.xrpl.xrpl4j.keypairs.DefaultKeyPairService
-
- All Implemented Interfaces:
KeyPairService
public class DefaultKeyPairService extends AbstractKeyPairService
AKeyPairService
that delegates to specificKeyPairService
implementations.
-
-
Field Summary
-
Fields inherited from class org.xrpl.xrpl4j.keypairs.AbstractKeyPairService
addressCodec, signer
-
-
Constructor Summary
Constructors Constructor Description DefaultKeyPairService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyPair
deriveKeyPair(String seed)
Derive a public/private keypair from a Base58Check encoded 16 byte seed.String
generateSeed(UnsignedByteArray entropy)
Generates a seed from the given entropy, encoded withVersionType.ED25519
.static KeyPairService
getInstance()
Get a JVM wide instance of thisKeyPairService
.String
sign(UnsignedByteArray message, String privateKey)
Sign a message using the given private key.boolean
verify(UnsignedByteArray message, String signature, String publicKey)
Verify that the signature is valid, based on the message that was signed and the public key.-
Methods inherited from class org.xrpl.xrpl4j.keypairs.AbstractKeyPairService
deriveAddress, deriveAddress, generateSeed, sign, verify
-
-
-
-
Method Detail
-
getInstance
public static KeyPairService getInstance()
Get a JVM wide instance of thisKeyPairService
.- Returns:
- A
DefaultKeyPairService
.
-
generateSeed
public String generateSeed(UnsignedByteArray entropy)
Generates a seed from the given entropy, encoded withVersionType.ED25519
. Seeds can be generated using secp255k1, but all new seeds generated by this client use the ED25519 algorithm.- Parameters:
entropy
- AnUnsignedByteArray
containing the bytes of entropy to encode into a seed.- Returns:
- An ED25519 encoded 16 byte seed value, encoded in Base58Check.
-
deriveKeyPair
public KeyPair deriveKeyPair(String seed)
Description copied from interface:KeyPairService
Derive a public/private keypair from a Base58Check encoded 16 byte seed.
-
sign
public String sign(UnsignedByteArray message, String privateKey)
Description copied from interface:KeyPairService
Sign a message using the given private key.- Parameters:
message
- AnUnsignedByteArray
with an arbitrary message.privateKey
- The hexadecimal encoded private key used to sign the transaction.- Returns:
- The signed message, in hexadecimal form.
-
verify
public boolean verify(UnsignedByteArray message, String signature, String publicKey)
Description copied from interface:KeyPairService
Verify that the signature is valid, based on the message that was signed and the public key.- Parameters:
message
- The arbitrary message that was signed with a private key.signature
- The hexadecimal encodedString
containing the signature to verify.publicKey
- The hexadecimal encoded public key derived from the private key that was used to sign the message.- Returns:
- true if the signature is valid, false if not.
-
-