modos.genomics.c4gh#
crypt4gh implementation
Crypt4gh allows envelop encryption of genomic files. See [1] for more details.
Here we use the crypt4gh python [2] implementation to allow de/encryption of genomic files within modos.
References
Functions#
|
Get the secret key for encryption/decryption. |
|
Derive the raw 32-byte X25519 public key from secret key bytes. |
|
Retrieves recipient public keys and builds a collection of "key tuples". |
|
Encrypt a file using the crypt4gh algorithm (authenticated encryption). |
|
Module Contents#
- modos.genomics.c4gh.get_secret_key(seckey_path=None, passphrase=None)[source]#
Get the secret key for encryption/decryption. If no secret key path is provided a new secret key will be generated automatically. This can be used to allow authicated encryption without prior key generation.
- Parameters:
seckey_path (os.PathLike | None) – Path to the secret key.
passphrase (str | None) – Passphrase for the secret key.
- Return type:
- modos.genomics.c4gh.derive_public_key(seckey)[source]#
Derive the raw 32-byte X25519 public key from secret key bytes.
Used to advertise the client public key to an htsget server via the Client-Public-Key header without requiring a separate public key file.
- modos.genomics.c4gh.get_keys(recipient_pubkeys, seckey)[source]#
Retrieves recipient public keys and builds a collection of “key tuples”.
- Parameters:
recipient_pubkeys (list[os.PathLike] | os.PathLike) – Path to the recipient public key, or list of paths if multiple recipients.
seckey (bytes) – Secret key of the sender.
- Returns:
Set of key triplets, one for each recipient.
- Return type:
{(method, seckey, recipient_pubkey)}
- modos.genomics.c4gh.encrypt_file(recipient_pubkeys, infile, outfile, seckey_path=None, passphrase=None)[source]#
Encrypt a file using the crypt4gh algorithm (authenticated encryption).
- Parameters:
recipient_pubkeys (list[os.PathLike] | os.PathLike)
infile (pathlib.Path | str)
outfile (pathlib.Path | str)
seckey_path (os.PathLike | None)
passphrase (str | None)
- modos.genomics.c4gh.decrypt_file(seckey_path, infile, outfile, sender_pubkey=None, passphrase=None)[source]#
- Parameters:
seckey_path (os.PathLike)
infile (pathlib.Path | str)
outfile (pathlib.Path | str)
sender_pubkey (os.PathLike | None)
passphrase (str | None)