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
- shared key is obtained using ECDHE. Transferred DH public keys are signed and verified with pre-obtained Ed25519 public keys.
- auth key is derived from shared key using ConcatKDF.
- Message using ChaCha20-Poly1305 with auth key.
Preparation before using
- Generate private key, give your public key to friend.
- Get friend's public key through reliable channel.
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
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.
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())
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.2.2.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file spproto-0.2.2.tar.gz
.
File metadata
- Download URL: spproto-0.2.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | be364f489895cd3e8482f1a88eb5d1d62980e9534d11f361c6697fd48ae08da6 |
|
MD5 | 75613ef1cbdf85ba608ced22cf37167a |
|
BLAKE2b-256 | 009767523024101f59c4dd15233fd630cdb9b0933f4486871d39502052cbdec0 |
File details
Details for the file spproto-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: spproto-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f07c5bf34fb4949dd9288747e059c416e4569b85f4abe1d88c6b0b2ffdb8361 |
|
MD5 | 05011512cb21ea1ced6d1c65ca668be6 |
|
BLAKE2b-256 | 7ac44320114dc5eda48866c01070a7abf7262cd6d17c434ce419ddf3b8c0081d |