Skip to content

Instantly share code, notes, and snippets.

@liu246542
Created March 22, 2019 06:48
Show Gist options
  • Save liu246542/294a2f055e9a877de68b5c80873f44dc to your computer and use it in GitHub Desktop.
Save liu246542/294a2f055e9a877de68b5c80873f44dc to your computer and use it in GitHub Desktop.
论文里面测试代码
from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair
def test_pair():
trials = 10
group = PairingGroup("SS512")
h = group.random(G1)
i = group.random(G2)
assert group.InitBenchmark(), "failed to initialize benchmark"
group.StartBenchmark(["CpuTime","RealTime","Pair"])
for a in range(trials):
n = pair(h, i)
group.EndBenchmark()
msmtDict = group.GetGeneralBenchmarks()
return msmtDict['CpuTime']/trials
T = []
for i in range(1000):
T.append(test_pair())
print(sum(T)/len(T))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment