pyecsca.ec.params module¶
Provides functions for obtaining domain parameters from the std-curves repository [STD].
It also provides a domain parameter class and a class for a whole category of domain parameters.
- class DomainParameters(curve, generator, order, cofactor, name=None, category=None)[source]¶
Bases:
object
Domain parameters which specify a subgroup on an elliptic curve.
>>> secp256r1 = get_params("secg", "secp256r1", "projective") >>> str(secp256r1) 'DomainParameters(secg/secp256r1)' >>> secp256r1.order 115792089210356248762697446949407573529996955224135760342422259061068512044369 >>> secp256r1.cofactor 1 >>> secp256r1.generator Point([X=48439561293906451759052585252797914202762949526041747995844080717082404635286, Y=36134250956749795798585127919587881956611106672985015071877198253568414405109, Z=1] in shortw/projective) >>> secp256r1.curve.prime 115792089210356248762697446949407573530086143415290314195533631308867097853951 >>> secp256r1.curve.parameters {'a': 115792089210356248762697446949407573530086143415290314195533631308867097853948, 'b': 41058363725152142129326129780047268409114441015993725554835256314039467401291}
-
curve:
EllipticCurve
[source]¶
- to_coords(coordinate_model)[source]¶
Convert the domain parameters into a different coordinate model, only possible if they are currently affine.
- Parameters:
coordinate_model¶ (
CoordinateModel
) – The target coordinate model.- Return type:
- Returns:
The transformed domain parameters
-
curve:
- class DomainParameterCategory(name, description, curves)[source]¶
Bases:
object
A category of domain parameters.
-
curves:
List
[DomainParameters
][source]¶
-
curves:
- load_category(file, coords, infty=True)[source]¶
Load a category of domain parameters containing several curves from a JSON file.
- Parameters:
file¶ (
Union
[str
,Path
,BinaryIO
,IO
[bytes
]]) – The file to load from.coords¶ (
Union
[str
,Callable
[[str
],str
]]) – The name of the coordinate system to use. Can be a callable that takes as argument the name of the curve and produces the coordinate system to use for that curve.infty¶ (
Union
[bool
,Callable
[[str
],bool
]]) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system. Can be a callable that takes as argument the name of the curve and returns the infinity option to use for that curve.
- Return type:
- Returns:
The category.
- load_params(file, coords, infty=True)[source]¶
Load a curve from a JSON file.
- Parameters:
file¶ (
Union
[str
,Path
,BinaryIO
]) – The file to load from.coords¶ (
str
) – The name of the coordinate system to use.infty¶ (
bool
) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system.
- Return type:
- Returns:
The curve.
- load_params_ecgen(file, coords, infty=True)[source]¶
Load a curve from a file that is output of ecgen.
- Parameters:
file¶ (
Union
[str
,Path
,BinaryIO
]) – The file to load from.coords¶ (
str
) – The name of the coordinate system to use.infty¶ (
bool
) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system.
- Return type:
- Returns:
The curve.
- load_params_ectester(file, coords, infty=True)[source]¶
Load a curve from a file that uses the format of ECTester.
- Parameters:
file¶ (
Union
[str
,Path
,BinaryIO
]) – The file to load from.coords¶ (
str
) – The name of the coordinate system to use.infty¶ (
bool
) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system.
- Return type:
- Returns:
The curve.
- get_category(category, coords, infty=True)[source]¶
Retrieve a category from the std-curves database at https://github.com/J08nY/std-curves.
- Parameters:
category¶ (
str
) – The category to retrieve.coords¶ (
Union
[str
,Callable
[[str
],str
]]) – The name of the coordinate system to use. Can be a callable that takes as argument the name of the curve and produces the coordinate system to use for that curve.infty¶ (
Union
[bool
,Callable
[[str
],bool
]]) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system. Can be a callable that takes as argument the name of the curve and returns the infinity option to use for that curve.
- Return type:
- Returns:
The category.
- get_params(category, name, coords, infty=True)[source]¶
Retrieve a curve from a set of stored parameters.
Uses the std-curves database at https://github.com/J08nY/std-curves.
- Parameters:
category¶ (
str
) – The category of the curve.name¶ (
str
) – The name of the curve.coords¶ (
str
) – The name of the coordinate system to use.infty¶ (
bool
) – Whether to use the specialInfinityPoint
(True) or try to use the point at infinity of the coordinate system.
- Return type:
- Returns:
The curve.