pullEx abstract method

SecretExStream<SecretStreamPlainMessage> pullEx({
  1. required Stream<SecretStreamCipherMessage> cipherStream,
  2. required SecureKey key,
})

Provides crypto_secretstream_xchacha20poly1305_(init_)pull.

Transforms the cipherStream of encrypted messages to a decrypted plain stream using crypto_secretstream_xchacha20poly1305_pull with the given key.

Unlike the C API, which requires manual state management etc., this API combines all the required parts into a single, simple dart stream. As a first step, crypto_secretstream_xchacha20poly1305_init_pull is used to generate the stream state from the key and the header, which is expected to be the first message that is added into cipherStream. After that, any cipher message (optionally with additional data) that is passed in the stream is encrypted with crypto_secretstream_xchacha20poly1305_push and the result returned as SecretExStream.

The stream also handles it's internal state gracefully and can react to tags and problems with the encryption, if the occur. It is also possible to explicitly rekey the stream via SecretExStream.rekey.

Note: It is required that the first message in the cipherStream is the header. If you created the stream with pushEx, this will aready be the case. When getting the stream from other sources, make sure to always pass in the header first. Also, if the last message of cipherStream does not have the SecretStreamMessageTag.finalPush tag, an error will be added to the returned stream before it gets closed. To change this behaviour, use createPullEx instead.

This method is basically a shortcut for createPullEx.bind(). Check the documentation of createPullEx if you need a transformer instead of a stream or need to adjust the finalization handling.

See https://libsodium.gitbook.io/doc/secret-key_cryptography/secretstream#decryption

Implementation

SecretExStream<SecretStreamPlainMessage> pullEx({
  required Stream<SecretStreamCipherMessage> cipherStream,
  required SecureKey key,
});