+
@@ -498,13 +501,13 @@
156
157
158
-159
class Curve :
# Curve
WEIERSTRASS = 0
MONTGOMERY = 1
- def __init__ ( self , a , b , t ):
+ def __init__ ( self , a , b , t ):
self . _a = a
self . _b = b
@@ -519,7 +522,7 @@
self . _points = list ()
self . _pointsSym = list ()
- def f ( self , x ):
+ def f ( self , x ):
if self . _type == Curve . WEIERSTRASS :
y = pow ( x , 3 ) + ( self . _a * x ) + self . _b
if self . _type == Curve . MONTGOMERY :
@@ -528,7 +531,7 @@
return sqrt ( y )
return None
- def generatePoints ( self ):
+ def generatePoints ( self ):
for x in self . _xtmp :
y = self . f ( x )
if y is None :
@@ -547,24 +550,24 @@
))
@property
- def x ( self ):
+ def x ( self ):
return self . _x
@property
- def y ( self ):
+ def y ( self ):
return self . _y
@property
- def yn ( self ):
+ def yn ( self ):
return self . _yn
- def getPoints ( self ):
+ def getPoints ( self ):
return self . _points
- def getPointsSym ( self ):
+ def getPointsSym ( self ):
return self . _pointsSym
- def add ( self , P , Q ) -> Point :
+ def add ( self , P , Q ) -> Point :
"""
This function operathe addition operation on two points P and Q
@@ -611,7 +614,7 @@
yr = ( m * ( P . x - xr )) - P . y
return Point ( xr , yr )
- def scalar ( self , P , n ) -> Point :
+ def scalar ( self , P , n ) -> Point :
"""
This function compute a Scalar Multiplication of P, n time. This algorithm is also known as Double and Add.
@@ -635,7 +638,7 @@
return nP
- def find_reverse ( self , P ):
+ def find_reverse ( self , P ):
"""
This function return the reverse of the Point P
Args:
@@ -655,7 +658,7 @@
-
+
@@ -735,7 +738,7 @@
-
+
Source code in Cryptotools/Groups/curve.py
74
75
@@ -782,7 +785,7 @@
116
117
118
-119 def add ( self , P , Q ) -> Point :
+119 def add ( self , P , Q ) -> Point :
"""
This function operathe addition operation on two points P and Q
@@ -872,7 +875,7 @@ Args:
-
+
Source code in Cryptotools/Groups/curve.py
145
146
@@ -888,7 +891,7 @@ Args:
156
157
158
-159 def find_reverse ( self , P ):
+159 def find_reverse ( self , P ):
"""
This function return the reverse of the Point P
Args:
@@ -978,7 +981,7 @@ Args:
-
+
Source code in Cryptotools/Groups/curve.py
121
122
@@ -1002,7 +1005,7 @@ Args:
140
141
142
-143 def scalar ( self , P , n ) -> Point :
+143 def scalar ( self , P , n ) -> Point :
"""
This function compute a Scalar Multiplication of P, n time. This algorithm is also known as Double and Add.
@@ -1037,6 +1040,7 @@ Args:
+
@@ -1052,7 +1056,7 @@ Args:
@@ -1078,7 +1082,7 @@ Args:
« Previous
- Next »
+ Next »
diff --git a/site/ecc/index.html b/site/ecc/index.html
new file mode 100644
index 0000000..137a325
--- /dev/null
+++ b/site/ecc/index.html
@@ -0,0 +1,1564 @@
+
+
+
+
+
+
+
+ Elliptic Curve Cryptography - CryptoTools documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CryptoTools documentation
+
+
+
+
+
+
+ Low-level cryptographic
+ Elliptic Curve Cryptography
+
+
+
+
+
+
+
+
+
Elliptic Curve Cryptography
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This class generate a group for Elliptic Curve
+An Elliptic Curve is a algebraic group from the Group theory branch.
+
An Elliptic Curve is a set of points from this equation (Weierstrass equations): $y2 = x3 + ax + b$
+
To generate points of $E(F_p)$, first, we need to generate all square modulos
+The, for all X, we increment it until $X < n$ and if exist a square modulos
+It's a point of the list $E(F_p)$
+
+
+
+
+
+
+
+
+
+ Attributes:
+
+
+
+ n
+ (Integer )
+ –
+
+
+
+ a
+ (Integer )
+ –
+
+
+
+
+
+ b
+ (Integer )
+ –
+
+
+
+
+
+ squares
+ (Dict )
+ –
+
+
Dictionary which contain quadratic nonresidue. The key is the quadratic nonresidue and for each entry, we have a list of point for the quadratic nonresidue
+
+
+
+ E
+ (List )
+ –
+
+
+
+ order
+ (Int )
+ –
+
+
Order (length) of the group
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239 class Elliptic :
+ """
+ This class generate a group for Elliptic Curve
+ An Elliptic Curve is a algebraic group from the Group theory branch.
+
+ An Elliptic Curve is a set of points from this equation (Weierstrass equations): $y2 = x3 + ax + b$
+
+
+ To generate points of $E(F_p)$, first, we need to generate all square modulos
+ The, for all X, we increment it until $X < n$ and if exist a square modulos
+ It's a point of the list $E(F_p)$
+
+ Attributes:
+ n (Integer): It's the modulo
+ a (Integer):
+ b (Integer):
+ squares (Dict): Dictionary which contain quadratic nonresidue. The key is the quadratic nonresidue and for each entry, we have a list of point for the quadratic nonresidue
+ E (List): List of all Points
+ order (Int): Order (length) of the group
+ """
+ def __init__ ( self , n , a , b ):
+ self . _n = n
+ self . _a = a
+ self . _b = b
+
+ self . _squares = dict ()
+ self . _E = list ()
+ self . _order = 0
+
+ def quadraticResidues ( self ):
+ """
+ This function generate all quadratic modulo of n.
+ A quadratic: if exist and satisfy $x^2 \equiv q mod n$, means it's a square modulo n and q is quadratic nonresidue modulo n
+ https://en.wikipedia.org/wiki/Quadratic_residue
+
+ For instance, n = 13, q = 9
+ For all x belongs to n
+ for x in n:
+ if x ** 2 % n == q:
+ print(x, q)
+ """
+ for q in range ( self . _n ):
+ x2 = pow ( q , 2 ) % self . _n
+ if x2 not in self . _squares :
+ self . _squares [ x2 ] = list ()
+ self . _squares [ x2 ] . append ( q )
+
+ def getQuadraticResidues ( self ) -> dict :
+ """
+ This function return the dict contains all squares modulo of n
+
+ Returns:
+ Return a dictionary of squares modulo
+ """
+ return self . _squares
+
+ def pointsE ( self ):
+ """
+ This function generate all points for $E(F_p)$. Each entry in the list contain another list of two entries: x and y
+
+ Returns:
+ Return the list of points of E(F_p)
+ """
+ self . _E . append ( Point ( 0 , 0 ))
+ for x in range ( self . _n ):
+ y = ( pow ( x , 3 ) + ( x * self . _a ) + self . _b ) % self . _n
+
+ # If not quadratic residue, no point in the curve
+ # and x not produce a point in the curve
+ if y in self . _squares :
+ for e in self . _squares [ y ]:
+ self . _E . append ( Point ( x , e ))
+ return self . _E
+
+ def additionTable ( self ):
+ raise NotImplementedError
+
+ def _slope ( self ):
+ raise NotImplementedError
+
+ def _curves ( self ):
+ self . _curves = dict ()
+ self . _curves [ "weierstrass" ] = weierstrass
+ self . _curves [ "curve25519" ] = curve25519
+ self . _curves [ "curve448" ] = curve448
+
+ def weierstrass ( self , x ):
+ raise NotImplementedError
+
+ def curve448 ( self , x ):
+ raise NotImplementedError
+
+ def curve25519 ( self , x ):
+ """
+ This function generate a curve based on the Montgomery's curve.
+ Using that formula: y2 = x^3 + 486662\times x^2 + x
+ """
+ y = pow ( x , 3 ) + 486662 * pow ( x , 2 ) + x
+ if y > 0 :
+ return sqrt ( y )
+ else :
+ return 0
+
+ def add ( self , P , Q ) -> Point :
+ """
+ This function operathe addition operation on two points P and Q
+
+ Args:
+ P (Object): The first Point on the curve
+ Q (Object): The second Point on the curve
+
+ Returns:
+ Return the Point object R
+ """
+
+ ## Check if P or Q are infinity
+ if ( P . x , P . y ) == ( 0 , 0 ) and ( Q . x , Q . y ) == ( 0 , 0 ):
+ return Point ( 0 , 0 )
+ elif ( P . x , P . y ) == ( 0 , 0 ):
+ return Point ( Q . x , Q . y )
+ elif ( Q . x , Q . y ) == ( 0 , 0 ):
+ return Point ( P . x , P . y )
+
+ # point doubling
+ if P . x == Q . x :
+ # Infinity
+ if P . y != Q . y or Q . y == 0 :
+ return Point ( 0 , 0 )
+
+ # Point doubling
+ try :
+ inv = pow ( 2 * P . y , - 1 , self . _n ); # It's working with the inverse modular, WHY ???
+ m = (( 3 * pow ( P . x , 2 )) + self . _a ) * inv % self . _n
+ except ValueError :
+ return Point ( 0 , 0 )
+
+ else :
+ try :
+ inv = pow ( Q . x - P . x , - 1 , self . _n )
+ m = (( Q . y - P . y ) * inv ) % self . _n
+ except ValueError :
+ # May call this Exception: base is not invertible for the given modulus
+ # I return an Infinity point until I fixed that
+ return Point ( 0 , 0 )
+
+ xr = int (( pow ( m , 2 ) - P . x - Q . x )) % self . _n
+
+ yr = int (( m * ( P . x - xr )) - P . y ) % self . _n
+ return Point ( xr , yr )
+
+ def scalar ( self , P , n ) -> Point :
+ """
+ This function compute a Scalar Multiplication of P, n time. This algorithm is also known as Double and Add.
+
+ Args:
+ P (point): the Point to multiplication
+ n (Integer): multiplicate n time P
+
+ Returns:
+ Return the result of the Scalar multiplication
+ """
+ binary = bin ( n )[ 2 :]
+ binary = binary [:: - 1 ] # We need to reverse the binary
+
+ nP = Point ( 0 , 0 )
+ Rtmp = P
+
+ for b in binary :
+ if b == '1' :
+ nP = self . add ( nP , Rtmp )
+ Rtmp = self . add ( Rtmp , Rtmp ) # Double P
+
+ return nP
+
+ def pointExist ( self , P ) -> bool :
+ """
+ This function determine if the Point P(x, y) exist in the Curve
+ To identify if a point P (x, y) lies on the curve
+ We need to compute y ** 2 mod n
+ Then, we compute x ** 3 + ax + b mod n
+ If both are equal, the point exist, otherwise not
+
+ Args:
+ P (Point): The point to check if exist in the curve
+
+ Returns:
+ Return True if lies on the curve otherwise it's False
+ """
+ y2 = pow ( P . y , 2 ) % self . _n
+ x3 = ( pow ( P . x , 3 ) + ( self . _a * P . x ) + self . _b ) % self . _n
+ if y2 == x3 :
+ return True
+
+ return False
+
+ def findOrder ( self ) -> int :
+ """
+ This function find the order of the Curve over Fp
+
+ Returns:
+ Return the order of the Curve
+ """
+ l = list ()
+ l . append ( Point ( 0 , 0 ))
+
+ # It's the same of the function pointsE
+ for x in range ( self . _n ):
+ r = ( pow ( x , 3 ) + ( self . _a * x ) + self . _b ) % self . _n
+ if r in self . _squares :
+ for s in self . _squares [ r ]:
+ P = Point ( x , s )
+ l . append ( P )
+
+ self . _order = len ( l )
+ return self . _order
+
+ @property
+ def order ( self ) -> int :
+ """
+ This function return the order of the Group
+ """
+ return self . _order
+
+ @property
+ def cofactor ( self ) -> int :
+ """
+ This function return the cofactor. A cofactor describe the relation between the number of points and the group.
+ It's based on the Lagrange's theorem.
+ """
+ if self . _order == 0 :
+ raise ValueError ( "You must generate the order of the group" )
+ return self . _order / self . _n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function return the cofactor. A cofactor describe the relation between the number of points and the group.
+It's based on the Lagrange's theorem.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function return the order of the Group
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function operathe addition operation on two points P and Q
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+ P
+ (Object )
+ –
+
+
The first Point on the curve
+
+
+
+ Q
+ (Object )
+ –
+
+
The second Point on the curve
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ Point
+ –
+
+
Return the Point object R
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156 def add ( self , P , Q ) -> Point :
+ """
+ This function operathe addition operation on two points P and Q
+
+ Args:
+ P (Object): The first Point on the curve
+ Q (Object): The second Point on the curve
+
+ Returns:
+ Return the Point object R
+ """
+
+ ## Check if P or Q are infinity
+ if ( P . x , P . y ) == ( 0 , 0 ) and ( Q . x , Q . y ) == ( 0 , 0 ):
+ return Point ( 0 , 0 )
+ elif ( P . x , P . y ) == ( 0 , 0 ):
+ return Point ( Q . x , Q . y )
+ elif ( Q . x , Q . y ) == ( 0 , 0 ):
+ return Point ( P . x , P . y )
+
+ # point doubling
+ if P . x == Q . x :
+ # Infinity
+ if P . y != Q . y or Q . y == 0 :
+ return Point ( 0 , 0 )
+
+ # Point doubling
+ try :
+ inv = pow ( 2 * P . y , - 1 , self . _n ); # It's working with the inverse modular, WHY ???
+ m = (( 3 * pow ( P . x , 2 )) + self . _a ) * inv % self . _n
+ except ValueError :
+ return Point ( 0 , 0 )
+
+ else :
+ try :
+ inv = pow ( Q . x - P . x , - 1 , self . _n )
+ m = (( Q . y - P . y ) * inv ) % self . _n
+ except ValueError :
+ # May call this Exception: base is not invertible for the given modulus
+ # I return an Infinity point until I fixed that
+ return Point ( 0 , 0 )
+
+ xr = int (( pow ( m , 2 ) - P . x - Q . x )) % self . _n
+
+ yr = int (( m * ( P . x - xr )) - P . y ) % self . _n
+ return Point ( xr , yr )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function generate a curve based on the Montgomery's curve.
+Using that formula: y2 = x^3 + 486662 imes x^2 + x
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 100
+101
+102
+103
+104
+105
+106
+107
+108
+109 def curve25519 ( self , x ):
+ """
+ This function generate a curve based on the Montgomery's curve.
+ Using that formula: y2 = x^3 + 486662\times x^2 + x
+ """
+ y = pow ( x , 3 ) + 486662 * pow ( x , 2 ) + x
+ if y > 0 :
+ return sqrt ( y )
+ else :
+ return 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function find the order of the Curve over Fp
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ int
+ –
+
+
Return the order of the Curve
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222 def findOrder ( self ) -> int :
+ """
+ This function find the order of the Curve over Fp
+
+ Returns:
+ Return the order of the Curve
+ """
+ l = list ()
+ l . append ( Point ( 0 , 0 ))
+
+ # It's the same of the function pointsE
+ for x in range ( self . _n ):
+ r = ( pow ( x , 3 ) + ( self . _a * x ) + self . _b ) % self . _n
+ if r in self . _squares :
+ for s in self . _squares [ r ]:
+ P = Point ( x , s )
+ l . append ( P )
+
+ self . _order = len ( l )
+ return self . _order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function return the dict contains all squares modulo of n
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ dict
+ –
+
+
Return a dictionary of squares modulo
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 55
+56
+57
+58
+59
+60
+61
+62 def getQuadraticResidues ( self ) -> dict :
+ """
+ This function return the dict contains all squares modulo of n
+
+ Returns:
+ Return a dictionary of squares modulo
+ """
+ return self . _squares
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function determine if the Point P(x, y) exist in the Curve
+To identify if a point P (x, y) lies on the curve
+We need to compute y ** 2 mod n
+Then, we compute x ** 3 + ax + b mod n
+If both are equal, the point exist, otherwise not
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+ P
+ (Point )
+ –
+
+
The point to check if exist in the curve
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ bool
+ –
+
+
Return True if lies on the curve otherwise it's False
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201 def pointExist ( self , P ) -> bool :
+ """
+ This function determine if the Point P(x, y) exist in the Curve
+ To identify if a point P (x, y) lies on the curve
+ We need to compute y ** 2 mod n
+ Then, we compute x ** 3 + ax + b mod n
+ If both are equal, the point exist, otherwise not
+
+ Args:
+ P (Point): The point to check if exist in the curve
+
+ Returns:
+ Return True if lies on the curve otherwise it's False
+ """
+ y2 = pow ( P . y , 2 ) % self . _n
+ x3 = ( pow ( P . x , 3 ) + ( self . _a * P . x ) + self . _b ) % self . _n
+ if y2 == x3 :
+ return True
+
+ return False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function generate all points for $E(F_p)$. Each entry in the list contain another list of two entries: x and y
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ –
+
+
Return the list of points of E(F_p)
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80 def pointsE ( self ):
+ """
+ This function generate all points for $E(F_p)$. Each entry in the list contain another list of two entries: x and y
+
+ Returns:
+ Return the list of points of E(F_p)
+ """
+ self . _E . append ( Point ( 0 , 0 ))
+ for x in range ( self . _n ):
+ y = ( pow ( x , 3 ) + ( x * self . _a ) + self . _b ) % self . _n
+
+ # If not quadratic residue, no point in the curve
+ # and x not produce a point in the curve
+ if y in self . _squares :
+ for e in self . _squares [ y ]:
+ self . _E . append ( Point ( x , e ))
+ return self . _E
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function generate all quadratic modulo of n.
+A quadratic: if exist and satisfy $x^2 \equiv q mod n$, means it's a square modulo n and q is quadratic nonresidue modulo n
+https://en.wikipedia.org/wiki/Quadratic_residue
+
For instance, n = 13, q = 9
+For all x belongs to n
+ for x in n:
+ if x ** 2 % n == q:
+ print(x, q)
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53 def quadraticResidues ( self ):
+ """
+ This function generate all quadratic modulo of n.
+ A quadratic: if exist and satisfy $x^2 \equiv q mod n$, means it's a square modulo n and q is quadratic nonresidue modulo n
+ https://en.wikipedia.org/wiki/Quadratic_residue
+
+ For instance, n = 13, q = 9
+ For all x belongs to n
+ for x in n:
+ if x ** 2 % n == q:
+ print(x, q)
+ """
+ for q in range ( self . _n ):
+ x2 = pow ( q , 2 ) % self . _n
+ if x2 not in self . _squares :
+ self . _squares [ x2 ] = list ()
+ self . _squares [ x2 ] . append ( q )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This function compute a Scalar Multiplication of P, n time. This algorithm is also known as Double and Add.
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+ P
+ (point )
+ –
+
+
the Point to multiplication
+
+
+
+ n
+ (Integer )
+ –
+
+
multiplicate n time P
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+ Point
+ –
+
+
Return the result of the Scalar multiplication
+
+
+
+
+
+
+
+
+
+ Source code in Cryptotools/Groups/elliptic.py
+ 158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180 def scalar ( self , P , n ) -> Point :
+ """
+ This function compute a Scalar Multiplication of P, n time. This algorithm is also known as Double and Add.
+
+ Args:
+ P (point): the Point to multiplication
+ n (Integer): multiplicate n time P
+
+ Returns:
+ Return the result of the Scalar multiplication
+ """
+ binary = bin ( n )[ 2 :]
+ binary = binary [:: - 1 ] # We need to reverse the binary
+
+ nP = Point ( 0 , 0 )
+ Rtmp = P
+
+ for b in binary :
+ if b == '1' :
+ nP = self . add ( nP , Rtmp )
+ Rtmp = self . add ( Rtmp , Rtmp ) # Double P
+
+ return nP
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/site/example-curves/index.html b/site/example-curves/index.html
index aaf1db6..55afc3c 100644
--- a/site/example-curves/index.html
+++ b/site/example-curves/index.html
@@ -52,6 +52,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
diff --git a/site/example-rsa-keys/index.html b/site/example-rsa-keys/index.html
index 16bb08a..303b683 100644
--- a/site/example-rsa-keys/index.html
+++ b/site/example-rsa-keys/index.html
@@ -52,6 +52,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
diff --git a/site/group-theory/index.html b/site/group-theory/index.html
index 43da606..79f7f32 100644
--- a/site/group-theory/index.html
+++ b/site/group-theory/index.html
@@ -122,6 +122,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
@@ -184,7 +186,7 @@
-
+
@@ -208,6 +210,7 @@
+
This class generate a group self._g based on the operation (here denoted +)
with the function ope: (a ** b) % n
In group theory, any group has an identity element (e), which with the binary operation, do not change the value and must satisfy the condition: $a + e = 0$
@@ -274,7 +277,6 @@ with the function ope: (a ** b) % n
-
Source code in Cryptotools/Groups/group.py
3
@@ -398,7 +400,7 @@ with the function ope: (a ** b) % n
121
122
123
-124 class Group :
"""
This class generate a group self._g based on the operation (here denoted +)
with the function ope: (a ** b) % n
@@ -412,14 +414,14 @@ with the function ope: (a ** b) % n
identity (Integer): The identity of the group.
reverse (Dict): For each elements of the Group of n, we have the reverse value
"""
- def __init__ ( self , n , g , ope ):
+ def __init__ ( self , n , g , ope ):
self . _n = n
self . _g = g
self . _operation = ope
self . _identity = 0
self . _reverse = dict ()
- def getG ( self ) -> list ():
+ def getG ( self ) -> list ():
"""
This function return the Group
@@ -428,7 +430,7 @@ with the function ope: (a ** b) % n
"""
return self . _g
- def closure ( self ) -> bool :
+ def closure ( self ) -> bool :
"""
Check the closure law
In a group, each element a, b belongs to G, such as a + b belongs to G
@@ -444,7 +446,7 @@ with the function ope: (a ** b) % n
return False
return True
- def associative ( self ) -> bool :
+ def associative ( self ) -> bool :
"""
Check the associative law.
In a group, for any a, b and c belongs to G,
@@ -467,7 +469,7 @@ with the function ope: (a ** b) % n
return False
return True
- def identity ( self ) -> bool :
+ def identity ( self ) -> bool :
"""
Check the identity law.
In a group, an identity element exist and must be uniq
@@ -484,7 +486,7 @@ with the function ope: (a ** b) % n
return True
return False
- def getIdentity ( self ) -> int :
+ def getIdentity ( self ) -> int :
"""
Return the identity element. The function identitu() must be called before.
@@ -493,7 +495,7 @@ with the function ope: (a ** b) % n
"""
return self . _identity
- def reverse ( self ) -> bool :
+ def reverse ( self ) -> bool :
"""
Check the inverse law
In a group, for each element belongs to G
@@ -511,7 +513,7 @@ with the function ope: (a ** b) % n
break
return reverse
- def getReverses ( self ) -> dict :
+ def getReverses ( self ) -> dict :
"""
This function return the dictionary of all reverses elements. The key is the element in G and the value is the reverse element
@@ -525,7 +527,7 @@ with the function ope: (a ** b) % n
-
+
@@ -575,7 +577,7 @@ they must respect this condition: (a + b) + c = a + (a + b)
-
+
Source code in Cryptotools/Groups/group.py
49
50
@@ -598,7 +600,7 @@ they must respect this condition: (a + b) + c = a + (a + b)
67
68
69
-70 def associative ( self ) -> bool :
+70 def associative ( self ) -> bool :
"""
Check the associative law.
In a group, for any a, b and c belongs to G,
@@ -664,7 +666,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
-
+
Source code in Cryptotools/Groups/group.py
33
34
@@ -680,7 +682,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
44
45
46
-47 def closure ( self ) -> bool :
+47 def closure ( self ) -> bool :
"""
Check the closure law
In a group, each element a, b belongs to G, such as a + b belongs to G
@@ -738,7 +740,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
-
+
Source code in Cryptotools/Groups/group.py
24
25
@@ -747,7 +749,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
28
29
30
-31 def getG ( self ) -> list ():
+31 def getG ( self ) -> list ():
"""
This function return the Group
@@ -798,7 +800,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
-
+
Source code in Cryptotools/Groups/group.py
89
90
@@ -807,7 +809,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
93
94
95
-96 def getIdentity ( self ) -> int :
+96 def getIdentity ( self ) -> int :
"""
Return the identity element. The function identitu() must be called before.
@@ -858,7 +860,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
-
+
Source code in Cryptotools/Groups/group.py
116
117
@@ -868,7 +870,7 @@ In a group, each element a, b belongs to G, such as a + b belongs to G
121
122
123
-124 def getReverses ( self ) -> dict :
+124 def getReverses ( self ) -> dict :
"""
This function return the dictionary of all reverses elements. The key is the element in G and the value is the reverse element
@@ -921,7 +923,7 @@ In a group, an identity element exist and must be uniq
-
+
Source code in Cryptotools/Groups/group.py
72
73
@@ -938,7 +940,7 @@ In a group, an identity element exist and must be uniq
84
85
86
-87 def identity ( self ) -> bool :
+87 def identity ( self ) -> bool :
"""
Check the identity law.
In a group, an identity element exist and must be uniq
@@ -999,7 +1001,7 @@ they must have an inverse a ^ (-1) = e (identity)
-
+
Source code in Cryptotools/Groups/group.py
98
99
@@ -1017,7 +1019,7 @@ they must have an inverse a ^ (-1) = e (identity)
111
112
113
-114 def reverse ( self ) -> bool :
+114 def reverse ( self ) -> bool :
"""
Check the inverse law
In a group, for each element belongs to G
@@ -1046,6 +1048,7 @@ they must have an inverse a ^ (-1) = e (identity)
+
@@ -1074,7 +1077,7 @@ they must have an inverse a ^ (-1) = e (identity)
-
+
@@ -1100,6 +1103,7 @@ they must have an inverse a ^ (-1) = e (identity)
Bases:
Group
+
This object contain a list of the Group for a cyclic group. This class find all generator of the group.
This class is inherited from Group object
@@ -1165,7 +1169,6 @@ This class is inherited from Group object
-
Source code in Cryptotools/Groups/cyclic.py
6
@@ -1253,7 +1256,7 @@ This class is inherited from Group object
88
89
90
-91 class Cyclic ( Group ):
"""
This object contain a list of the Group for a cyclic group. This class find all generator of the group.
This class is inherited from Group object
@@ -1265,7 +1268,7 @@ This class is inherited from Group object
generators (list): contain all generators of the group
generatorChecked (boolean): Check if generators has been found
"""
- def __init__ ( self , G : list , n , ope ):
+ def __init__ ( self , G : list , n , ope ):
super () . __init__ ( n , G , ope ) # Call the Group's constructor
self . _G = G
self . _n = n
@@ -1273,7 +1276,7 @@ This class is inherited from Group object
self . _generators = list ()
self . _generatorChecked = False
- def generator ( self ):
+ def generator ( self ):
"""
This function find all generators in the group G
"""
@@ -1294,7 +1297,7 @@ This class is inherited from Group object
self . _generators . append ( g )
self . _generatorChecked = True
- def getPrimitiveRoot ( self ):
+ def getPrimitiveRoot ( self ):
"""
This function return the primitive root modulo of n
@@ -1317,7 +1320,7 @@ This class is inherited from Group object
return g
return None
- def getGenerators ( self ) -> list :
+ def getGenerators ( self ) -> list :
"""
This function return all generators of that group
@@ -1329,7 +1332,7 @@ This class is inherited from Group object
self . _generatorChecked = True
return self . _generators
- def isCyclic ( self ) -> bool :
+ def isCyclic ( self ) -> bool :
"""
Check if the group is a cyclic group, means we have at least one generator
@@ -1344,7 +1347,7 @@ This class is inherited from Group object
-
+
@@ -1369,7 +1372,7 @@ This class is inherited from Group object
This function find all generators in the group G
-
+
Source code in Cryptotools/Groups/cyclic.py
26
27
@@ -1390,7 +1393,7 @@ This class is inherited from Group object
42
43
44
-45 def generator ( self ):
"""
This function find all generators in the group G
"""
@@ -1453,7 +1456,7 @@ This class is inherited from Group object
-
+
Source code in Cryptotools/Groups/cyclic.py
70
71
@@ -1465,7 +1468,7 @@ This class is inherited from Group object
77
78
79
-80 def getGenerators ( self ) -> list :
+80 def getGenerators ( self ) -> list :
"""
This function return all generators of that group
@@ -1518,7 +1521,7 @@ This class is inherited from Group object
-
+
Source code in Cryptotools/Groups/cyclic.py
47
48
@@ -1541,7 +1544,7 @@ This class is inherited from Group object
65
66
67
-68 def getPrimitiveRoot ( self ):
+68 def getPrimitiveRoot ( self ):
"""
This function return the primitive root modulo of n
@@ -1606,7 +1609,7 @@ This class is inherited from Group object
-
+
Source code in Cryptotools/Groups/cyclic.py
82
83
@@ -1617,7 +1620,7 @@ This class is inherited from Group object
88
89
90
-91 def isCyclic ( self ) -> bool :
+91 def isCyclic ( self ) -> bool :
"""
Check if the group is a cyclic group, means we have at least one generator
@@ -1639,6 +1642,7 @@ This class is inherited from Group object
+
@@ -1667,7 +1671,7 @@ This class is inherited from Group object
-
+
@@ -1691,6 +1695,7 @@ This class is inherited from Group object
+
This class contain the Galois Field (Finite Field)
@@ -1747,7 +1752,6 @@ This class is inherited from Group object
-
Source code in Cryptotools/Groups/galois.py
6
@@ -1971,7 +1975,7 @@ This class is inherited from Group object
224
225
226
-227 class Galois :
"""
This class contain the Galois Field (Finite Field)
@@ -1983,7 +1987,7 @@ This class is inherited from Group object
identityAdd (Integer): it's the identity element in the GF(n) for the addition operation
identityMul (Integer): it's the identity element in the GF(n) for the multiplicative operation
"""
- def __init__ ( self , q , operation ):
+ def __init__ ( self , q , operation ):
self . _q = q
self . _operation = operation
self . _identityAdd = 0
@@ -1997,7 +2001,7 @@ This class is inherited from Group object
self . _sub = [[ 0 for x in range ( q )] for y in range ( q )]
self . _primitiveRoot = list ()
- def primitiveRoot ( self ):
+ def primitiveRoot ( self ):
"""
In this function, we going to find the primitive root modulo n of the galois field
@@ -2016,7 +2020,7 @@ This class is inherited from Group object
self . _primitiveRoot . append ( x )
return z
- def getPrimitiveRoot ( self ):
+ def getPrimitiveRoot ( self ):
"""
Return the list of primitives root
@@ -2025,7 +2029,7 @@ This class is inherited from Group object
"""
return self . _primitiveRoot
- def isPrimitiveRoot ( self , z , length ):
+ def isPrimitiveRoot ( self , z , length ):
"""
Check if z is a primitive root
@@ -2037,7 +2041,7 @@ This class is inherited from Group object
return True
return False
- def add ( self ):
+ def add ( self ):
"""
This function do the operation + on the Galois Field
@@ -2049,7 +2053,7 @@ This class is inherited from Group object
self . _add [ x ][ y ] = ( x + y ) % self . _q
return self . _add
- def _inverseModular ( self , a , n ):
+ def _inverseModular ( self , a , n ):
"""
This function find the reverse modular of a by n
@@ -2062,7 +2066,7 @@ This class is inherited from Group object
break
return inv
- def div ( self ):
+ def div ( self ):
"""
This function do the operation / on the Galois Field
@@ -2076,7 +2080,7 @@ This class is inherited from Group object
self . _div [ x ][ y ] = ( x * inv ) % self . _q
return self . _div
- def mul ( self ):
+ def mul ( self ):
"""
This function do the operation * on the Galois Field
@@ -2088,7 +2092,7 @@ This class is inherited from Group object
self . _mul [ x ][ y ] = ( x * y ) % self . _q
return self . _mul
- def sub ( self ):
+ def sub ( self ):
"""
This function do the operation - on the Galois Field
@@ -2100,7 +2104,7 @@ This class is inherited from Group object
self . _sub [ x ][ y ] = ( x - y ) % self . _q
return self . _sub
- def check_closure_law ( self , arithmetic ):
+ def check_closure_law ( self , arithmetic ):
"""
This function check the closure law.
By definition, every element in the GF is an abelian group, which respect the closure law: for a and b belongs to G, a + b belongs to G, the operation is a binary operation
@@ -2139,7 +2143,7 @@ This class is inherited from Group object
else :
print ( f "The group { arithmetic } does not respect closure law" )
- def check_identity_add ( self ):
+ def check_identity_add ( self ):
"""
This function check the identity element and must satisfy this condition: $a + 0 = a$ for each element in the GF(n)
In Group Theory, an identity element is an element in the group which do not change the value every element in the group
@@ -2154,7 +2158,7 @@ This class is inherited from Group object
"do not satisfy $a + element = a$"
)
- def check_identity_mul ( self ):
+ def check_identity_mul ( self ):
"""
This function check the identity element and must satisfy this condition: $a * 1 = a$ for each element in the GF(n)
In Group Theory, an identity element is an element in the group which do not change the value every element in the group
@@ -2169,7 +2173,7 @@ This class is inherited from Group object
"do not satisfy $a * element = a$"
)
- def printMatrice ( self , m ):
+ def printMatrice ( self , m ):
"""
This function print the GF(m)
@@ -2198,7 +2202,7 @@ This class is inherited from Group object
-
+
@@ -2245,7 +2249,7 @@ This class is inherited from Group object
-
+
Source code in Cryptotools/Groups/galois.py
72
73
@@ -2257,7 +2261,7 @@ This class is inherited from Group object
79
80
81
-82 def add ( self ):
"""
This function do the operation + on the Galois Field
@@ -2313,7 +2317,7 @@ By definition, every element in the GF is an abelian group, which respect the cl
-
+
Source code in Cryptotools/Groups/galois.py
135
136
@@ -2352,7 +2356,7 @@ By definition, every element in the GF is an abelian group, which respect the cl
169
170
171
-172 def check_closure_law ( self , arithmetic ):
+172 def check_closure_law ( self , arithmetic ):
"""
This function check the closure law.
By definition, every element in the GF is an abelian group, which respect the closure law: for a and b belongs to G, a + b belongs to G, the operation is a binary operation
@@ -2412,7 +2416,7 @@ In Group Theory, an identity element is an element in the group which do not cha
Returns:
-
+
Source code in Cryptotools/Groups/galois.py
174
175
@@ -2427,7 +2431,7 @@ In Group Theory, an identity element is an element in the group which do not cha
184
185
186
-187 def check_identity_add ( self ):
+187 def check_identity_add ( self ):
"""
This function check the identity element and must satisfy this condition: $a + 0 = a$ for each element in the GF(n)
In Group Theory, an identity element is an element in the group which do not change the value every element in the group
@@ -2463,7 +2467,7 @@ In Group Theory, an identity element is an element in the group which do not cha
Returns:
-
+
Source code in Cryptotools/Groups/galois.py
189
190
@@ -2478,7 +2482,7 @@ In Group Theory, an identity element is an element in the group which do not cha
199
200
201
-202 def check_identity_mul ( self ):
+202 def check_identity_mul ( self ):
"""
This function check the identity element and must satisfy this condition: $a * 1 = a$ for each element in the GF(n)
In Group Theory, an identity element is an element in the group which do not change the value every element in the group
@@ -2534,7 +2538,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
97
98
@@ -2548,7 +2552,7 @@ In Group Theory, an identity element is an element in the group which do not cha
106
107
108
-109 def div ( self ):
"""
This function do the operation / on the Galois Field
@@ -2603,7 +2607,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
51
52
@@ -2612,7 +2616,7 @@ In Group Theory, an identity element is an element in the group which do not cha
55
56
57
-58 def getPrimitiveRoot ( self ):
+58 def getPrimitiveRoot ( self ):
"""
Return the list of primitives root
@@ -2672,7 +2676,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
60
61
@@ -2684,7 +2688,7 @@ In Group Theory, an identity element is an element in the group which do not cha
67
68
69
-70 def isPrimitiveRoot ( self , z , length ):
+70 def isPrimitiveRoot ( self , z , length ):
"""
Check if z is a primitive root
@@ -2737,7 +2741,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
111
112
@@ -2749,7 +2753,7 @@ In Group Theory, an identity element is an element in the group which do not cha
118
119
120
-121 def mul ( self ):
"""
This function do the operation * on the Galois Field
@@ -2802,7 +2806,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
32
33
@@ -2821,7 +2825,7 @@ In Group Theory, an identity element is an element in the group which do not cha
46
47
48
-49 def primitiveRoot ( self ):
+49 def primitiveRoot ( self ):
"""
In this function, we going to find the primitive root modulo n of the galois field
@@ -2883,7 +2887,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
204
205
@@ -2908,7 +2912,7 @@ In Group Theory, an identity element is an element in the group which do not cha
224
225
226
-227 def printMatrice ( self , m ):
+227 def printMatrice ( self , m ):
"""
This function print the GF(m)
@@ -2974,7 +2978,7 @@ In Group Theory, an identity element is an element in the group which do not cha
-
+
Source code in Cryptotools/Groups/galois.py
123
124
@@ -2986,7 +2990,7 @@ In Group Theory, an identity element is an element in the group which do not cha
130
131
132
-133 def sub ( self ):
"""
This function do the operation - on the Galois Field
@@ -3009,6 +3013,7 @@ In Group Theory, an identity element is an element in the group which do not cha
+
diff --git a/site/index.html b/site/index.html
index 7b1af2b..186d4f3 100644
--- a/site/index.html
+++ b/site/index.html
@@ -52,6 +52,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
Public Keys:
@@ -159,5 +162,5 @@
diff --git a/site/installation/index.html b/site/installation/index.html
index b961957..03a64a3 100644
--- a/site/installation/index.html
+++ b/site/installation/index.html
@@ -56,6 +56,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
diff --git a/site/introduction/index.html b/site/introduction/index.html
index ded7ef2..77672a6 100644
--- a/site/introduction/index.html
+++ b/site/introduction/index.html
@@ -54,6 +54,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
diff --git a/site/number-theory/index.html b/site/number-theory/index.html
index fe77019..69c7da3 100644
--- a/site/number-theory/index.html
+++ b/site/number-theory/index.html
@@ -82,6 +82,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
-
+
Source code in Cryptotools/Numbers/primeNumber.py
153
154
@@ -242,7 +244,7 @@
166
167
168
-169 def are_coprime ( p1 , p2 ):
+169 def are_coprime ( p1 , p2 ):
"""
This function check if p1 and p2 are coprime
@@ -339,7 +341,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
35
36
@@ -385,7 +387,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
76
77
78
-79 def getPrimeNumber ( n , safe = True ):
+79 def getPrimeNumber ( n , safe = True ):
"""
This function generate a large prime number
based on "A method for Obtaining Digital Signatures
@@ -497,7 +499,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
81
82
@@ -524,7 +526,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
103
104
105
-106 def getSmallPrimeNumber ( n ) -> int :
+106 def getSmallPrimeNumber ( n ) -> int :
"""
This function is deprecated
@@ -617,7 +619,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
124
125
@@ -646,7 +648,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
148
149
150
-151 def get_n_prime_numbers ( n ) -> list :
+151 def get_n_prime_numbers ( n ) -> list :
"""
This function return a list of n prime numbers
@@ -741,7 +743,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
108
109
@@ -757,7 +759,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
119
120
121
-122 def get_prime_numbers ( n ) -> list :
+122 def get_prime_numbers ( n ) -> list :
"""
This function get all prime number of the n
@@ -840,7 +842,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
8
9
@@ -859,7 +861,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
22
23
24
-25 def isPrimeNumber ( p ):
+25 def isPrimeNumber ( p ):
"""
Check if the number p is a prime number or not. The function iterate until p is achieve.
@@ -944,7 +946,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
272
273
@@ -961,7 +963,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
284
285
286
-287 def isSafePrime ( n ) -> bool :
+287 def isSafePrime ( n ) -> bool :
"""
This function has not been implemented yet, but check if the number n is a safe prime number. This function will test different properties of the possible prime number n
@@ -1044,7 +1046,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
171
172
@@ -1073,7 +1075,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
195
196
197
-198 def sieveOfEratosthenes ( n ) -> list :
+198 def sieveOfEratosthenes ( n ) -> list :
"""
This function build a list of prime number based on the Sieve of Erastosthenes
@@ -1168,7 +1170,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/primeNumber.py
259
260
@@ -1181,7 +1183,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
267
268
269
-270 def sophieGermainPrime ( p ) -> bool :
+270 def sophieGermainPrime ( p ) -> bool :
"""
Check if the number p is a safe prime number: 2p + 1 is also a prime
@@ -1224,7 +1226,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
@@ -1296,7 +1298,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
-
+
Source code in Cryptotools/Numbers/numbers.py
4
5
@@ -1312,7 +1314,7 @@ https://dl.acm.org/doi/pdf/10.1145/359340.359342
15
16
17
-18 def fibonacci ( n ) -> list :
+18 def fibonacci ( n ) -> list :
"""
This function generate the list of Fibonacci
diff --git a/site/objects.inv b/site/objects.inv
index 20fc800..dee7386 100644
Binary files a/site/objects.inv and b/site/objects.inv differ
diff --git a/site/rsa/index.html b/site/rsa/index.html
index 4f61578..388faa4 100644
--- a/site/rsa/index.html
+++ b/site/rsa/index.html
@@ -52,6 +52,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
@@ -115,7 +117,7 @@
-
+
@@ -139,6 +141,7 @@
+
This class generate public key based on RSA algorithm
@@ -191,7 +194,6 @@
-
Source code in Cryptotools/Encryptions/RSA.py
45
@@ -323,7 +325,7 @@
171
172
173
-174 class RSA :
"""
This class generate public key based on RSA algorithm
@@ -334,7 +336,7 @@
private: Object of the RSAKey for the private key
"""
- def __init__ ( self ):
+ def __init__ ( self ):
"""
Build a RSA Key
"""
@@ -343,7 +345,7 @@
self . _public = None
self . _private = None
- def generateKeys ( self , size = 512 ):
+ def generateKeys ( self , size = 512 ):
"""
This function generate both public and private keys
Args:
@@ -376,26 +378,26 @@
self . _private = RSAKey ( d , n , getsizeof ( d ))
@property
- def e ( self ):
+ def e ( self ):
return self . _public . key
@property
- def d ( self ):
+ def d ( self ):
return self . _private . key
@property
- def n ( self ):
+ def n ( self ):
return self . _public . modulus
@property
- def p ( self ):
+ def p ( self ):
return self . _p
@property
- def q ( self ):
+ def q ( self ):
return self . _q
- def encrypt ( self , data ) -> list :
+ def encrypt ( self , data ) -> list :
"""
This function return a list of data encrypted with the public key
@@ -411,7 +413,7 @@
for x in dataEncoded
)
- def decrypt ( self , data ) -> list :
+ def decrypt ( self , data ) -> list :
"""
This function return a list decrypted with the private key
@@ -427,7 +429,7 @@
decrypted . append ( chr ( d ))
return '' . join ( decrypted )
- def _str2bin ( self , data ) -> list :
+ def _str2bin ( self , data ) -> list :
"""
This function convert a string into the unicode value
@@ -439,7 +441,7 @@
"""
return list ( ord ( x ) for x in data )
- def _inverseModular ( self , a , n ):
+ def _inverseModular ( self , a , n ):
"""
This function compute the modular inverse for finding d, the decryption key
@@ -458,7 +460,7 @@
-
+
@@ -483,7 +485,7 @@
Build a RSA Key
-
+
Source code in Cryptotools/Encryptions/RSA.py
56
57
@@ -492,7 +494,7 @@
60
61
62
-63 def __init__ ( self ):
"""
Build a RSA Key
"""
@@ -567,7 +569,7 @@
-
+
Source code in Cryptotools/Encryptions/RSA.py
133
134
@@ -583,7 +585,7 @@
144
145
146
-147 def decrypt ( self , data ) -> list :
+147 def decrypt ( self , data ) -> list :
"""
This function return a list decrypted with the private key
@@ -665,7 +667,7 @@
-
+
Source code in Cryptotools/Encryptions/RSA.py
117
118
@@ -681,7 +683,7 @@
128
129
130
-131 def encrypt ( self , data ) -> list :
+131 def encrypt ( self , data ) -> list :
"""
This function return a list of data encrypted with the public key
@@ -718,7 +720,7 @@ Args:
size: It's the size of the key and must be multiple of 64
-
+
Source code in Cryptotools/Encryptions/RSA.py
65
66
@@ -750,7 +752,7 @@ Args:
92
93
94
-95 def generateKeys ( self , size = 512 ):
+95 def generateKeys ( self , size = 512 ):
"""
This function generate both public and private keys
Args:
@@ -793,6 +795,7 @@ Args:
+
@@ -809,6 +812,7 @@ Args:
+
This class store the RSA key with the modulus associated
The key is a tuple of the key and the modulus n
@@ -855,7 +859,6 @@ The key is a tuple of the key and the modulus n
-
Source code in Cryptotools/Encryptions/RSA.py
9
@@ -892,7 +895,7 @@ The key is a tuple of the key and the modulus n
40
41
42
-43 class RSAKey :
"""
This class store the RSA key with the modulus associated
The key is a tuple of the key and the modulus n
@@ -902,7 +905,7 @@ The key is a tuple of the key and the modulus n
modulus: It's the public modulus
length: It's the key length
"""
- def __init__ ( self , key , modulus , length ):
+ def __init__ ( self , key , modulus , length ):
"""
Contain the RSA Key. An object of RSAKey can be a public key or a private key
@@ -917,22 +920,22 @@ The key is a tuple of the key and the modulus n
self . _length = length
@property
- def key ( self ):
+ def key ( self ):
return self . _key
@property
- def modulus ( self ):
+ def modulus ( self ):
return self . _modulus
@property
- def length ( self ):
+ def length ( self ):
return self . length
-
+
@@ -997,7 +1000,7 @@ The key is a tuple of the key and the modulus n
-
+
Source code in Cryptotools/Encryptions/RSA.py
19
20
@@ -1011,7 +1014,7 @@ The key is a tuple of the key and the modulus n
28
29
30
-31 def __init__ ( self , key , modulus , length ):
+31 def __init__ ( self , key , modulus , length ):
"""
Contain the RSA Key. An object of RSAKey can be a public key or a private key
@@ -1036,6 +1039,7 @@ The key is a tuple of the key and the modulus n
+
@@ -1050,7 +1054,7 @@ The key is a tuple of the key and the modulus n
@@ -1074,7 +1078,7 @@ The key is a tuple of the key and the modulus n
- « Previous
+ « Previous
Next »
diff --git a/site/sitemap.xml.gz b/site/sitemap.xml.gz
index 0ced834..aa8f5ab 100644
Binary files a/site/sitemap.xml.gz and b/site/sitemap.xml.gz differ
diff --git a/site/utils/index.html b/site/utils/index.html
index 73dfa92..6cf3e88 100644
--- a/site/utils/index.html
+++ b/site/utils/index.html
@@ -52,6 +52,8 @@
Curves
+ Elliptic Curve Cryptography
+
Public Keys
-
+
Source code in Cryptotools/Utils/utils.py
35
36
@@ -227,7 +229,7 @@ And for each 1 bit, we compute the exponent.
59
60
61
-62 def bin_expo ( n , e ) -> int :
+62 def bin_expo ( n , e ) -> int :
"""
This function perform an binary exponentiation, also known as Exponentiation squaring.
A binary exponentiation is the process for computing an integer power of a number, such as a ** n.
@@ -309,7 +311,7 @@ https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
-
+
Source code in Cryptotools/Utils/utils.py
18
19
@@ -326,7 +328,7 @@ https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
30
31
32
-33 def egcd ( a , b ):
"""
This function compute the Extended Euclidean algorithm
https://user.eng.umd.edu/~danadach/Cryptography_20/ExtEuclAlg.pdf
@@ -399,7 +401,7 @@ https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
-
+
Source code in Cryptotools/Utils/utils.py
64
65
@@ -421,7 +423,7 @@ https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
81
82
83
-84 def exponent_squaring ( n , e ):
+84 def exponent_squaring ( n , e ):
"""
This function perform an exponentiation squaring, which compute an integer power of a number based on the following algorithm:
n ** e = {
@@ -470,7 +472,7 @@ Args:
the GCD
-
+
Source code in Cryptotools/Utils/utils.py
3
4
@@ -485,7 +487,7 @@ Args:
13
14
15
-16 def gcd ( a , b ):
"""
This function calculate the GCD (Greatest Common Divisor of the number a of b
Args: