create static method

Future<NoiseXXPattern> create(
  1. bool isInitiator,
  2. SimpleKeyPair staticKeys
)

Creates a new NoiseXXPattern instance

Implementation

static Future<NoiseXXPattern> create(bool isInitiator, SimpleKeyPair staticKeys) async {
  // Generate ephemeral keys
  final ephemeralKeys = await X25519().newKeyPair();

  // Initialize symmetric state
  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);
}