anchor.diff:  	end
       catch
   	error:E ->
  -	    io:fwrite("~p: ERROR: ~p~n~p~n",
  -		      [?MODULE, E, erlang:get_stacktrace()])
  +	    ?error("~p: ERROR: ~p~n~p~n",
  +		   [?MODULE, E, erlang:get_stacktrace()])
       end.
   %% authenticate(Socket, {server, ID, {M,F}}) ->
  -%%     ?dbg("authenticate, server side dynamic~n", []),
  +%%     ?debug("authenticate, server side dynamic~n", []),
   %%     St = init(ID, undefined, {M,F}),
   %%     await_first_challenge(Socket, St);
   %% authenticate(Socket, {server, ID, MyKey, TheirKey}) ->
  -%%     ?dbg("authenticate, server side~n", []),
  +%%     ?debug("authenticate, server side~n", []),
   %%     St = init(ID, MyKey, TheirKey),
   %%     await_first_challenge(Socket, St).
   
  
positive.code: 
  -define(TIMEOUT, 10000).
  
  -define(dbg(Fmt,A), io:fwrite("~p-~p: " ++ Fmt,[?MODULE,?LINE|A])).
  
  authenticate(Socket, Role, Opts) ->
      try
  	?dbg("authenticate, client side~n", []),
  	%% St = init(ID, MyKey, TheirKey),
  	St = init(Opts),
  	if Role == client ->
  
negative.code: 
  %% client (1)
  send_first_challenge(Socket, St) ->
      ?debug("Sending first challenge~n", []),
      {Bin, St1} = init_challenge(St),
      exo_socket:send(Socket, Bin),
      await_response(Socket, St1).
  
  %% server (1)
  await_first_challenge(Socket, St) ->
      ?debug("await_first_challenge~n", []),
      Data = recv(Socket),
      case recv_challenge(Data, St) of
  	error ->
  	    ?debug("auth error~n", []),
  	    error;
  	{Response, St1} ->
  	    ?debug("received good challenge~n", []),
  	    exo_socket:send(Socket, Response),
  	    await_ack(Socket, St1)
      end.
  
  %% client (2)
  await_response(Socket, St) ->
      ?debug("await_response~n", []),
      Data = recv(Socket),
      case recv_challenge(Data, St) of
  	error ->
  	    ?debug("auth error~n", []),
  	    error;
  	{Response, St1} ->
  	    ?debug("received good response - auth ok~n", []),
  	    exo_socket:send(Socket, Response),
  	    {ok, St1}
      end.
  
  %% server (2)
  await_ack(Socket, St) ->
      ?debug("await_ack~n", []),
      Data = recv(Socket),
      case recv_challenge(Data, St) of
  	error ->
  	    ?debug("auth error~n", []),
  	    error;
  	{_, St1} ->
  	    ?debug("received good ack - auth ok.~n", []),
  	    {ok, St1}
      end.
  
  