Giter VIP home page Giter VIP logo

zero-knowledge-proof-python-implementation's Introduction

Zero-Knowledge Proof (ZKP) Python Implementation

Zero-Knowledge Proofs (ZKP) are a cryptographic concept where one party (the prover) can prove to another party (the verifier) that they know a value, without conveying any information apart from the fact that they know the value. This concept is fundamental in various privacy-preserving technologies, including cryptocurrencies and secure multi-party computations.

The prover does not reveal the actual secret during the interaction, maintaining the secrecy of the information. It's a form of "interactive proof system."

This repository contains a simple implementation of Zero-Knowledge Proofs (ZKP) in Python.

Table of Contents

  1. Requirements
  2. Usage
  3. Example
  4. License

Requirements

The Python version required for this script is Python 3.7+. The script also makes use of the hashlib, os, and random libraries, which are included in the standard Python distribution.

Usage

The main script is zkp.py, which contains the ZKProof class. Here's a step-by-step guide on how to use it:

  1. Import the ZKProof class from the zkp.py script. This class contains the main methods for generating proofs and verifying them.
  2. Initialize a ZKProof object. When initializing, the object generates a random 'salt' value, used in the hashing process to increase security.
  3. Generate a proof using a secret value. Call the generate_proof method on the object, passing the secret value you want to prove knowledge of. This will return a hashed value of a randomly generated number. This hashed number is a commitment that the prover sends to the verifier.
  4. Verify a guessed value. To verify a guessed value, call the verify method on the object, passing the guessed value. This will return True if the hashed guessed value matches the stored hashed value, and False otherwise.

Example

zkp = ZKProof()
x = zkp.generate_proof('secret_value')
print('Proof:', x)
response = input('Enter the value to verify: ')
print('Verified:', zkp.verify(response))

In this example, the script will print the hashed proof and wait for a user input. If the input matches the secret value, it will print Verified: True; otherwise, it will print Verified: False.

License

This project is licensed under the terms of the MIT license. You are free to use, modify, and distribute the code under this license.

zero-knowledge-proof-python-implementation's People

Contributors

codeesura avatar

Stargazers

Sunny avatar Endogen avatar UserCr4ig avatar  avatar atloti avatar Roman avatar Erik Källström avatar addison carey avatar  avatar Lucy Arrowsmith avatar  avatar MIZUKI Sonoko avatar Murat Selim avatar

Watchers

 avatar  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.