Sign JSON objects with ED25519 signatures
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Robertson 067ae81616
Expose __bytes__ on Key protocols (#22)
Partially reverts #21.
2022-03-29 17:26:37 +01:00
.github Configure @matrix-org/synapse-core to be the code owner for the repo (#11) 2021-10-25 14:31:18 +01:00
.idea use nosetests in pycharm 2020-03-27 16:38:28 +00:00
changelog.d 1.1.2 2022-03-29 14:15:41 +01:00
signedjson Expose __bytes__ on Key protocols (#22) 2022-03-29 17:26:37 +01:00
tests Run black 2022-01-24 13:45:17 +00:00
.flake8 flake8 2022-01-24 14:23:07 +00:00
.gitignore Signed JSON 2015-08-24 14:40:17 +01:00
.travis.yml Cleanups to fix the CI (#3) 2020-01-29 14:22:48 +00:00
CHANGELOG.md 1.1.3 2022-03-29 16:43:31 +01:00
LICENSE Signed JSON 2015-08-24 14:40:17 +01:00
MANIFEST.in more packaging cleanup 2020-01-29 17:17:58 +00:00
pyproject.toml Run mypy 2022-01-24 13:45:43 +00:00
README.rst Signed JSON 2015-08-24 14:40:17 +01:00
RELEASING.md Update RELEASING.md 2022-03-29 14:10:42 +01:00
setup.py Mark the package as containing type hints 2022-01-24 13:53:24 +00:00
tox.ini more packaging cleanup 2020-01-29 17:17:58 +00:00

Signed JSON
===========

.. image:: https://img.shields.io/pypi/v/signedjson.svg
    :target: https://pypi.python.org/pypi/signedjson/
    :alt: Latest Version

.. image:: https://img.shields.io/travis/matrix-org/python-signedjson.svg
   :target: https://travis-ci.org/matrix-org/python-signedjson


Signs JSON objects with ED25519 signatures.


Features
--------

* More than one entity can sign the same object.
* Each entity can sign the object with more than one key making it easier to
  rotate keys
* ED25519 can be replaced with a different algorithm.
* Unprotected data can be added to the object under the ``"unsigned"`` key.


Installing
----------

.. code:: bash

   pip install signedjson

Using
-----

.. code:: python

    from signedjson.key import generate_signing_key, get_verify_key
    from signedjson.sign import (
        sign_json, verify_signed_json, SignatureVerifyException
    )

    signing_key = generate_signing_key('zxcvb')
    signed_json = sign_json({'my_key': 'my_data'}, 'Alice', signing_key)

    verify_key = get_verify_key(signing_key)

    try:
        verify_signed_json(signed_json, 'Alice', verify_key)
        print 'Signature is valid'
    except SignatureVerifyException:
        print 'Signature is invalid'

Format
------

.. code:: json

    {
        "<protected_name>": "<protected_value>",
        "signatures": {
            "<entity_name>": {
                "ed25519:<key_id>": "<unpadded_base64_signature>"
            }
        },
        "unsigned": {
            "<unprotected_name>": "<unprotected_value>",
        }
    }