XrpVerifier.fromKeyBytes constructor
XrpVerifier.fromKeyBytes(
- List<
int> keyBytes, - EllipticCurveTypes curve
Factory method to create an XrpVerifier instance from key bytes and curve type.
This factory method takes a list of key bytes keyBytes
and an EllipticCurveTypes curve
as input, and returns a new XrpVerifier instance based on the specified curve type and key bytes.
keyBytes
The bytes representing the public key.
curve
The elliptic curve type of the public key.
Implementation
factory XrpVerifier.fromKeyBytes(
List<int> keyBytes, EllipticCurveTypes curve) {
switch (curve) {
case EllipticCurveTypes.ed25519:
final pub = Ed25519PublicKey.fromBytes(keyBytes);
final verifyingKey = EDDSAPublicKey(
_XrpSignerConst.ed25519Generator, pub.compressed.sublist(1));
return XrpVerifier._(verifyingKey, null);
case EllipticCurveTypes.secp256k1:
final point = ProjectiveECCPoint.fromBytes(
curve: _XrpSignerConst.secp256.curve, data: keyBytes, order: null);
final verifyingKey = ECDSAPublicKey(_XrpSignerConst.secp256, point);
return XrpVerifier._(null, ECDSAVerifyKey(verifyingKey));
default:
throw MessageException(
"xrp signer support ${EllipticCurveTypes.secp256k1.name} or ${EllipticCurveTypes.ed25519} private key");
}
}