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_secret_key([seckey_path, passphrase])

Get the secret key for encryption/decryption.

get_keys(recipient_pubkeys, seckey)

Retrieves recipient public keys and builds a collection of "key tuples".

encrypt_file(recipient_pubkeys, infile, outfile[, ...])

Encrypt a file using the crypt4gh algorithm (authenticated encryption).

decrypt_file(seckey_path, infile, outfile[, ...])

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 (Optional[os.PathLike]) – Path to the secret key.

  • passphrase (Optional[str]) – Passphrase for the secret key.

Return type:

bytes

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:
modos.genomics.c4gh.decrypt_file(seckey_path, infile, outfile, sender_pubkey=None, passphrase=None)[source]#
Parameters: