Comments (1)
This question is off-topic here but then again you can't really open an issue in my fork of the pypbc code.
I'll start with the easy question first. I put together a short example illustrating the use of GetItem (which allows you to index the x,y coordinates of a point:
#! /usr/bin/env python3
from pypbc import *
if __name__ == '__main__':
params = Parameters(qbits=8, rbits=4)
#print("params =", str(params))
pairing = Pairing(params)
#print("pairing =", str(pairing))
P = Element.random(pairing, G1)
print("P =", str(P))
print("P[0] = %d" % (P[0]))
print("P[1] = %d" % (P[1]))
Q = Element.random(pairing, G2)
print("Q =", str(Q))
print("P[0] = %d" % (Q[0]))
print("P[1] = %d" % (Q[1]))
e = pairing.apply(P, Q)
print("len(e) =", len(e))
print("e[0] = %d" % (e[0]))
print("e[1] = %d" % (e[1]))
The output should be something like:
P = 0237
P[0] = 55
P[1] = 86
Q = 0331
P[0] = 49
P[1] = 45
len(e) = 2
e[0] = 85
e[1] = 80
Showing P is the point at (55, 86) and Q is the point at (49, 45).
The problem of calculating the product of P and Q is that G1 is an additive group. P+Q is defined, but P*Q is not. You can mulitply either P or Q by a scalar but you cannot directly multiply two points.
Having said that, the pairing operation e(P,Q) is somewhat similar to a "product' of the two points. So as long as you have a symmetric pairing (one which G1 and G2 are equivalent) then you can combine any two points from G1 via pairing. As the pairing is a bilinear map it has similar mathematical properties to a product (i.e. e(aP, Q) = e(P, aQ) for any scalar a.
As far as the element_to_mpz() function goes, I haven't found that particular API necessary or even generally useful. I vaguely recall it may only actually defined for cases where e is a scalar (member of Zr).
from ctclient.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctclient.