Decentralized Instant Messaging Protocol (Python)
Talk is cheap, show you the codes!
Dependencies
pip3 install dimp
Common Extensions
facebook.py
class Facebook(Barrack):
""" Access database to load/save user's private key, meta and profiles """
def save_private_key(self, private_key: PrivateKey, identifier: ID) -> bool:
pass
#
# singleton
#
facebook = Facebook()
keystore.py
class KeyStore(KeyCache):
""" For reuse symmetric key """
def save_keys(self, key_map: dict) -> bool:
pass
def load_keys(self) -> dict:
pass
#
# singleton
#
keystore = KeyStore()
messanger.py
class Messanger(Transceiver, ITransceiverDelegate):
""" Transform and send message """
def __init__(self):
super().__init__()
self.delegate = self
#
# ITransceiverDelegate
#
def send_package(self, data: bytes, handler: ICompletionHandler) -> bool:
pass
def upload_data(self, data: bytes, msg: InstantMessage) -> str:
pass
def download_data(self, url: str, msg: InstantMessage) -> bytes:
pass
#
# singleton
#
messanger = Messanger()
messanger.barrack = facebook
messanger.key_cache = keystore
User Account
register.py
def register(username: str) -> User:
# 1. generate private key
sk = PrivateKey({'algorithm': 'RSA'})
# 2. generate meta with username(as seed) and private key
meta = Meta.generate(private_key=sk, seed=username)
# 3. generate ID with network type by meta
identifier = meta.generate_identifier(network=network)
# 4. save private key and meta info
facebook.save_private_key(private_key=sk, identifier=identifier)
facebook.save_meta(meta=meta, identifier=identifier)
# 5. create user with ID
user = User(identifier)
facebook.cache_user(user)
return user
Messaging
send.py
def pack(content: Content, sender: ID, receiver: ID) -> ReliableMessage:
msg = InstantMessage.new(content=content, sender=sender, receiver=receiver)
return messanger.encrypt_sign(msg)
if __name__ == '__main__':
moki = ID("moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk");
hulk = ID("hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj");
content = TextContent.new(text='Hello world!')
msg = pack(content=content, sender=moki, receiver=hulk)
# TODO: send out the request data
request = json.dumps(msg) + '\n'
data = request.encode('utf-8')
Copyright © 2019 Albert Moky
Metadata
Release files for dimp 0.3.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dimp-0.3.11.tar.gz | 17.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dimp-0.3.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.9 kB
Release files / dimp-0.3.11.tar.gz
| Download URL | dimp-0.3.11.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
996fafe7d89945045bcc0e7fb172133c33c50013fb8ae5e84a92c774db6c0275
|
|
BLAKE2b-256 checksum How to use checksums |
a23a6e399b64a8bd47560e0f5d10457839277eca1787f3116362232d0e753cf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0b3
|
Release files / dimp-0.3.11-py3-none-any.whl
| Download URL | dimp-0.3.11-py3-none-any.whl |
|---|---|
| Size | 37.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
112c034a21ed258d08168631a17f4cc7edbbaa32a5d542f8507b5f3d13cd5bc5
|
|
BLAKE2b-256 checksum How to use checksums |
f24a335a92385ead86cdc0bafc7ffcca10d1bb936b7ae91b8025f1b0b3c33272
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0b3
|
Security for dimp 0.3.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.