0

I have a decryption key in hex as follows with a modulo of n:

d = 0x74D806F9F3A62BAE331FFE3F0A68AFE35B3D2E4794148AACBC26AA381CD7D30D
n = 0xDCBFFE3E51F62E09CE7032E2677A78946A849DC4CDDE3A4D0CB81629242FB1A5

The goal is to have a message and use the d key to "sign" it.

So I know this means m^d % n = c

I tried the following code:

m = "I owe you $2000"
def enc(m):
    s = ""
    for ch in m:
        sig = (ord(ch)**d) % n

The program will just continuously run with no output. Obviously the number is very large so how do we deal with this. I tried using floats and got an overflow error which was expected.

  • are you sure you want to sign the whole message and not just the hash of it? you are encrypting the message... – hiro protagonist Aug 27 '19 at 09:25
  • Possible duplicate of [How to implement modular exponentiation?](https://stackoverflow.com/questions/48738650/how-to-implement-modular-exponentiation) – Sneftel Aug 27 '19 at 09:25

0 Answers0