CardanoSigner.fromKeyBytes constructor
Factory method to create an SolanaSigner instance from key bytes.
Implementation
factory CardanoSigner.fromKeyBytes(List<int> keyBytes) {
if (keyBytes.length != Ed25519KholawKeysConst.privKeyByteLen &&
keyBytes.length != Ed25519KeysConst.privKeyByteLen) {
throw ArgumentException.invalidOperationArguments(
"CardanoSigner",
name: "signature",
reason: "Invalid secret key.",
);
}
final algorithm =
keyBytes.length == Ed25519KholawKeysConst.privKeyByteLen
? EllipticCurveTypes.ed25519Kholaw
: EllipticCurveTypes.ed25519;
// Create an EDDSA private key from the key bytes using the ED25519 curve.
final EDDSAPrivateKey signingKey = EDDSAPrivateKey(
generator: CryptoSignerConst.generatorED25519,
secretKey: keyBytes,
type: algorithm,
);
return CardanoSigner._(signingKey);
}