1

I need the identity element on an elliptic curve in charm crypto. Because I want to sum up 5 different random elements in G1 i.e. elementList= {g1, g2, g3, g4, g5}. Right now, I have generated another random element in G1 i.e. temp= group.random(G1).

temp = group.random(G1)
elementList= {g1,  g2,  g3,  g4,  g5}
for num in range(0, 5):
    temp= temp+ elementList[num]

Can someone tell me how could I do it? Hope to hear from some experts.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Aisha
  • 127
  • 10
  • @ArtjomB. There are two functions in Charm using which we can initialize elements in Zr i.e. group.init(ZR, 0) and group.init(ZR, 1). I have used above functions to get the sum and product of different elements in Zr. But there is no such function for group G1. – Aisha Aug 28 '17 at 18:09

1 Answers1

1

The identity element under addition is the point at infinity for groups over elliptic curves. You can use PairingGroup.init(G1) without a value argument to get this point at infinity.

Example code:

>>> from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair
>>> group = PairingGroup('SS512')
>>> g = group.random(G1)
>>> i = group.init(G1) # point at infinity
>>> i + g == g
True

Note: this is undocumented and might change in future versions.


You don't need an identity element for your specific example. Just change your code a bit:

elementList = [g1,  g2,  g3,  g4,  g5]
for num in range(len(elementList)):
    if num == 0:
        temp = elementList[num]
    else:
        temp = temp + elementList[num]
Artjom B.
  • 61,146
  • 24
  • 125
  • 222