2015-02-03 15:18:20 +0200 | received badge | ● Editor (source) |
2015-02-03 15:12:04 +0200 | asked a question | Issues with RSA CRT Recombination (coercion issue?) Hiya ! I got a little issue with Sage. I am trying to implement the CRT recombination of an RSA and i have a problem when trying to subtract two elements from 2 different rings. Basically, i have (with p and q prime): p = 0xe49d4b6d; q = 0x2120263d; N = 0x1d94fc884d4d26f9; d = 0x13b8a85a2fb5238b; dp = 0x9868dcf3; dq = 0x16156ed3; M = 0x1A5CB03B63ACBB40; M = M % N; Mp = M % p; Mq = M % q; Sp = pow(Mp, dp, p); Sq = pow(Mq, dq, q); iq = inverse_mod(q,p); tmp1 = Sp - Sq; ... Everything goes right until i try to compute (Sp-Sq)%p Apparently, because Sp is from the ring of integers modulo p and Sq from the ring of integers modulo q, the subtraction cannot be performed. Would anyone have an idea how to bypass that please? |