fromSecretKey static method

Ed25519Keypair fromSecretKey(
  1. Uint8List secretKey, {
  2. bool skipValidation = true,
})

Implementation

static Ed25519Keypair fromSecretKey(Uint8List secretKey,
    {bool skipValidation = true}) {
  var privateKey = ed.PrivateKey(secretKey);
  var publicKey = ed.public(privateKey);

  if (!skipValidation) {
    final message =
    utf8.encode("@accumulate/accumulate.js-validation-v1").asUint8List();
    final sig = ed.sign(privateKey, message);
    bool valid = ed.verify(publicKey, message, sig);
    if (!valid) {
      throw Exception('Invalid Private key');
    }
  }

  Keypair keypair = Keypair();
  keypair.secretKey = privateKey.bytes.asUint8List();
  keypair.publicKey = publicKey.bytes.asUint8List();
  keypair.mnemonic = "";

  return Ed25519Keypair(keypair);
}