Skip to main content

Secure Peer Protocol

Project description

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 HKDF.
  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.
from pathlib import Path
from spp.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

import asyncio
from pathlib import Path
from spp.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.

import asyncio
from pathlib import Path
from spp.connection import Connection
from spp.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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spproto-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spproto-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file spproto-0.1.1.tar.gz.

File metadata

  • Download URL: spproto-0.1.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for spproto-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf0de8861ffb12da41be0065eee3a4b75a389dabee2baeed31c842030e007059
MD5 515891a4c7ee3071d4884c579ff71e09
BLAKE2b-256 3255d7b072bcf1698d98c70895ceded0c65ddb49013aab306283574394dd63dd

See more details on using hashes here.

File details

Details for the file spproto-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spproto-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for spproto-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 baf5b64145fb0a96933b29655eb55ea9b46074828e28f24de50c5a98c56de6ea
MD5 9c590aaf16ad24e8f6c4236407c43094
BLAKE2b-256 65bf055c42cfb3eb3168f527d73967c49195566748c6ef26e5350b7a96d0f400

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page