brunollopes / zkpprotocolkafka

MIT License
1 stars 1 forks source link

The ZKP Protocol

What will you learn with this demo?

Two-phase protocol: Register and Authentication

==============================================

Register Process

The prover (client) has a secret password x (i.e. it is a number) and wishes to register it with the verifier (server). To do that, they calculate y1 and y2 using public g and h and the secret x and send to the verifier y1, y2.

Login/Authentication Process

The login process is done following the ZKP Protocol shown in the diagram. Been the Prover the authenticating party and the Verifier the server running the authentication check:
My image

Tasks in hand

Design and write the code that implements the ZKP Protocol outlined above. The solution should be implemented as server and client using gRPC protocol.

Instructions on how to run/deploy/test

Tech stack

Components and composition

Prover client

Workflow

Register process API

HTTP1 POST/JSON register /zkp/register

body signature example

{ "user" : "blopes", "number" : "12345" }

This facilitator endpoint will be used to generate all the input data required to invoke the ZKP protocol register process.

Authentication process API

HTTP1 GET login parameters: user and password

Example: /zkp/login/blopes/101

How to run

On your command line under the root folder run the following command:

Four containers will be created 1) zookeeper 2) kafka 3) zkpprover 4) zkpverifier

Kafka topic will be automatically created and ready to be used.

How to test

1) Use your favourite tool to execute an HTTP1 POST (curl, postman, etc) for the register endpoint
Returned message in case of success:
{ "message": "Y1 and Y2 successfully registered in the server." }

2) Use your favourite tool to execute a HTTP1 GET (curl, postman, etc) for the login endpoint
Returned message if successfully authenticated:
{ "message": "Authentication Successfully ended with session ID: 178d6395-39b9-4696-80c6-14dea9b252c8" }
Returned message if prover was not verified:
{ "message": "Authentication not verified actual R1 and R2 are not equal to the expected R1 and R2" }
In case you try to login/authenticate without first register
Returned message:
{ "message": "The user john keys have not been registered." }

3) Isolated, you can test parts of each process by executing the available unitary tests.

How to deploy in AWS serverless

All you need to do is create in your local machine an ECS context with Docker and run docker-compose up this will automatically convert the docker-compose.yml in a CloudFormation template with the needed resources to deploy in de AWS ECS and will immediately deploy all the resources required to make the service available.

Base requirements:

The following diagram shows the components and how they intercommunicate.

My image

Each one of our docker containers will be a Fargate task deployed and run without managing servers or clusters

How to access the REST API from ECS-AWS:

dns: http://zkppr-loadb-qip0x70sauz1-6db49107ebfc7deb.elb.us-east-1.amazonaws.com

Prover register endpoint - http1 post: :8000/zkp/register
Prover login endpoint - http1 get: :8000/zkp/login/{user}/{password}

Some References