简体   繁体   English

Charm Crypto中的乘法逆

[英]Multiplicative inverse in Charm Crypto

In Charm Crypto, how would I go about getting at the multiplicative inverse for ZR ? 在Charm Crypto中,我如何获得ZR的乘法逆? I have roughly the following code: 我大致有以下代码:

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

where a is not stored on purpose. 其中a不是故意存储的。 However while -e works fine to get the additive inverse there doesn't seem to be a proper way to get at the multiplicative inverse. 然而,虽然-e可以很好地得到加法逆,但似乎没有一种正确的方法来得到乘法逆。

Not sure what you mean. 不明白你的意思。 1/e is the proper modular inverse in Charm Crypto. 1/e是Charm Crypto中适当的模块化逆。 Here is a full example: 这是一个完整的例子:

>>> 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

Perhaps somestuff() changes x or e in some way that it doesn't work. 也许somestuff()以某种方式改变xe它不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM