s of message
m
m
m. Print valid
if the signature is valid. Print invalid
otherwise.
- Randomly pick a number as a faked message
m
′
m^\prime
m′, and verify the signature
s
s
s of message
m
′
m^\prime
m′. Print valid
if the signature is valid. Print invalid
otherwise.
- Randomly pick a number as a faked signature
s
′
s^\prime
s′, and verify the signature
s
′
s^\prime
s′ of message
m
m
m. Print valid
if the signature is valid. Print invalid
otherwise.
Note that in this program, you may only include third-party codes or libraries for:
- Miller-Rabin Test
- Extended Euclidean Algorithm
Example Input & Output
Input:
34862844108815430278935886114814204661242105806196134451262421197958661737288465541172280522822644267285105893266043422314800759306377373320298160258654603531159702663926160107285223145666239673833817786345065431976764139550904726039902450456522584204556470321705267433321819673919640632299889369457498214445
Output:
Private key:
N: 60578014255102269896133371904627262317416253087521326961353447386111108220456127698087451094233400895389904195033258942460533045725424252051031082346623918833115880605331217845541371778050413570487118811797680786863916249631173243202415281126677535724142072672389239932425514746354116788337452709735978693441
d: 29794267204372868920195293823377577521348286669753768926422253485197790892996900859124258444603569195973796199037022534122349660497314477050901363975617785986341374781520104383687018770714375371190852092718547427166813248293087229107819441125188332290624176181241072609675470769160255268721140521999754996495
Public key:
N: 605780142551022698961333719046272623174162530875213269613534473861111082204561276980874510942334008953899041950332589424605330457254242520510310823466239188331158806053312178455413717780504135704