Remix.run Logo
fainpul 10 hours ago

In Prolog you can write rules (similar to functions in other languages) so that they work "both ways". Let's say you have this rule that defines how pace ("runner's speed") relates to distance and time:

  :- use_module(library(clpr)).

  pace(Km, Minutes, Pace) :-
    { Minutes = Km * Pace }.

Even though the rule only specifies how Minutes are calculated, Prolog can now also calculate the other values.

You can query it, giving unknowns an uppercase `Name`, and it will give you the possible values for it:

  pace(5, 24.5, Pace)
  pace(40, Min, 5)
  pace(Km, 24.5, 5)
  pace(Km, Time, 5)
  
You can try it here: https://swish.swi-prolog.org/

So if you had a rule that defines RSA key calculation this way, you could enter a key and get all valid solutions for the primes. But of course complex calculations still take a long time. I assume it's similar to a brute force attack in that way (Prolog has clever strategies to explore the solution space though).

Disclaimer: I'm not an expert in Prolog or cryptography, so this might not be 100% accurate.