PeerId.fromKeys constructor

PeerId.fromKeys({
  1. required Uint8List encryptionKey,
  2. required Uint8List signKey,
})

Implementation

factory PeerId.fromKeys({
  required Uint8List encryptionKey,
  required Uint8List signKey,
}) {
  if (encryptionKey.length != _keyLength) {
    throw const FormatException('Encryption key length is invalid.');
  }
  if (signKey.length != _keyLength) {
    throw const FormatException('Signing key length is invalid.');
  }

  final builder = BytesBuilder(copy: false)
    ..add(encryptionKey)
    ..add(signKey);

  return PeerId(value: builder.toBytes());
}