src.crypto¶
Generic functions for the cryptographic primitives used in this project.
Functions
get_hasher () |
Returns a object that you can use for hashing, compatible to the hashlib interface. |
Classes
Signing (byte_repr) |
Functionality for creating and verifying signatures, and their public/private keys. |
-
src.crypto.
get_hasher
()¶ Returns a object that you can use for hashing, compatible to the hashlib interface.
-
class
src.crypto.
Signing
(byte_repr)¶ Functionality for creating and verifying signatures, and their public/private keys.
Parameters: byte_repr ( bytes
) – The bytes serialization of a public key.-
as_bytes
(include_priv=False)¶ Serialize this key to a bytes value.
Return type: bytes
-
classmethod
from_file
(path)¶ Reads a private or public key from the file at path.
-
classmethod
from_json_compatible
(obj)¶ Creates a new object of this class, from a JSON-serializable representation.
-
classmethod
generate_private_key
()¶ Generate a new private key.
-
has_private
¶ Returns a bool value indicating whether this instance has a private key that can be used to sign things.
-
classmethod
read_many_private
(file_contents)¶ Reads many private keys from the (binary) contents of a file written with write_many_private.
Return type: Iterator
-
sign
(hashed_value)¶ Sign a hashed value with this private key.
Return type: bytes
-
to_json_compatible
()¶ Returns a JSON-serializable representation of this object.
-
verify_sign
(hashed_value, signature)¶ Verify a signature for an already hashed value and a public key.
Return type: bool
-
static
write_many_private
(keys)¶ Writes the private keys in keys to the file at path.
-
-
src.crypto.
MAX_HASH
= 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095¶ The largest possible hash value, when interpreted as an unsigned int.