Skip to content

Instantly share code, notes, and snippets.

View ZM-J's full-sized avatar

ZM.J ZM-J

View GitHub Profile
import qrcode
from qrcode.util import *
def hack_put(self, num, length):
if num == 0:
num = 233 # make a fake length
for i in range(length):
self.put_bit(((num >> (length - i - 1)) & 1) == 1)
qrcode.util.BitBuffer.put = hack_put
m = 3
# Generate test data set
scale_factor = 1
p_size = int(1000 * scale_factor)
l_size = int(55 * scale_factor)
d_size = int(105 * scale_factor)
M = 2^l_size
N, e = (44774502335951608354043148360684114092901940301155357314508676399067538307546121753785009844275454594381602690061553832466871574728524408152400619047820736137949166290404514747591817206669966103047443912935755873432503095952914080827536130899968275165557303493867755627520568588808534411526058896791373252974606364861105086430729757064078675811147972536205086402752245214343186536177015741922559575575911278873118556603923689408629477875537332177644886701517140711134017511229202430437068095342526435886609381176269251580339549071944830141516001532825295594908434587285225415103472279090325281062442217, 2962436618322746296564555839295409407448535387680745149714754992709302519711805128044593054376217085376957396220024766930528633321241043962426214210929583943358466398955441981034126682006307490874329555351779035414962387302816228275135261333318121847
@mcieno
mcieno / howgrave-seifert.sage
Last active March 22, 2021 05:56
Howgrave-Graham and Seifert's small private exponent attack on common modulus RSA (2 public exponents).
# -*- coding: utf8 -*-
# See: https://eprint.iacr.org/2009/037.pdf
N = 24402191928494981635640497435944050736451453218629774561432653700273120014058697415669445779441226800209154604159648942665855233706977525093135734838825433023506185915211877990448599462290859092875150657461517275171867229282791419867655722945527203477335565212992510088077874648530075739380783193891617730212062455173395228143660241234491822044677453330325054451661281530021397747260054593565182679642519767415355255125571875708238139022404975788807868905750857687120708529622235978672838872361435045431974203089535736573597127746452000608771150171882058819685487644883286497700966396731658307013308396226751130001733
e1 = 4046316324291866910571514561657995962295158364702933460389468827072872865293920814266515228710438970257021065064390281148950759462687498079736672906875128944198140931482449741147988959788282715310307170986783402655196296704611285447752149956531303574680859541910243014672391229934386132475024308686852032924357952489090295552491