Questions tagged [chinese-remainder-theorem]

The Chinese remainder theorem is a result about congruences in number theory and its generalizations in abstract algebra. In its basic form, the Chinese remainder theorem will determine a number n that when divided by some given divisors leaves given remainders.

28 questions
7
votes
4 answers

How to calculate D for RSA encryption from P,Q and E

I am trying to find D using P,Q and E (Dp, Dq and (p-1mod q) are available too). According to this answer and this answer and update for this question using following method I should get D. To test this I generated Key pair and tried to calculate…
AaA
  • 3,600
  • 8
  • 61
  • 86
6
votes
3 answers

Mapping RSA Encryption Parameters from CRT (Chinese remainder theorem) to .NET format

I need to implement RSA encryption/decryption using C# I have a private key with following parameters: mod n, exponent, p, q, dP, dQ, and (p-1mod q) Above parameters are explained in Chinese remainder algorithm However C#.NET implementation of the…
AaA
  • 3,600
  • 8
  • 61
  • 86
5
votes
3 answers

Restore a number from several its remainders (chinese remainder theorem)

I have a long integer number, but it is stored not in decimal form, but as set of remainders. So, I have not the N number, but set of such remainders: r_1 = N % 2147483743 r_2 = N % 2147483713 r_3 = N % 2147483693 r_4 = N % 2147483659 r_5 = N %…
osgx
  • 90,338
  • 53
  • 357
  • 513
5
votes
2 answers

Functional python -- why does only one of these generators require list() to work?

In computing the Chinese Remainder theorem from a vector of tuples (residue, modulus) the following code fails : c = ((1,5),(3,7),(11,13),(19,23)) def crt(c): residues, moduli = zip(*c) N = product(moduli) complements =…
5
votes
1 answer

Modulo and remainder (Chinese remainder theorem) in MATLAB

How do I find the least possible value in Matlab, given the modulo values and its remainder values in an array? for example: A=[ 23 90 56 36] %# the modulo values B=[ 1 3 37 21] %# the remainder values which leads to the answer 93; which is the…
Jey
  • 61
  • 1
  • 2
4
votes
2 answers

Minimize the remainder in the chinese remainder theorem

I have multiple sets containing multiple congruences. I am trying to find the smallest remainder when applying the Chinese remainder theorem on one item from each set. For example with 2 sets: Set 1: 7x + 1 7x + 3 Set 2: 11x 11x + 2 11x +…
3
votes
2 answers

Chinese Remainder Theorem Haskell

I need to write a function or functions in Haskell that can solve the Chinese Remainder Theorem. It needs to be created with the following definition: crt :: [(Integer, Integer)] -> (Integer, Integer) That the answer looks like >crt [(2,7), (0,3),…
JMV12
  • 965
  • 1
  • 20
  • 52
3
votes
1 answer

Encode a sequence of numbers as a single number -- use chinese remainder theorem

I need to encode a sequence S of an arbitrary number of elements (but finite) with an whole number K, and be able to decode K in order to obtain back the initial sequence. I need to do it such that a computer be able to cope good with the number…
alinsoar
  • 15,386
  • 4
  • 57
  • 74
1
vote
1 answer

TypeError float object cannot be interpreted as an integer

I'm trying to get the result in hex format, but I get the error "TypeError: 'float' object cannot be interpreted as an integer!" 39 d = chinese_remainder(a, n) ---> 40 number = hex(d) 41 print(number) Code: import functools # Euclidean…
JDop
  • 25
  • 1
  • 4
1
vote
0 answers

Arithmetic with Large Integers using Chinese Remainder Theorem

This is done by Python Suppose we represent the sum of a collection of exponentiation operations as a list of tuples, where each tuple contains two integers: the base and the exponent. For example, the list [(2,4),(3,5),(-6,3)] represents the sum of…
1
vote
1 answer

Calculating inverse Mod where Mod is not prime

I want to calculate value of F(N) = (F(N-1) * [((N-R+1)^(N-R+1))/(R^R)]) mod M for given values of N,R and M. Here A^B shows A power B and NOT any Bitwise operation Here M need not to be prime.How to approach this question?Please help because if M…
somu Boy
  • 19
  • 5
1
vote
1 answer

inverse Function works properly, but if works after while loops it produces wrong answers

I try to implement Chinese remainder theorem, for doing this I should find multiplicative inverse of some numbers. Function works properly, but if it works after while loops it produces wrong…
aylin
  • 101
  • 10
1
vote
1 answer

CRT implementation in Haskell

I'm trying to get the Chinese Remainder Theorem algorithm to work, so I've been trawling online looking for help. I'm trying to just get this example of the CRT in haskell to compile, but I'm getting these errors. I've implemented my own extGCD…
1
vote
0 answers

The most efficient way to calculate nCr mod M in cases when M isn't prime

I have always faced lots of questions on online coding platforms dealing with nCr mod M where M is usually a prime. In the cases where it is not, we usually prefer to use the Chinese remainder theorem Could we do this more easily than the Chinese…
Kavish Dwivedi
  • 735
  • 6
  • 24
1
vote
2 answers

modular exponentiation in Java using eulers totient and the chinese remainder theorem

Edit - clarified I'm trying to implement modular exponentiation in Java using lagrange and the chinese remainder theorem. For example, if N is 55, having been given the prime factors 5 and 11, phi is 40, so I know there are 40 numbers co-prime to N…
Saf
  • 517
  • 1
  • 9
  • 24
1
2