templates.symmetric_encryption_scheme module¶
Generic classes used for creating a symmetric encryption scheme.
- class templates.symmetric_encryption_scheme.SymmetricEncryptionScheme(key, *_args, **_kwargs)[source]¶
Bases:
EncryptionScheme
[SK
,PT
,RP
,CV
,CT
],ABC
Abstract base class for a SymmetricEncryptionScheme. Subclass of EncryptionScheme.
- __eq__(other)[source]¶
Compare equality of two SymmetricEncryptionSchemes
- Parameters:
other (
object
) – The other object to compare with.- Raises:
TypeError – When the type of the other object is not the same is of this scheme.
- Return type:
bool
- Returns:
Boolean value representing (in)equality of self and other.
- __init__(key, *_args, **_kwargs)[source]¶
Construct a SymmetricEncryptionScheme with the given key.
- Parameters:
key (
TypeVar
(SK
, bound=SymmetricKey
)) – Symmetric key.*_args (
Any
) – Possible extra parameters for this scheme.**_kwargs (
Any
) – Possible extra keyword parameters for this scheme.
- classmethod deserialize(json, **_kwargs)[source]¶
Construct this scheme from the serialization.
- Parameters:
json (
dict
[str
,dict
[str
,int
]]) – Serialization of this scheme.**_kwargs (
Any
) – Optional extra keyword arguments.
- Return type:
TypeVar
(SE
, bound= SymmetricEncryptionScheme[Any, Any, Any, Any, Any])- Returns:
An initialized version of this scheme.
- classmethod from_security_parameter(*args, **kwargs)[source]¶
Generate a new SymmetricEncryptionScheme from a security parameter.
- Parameters:
*args (
Any
) – Security parameter(s) and optional extra arguments for the SymmetricEncryptionScheme constructor.**kwargs (
Any
) – Security keyword parameter(s) and optional extra arguments for the SymmetricEncryptionScheme constructor.
- Return type:
TypeVar
(SE
, bound= SymmetricEncryptionScheme[Any, Any, Any, Any, Any])- Returns:
Symmetric cryptographic scheme
- static generate_key_material(bit_length)[source]¶
Method to generate key material (SymmetricKey) for this scheme.
- Parameters:
bit_length (
int
) – Desired bit security of the secret key- Return type:
- Returns:
The SymmetricKey that was generated.
- property key: SK¶
SymmetricKey of this instantiation of the scheme.
- Returns:
SymmetricKey of this instantiation.
- class templates.symmetric_encryption_scheme.SymmetricKey(key_value)[source]¶
Bases:
object
Class for storing and generating symmetric key material
- classmethod deserialize(json)[source]¶
Construct this key from its serialization.
- Parameters:
json (
dict
[str
,int
]) – Serialization of this key.- Return type:
- Returns:
An initialized version of this key.
- classmethod from_sec_param(sec_param)[source]¶
Class method that generates a uniformly random secret key
- Parameters:
sec_param (
int
) – bit security of the key to be generated- Return type:
- Returns:
uniformly random symmetric key with bit security equal to sec_param
- serialize()[source]¶
Serialize this symmetric key.
- Return type:
dict
[str
,int
]- Returns:
Dictionary object containing the value of this key.
- classmethod to_bits(to_convert)[source]¶
Class method that converts alternate representations of a symmetric key to the right format
- Parameters:
to_convert (
bytes
|str
) – variable of type bytes or str (of format ‘0b{0,1}*’) to be converted- Return type:
List
[int
]- Returns:
list of integers in that are either 0 or 1