File: README.rst

package info (click to toggle)
python-signedjson 1.0.0+git20151019-3
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 128 kB
  • sloc: python: 302; makefile: 3
file content (71 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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>",
        }
    }