signOwnerChange method

Future<MsgSignature> signOwnerChange(
  1. String privateKeyFrom,
  2. String identityDid,
  3. String newDid
)

Implementation

Future<MsgSignature> signOwnerChange(
  String privateKeyFrom,
  String identityDid,
  String newDid,
) async {
  var privateKey = EthPrivateKey.fromHex(privateKeyFrom).privateKey;
  var nonceToSign = await nonce(await identityOwner(identityDid));
  var paddedNonce = nonceToSign!.toRadixString(16).padLeft(64, '0');

  List<int> message = [];
  message.addAll(hexToBytes("0x19"));
  message.addAll(hexToBytes("0x00"));
  message.addAll(contractAddress.addressBytes);
  message.addAll(hexToBytes(paddedNonce));
  message.addAll(_didToAddress(identityDid).addressBytes);
  message.addAll("changeOwner".codeUnits);
  message.addAll(_didToAddress(newDid).addressBytes);

  var messageHash = keccak256(Uint8List.fromList(message));
  MsgSignature signature = sign(messageHash, privateKey);

  return signature;
}