anchor.diff:  -spec enable_fips_mode(Enable) -> Result when Enable :: boolean(),
                                                 Result :: boolean().
   enable_fips_mode(Enable) ->
  -    enable_fips_mode_nif(Enable).
  -
  -enable_fips_mode_nif(Enable) -> ?nif_stub.
  +    OldState = info_fips(),
  +    Result = enable_fips_mode_nif(Enable),
  +    case info_fips() of
  +        OldState ->
  +            %% No state change, so no need to touch the curve's cache
  +            Result;
  +        NewState ->
  +            %% State change (not_enabled -> enabled  or  enabled -> not_enabled)
  +            NewCurves =
  +                case application:get_env(?MODULE, var_name(NewState)) of
  +                    {ok,Cs} when is_list(Cs) ->
  +                        %% We have been in this state before, and saved the
  +                        %% list for that state.
  +                        Cs;
  +                    _ ->
  +                        %% We have not been in this state before. Rebuild and save.
  +                        %% But first maintain the local enable_fips_mode_nif cache:
  +                        case application:get_env(?MODULE, var_name(OldState)) of
  +                            undefined ->
  +                                %% Make the next state change fast:
  +                                OldCs = application:get_env(?MODULE,?CURVES), 
  +                                application:set_env(?MODULE, var_name(OldState), OldCs);
  +                            _ ->
  +                                ok
  +                        end,
  +                        %% Now rebuild the list by hard work:
  +                        application:unset_env(?MODULE, ?CURVES), % This will force a re-build
  +                        %% Re-build curves cache. Not strictly needed here.
  +                        Cs = supports(curves),
  +                        %% We came here because var(NewState) wasn't set, so make the
  +                        %% next state change fast:
  +                        application:set_env(?MODULE, var_name(NewState), Cs),
  +                        Cs
  +                end,
  +            application:set_env(?MODULE, ?CURVES, NewCurves), % So the call to supports(curves) will be fast
  +            Result
  +    end.
  +
  +var_name(enabled) -> '$curves-fips-enabled$';
  +var_name(not_enabled) -> '$curves-fips-not_enabled$'.
  +
  +
  +enable_fips_mode_nif(_) -> ?nif_stub.
   
   %%%================================================================
   %%%
  
positive.code: 
  do_exor(_A, _B) -> ?nif_stub.
  
  hash_algorithms() -> ?nif_stub.
  pubkey_algorithms() -> ?nif_stub.
  cipher_algorithms() -> ?nif_stub.
  
negative.code:                              Curves :: [ec_named_curve() | edwards_curve_dh() | edwards_curve_ed()],
                               RSAopts :: [rsa_sign_verify_opt() | rsa_opt()] .
  
  -define(CURVES, '$curves$').
  
  supports(hashs)       -> hash_algorithms();
  supports(public_keys) -> pubkey_algorithms();
  supports(ciphers)     -> cipher_algorithms();
  supports(macs)        -> mac_algorithms();
  supports(curves)      -> cached_curve_algorithms();
  supports(rsa_opts)    -> rsa_opts_algorithms().
  
  
  