Skip to main content

KSI Python SDK

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

Synopsis

import ksi
import hashlib

# Instantiate service parameters from the 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()
h.update(b"Tere!")
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)
KSI.set_verification_policy(KSI.verification.POLICY_CALENDAR_BASED)
print(KSI.verify_hash(sig2, h))

Install

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

  2. Install fresh libksi aka KSI C SDK; see https://github.com/guardtime/libksi/

  3. Install python-devel package

  4. Run:

    > pip install ksi-python

or

> easy_install ksi-python

Tests

Specify KSI Gateway access parameters and run

> python setup.py test

Documentation

http://guardtime.github.io/ksi-python/

Type:

> 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

Limitations

  • Synchronous calls–especially signing–block green threads.

  • Advanced functions like block signing, containers, async operations, are not implemented.

  • Python’s __del__ destructor is not guaranteed to execute. Please help garbage collector by dereferencing unnecessary signature objects with del.

License

Apache 2.0. Please contact Guardtime for supported options.

Metadata

Release files for ksi-python 0.3.2

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

Source distribution (sdist)

Source distribution for ksi-python 0.3.2
File Size Uploaded
ksi-python-0.3.2.tar.gz 13.0 kB Details

Release files / ksi-python-0.3.2.tar.gz

Download URL ksi-python-0.3.2.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
565c8acf2d4882e845fed4abe22d69fc273214bfdaefa63c142f6443ad1d1bc0
BLAKE2b-256 checksum
How to use checksums
f6de07fed3066cdd6b00a18a4907b70351753af6a9249ad12a5a650a7af5a9c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0.0

1 release file

This release

0.3.2 This release

1 release file

0.3.1

1 release file

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