A Python implementation of GLOME protocol
Project description
PyGLOME
This is not an officially supported Google product.
This repository contains a Python implementation for the GLOME protocol. You can find the library in the folder pyglome. The test files can be found in the test folder.
Python API
Requirements
- Python >= 3.6
- pyca/cryptography >= 2.5
Example
We provide a brief example of use. In order for Alice and Bob to communicate, the first step would be to generate some new keys:
import pyglome
alice_keys = pyglome.generate_keys()
bob_keys = pyglome.generate_keys()
Suppose that Alice knows Bob's public_key and wants to send Bob the message
msg and no other message have been shared before. Alice will need to:
glome = pyglome.Glome(bob_keys.public, alice_keys.private)
first_tag = glome.tag(msg, counter=0)
And Alice will send Bob both msg, first_tag as well as Alice's public key.
On Bob's end he will need to do the following:
glome = pyglome.Glome(alice_keys.public, bob_keys.private)
try:
glome.check(first_tag, msg, counter=0)
except pyglome.TagCheckError as tag_error:
## Handle the exception.
## do what you have to do
Key generation.
Should you want to use a preexisting key, it should match the format
X25519Private/PublicKey provided in pyca/cryptography.
Such a key can be easily read from a bytes object as follows:
from cryptography.hazmat.primitives.asymmetric import x25519
my_private_key = x25519.X25519PrivateKey.from_private_bytes(private_key_bytes)
my_public_key = x25519.X25519PublicKey.from_private_bytes(public_key_bytes)
We provide a key generation function generate_keys that uses these methods to
create a new key pair from os.urandom bytes.
Documentation
For more information see the in-code documentation.
Test
In the test folder we have scripts that implement test classes based on unittest. To run all tests use:
python -m test
from this directory. If you only want to execute a particular test module, then run:
python -m test.my_module_name
where my_module_name is the name of the test module to be executed (the name of the file without the .py).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyglome-0.0.2.tar.gz.
File metadata
- Download URL: pyglome-0.0.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2114d14baea6a2b61ccdbbbe3a122204d73c8111d9dd4830537887b122f45cb6
|
|
| MD5 |
4256f06332f0ef79b029f236b24379ce
|
|
| BLAKE2b-256 |
ca1c93787f5189d545fafaa9430353d09dcbe689e439b901cc2c6d12c701deec
|
File details
Details for the file pyglome-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyglome-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4efaaa2017e1fd47d3f9dd90c87a422cc14bfe7b0bcc97da3fbcae39cec3bf1d
|
|
| MD5 |
96f4bab32de8ff5c475087225546437f
|
|
| BLAKE2b-256 |
1f8f05e854e3df6919b9aa9660c5c66362583ac1d51f51605532919b3972715b
|