![Logo: кошка Свинья](https://i.imgur.com/5AHvXQm.jpeg)
# catpig
`catpig` is a [memory-hard](https://en.wikipedia.org/wiki/Memory-hard_function) [password-hashing function](https://en.wikipedia.org/wiki/Key_derivation_function).
It uses `SHAKE256` to create data that will occupy memory of a given size (`space_mib`).
The data will be read in 4096-byte chunks with a pseudo-random offset and hashed by the `BLAKE2b` function.
Memory access patterns during reading of the first half of a given amount of data depend only on the salt (iMHF). Memory access patterns during reading of the second half of a given amount of data also depend the results of previous steps (dMHF).
The output length is always 64 bytes.
## Install
```bash
pip install catpig
```
## Usage
```python
from catpig.catpig import catpig
derived_key = catpig(password, salt, space_mib, passes)
```
`password` and `salt` must be bytes-like objects.
`space_mib` defines the memory usage in mebibytes.
`passes` defines the amount of data that will be read and hashed by the `BLAKE2b` function. One pass corresponds to reading a data size equal to `space_mib`.
## Test vectors
```python
>>> from catpig.catpig import catpig
>>>
>>> catpig(b'', b'', space_mib=1, passes=1).hex()
'831e43e4a352066a8ade279225d95e7543203cce8ce77348e4f7898741f32b9f1b8793393aa69cef84016d5f391aa9a7840050c5c59b9defd6cc324cb44e3e9a'
>>>
>>> catpig(password=b'password', salt=b'salt', space_mib=64, passes=4).hex()
'd1999b1a7749de88ac8b6f1d8659ccf3b1c2cfe7fd84426bddc75de4b9f57bc07293cca52bb22e0915945d462bb760dfab02d78a713e65620307bc08b8fb7905'
>>>
>>> catpig(password=b'passphrase', salt=b'NaCl', space_mib=512, passes=8).hex()
'83b6181449eb405e7bb662642090c077298e445f63846a98f18b8102df5e80f8a50dcf43f951ce8e893aac5beb23d33e5282624fd288fac4d07b8647f6c9bffe'
>>>
>>> catpig(password=b'new_passphrase', salt=b'SodiumChloride', space_mib=5000, passes=15).hex()
'b4f96ceddf5c46380f6a425ebf2a30372cccfb3e4d7d95fd1cfc7c64910142eca3b7e61c20e32db7c97c72230c3b63abf1802dc068513297b67c274267fd1dde'
```
## Warnings
- The author is not an expert in cryptography.
- `catpig` has not been independently audited.
## Requirements
- Python >= 3.6
Raw data
{
"_id": null,
"home_page": "https://github.com/hakavlad/catpig",
"name": "catpig",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "kdf pbkdf memory-hard",
"author": "Alexey Avramov",
"author_email": "hakavlad@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1d/45/83115d7651636c9696fcb64a3877019d5915922e600bcea6d86723dabeec/catpig-0.3.0.tar.gz",
"platform": null,
"description": "![Logo: \u043a\u043e\u0448\u043a\u0430 \u0421\u0432\u0438\u043d\u044c\u044f](https://i.imgur.com/5AHvXQm.jpeg)\n\n# catpig\n\n`catpig` is a [memory-hard](https://en.wikipedia.org/wiki/Memory-hard_function) [password-hashing function](https://en.wikipedia.org/wiki/Key_derivation_function).\n\nIt uses `SHAKE256` to create data that will occupy memory of a given size (`space_mib`).\n\nThe data will be read in 4096-byte chunks with a pseudo-random offset and hashed by the `BLAKE2b` function.\n\nMemory access patterns during reading of the first half of a given amount of data depend only on the salt (iMHF). Memory access patterns during reading of the second half of a given amount of data also depend the results of previous steps (dMHF).\n\nThe output length is always 64 bytes.\n\n## Install\n\n```bash\npip install catpig\n```\n\n## Usage\n\n```python\nfrom catpig.catpig import catpig\n\nderived_key = catpig(password, salt, space_mib, passes)\n```\n\n`password` and `salt` must be bytes-like objects.\n\n`space_mib` defines the memory usage in mebibytes.\n\n`passes` defines the amount of data that will be read and hashed by the `BLAKE2b` function. One pass corresponds to reading a data size equal to `space_mib`.\n\n## Test vectors\n\n```python\n>>> from catpig.catpig import catpig\n>>>\n>>> catpig(b'', b'', space_mib=1, passes=1).hex()\n'831e43e4a352066a8ade279225d95e7543203cce8ce77348e4f7898741f32b9f1b8793393aa69cef84016d5f391aa9a7840050c5c59b9defd6cc324cb44e3e9a'\n>>>\n>>> catpig(password=b'password', salt=b'salt', space_mib=64, passes=4).hex()\n'd1999b1a7749de88ac8b6f1d8659ccf3b1c2cfe7fd84426bddc75de4b9f57bc07293cca52bb22e0915945d462bb760dfab02d78a713e65620307bc08b8fb7905'\n>>>\n>>> catpig(password=b'passphrase', salt=b'NaCl', space_mib=512, passes=8).hex()\n'83b6181449eb405e7bb662642090c077298e445f63846a98f18b8102df5e80f8a50dcf43f951ce8e893aac5beb23d33e5282624fd288fac4d07b8647f6c9bffe'\n>>>\n>>> catpig(password=b'new_passphrase', salt=b'SodiumChloride', space_mib=5000, passes=15).hex()\n'b4f96ceddf5c46380f6a425ebf2a30372cccfb3e4d7d95fd1cfc7c64910142eca3b7e61c20e32db7c97c72230c3b63abf1802dc068513297b67c274267fd1dde'\n```\n\n## Warnings\n\n- The author is not an expert in cryptography.\n- `catpig` has not been independently audited.\n\n## Requirements\n\n- Python >= 3.6\n\n\n",
"bugtrack_url": null,
"license": "CC0",
"summary": "A memory-hard password-hashing function",
"version": "0.3.0",
"project_urls": {
"Bug Tracker": "https://github.com/hakavlad/catpig/issues",
"Documentation": "https://github.com/hakavlad/catpig/blob/main/README.md",
"Homepage": "https://github.com/hakavlad/catpig"
},
"split_keywords": [
"kdf",
"pbkdf",
"memory-hard"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d4511848e195501ac3725de1be873cdb2621dc5c1268de6d66f11bd97ba1d7aa",
"md5": "a3bdad4f422805db530e249a782a281f",
"sha256": "043361801fefd486d731db7baf2084a6ffe28ddf2b8febaf46e5d9a950aa75e0"
},
"downloads": -1,
"filename": "catpig-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3bdad4f422805db530e249a782a281f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6806,
"upload_time": "2023-10-12T15:32:05",
"upload_time_iso_8601": "2023-10-12T15:32:05.343468Z",
"url": "https://files.pythonhosted.org/packages/d4/51/1848e195501ac3725de1be873cdb2621dc5c1268de6d66f11bd97ba1d7aa/catpig-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1d4583115d7651636c9696fcb64a3877019d5915922e600bcea6d86723dabeec",
"md5": "e2a388fc66c0d3bf567d3039ee16e7ed",
"sha256": "9def934f7437c4bf9c22757bf1eeac90422e9c87afe43ca23a33c401205c4ec7"
},
"downloads": -1,
"filename": "catpig-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "e2a388fc66c0d3bf567d3039ee16e7ed",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3859,
"upload_time": "2023-10-12T15:32:06",
"upload_time_iso_8601": "2023-10-12T15:32:06.688392Z",
"url": "https://files.pythonhosted.org/packages/1d/45/83115d7651636c9696fcb64a3877019d5915922e600bcea6d86723dabeec/catpig-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-12 15:32:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hakavlad",
"github_project": "catpig",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "catpig"
}