a portable and fast pairing-based cryptography library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mcl/docs/demo/pairing.html

87 lines
2.8 KiB

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>pairing sample</title>
<script type='text/javascript' src="./mclbn.js"></script>
<script type='text/javascript' src="./exported-mcl.js"></script>
<script type='text/javascript' src="./pairing.js"></script>
</script>
</head>
<body>
<h1>
See <a href="https://herumi.github.io/bls/demo/bls.html">BLS signature demo</a>. This page is obsolete.
</h1>
<div>
library status <span name="status">initializing...</span>
</div>
<h2>optimal Ate pairing over 256-bit BN curve</h2>
<button type="text" onclick="TestPairing()">test Pairing</button>
<div>pairing time : <span name="time_pairing">0</span>msec</div>
<div>G1 scalar mul : <span name="time_g1mul">0</span>msec</div>
<div>G2 scalar mul : <span name="time_g2mul">0</span>msec</div>
<hr>
<div>
a = <input type="text" name="a" value="3"><br>
b = <input type="text" name="b" value="4"><br>
ab = <span name="ab">0</span><br>
</div>
<div>
P = hashAndMapToG1(<input type="text" name="hash_P" value="abc">) = <span name="P">0</span><br>
Q = hashAndMapToG2(<input type="text" name="hash_Q" value="def">) = <span name="Q">0</span><br>
aP = <span name="aP">0</span><br>
bQ = <span name="bQ">0</span><br>
</div>
<hr>
<div>
e(P, Q) = <span name="ePQ">0</span><br>
e(aP, bQ) = <span name="eaPbQ">0</span><br>
e(P, Q)^ab = <span name="ePQab">0</span><br>
</div>
<hr>
<div>
e(aP, bQ) == e(P, Q)^ab is <span name="verify_pairing"></span>
</div>
<h2>Fr</h2>
<button type="text" onclick="TestFr()">test Fr</button>
<div>
x = <input type="text" name="x" value="0" size="100">
<button type="text" onclick="rand('x')">rand x</button><br>
y = <input type="text" name="y" value="0" size="100">
<button type="text" onclick="rand('y')">rand y</button>
</div>
<div>
x + y = <span name="ret_add"></span><br>
x - y = <span name="ret_sub"></span><br>
x * y = <span name="ret_mul"></span><br>
x / y = <span name="ret_div"></span><br>
</div>
<div>
hash(<input type="text" name="hash_x" value="">) = <span name="ret_hash_x"></span>
</div>
<h2>G1</h2>
<button type="text" onclick="TestG1()">test G1</button>
<div>
P1 = hashAndMapToG1(<input type="text" name="hash_P1" value="a">) = <span name="P1">0</span><br>
P2 = hashAndMapToG1(<input type="text" name="hash_P2" value="b">) = <span name="P2">0</span><br>
</div>
<hr>
<div>
P1 + P2 = <span name="P1addP2"></span><br>
P1 - P2 = <span name="P1subP2"></span><br>
P1 * x = <span name="P1mulx"></span><br>
</div>
<h2>G2</h2>
<button type="text" onclick="TestG2()">test G2</button>
<div>
Q1 = hashAndMapToG2(<input type="text" name="hash_Q1" value="a">) = <span name="Q1">0</span><br>
Q2 = hashAndMapToG2(<input type="text" name="hash_Q2" value="b">) = <span name="Q2">0</span><br>
</div>
<hr>
<div>
Q1 + Q2 = <span name="Q1addQ2"></span><br>
Q1 - Q2 = <span name="Q1subQ2"></span><br>
Q1 * x = <span name="Q1mulx"></span><br>
</div>
</body>
</html>