spproto


Namespproto JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummarySecure Peer Protocol
upload_time2024-07-30 04:59:16
maintainerNone
docs_urlNone
authorLifr0m
requires_python>=3.12
licenseMIT License Copyright (c) 2024-Present Lifr0m Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords chacha20 chacha20-poly1305 chat concatkdf cryptography dh ec ecdh ecdhe ecdsa ed25519 eddsa kdf message peer poly1305 protocol secure
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Secure Peer Protocol (SPP)

## Description

Chat with friends in a truly cryptographically secure way.

Intended to work as 5th OSI layer usually on top of TCP/IP.

### Mechanism

1. shared key is obtained using ECDHE. Transferred DH public keys are
signed and verified with pre-obtained Ed25519 public keys.
2. auth key is derived from shared key using ConcatKDF.
3. Message using ChaCha20-Poly1305 with auth key.

## Preparation before using

1. Generate private key, give your public key to friend.
2. Get friend's public key through reliable channel.

```python
from pathlib import Path
from spproto.key import generate_private_key, get_public_key

def main() -> None:
    privkey_path = Path('~/Desktop/privkey').expanduser()
    pubkey_path = Path('~/Desktop/pubkey').expanduser()
    
    privkey = generate_private_key()
    pubkey = get_public_key(privkey)
    
    privkey_path.write_bytes(privkey)
    pubkey_path.write_bytes(pubkey)

main()
```

## How to use

### Client

Connect to your friend

```python
import asyncio
from pathlib import Path
from spproto.client import connect

async def main() -> None:
    privkey = Path('~/Desktop/privkey').expanduser().read_bytes()
    peer_pubkey = Path('~/Desktop/friend_pubkey').expanduser().read_bytes()

    host = '1.2.3.4'
    port = 4321
    async with connect(host, port, privkey, peer_pubkey) as conn:
        await conn.send(b'Hello, server!')
        print(await conn.receive())

asyncio.run(main())
```

### Server

Make your friend available to connect to you.

```python
import asyncio
from pathlib import Path
from spproto.connection import Connection
from spproto.server import serve

async def callback(
    conn: Connection
) -> None:
    print(await conn.receive())
    await conn.send(b'Hello, client')

async def main() -> None:
    privkey = Path('~/Desktop/privkey').expanduser().read_bytes()
    peer_pubkey = Path('~/Desktop/friend_pubkey').expanduser().read_bytes()

    host = '1.2.3.4'
    port = 4321
    await serve(host, port, privkey, peer_pubkey, callback)

asyncio.run(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "spproto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "chacha20, chacha20-poly1305, chat, concatkdf, cryptography, dh, ec, ecdh, ecdhe, ecdsa, ed25519, eddsa, kdf, message, peer, poly1305, protocol, secure",
    "author": "Lifr0m",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/00/97/67523024101f59c4dd15233fd630cdb9b0933f4486871d39502052cbdec0/spproto-0.2.2.tar.gz",
    "platform": null,
    "description": "# Secure Peer Protocol (SPP)\n\n## Description\n\nChat with friends in a truly cryptographically secure way.\n\nIntended to work as 5th OSI layer usually on top of TCP/IP.\n\n### Mechanism\n\n1. shared key is obtained using ECDHE. Transferred DH public keys are\nsigned and verified with pre-obtained Ed25519 public keys.\n2. auth key is derived from shared key using ConcatKDF.\n3. Message using ChaCha20-Poly1305 with auth key.\n\n## Preparation before using\n\n1. Generate private key, give your public key to friend.\n2. Get friend's public key through reliable channel.\n\n```python\nfrom pathlib import Path\nfrom spproto.key import generate_private_key, get_public_key\n\ndef main() -> None:\n    privkey_path = Path('~/Desktop/privkey').expanduser()\n    pubkey_path = Path('~/Desktop/pubkey').expanduser()\n    \n    privkey = generate_private_key()\n    pubkey = get_public_key(privkey)\n    \n    privkey_path.write_bytes(privkey)\n    pubkey_path.write_bytes(pubkey)\n\nmain()\n```\n\n## How to use\n\n### Client\n\nConnect to your friend\n\n```python\nimport asyncio\nfrom pathlib import Path\nfrom spproto.client import connect\n\nasync def main() -> None:\n    privkey = Path('~/Desktop/privkey').expanduser().read_bytes()\n    peer_pubkey = Path('~/Desktop/friend_pubkey').expanduser().read_bytes()\n\n    host = '1.2.3.4'\n    port = 4321\n    async with connect(host, port, privkey, peer_pubkey) as conn:\n        await conn.send(b'Hello, server!')\n        print(await conn.receive())\n\nasyncio.run(main())\n```\n\n### Server\n\nMake your friend available to connect to you.\n\n```python\nimport asyncio\nfrom pathlib import Path\nfrom spproto.connection import Connection\nfrom spproto.server import serve\n\nasync def callback(\n    conn: Connection\n) -> None:\n    print(await conn.receive())\n    await conn.send(b'Hello, client')\n\nasync def main() -> None:\n    privkey = Path('~/Desktop/privkey').expanduser().read_bytes()\n    peer_pubkey = Path('~/Desktop/friend_pubkey').expanduser().read_bytes()\n\n    host = '1.2.3.4'\n    port = 4321\n    await serve(host, port, privkey, peer_pubkey, callback)\n\nasyncio.run(main())\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024-Present Lifr0m  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Secure Peer Protocol",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/lifr0m/spproto"
    },
    "split_keywords": [
        "chacha20",
        " chacha20-poly1305",
        " chat",
        " concatkdf",
        " cryptography",
        " dh",
        " ec",
        " ecdh",
        " ecdhe",
        " ecdsa",
        " ed25519",
        " eddsa",
        " kdf",
        " message",
        " peer",
        " poly1305",
        " protocol",
        " secure"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ac44320114dc5eda48866c01070a7abf7262cd6d17c434ce419ddf3b8c0081d",
                "md5": "05011512cb21ea1ced6d1c65ca668be6",
                "sha256": "6f07c5bf34fb4949dd9288747e059c416e4569b85f4abe1d88c6b0b2ffdb8361"
            },
            "downloads": -1,
            "filename": "spproto-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05011512cb21ea1ced6d1c65ca668be6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 8356,
            "upload_time": "2024-07-30T04:59:15",
            "upload_time_iso_8601": "2024-07-30T04:59:15.042813Z",
            "url": "https://files.pythonhosted.org/packages/7a/c4/4320114dc5eda48866c01070a7abf7262cd6d17c434ce419ddf3b8c0081d/spproto-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "009767523024101f59c4dd15233fd630cdb9b0933f4486871d39502052cbdec0",
                "md5": "75613ef1cbdf85ba608ced22cf37167a",
                "sha256": "be364f489895cd3e8482f1a88eb5d1d62980e9534d11f361c6697fd48ae08da6"
            },
            "downloads": -1,
            "filename": "spproto-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "75613ef1cbdf85ba608ced22cf37167a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 5022,
            "upload_time": "2024-07-30T04:59:16",
            "upload_time_iso_8601": "2024-07-30T04:59:16.255445Z",
            "url": "https://files.pythonhosted.org/packages/00/97/67523024101f59c4dd15233fd630cdb9b0933f4486871d39502052cbdec0/spproto-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-30 04:59:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lifr0m",
    "github_project": "spproto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "spproto"
}
        
Elapsed time: 3.28303s