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 CryptoSignException("Invalid key bytes length.", details: {
"length": keyBytes.length,
"Excepted":
"${Ed25519KholawKeysConst.privKeyByteLen} or ${Ed25519KeysConst.privKeyByteLen}"
});
}
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,
privateKey: keyBytes,
type: algorithm);
return CardanoSigner._(signingKey);
}