encryptEnvelope static method

Map<String, dynamic> encryptEnvelope(
  1. String plaintext,
  2. String senderId,
  3. String receiverId, {
  4. String? timestamp,
  5. int windowSeconds = 120,
  6. int seq = 1,
})

Create a canonical envelope

Implementation

static Map<String, dynamic> encryptEnvelope(
  String plaintext,
  String senderId,
  String receiverId, {
  String? timestamp,
  int windowSeconds = 120,
  int seq = 1,
}) {
  final time = timestamp ?? DateTime.now().toUtc().toIso8601String();
  final key = keyResonance(senderId, timestamp: time);
  final ct = _drum(utf8.encode(plaintext), time);
  final envelope = {
    'senderId': senderId,
    'receiverId': receiverId,
    'timestamp': time,
    'window': windowSeconds,
    'seq': seq,
    'ciphertext': base64.encode(ct),
  };
  envelope['seal'] = _seal(envelope, key, time);
  return envelope;
}