docs: Create the skeleton of documentation
This commit is contained in:
24
docs/Makefile
Normal file
24
docs/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# SPDX-Copyright-Text: © 2017 PySecretHandshake contributors (see AUTHORS for more details)
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
39
docs/make.bat
Normal file
39
docs/make.bat
Normal file
@@ -0,0 +1,39 @@
|
||||
REM SPDX-License-Identifier: MIT
|
||||
REM
|
||||
REM SPDX-Copyright-Text: © 2023 PySecretHandshake contributors (see AUTHORS for more details)
|
||||
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
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