Reversing MODULO operation ? system of equations

99 Views Asked by At

i have 1000 prime numbers p1 ... p1000 .. which i use to encode a value

 v % p1 = r1
 v % p2 = r2
 v % p3 = r3
 ....
 v % p1000 = r1000

then I pick the 20 PRIMES which gives the SMALLEST reminders and store them.

Later I want to be able to recover back the VALUE (or approximate value) by only having the 20 PRIMES available, and knowing they give the smallest reminders out of the 1000.

btw i still have access to the 1000 primes

if it also helps I pick the sequence of 1000 primes above number N ... and for ease of use I encode a NEW_VALUE = VALUE + BIGGEST_PRIME


  def encode(self, value) :
    mods = (value + self.max_prime) % self.primes
    return np.argsort(mods)[:20]

@lulu

finding multiple values that match the prime-mods, should be ok too ... not 100% but i suspect i will use values in range .. 1-100, 1-1000 or any other , so I can narrow it down to that range.

I dont want to , but If I have to ;(

... may be some sort of constraint satisfaction


my final goal is to generate sparse 1000 bit binary based the position of the small-reminder primes

 self.primes = np.array(nprimes(start=11,cnt=1000), dtype=DTYPE)
 np.random.shuffle(self.primes)

Looking for the decode() part !

1

There are 1 best solutions below

2
On BEST ANSWER

By the Chinese Remainder theorem, you can retrieve your number modulo the product of the twenty primes. That might be enough for your number.

If not, you are stuck because you can hypothesize any combination of remainders with the other primes (that are larger than the twenty remainders) and retrieve some number.