This project implements the Feige-Fiat-Shamir (FFS) identification protocol in Python. The protocol is designed for secure user authentication, where a prover (Alice) convinces a verifier (Bob) of her identity without revealing her secret key. This implementation also includes a simulation of a hacker attempting to falsely authenticate.
The project consists of the following files:
alice_and_hacker.py
: Contains classes for selecting user secrets and simulating a hacker.round.py
: Manages the protocol messages and the steps involved in each round of the identification process.trusted_center.py
: Contains the logic for generating system parameters, including prime numbers and security parameters.main.py
: The main script that ties everything together, executing the authentication process and interacting with the user.
git clone <repository-url>
cd <repository-directory>
python main.py
- The trusted center will generate the system parameters.
- Alice (or a hacker) will generate the public and private keys.
- The identification process will run for a specified number of rounds.
- SelectingSystemParameters
__init__(self, p, q, k, t)
: Initializes the system parameters.is_prime(l)
: Checks if a number is prime.generate_prime()
: Generates a prime number.generate_n()
: Generatesn
as the product of two prime numbers.generate_security_params()
: Generates the security parametersk
andt
.
-
SelectingUserSecrets
__init__(self, n, k)
: Initializes the user secrets.select_user_secrets()
: Selects the user secretss
andb
.extended_gcd(a, b)
: Computes the greatest common divisor using the extended Euclidean algorithm.mod_inverse(a, m)
: Finds the modular inverse.v_calculation()
: Calculates the public valuesv
.keys()
: Forms the public and private keys.
-
Hacker
__init__(self, n, k, v)
: Initializes the hacker's parameters.hacker_generates_s()
: Generates the hacker's secret values.keys()
: Forms the public and private keys for the hacker.
- ProtocolMessages
x_calculation(n, b)
: Calculates the valuex
and a random valuer
.random_vector_generation(k)
: Generates a random vectore
.y_calculation(r, e, s, n)
: Calculates the valuey
.z_calculation(y, v, e, n)
: Calculates the valuez
.identification(x, z, n)
: Performs the identification check.
identify_user()
: Prompts the user to identify as Alice or a hacker.perform_identification(n, k, t, s, b, v)
: Executes the identification process fort
rounds.- Main script flow:
- Generates system parameters.
- Alice or a hacker generates keys.
- Sends the public key to the verifier.
- Performs the identification process and prints the result.
The Feige-Fiat-Shamir identification protocol is a zero-knowledge proof system used for authentication. It allows one party (the prover) to prove to another party (the verifier) that they know a value, without conveying any information apart from the fact that they know the value.