Skip to main content

keyraser python client

pipeline status coverage report

Keyraser is a system that helps you to use key-shredding for managing data privacy in distributed system. This python library includes a client that allows to encrypt or decrypt data with keys that are managed by keyraser.

What it does

The library contains a single class Client that exposes methods for encrypting or decrypting data that is either provided in form of files, python io streams or bytes. The data is encrypted with encryption keys that are specific for the owning entity of the data. Encrypted data contains an identifier of the key that it was encrypted with so it can be automatically fetched from the keyraser keystore.

How it works

Internally the library uses the Keyraser client binaries for en-/decrypting the data. The python process communicates with the cli client in a subprocess using stdout/stdin.

Using the library is quite easy:

import keyraser_client

...

client = keyraser_client.Client(
    keystore_address='localhost:1996',
    credential_path='/path/to/credential.kred',
)

src = '/path/to/ndjson/file'
dest = '/path/to/encrypted/file'

client.encrypt(
    keyraser_client.NdjsonFormat(id_property = 'user_id'), src, dest,
)

After importing the module we can create a new Client to which we need to provide configuration parameter like the address of the keystore, from where the keys should be fetched and the credential that should be used for authenticating the client. With the client we can then encrypt or decrypt by proving the arguments on where to read the data from and where to write it into.

For more information take a look at the latest user guide.

Develop

The Keyraser python client uses tox to build and test the library. Tox runs all tests on different python versions, can generate the documentation and run linters and style checks to improve the code quality. In order to install all the necessary python modules, please run:

pip install tox

Afterwards the tests can be run by just calling

tox

from the project directory. For this to work, you need to have multiple python interpreters installed. If you don't want to run the tests on all supported platforms just edit the tox.ini file and set

envlist = py38,py39,py310,py311,py312

to contain only the python version you want to use. Another option is to run tox with the additional command line argument '--skip_missing_interpreters' which skips python versions that aren't installed.

Alternatively, one can use pyenv which will use the available python version and skip the others. For this to work, export the VIRTUALENV_DISCOVERY environment variable with a value of pyenv.

export VIRTUALENV_DISCOVERY=pyenv

Documentation

The latest version of the documentation can always be found under https://docs.kant.ai/keyraser/python-client/latest. The documentation is written in Markdown and is located in the docs directory of the project. It can be built into static HTML by using MkDocs. In order to manually generate the documentation we can use tox to build the HTML pages from our markdown.

tox -e docs

Release

Releasing a new package version

Releasing new versions of multimeter is done using flit.

pip install flit

In order to be able to publish a new release, you need an account with PyPI or their respective test environment.

Add those accounts into your ~.pypirc:

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
username: <my-user>

[pypitest]
repository: https://test.pypi.org/legacy/
username: <my-test-user>

Publishing a new release to test

flit publish --repository pypitest

Releasing a new version of the documentation

The package uses mike to manage multiple versions of the documentation. The already generated documentation is kept in the docs-deployment branch and will be automatically deployed, if the branch is pushed to the repository.

In order to build a new version of the documentation, we need to use the corresponding tox environment:

VERSION_TAG='<my-version>' tox -e docs-release

The VERSION_TAG environment variable should be set to the new version in format '.'. This will build the documentation and add it as new commits to the docs-deployment branch.

By pushing the updated branch to the gitlab repository, the documentation will be automatically deployed to the official documentation website.

Metadata

Release files for keyraser_client 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keyraser_client 0.5.0
File Size Uploaded Provenance
keyraser_client-0.5.0.tar.gz 43.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for keyraser_client 0.5.0
File Interpreter ABI Platform
keyraser_client-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / keyraser_client-0.5.0.tar.gz

Download URL keyraser_client-0.5.0.tar.gz
Size 43.5 kB
Tags Source
SHA-256 checksum
How to use checksums
989099236fce346f2a8ca47b214da91776969b034fcc4aeb66e6d262c69239bb
BLAKE2b-256 checksum
How to use checksums
6fea3b933c6c6dee4368f24ab6e3b16f3c9603befb8a50d16f3b579f60a2fa57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.2

Release files / keyraser_client-0.5.0-py3-none-any.whl

Download URL keyraser_client-0.5.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efc9c44ee53d8117fe4749e2ca184277589a4fc6cd1320ffce24796e5b1f5c29
BLAKE2b-256 checksum
How to use checksums
c6ab284e81270f39ef700dd5f38ded8e2b903d401562e793a1b5749a2147a1fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.2

Security for keyraser_client 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page