fetchRootKey method

  1. @override
Future<BinaryBlob> fetchRootKey()
override

By default, the agent is configured to talk to the main Internet Computer, and verifies responses using a hard-coded public key.

This function will instruct the agent to ask the endpoint for its public key, and use that instead. This is required when talking to a local test instance, for example.

Only use this when you are not talking to the main Internet Computer, otherwise you are prone to man-in-the-middle attacks! Do not call this function by default.

Implementation

@override
Future<BinaryBlob> fetchRootKey() async {
  // Hex-encoded version of the replica root key.
  rootKey = (await status())['root_key'] as Uint8List;
  return Future.value(rootKey);
}