Download decrypt_checkpoints.py from Andandd/amy-checkpoints: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/Andandd/amy-checkpoints/resolve/3db90e2a435ca030d6e1104e6872934da6bbff9e/decrypt_checkpoints.py
- Command line
-
hf download hf://Andandd/amy-checkpoints@3db90e2a435ca030d6e1104e6872934da6bbff9e/decrypt_checkpoints.py
-
curl -L -o decrypt_checkpoints.py https://huggingface.co/Andandd/amy-checkpoints/resolve/3db90e2a435ca030d6e1104e6872934da6bbff9e/decrypt_checkpoints.py
2 kB
| """ | |
| decrypt_checkpoints.py — Decrypt Amy .pt.enc checkpoints back to .pt | |
| Usage: | |
| python decrypt_checkpoints.py <encrypted_dir> <output_dir> | |
| python decrypt_checkpoints.py ./v1_cache_encrypted ./checkpoints | |
| Requires: pip install cryptography | |
| Key: see DECRYPTION_KEY.md (private, do NOT commit) | |
| """ | |
| import os | |
| import sys | |
| import glob | |
| from cryptography.hazmat.primitives.ciphers.aead import AESGCM | |
| # Paste your key here or set AMY_DECRYPT_KEY env var | |
| KEY_HEX = os.environ.get( | |
| "AMY_DECRYPT_KEY", | |
| "44ab060120516fadb0fc1be322d16e4fda0571f041fb534d9a6a0c945d5d9b1e" | |
| ) | |
| KEY = bytes.fromhex(KEY_HEX) | |
| def decrypt_file(src_path: str, dst_path: str): | |
| """Decrypt src_path (.enc) → dst_path (.pt)""" | |
| aesgcm = AESGCM(KEY) | |
| raw = open(src_path, "rb").read() | |
| nonce = raw[:12] | |
| ct = raw[12:] | |
| plaintext = aesgcm.decrypt(nonce, ct, None) | |
| with open(dst_path, "wb") as f: | |
| f.write(plaintext) | |
| return len(plaintext) | |
| def decrypt_directory(src_dir: str, dst_dir: str): | |
| """Decrypt all .pt.enc files in src_dir → dst_dir as .pt""" | |
| os.makedirs(dst_dir, exist_ok=True) | |
| files = sorted(glob.glob(os.path.join(src_dir, "*.pt.enc"))) | |
| print(f"Found {len(files)} encrypted files in {src_dir}") | |
| for i, fpath in enumerate(files): | |
| name = os.path.basename(fpath).replace(".enc", "") | |
| dst = os.path.join(dst_dir, name) | |
| if os.path.exists(dst): | |
| print(f" [{i+1}/{len(files)}] SKIP (exists): {name}") | |
| continue | |
| size_mb = os.path.getsize(fpath) / 1e6 | |
| print(f" [{i+1}/{len(files)}] Decrypting {name} ({size_mb:.0f}MB)...", flush=True) | |
| orig = decrypt_file(fpath, dst) | |
| print(f" → {name} ({orig/1e6:.0f}MB)") | |
| print(f"\nDone. {len(files)} files decrypted to {dst_dir}") | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 3: | |
| print("Usage: python decrypt_checkpoints.py <encrypted_dir> <output_dir>") | |
| sys.exit(1) | |
| decrypt_directory(sys.argv[1], sys.argv[2]) | |