A bird is recognized by its plumage… or professional protection against spam
Often, each of us has a desire to find people similar to ourselves (in a professional sense), but at the same time, posting our contact information on public networks can generate a lot of spam (oh, those ancient canned goods).
In this case, general knowledge comes to the rescue – educational qualifications in a professional field – which will not allow the “uninitiated” to use the data.
Please accept this simple privacy protection for mathematicians and programmers.
Let's remember one of the first asymmetric encryption systems, RSA – what is its basis?
Simple fact:
if for number m the value of the Euler function is known E(m),
then for anyone a != 0 performed a ^ E(m) % m = 1
Which means if p And E(m) are relatively simple, that is, they exist c And dsuch that c*p + d*E(m) = 1And s = c % m
then for anyone a from [0m)[0m) performed a ^ (s*p) % m = a
Let's take advantage of this.
Let's sketch out a program in js (I hope those reading this in a browser know how to log into the console)
function split(x) {
for (let i = 2n; i * i <= x; i++) {
let j = x / i;
if (i * j == x) return [i, j];
}
}
function toPrimes(x) {
let arr = [x];
let primes = [];
while (arr.length > 0) {
let x = arr.pop();
let s = split(x);
if (s) s.forEach(y => arr.push(y));
else primes.push(x);
}
primes.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
return primes;
}
function euler(p) {
let z = 1n;
let map = new Map();
p.forEach(x => {
let value = 0n;
if (map.has(x)) { value = map.get(x); map.delete(x); }
value++;
map.set(x, value);
});
for (let [key, value] of map.entries()) {
z *= pow(key, value) - 1n;
}
return z;
}
function xgcd(a, b) {
if (!b) return [1n, 0n];
let [c, d] = xgcd(b, a % b);
let q = a / b;
return [d, c - d * q];
}
function pow(x, y) {
if (!y) return 1n;
let h = y / 2n;
let z = pow(x, h);
let r = (z * z);
if (y % 2n) r = (r * x);
return r;
}
function powmod(x, y, m) {
if (!y) return 1n;
let h = y / 2n;
let z = powmod(x, h, m);
let r = (z * z) % m;
if (y % 2n) r = (r * x) % m;
return r;
}
let p = 3n;
let q = 13n;
let m = pow(10n, q) + 1n;
let primes = toPrimes(m);
let z = euler(primes);
let primes2 = toPrimes(z);
while (primes2.find(x => x == p)) p += 2n;
let [c, d] = xgcd(p, z);
let s = c >= 0n ? c : (m + c);
function get(x) {
let t = powmod(x, s, m);
console.log(`(${t} ^ ${p}) % (10 ^ ${q} + 1) =`, powmod(t, p, m));
}
get(81234567890n);
We launch, check, receive
(275491122648 ^ 7) % (10 ^ 13 + 1) = 81234567890n
Does the English typewriter work?