getNonceInternal method

Uint8List getNonceInternal(
  1. String nonceEndpoint,
  2. String privateKey
)

Implementation

Uint8List getNonceInternal(String nonceEndpoint, String privateKey) {
  var nonceHash = crypto.keccak256(
      crypto.keccak256(Uint8List.fromList(utf8.encode(nonceEndpoint))));
  print("nonceHash : " + nonceHash.toString());

  crypto.MsgSignature msgSignature =
      crypto.sign(nonceHash, crypto.hexToBytes(privateKey));

  final header = msgSignature.v & 0xFF;
  var recId = header - 27;
  var signature = Uint8List.fromList(([
    ...padUint8ListTo32(crypto.intToBytes(msgSignature.r)),
    ...padUint8ListTo32(crypto.intToBytes(msgSignature.s)),
    recId
  ]));

  print("signature : " + signature.toString());

  return signature;
}