Secp256k1Layout.fromPrivateKey constructor

Secp256k1Layout.fromPrivateKey({
  1. required ETHPrivateKey privateKey,
  2. required List<int> message,
  3. required int instructionIndex,
})

Create an secp256k1 layout with a private key.

Implementation

factory Secp256k1Layout.fromPrivateKey(
    {required ETHPrivateKey privateKey,
    required List<int> message,
    required int instructionIndex}) {
  final address = privateKey.publicKey().toAddress();
  final signature = privateKey.sign(message, hashMessage: true);
  final sigBytes = signature.toBytes(false);
  return Secp256k1Layout.fromEthAddress(
      address: address,
      message: message,
      signature: sigBytes.sublist(0, ETHSignerConst.ethSignatureLength),
      recoveryId: sigBytes[ETHSignerConst.ethSignatureLength],
      instructionIndex: instructionIndex);
}