createForTesting static method

  1. @visibleForTesting
Future<NoiseXXPattern> createForTesting(
  1. bool isInitiator,
  2. SimpleKeyPair staticKeys,
  3. SimpleKeyPair ephemeralKeys
)

Implementation

@visibleForTesting
static Future<NoiseXXPattern> createForTesting(
  bool isInitiator,
  SimpleKeyPair staticKeys,
  SimpleKeyPair ephemeralKeys,
) async {
  final protocolName = utf8.encode(PROTOCOL_NAME);
  _validateProtocolName(protocolName);

  final initialHash = await Sha256().hash(protocolName);
  final tempKey = SecretKey(Uint8List.fromList(initialHash.bytes));

  final state = HandshakeState(
    chainKey: Uint8List.fromList(initialHash.bytes),
    handshakeHash: Uint8List.fromList(initialHash.bytes),
    state: XXHandshakeState.initial,
    sendKey: tempKey,
    recvKey: tempKey,
  );

  return NoiseXXPattern._(isInitiator, staticKeys, ephemeralKeys, state);
}