Ghost Key Protocol for passwordless asymmetric encryption using RSA-4096 and AES-256-GCM
Project description
GUN-101-GKP: Ghost Key Protocol
A passwordless asymmetric encryption library for file encryption using RSA-4096 and AES-256-GCM.
What is GUN-101-GKP?
GUN-101-GKP (Ghost Key Protocol) is a Python library that enables secure file encryption without shared secrets or passwords. The recipient generates an RSA-4096 key pair and shares only their public key (called an Identity Token). Anyone with this token can encrypt files for the recipient, but only the holder of the private key can decrypt them.
Who is it for?
- Individuals who need to send sensitive files to a specific recipient without exchanging passwords or using a secure channel for key agreement.
- Applications that require asymmetric encryption for file storage or transmission where the recipient's identity is known in advance.
- Users who want a simple, stateless encryption scheme where the sender holds no long-term secrets.
What does it protect?
GUN-101-GKP provides confidentiality of file contents against attackers who do not possess the recipient's private key. Specifically:
- Encrypted files cannot be decrypted without the matching RSA-4096 private key.
- The encrypted container integrates authentication via AES-256-GCM, ensuring that any modification to the ciphertext, nonce, or tag is detected before decryption proceeds.
- A fingerprint of the recipient's public key is included in the container and verified before any RSA operation, preventing decryption attempts with the wrong key.
What does it NOT protect?
- Private key compromise: If the recipient's private key is stolen or leaked, all past and future files encrypted for that key can be decrypted.
- Malware or endpoint compromise: The library cannot protect against malware that steals the plaintext before encryption or after decryption, or that steals the private key from the victim's machine.
- Quantum attacks: RSA-4096 is vulnerable to Shor's algorithm on a sufficiently large quantum computer. This library does not claim post-quantum security.
- Forward secrecy: Compromise of the private key allows decryption of all previously encrypted files; no forward secrecy is provided.
- Traffic analysis or metadata protection: The length of the file and the fact that encryption occurred are not concealed.
How to use it
1. Generate an identity (recipient only)
The recipient runs this once to create a key pair:
gun101gkp generate-identity
This prints an Identity Token (starting with GUN101GKP-v2-) and a fingerprint. The private key is stored at ~/.gun101gkp/private_key.pem with permission 600.
Share the Identity Token with anyone who needs to send you encrypted files. You may also share the fingerprint for out-of-band verification.
2. Encrypt a file (sender only)
To encrypt a file for a recipient, use their Identity Token:
gun101gkp encrypt <file> --recipient <TOKEN> [--output <output_path>]
Example:
gun101gkp encrypt report.pdf --recipient GUN101GKP-v2-c2VjcmV0...
This creates an encrypted file (default: report.pdf.gkp). No password or shared secret is needed.
3. Decrypt a file (recipient only)
To decrypt a file received from a sender:
gun101gkp decrypt <file> [--passphrase] [--output <output_path>]
If your private key is encrypted with a passphrase, you will be prompted for it. The decrypted file will be written to the original name without the .gkp extension, or to the specified output path.
4. Manage your identity
gun101gkp show-identity: Display your stored Identity Token.gun101gkp fingerprint [--token <TOKEN>]: Show the fingerprint of your stored identity or a provided token.gun101gkp reset-identity: Delete your private key (irreversible). Warning: This makes all previously encrypted files permanently undecryptable.
Example workflow
-
Alice (recipient) runs:
$ gun101gkp generate-identity Identity token: GUN101GKP-v2-BEkEj... Fingerprint: 3A:5F:8C:...:1F:4B Warning: Store your private key backup at ~/.gun101gkp/private_key.pem. Losing it makes all encrypted files permanently unreadable.
-
Alice sends the token (and optionally the fingerprint via a separate channel) to Bob.
-
Bob (sender) has a file
contract.pdfand encrypts it for Alice:$ gun101gkp encrypt contract.pdf --recipient GUN101GKP-v2-BEkEj... Encrypted file written to: contract.pdf.gkp
-
Bob sends
contract.pdf.gkpto Alice (e.g., via email). -
Alice decrypts the file:
$ gun101gkp decrypt contract.pdf.gkp Enter passphrase for private key: ******** Decrypted file written to: contract.pdf
Installation
pip install gun101-gkp
Algorithm details
- Key encapsulation: RSA-4096 with OAEP padding (MGF1-SHA256, label=None).
- Data encryption: AES-256-GCM with a random 96-bit nonce.
- Key derivation: A fresh 256-bit data encryption key (DEK) is generated per encryption using
os.urandom. - Authentication: AES-256-GCM provides integrity and authenticity; decryption fails if the ciphertext, nonce, or tag is altered.
- Key confirmation: Before any RSA operation, the recipient's public key fingerprint (SHA-256 of the DER-encoded public key, formatted as colon-separated hex) is compared to the value in the container. A mismatch aborts decryption immediately.
File format
The encrypted container is a JSON object (UTF-8 encoded) base64-encoded fields:
{
"protocol": "GUN-101-GKP",
"version": "2.0",
"recipient_fingerprint": "3A:5F:8C:...:1F:4B",
"sealed_dek": "<base64-encoded RSA-OAEP encrypted DEK>",
"nonce": "<base64-encoded 12-byte nonce>",
"ciphertext": "<base64-encoded encrypted file contents>",
"tag": "<base64-encoded 16-byte authentication tag>"
}
Security notes
- The private key file (
~/.gun101gkp/private_key.pem) must be backed up securely. Loss of this file means permanent inability to decrypt any files encrypted for the corresponding public key. - If you choose to encrypt your private key with a passphrase, remember that loss of the passphrase also results in irreversible loss of the key.
- This library is intended for file encryption. It is not suitable for encrypting large streams or for use in network protocols without additional framing.
License
MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gun101_gkp-3.0.1.tar.gz.
File metadata
- Download URL: gun101_gkp-3.0.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b84bb804c57175622123eec01707142447b29df5f0f98ba733e9dc488e98f0c
|
|
| MD5 |
632829e174c5c10221d351de00e4cf5a
|
|
| BLAKE2b-256 |
1dd3fbbc25e4ce639e43ab134de01f9bc2be24a4ad2921a5b2f2f577c18f2391
|
Provenance
The following attestation bundles were made for gun101_gkp-3.0.1.tar.gz:
Publisher:
publish.yml on dialga-cmd/gun101-gkp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gun101_gkp-3.0.1.tar.gz -
Subject digest:
5b84bb804c57175622123eec01707142447b29df5f0f98ba733e9dc488e98f0c - Sigstore transparency entry: 2211822899
- Sigstore integration time:
-
Permalink:
dialga-cmd/gun101-gkp@9b20597c2d5c754b26d9814424513a8e13727b63 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dialga-cmd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b20597c2d5c754b26d9814424513a8e13727b63 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gun101_gkp-3.0.1-py3-none-any.whl.
File metadata
- Download URL: gun101_gkp-3.0.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96d8b1204916f69b0d039cd263ac3f41d873ed5f0650b569f5ad3eb2621508f1
|
|
| MD5 |
205228a1e214ac788e4469af37a3f2ba
|
|
| BLAKE2b-256 |
bcc92bfbd27789847f40dcaa337b3c3f38f99d9ecac5199a869bf5d23044f6b1
|
Provenance
The following attestation bundles were made for gun101_gkp-3.0.1-py3-none-any.whl:
Publisher:
publish.yml on dialga-cmd/gun101-gkp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gun101_gkp-3.0.1-py3-none-any.whl -
Subject digest:
96d8b1204916f69b0d039cd263ac3f41d873ed5f0650b569f5ad3eb2621508f1 - Sigstore transparency entry: 2211822937
- Sigstore integration time:
-
Permalink:
dialga-cmd/gun101-gkp@9b20597c2d5c754b26d9814424513a8e13727b63 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dialga-cmd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b20597c2d5c754b26d9814424513a8e13727b63 -
Trigger Event:
push
-
Statement type: