XRPPrivateKey.fromEntropy constructor
XRPPrivateKey.fromEntropy(
- String entropy, {
- XRPKeyAlgorithm algorithm = XRPKeyAlgorithm.ed25519,
Factory constructor for creating an XRP private key from entropy.
entropy
is the entropy for generating the private key.
algorithm
specifies the cryptographic algorithm, with ED25519 being the default.
Implementation
factory XRPPrivateKey.fromEntropy(String entropy,
{XRPKeyAlgorithm algorithm = XRPKeyAlgorithm.ed25519}) {
final entropyBytes = BytesUtils.fromHexString(entropy);
/// Encode the seed using XRPAddressUtilities
XrpSeedUtils.encodeSeed(entropyBytes, algorithm);
switch (algorithm) {
case XRPKeyAlgorithm.secp256k1:
final derive = XrpSeedUtils.deriveKeyPair(entropyBytes);
final privateKey = Secp256k1PrivateKeyEcdsa.fromBytes(derive);
return XRPPrivateKey._(privateKey, algorithm);
default:
final privateBytes = XrpSeedUtils.deriveED25519(entropyBytes);
final prive = Ed25519PrivateKey.fromBytes(privateBytes);
return XRPPrivateKey._(prive, algorithm);
}
}