deserializePublicKey function

ASEPublicKey deserializePublicKey(
  1. String path
)

Deserializes the public key from a JSON file The file should contain a JSON object with the keys 'A' and 'b'.

Implementation

ASEPublicKey deserializePublicKey(String path) {
  if (!isPathSafe(path)) {
    throw ArgumentError('Unsafe file path');
  }

  final file = File(path);
  if (!file.existsSync()) {
    throw FileSystemException('File not found', path);
  }

  if (file.lengthSync() > 1024 * 1024) {
    throw FileSystemException('File too large', path);
  }

  var m = jsonDecode(file.readAsStringSync());
  return deserializePublicKeyFromJson(m);
}