findAlgorithm static method
Finds the XRP key algorithm based on the given key bytes.
This method takes the key bytes as input and determines the XRP key algorithm based on the validity of the key bytes for different algorithms.
Implementation
static XRPKeyAlgorithm findAlgorithm(List<int> keyBytes) {
if (keyBytes.length == XrpKeyConst.privateKeyWithPrefix) {
final keyPrefix = keyBytes.sublist(0, 1);
if (bytesEqual(keyPrefix, XrpKeyConst.secpPrivateKey)) {
return XRPKeyAlgorithm.secp256k1;
} else if (bytesEqual(keyPrefix, XrpKeyConst.ed255PrivateKeyPrefix)) {
return XRPKeyAlgorithm.ed25519;
}
}
throw ArgumentError(
"cannot find key algorithm please check algorithm argrument");
}