XrpSigner.fromKeyBytes constructor
XrpSigner.fromKeyBytes(
- List<
int> keyBytes, - EllipticCurveTypes algorithm
Factory method to create an XrpSigner instance from key bytes and algorithm type.
keyBytes The bytes representing the private key.
algorithm The elliptic curve type of the private key.
Implementation
factory XrpSigner.fromKeyBytes(
List<int> keyBytes,
EllipticCurveTypes algorithm,
) {
switch (algorithm) {
case EllipticCurveTypes.ed25519:
// Create an EDDSA private key from the key bytes using the ED25519 curve.
final signingKey = EDDSAPrivateKey(
generator: CryptoSignerConst.generatorED25519,
secretKey: keyBytes,
type: EllipticCurveTypes.ed25519,
);
return XrpSigner._(signingKey, null);
case EllipticCurveTypes.secp256k1:
return XrpSigner._(
null,
Secp256k1SigningKey.fromBytes(keyBytes: keyBytes),
);
default:
throw ArgumentException.invalidOperationArguments(
"XrpSigner",
name: "algorithm",
reason: "Unsupported secret key algorithm.",
);
}
}