GithubHelp home page GithubHelp logo

nova-collective / crypto-py Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 69 KB

A cryptographic set of utilities written in Python

License: GNU General Public License v3.0

Python 100.00%
cli-app cryptography library-app python3

crypto-py's Introduction

crypto-py

Known Vulnerabilities codecov main workflow HitCount

A pre-quantum cryptographic set of utilities written in Python.

About

This library exposes a set of cryptographic primitives and algorithms implementations that helps with the setup of cryptographic protocols.

The library exposes a CLI and methods that can be imported in other projects.

System requirements

In order to run this library you need python3 installed on your machine.

The library is implemented using version 3.11.2.

How to run

  1. Create your Python environment;

  2. Install the required dependencies with the command:

    pip install -r requirements.txt

  3. Invoke a method with the following command:

    python3 -m crypto <method_name> --param1 <value>

NOTE: on your system the python3 binary name could be different.

Primitives

The following primitives are available:

SHA-3 family

primitive parameters description output
sha3_224 input: string returns a SHA-3 hash of 224 bits length { "hash": <hexadecimal_string> }
sha3_256 input: string returns a SHA-3 hash of 256 bits length { "hash": <hexadecimal_string> }
sha3_512 input: string returns a SHA-3 hash of 512 bits length { "hash": <hexadecimal_string> }

All the functions return the data as JSON.

Authenticated encryption family

primitive parameters description output
generate_key key_length: number returns an hexadecimal string key of 128, 192, 256 bits length,
based on the parameter passed
{ "key": <hexadecimal_string> }
AESGCM_encrypt key: a 365-bit length key
secret: the secret to encrypt
unencrypted_data: optional, unencrypted data to associate to the chiper
returns the chiper with the associated data (if any) and the nonce used for the encryption { "chiper": <hexadecimal_string>, "nonce": <hexadecimal_string> }
AESGCM_decrypt key: the same key used for the encryption
nonce: the nonce returned from the encryption operation
chiper: the secret to decrypt
unencrypted_data: optional, unencrypted data to associate to the chiper
returns the decrypted secret as string { "message": <string> }

All the functions return the data as JSON.

Digital signature family

The following digital signatures utilities implements the Elliptic Curve Signature Algorithm Ed25519:

primitive parameters description output
generates_key_pair none generates a private and public keys pair { "privateKey": <hexadecimal_string>, "publicKey": <hexadecimal_string> }
sign private_key: hexadecimal string
message: string
signs a message with the private key and produce the signature for the message { "signature": <hexadecimal_string> }
verify public_key: hexadecimal_string
signature: hexadecimal_string
message: hexadecimal_string
verifies a signature on a particular message { "result": <"success"|"failure"> }

All the functions return the data as JSON.

Homomorphic encryption family

In order to use the homomorphic functions, for the first run the function for the keys generation, specifying an algorithm schema. The following schemas are supported:

"rsa",
"el_gamal",
"exponential_el_gamal",
"paillier",
"damgard_jurik",
"okamoto_uchiyama",
"benaloh",
"naccache_stern",
"goldwasser_micali",
"elliptic_curve_el_gamal"

if no schema is passed, the default schema applied is paillier. Not all the schemas supports all the operations, please refer to this documentation for further details.

primitive parameters description output
he_generate_keys algorithm: string
key_file: string
generates a file of public/private keys { "result": <string> }
he_encrypt m: number
algorithm: string
encrypt a numeric value
key_file: string
`{ "result": <int
he_sum m: int|list|tuple
n: int|list|tuple
algorithm: string
key_file: string
returns the sum of the encrypted values { "result": <int|list|tuple> }
he_decrypt c: int|list|tuple
algorithm: string
key_file: string
returns the value decrypted { "result": <number> }

All the functions return the data as JSON.

Test

To run the complete unit test suite run the command:

pytest

License

This software is released under the terms of the GNU General Public License 3.0

crypto-py's People

Contributors

g3k0 avatar

Stargazers

Christian Palazzo avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.