Skip to content

Instantly share code, notes, and snippets.

@guidovranken
Created June 3, 2022 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guidovranken/ceff1bbeab9d6090f10804aa6d4c4f94 to your computer and use it in GitHub Desktop.
Save guidovranken/ceff1bbeab9d6090f10804aa6d4c4f94 to your computer and use it in GitHub Desktop.
#include <openssl/bn.h>
int main(void)
{
BIGNUM* base = BN_new();
BIGNUM* exp = BN_new();
BIGNUM* mod = BN_new();
BIGNUM* res = BN_new();
BN_CTX* ctx = BN_CTX_new();
BN_dec2bn(&base, "20602718629153394716678609007360754677019714782193251481833419525142182531659985037375070145510293237451017584368188091022126870685458069386237266432");
BN_dec2bn(&exp, "8646072172522723289285451395118059203226220595031337220714754488877073198942910827355405547677066194881316003968028602339018029787285256477955928674214125145757261813765102077120020348662047672265095112624335465933081227062331813594682567167259126154448775411057717829892899552539746417397392416890836277632427437055529986997006820099338268068377251201349532353680948060922111930260394664050003003654368102452352273873481173153359585865722725318169777425255629520204948217518067094262242112075226295920696251939344853053208819302872840610752872144342123601537039239354965189825655718008007946773918830209280760162278549183583082249056931166836116718584854013841694330561794057354776029867680382661135711000884449136573773656137205919514869924930043472955000228778118938591742662869743579876653820668514868247108313228733103819133590051602904692615309920939766405631229364589753843692155767643140598499012894986173110469695294347745237203661602654263676945217797095576633206253654871197530579757157076065656487023622879415601310488589609473450781446678374514119737461996794505992473232044768143050745661356289270068972329218153684210439640656456264233238821640906879585767792806284858997038517766792713587858347690857594430127530497755675501835457934713019869369183746187284724196828455343063145565748453642815051272810258412045503262186450055469313921781797951593637543595084220299255122218933027487600353459193779261673762128674110812168847316118677201115555482618739827073367016605952251219258606425733973111613003291163385682069065076033985575821516884132193520348830266645775978360435523615012220328350379708694886136420847354628823199487644652792866541784246485547136054205057873060575621213133250908654660234028376849815483857444244931221465418477111226060117909794454086266935428556351338990306778901346014544630058163976944668367136512654438528115613200373468860734757807505904042794312772600343430009506842937916979060650660556888761731141607875141048621808852232599987400492318188051817545837239793541264379674405818550205796671564770118451099562355329527568458443580033281640823777259286583721123229900535924928147349395462494755378680822759367089024361225258572966856405622105571262504596050512646741890213097084657039058112352742");
BN_dec2bn(&mod, "65217794507498284936929595904182101586640070918206415302952825748181333802289344613133621268930484603009814379302693417284819444828923226393652383809");
if ( BN_mod_exp_mont_consttime(res, base, exp, mod, ctx, NULL) == 1 ) {
printf("%s\n", BN_bn2dec(res));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment