IPrivateKey.fromBytes constructor

IPrivateKey.fromBytes(
  1. List<int> keyBytes,
  2. EllipticCurveTypes type
)

Factory method for creating an IPrivateKey instance from a byte array and an elliptic curve type.

Implementation

factory IPrivateKey.fromBytes(List<int> keyBytes, EllipticCurveTypes type) {
  switch (type) {
    case EllipticCurveTypes.nist256p1:
      return Nist256p1PrivateKey.fromBytes(keyBytes);
    case EllipticCurveTypes.ed25519:
      return Ed25519PrivateKey.fromBytes(keyBytes);
    case EllipticCurveTypes.ed25519Kholaw:
      return Ed25519KholawPrivateKey.fromBytes(keyBytes);
    case EllipticCurveTypes.ed25519Blake2b:
      return Ed25519Blake2bPrivateKey.fromBytes(keyBytes);
    case EllipticCurveTypes.ed25519Monero:
      return MoneroPrivateKey.fromBytes(keyBytes);
    case EllipticCurveTypes.sr25519:
      return Sr25519PrivateKey.fromBytes(keyBytes);

    default:
  }
  return Secp256k1PrivateKeyEcdsa.fromBytes(keyBytes);
}