Skip to main content

Python wrapper for libksi, a library for accessing Guardtime KSI service

Project description

This is a thin wrapper on top of KSI C SDK. Experimental, non-supported code.


import ksi
import hashlib

# Instantiate service parameters from environment
KSI = ksi.KSI(**ksi.ksi_env())

# Sign a text string
sig = KSI.sign_hash(hashlib.sha256(b"Tere!"))
# Print some signature properties
print(sig.get_signing_time(), sig.get_signer_id())

# Now verify this text string, first obtaining a data hasher
h = sig.get_hasher()
print(KSI.verify_hash(sig, h))

# Obtain a binary blob which can be stored for long term
serialized_signature = sig.serialize()

# Some time have passed, fetch the signature and verify again
sig2 = KSI.parse(serialized_signature)
print(KSI.verify_hash(sig2, h))


  1. Requirements: Python 2.7+ or Python 3.1+. Jython, IronPython do not work.

  2. Install fresh libksi aka KSI C SDK; see

  3. Install python-devel package

  4. Run:

    > python install

For development something like below is more appropriate:

> python build_ext --inplace

Using pip:

> pip install git+

Library can be packaged as a binary rpm:

> python bdist_rpm



> python test



> pydoc ksi

to read the documentation after installation. Generating html or pdf documentation: make sure that dependencies like sphinx (pip install sphinx) are installed and run:

> cd docs
> make html
> make latexpdf


Apache 2.0. Please contact Guardtime for supported options.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ksi-python-0.3.1.tar.gz (12.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page