【问题标题】:Multiplicative inverse in Charm CryptoCharm Crypto 中的乘法逆
【发布时间】:2017-10-01 13:30:43
【问题描述】:

在 Charm Crypto 中,我将如何获得 ZR 的乘法逆?我大致有以下代码:

a = group.random(G)
e = group.random(ZR)
x = a ** e
somestuff()
y = x ** (1/e)

a 不是故意存储的。然而,虽然-e 可以很好地获得加法逆,但似乎没有合适的方法来获得乘法逆。

【问题讨论】:

    标签: python cryptography modular-arithmetic charm-crypto


    【解决方案1】:

    不确定你的意思。 1/e 是 Charm Crypto 中正确的模逆。这是一个完整的例子:

    >>> from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair
    >>> group = PairingGroup('SS512')
    >>> a = group.random(G1)
    >>> a
    [2580989876233721415297389560556166670922761116088625446257120303747454767083854114997254567159052287206977413471899062293779511058710074633103823400659019, 5996565379972917992663126989138580820515927146496218666993731728783513412956887506732385903379922348877197471677004946545491932261438787373567446770237791]
    >>> e = group.random(ZR)
    >>> x = a ** e
    >>> x
    [6891729780372399189041525470592995101919015470165150216677136432042436097937961533731911650601678002293909918119625724503886943879739773465990776556262311, 1548281541526614042816533932120191809063134798488215929407179466331621937371141709171095414449680510602430538669648224266688052566354236898986673964076468]
    >>> y = x ** (1/e)
    >>> y
    [2580989876233721415297389560556166670922761116088625446257120303747454767083854114997254567159052287206977413471899062293779511058710074633103823400659019, 5996565379972917992663126989138580820515927146496218666993731728783513412956887506732385903379922348877197471677004946545491932261438787373567446770237791]
    >>> y == a
    True
    

    也许somestuff() 更改xe 以某种方式不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多