打卡_paillier



  • Paillier加密算法(Paillier Pascal)
    基于复合剩余类的困难性问题

    具体过程:
    2b3f75ed-28a0-4800-8f25-6b9c0e9c5afd-image.png

    算法讲解:https://blog.b3ale.cn/2019/10/24/Python实现Paillier加密解密算法/

    接着上次安恒月赛的not_rsa,就用到Paillier加密算法
    大佬的wp:
    http://ggb0n.cool/2020/04/25/安恒月赛DSACTF/
    https://blog.csdn.net/zhang14916/article/details/105764126/

    import gmpy2
    c=29088911054711509252215615231015162998042579425917914434962376243477176757448053722602422672251758332052330100944900171067962180230120924963561223495629695702541446456981441239486190458125750543542379899722558637306740763104274377031599875275807723323394379557227060332005571272240560453811389162371812183549
    n=6401013954612445818165507289870580041358569258817613282142852881965884799988941535910939664068503367303343695466899335792545332690862283029809823423608093
    p= 80006336965345725157774618059504992841841040207998249416678435780577798937819
    q = 80006336965345725157774618059504992841841040207998249416678435780577798937447
    assert p*q==n
    phi=(p-1)*(q-1)
    c1=pow(c,phi,n*n)-1
    c2=c1/n
    m=(c2*gmpy2.invert(phi,n))%n
    print hex(m)[2:].decode("hex")
    

Log in to reply