anchor.diff:      NextIV = next_iv(T, IV),
       {T, CS0#cipher_state{iv=NextIV}};
   
  -block_cipher(Fun, BlockSz, #cipher_state{key=Key, iv=IV} = CS0,
  +block_cipher(Fun, BlockSz, #cipher_state{key=Key, iv=IV, state = IV_Cache0} = CS0,
   	     Mac, Fragment, {3, N})
     when N == 2; N == 3 ->
  -    NextIV = random_iv(IV),
  +    IV_Size = byte_size(IV),
  +    <<NextIV:IV_Size/binary, IV_Cache/binary>> =
  +        case IV_Cache0 of
  +            <<>> ->
  +                random_bytes(IV_Size bsl 5); % 32 IVs
  +            _ ->
  +                IV_Cache0
  +        end,
       L0 = build_cipher_block(BlockSz, Mac, Fragment),
       L = [NextIV|L0],
       T = Fun(Key, IV, L),
  -    {T, CS0#cipher_state{iv=NextIV}}.
  +    {T, CS0#cipher_state{iv=NextIV, state = IV_Cache}}.
   
   %%--------------------------------------------------------------------
   -spec decipher(cipher_enum(), integer(), #cipher_state{}, binary(), 
  
positive.code:         PadLen ->
              binary:copy(<<PadLen>>, PadLen + 1)
      end.
  
  random_iv(IV) ->
      IVSz = byte_size(IV),
      random_bytes(IVSz).
  
  next_iv(Bin, IV) ->
      BinSz = byte_size(Bin),
  
negative.code: cipher_init(?CHACHA20_POLY1305, IV, Key) ->
      #cipher_state{iv = IV, key = Key, tag_len = 16};
  cipher_init(_BCA, IV, Key) ->
      %% Initialize random IV cache, not used for aead ciphers
      #cipher_state{iv = IV, key = Key, state = <<>>}.
  
  nonce_seed(Seed, CipherState) ->
      CipherState#cipher_state{nonce = Seed}.
  