本文整理汇总了Python中charm.toolbox.pairinggroup.PairingGroup.order方法的典型用法代码示例。如果您正苦于以下问题:Python PairingGroup.order方法的具体用法?Python PairingGroup.order怎么用?Python PairingGroup.order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charm.toolbox.pairinggroup.PairingGroup
的用法示例。
在下文中一共展示了PairingGroup.order方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import order [as 别名]
def setup(n, group_name = 'MNT159', simulated = False):
"""
Performs the setup algorithm for IPE.
This function samples the generators from the group, specified optionally by
"group_name". This variable must be one of a few set of strings specified by
Charm.
Then, it invokes the C program ./gen_matrices, which samples random matrices
and outputs them back to this function. The dimension n is supplied, and the
prime is chosen as the order of the group. Additionally, /dev/urandom is
sampled for a random seed which is passed to ./gen_matrices.
Finally, the function constructs the matrices that form the secret key and
publishes the pulbic marapeters and secret key (pp, sk).
"""
group = PairingGroup(group_name)
g1 = group.random(G1)
g2 = group.random(G2)
assert g1.initPP(), "ERROR: Failed to init pre-computation table for g1."
assert g2.initPP(), "ERROR: Failed to init pre-computation table for g2."
proc = Popen(
[
os.path.dirname(os.path.realpath(__file__)) + '/gen_matrices',
str(n),
str(group.order()),
"1" if simulated else "0",
""
],
stdout=PIPE
)
detB_str = proc.stdout.readline().decode()
B_str = proc.stdout.readline().decode()
Bstar_str = proc.stdout.readline().decode()
detB = int(detB_str)
B = parse_matrix(B_str, group)
Bstar = parse_matrix(Bstar_str, group)
pp = ()
sk = (detB, B, Bstar, group, g1, g2)
return (pp, sk)