docs: Create the skeleton of documentation
This commit is contained in:
14
docs/source/api.rst
Normal file
14
docs/source/api.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
API
|
||||
===
|
||||
|
||||
.. automodule:: secret_handshake.boxstream
|
||||
:members:
|
||||
|
||||
.. automodule:: secret_handshake.crypto
|
||||
:members:
|
||||
|
||||
.. automodule:: secret_handshake.network
|
||||
:members:
|
||||
|
||||
.. automodule:: secret_handshake.util
|
||||
:members:
|
37
docs/source/conf.py
Normal file
37
docs/source/conf.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# SPDX-Copyright-Text: © 2017 PySecretHandshake contributors (see AUTHORS for more details)
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
"""Sphinx configuration"""
|
||||
|
||||
from typing import List
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
project = "PySecretHandshake"
|
||||
copyright = "2023, Pedro Ferreira, Gergely Polonkai" # pylint: disable=redefined-builtin
|
||||
author = "Pedro Ferreira, Gergely Polonkai"
|
||||
release = "0.1.0"
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = ["sphinx.ext.duration", "sphinx.ext.autodoc", "sphinx.ext.autosummary"]
|
||||
|
||||
templates_path = ["_templates"]
|
||||
exclude_patterns: List[str] = []
|
||||
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
html_theme = "alabaster"
|
||||
html_static_path = ["_static"]
|
33
docs/source/index.rst
Normal file
33
docs/source/index.rst
Normal file
@@ -0,0 +1,33 @@
|
||||
.. PySecretHandshake documentation master file, created by
|
||||
sphinx-quickstart on Tue Oct 31 08:11:45 2023.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to PySecretHandshake's documentation!
|
||||
=============================================
|
||||
|
||||
**PySecretHandshake** is a Python library that implements the Secret Handshake protocol as described in Dominc Tarr's
|
||||
paper `"Designing a Secret Handshake: Authenticated Key Exchange as a Capability System"
|
||||
<http://dominictarr.github.io/secret-handshake-paper/shs.pdf>`_ (Dominic Tarr, 2015).
|
||||
|
||||
.. warning::
|
||||
|
||||
**Please, don't use this package in production. The implementation hasn't yet been carefully checked.**
|
||||
|
||||
The project is under development, and is known not to cooperate with recent SSB implementations like Manyverse.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
usage
|
||||
api
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
77
docs/source/usage.rst
Normal file
77
docs/source/usage.rst
Normal file
@@ -0,0 +1,77 @@
|
||||
Usage
|
||||
=====
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To use PySecretHandshake, install it using ``pip``:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
(.venv) $ pip install secret-handshake
|
||||
|
||||
Create a server
|
||||
---------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from asyncio import new_event_loop
|
||||
from base64 import b64encode
|
||||
from nacl.signing import SigningKey
|
||||
from secret_handshake import SHSServer
|
||||
|
||||
async def on_connect(conn):
|
||||
async for msg in conn:
|
||||
print(msg)
|
||||
|
||||
async def main():
|
||||
# In a real world implementation you should load/save this key
|
||||
# e.g. from ~/.ssb/secret
|
||||
server_keypair = SigningKey.generate()
|
||||
print(
|
||||
"Server keypair: "
|
||||
f"{b64encode(server_keypair.verify_key.encode())}.ed25519"
|
||||
)
|
||||
server = SHSServer("localhost", 8008, server_keypair)
|
||||
server.on_connect(_on_connect)
|
||||
await server.listen()
|
||||
|
||||
loop = new_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
loop.run_forever()
|
||||
loop.close()
|
||||
|
||||
Create a client
|
||||
---------------
|
||||
|
||||
.. note::
|
||||
|
||||
To run this example you will have to define ``SERVER_PUB_KEY`` which can be obtained from an actual server, or from
|
||||
the output of the example client above.
|
||||
|
||||
Make sure the server key doesn’t start with the ``@`` character, as the code below doesn’t handle that.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from asyncio import new_event_loop
|
||||
from nacl.signing import SigningKey, VerifyKey
|
||||
from secret_handshake import SHSClient
|
||||
|
||||
async def main() -> None:
|
||||
# In a real world implementation you should load/save this key
|
||||
# e.g. from ~/.ssb/secret
|
||||
client_keypair = SigningKey.generate()
|
||||
# In a real world implementation you should get this from
|
||||
# network discovery or pub messages
|
||||
server_pub_keypair = VerifyKey(SERVER_PUB_KEY[:-8])
|
||||
client = SHSClient(
|
||||
"localhost", 8008, SigningKey.generate(), server_pub_key
|
||||
)
|
||||
await client.open()
|
||||
|
||||
async for msg in client:
|
||||
print(msg)
|
||||
|
||||
loop = new_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
loop.close()
|
Reference in New Issue
Block a user