Score:1

Calculating RSA private key d

tj flag

Modulus n = 1024 bit

p * q = 1024 bit

phi_n = (p-1)*(q-1) = 1024 bit

When calculating key d the multiplicative inverse

d = inverse_mod(e, phi_n)

The result of d is 1022 bit long instead of 1024 bit long, which is stopping me to decrypting the cyphertext of 1023 bit, the calculation is done in sagemath, where am I doing wrong?

dave_thompson_085 avatar
cn flag
There is no requirement d be larger/longer than the ciphertext, only that n is. You haven't shown any computation so we don't know what you're doing wrong. Also d doesn't need to be e^-1 mod phi, it is sufficient to be e^-1 mod lambda (there are MANY existing Qs on this) and for an RSA modulus lambda is always shorter than phi by at least one bit and sometimes more (but not very much more).
Score:0
hk flag

Maybe you need to pad the $d$ with 0's at the start?

Score:0
sz flag

there is no problem in the bit size of the keys, for example

run the following little code several times and you'll notice a lot of time you get a shorter bit size length of $d$

 p,q = random_prime(2^512,lbound=2^511) , random_prime(2^512,lbound=2^511
 n = p*q
 phi_n=(p-1)*(q-1);
 d = inverse_mod(0x10001,phi_n)
 m = 11
 e= 0x10001
 c = Mod(m,n)^e
 print(c^d == m)
 print("d - number of bits:", d.nbits(), "\nn - number of bits: ", n.nbits())
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.