A lightweight module for elliptic-curve security schemes.
Project description
Elite v1.1.1
A lightweight module for elliptic-curve security schemes.
Repository: https://github.com/origamizyt/Elite
1. Installation
This module is available on PyPI, which you can install by running the command below:
pip install Elite
The source code is also available on Github.
2. Usage
2.1 Concepts
There are a few concepts you need to know before coping with this module. Otherwise you may get lost in the usage and description. You'll need to you what is a:
- Scheme. A security scheme is an object which encapsulates the standard procedures in its methods and provides simple interfaces to operate with.
- Cryptography Provider. A crypto provider is an instance which manages the symmetric algorithm part of the scheme.
2.2 Basic usage
For top-level functionalities, you can instantiate an instance of a scheme either by calling getscheme
or directly create an instance. However, it's recommended that beginners use the getscheme
method:
import elite
# server side
s = elite.getscheme()
# client side
c = elite.getscheme()
After instantiating a scheme, you can export your local public key or import remote key by calling the following methods:
# binary version
c.importBinaryKey(s.exportBinaryKey())
# hex version
s.importHexKey(c.exportHexKey())
After loading the keys, a shared secret should now be established. Call the secret
method to generate a shared secret. The two secrets should be the same.
# should be the same
print(s.secret())
print(c.secret())
Sign / Verify data via the sign
/ verify
method:
signature = s.sign(b'data')
assert c.verify(b'data', signature)
Encrypt / Decrypt data via the encrypt
/ decrypt
method:
data = s.encrypt(b'data')
assert b'data' == c.decrypt(data)
NOTE: a scheme can only verify / decrypt data from the other side. Don't try to verify / decrypt data generated by yourself.
2.3 Advanced usage
For mid-level programmers, you could try instantiating the schemes directly. They are in the scheme
submodule.
from elite.scheme import P384r1AesGcmScheme
# secp384r1 with AES_GCM
s = P384r1AesGcmScheme()
c = P384r1AesGcmScheme()
For high-level programmers, you can instantiate the ECCScheme
class to create your own schemes:
from elite.scheme import ECCScheme
from elite.cipher import getprovider
from elite.secret import CurveKind
s = ECCScheme(CurveKind.CK_SECP256K1, getprovider())
You can test the module using unittest:
$ python -m unittest elite.test --verbose
For deeper usage, please view the source code.
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
File details
Details for the file Elite-1.1.1.tar.gz
.
File metadata
- Download URL: Elite-1.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07a6a399cb4a1b61c45c484c5c4a072231cb3b57153ee04054e398f404228836 |
|
MD5 | f2e9ea4e9e9db4d6e36d18954fc7af41 |
|
BLAKE2b-256 | e2512c3ef920a398f4b6291d1e2e321847e43cd2094e98689ba51efd685061ba |
File details
Details for the file Elite-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: Elite-1.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1e7d1009fe44b0fb0718658b7bfc87ae7d8483783f6641c0f45df2150716d7c |
|
MD5 | 9763c62a7b61c2095f420d4f75cf5c9a |
|
BLAKE2b-256 | 2f7436139c2794ee9abb73f2618f2a8e153c37f0a20f78bb04d3fe946be1776b |