anchor.diff:          crypto:generate_key(Type, Params),
       #key_pair{public = Public, private = Private}.
   
  +
   cancel_timer(undefined) ->
       ok;
   cancel_timer(Timer) ->
  +    erlang_cancel_timer(Timer).
  +
  +start_rekey_timer(Time) ->
  +    Timer = erlang:start_timer(Time, self(), rekey_time),
  +    {timeout, Timer, rekey_time}.
  +
  +cancel_rekey_timer({timeout, Timer, rekey_time}) ->
  +    erlang_cancel_timer(Timer).
  +
  +erlang_cancel_timer(Timer) ->
       case erlang:cancel_timer(Timer) of
           false ->
               receive
  
positive.code:                           rekey_key = PubKeyB,
                            key = Key2A, iv = IV2A},
                      %%
                      StartCleartext = [R2B, R3B, <<RekeyInterval:32>>],
                      StartMsgLen = TagLen + iolist_size(StartCleartext),
                      StartAAD = <<StartMsgLen:32>>,
                      {StartCiphertext, StartTag} =
  
negative.code:                 hmac_key_iv(
                    HmacAlgo, SharedSecret, [Key, IVSalt, IV],
                    KeyLen, IVSaltLen + 6),
              Params#params{
                key = Key_1, iv = {IVSalt_1, IVNo_1},
                rekey_msg = start_rekey_timer(Params#params.rekey_time)};
          SendError ->
              SendError
      end.
      
  encrypt_chunk(
    #params{
       aead_cipher = AeadCipher,
  