Zero Knowledge Authentication
Author
Armando Cruz Hinojosa
Title
Zero Knowledge Authentication
Description
Zero Knowledge Authentication Livestream Notebook
Category
Essays, Posts & Presentations
Keywords
zero proof, zero knowledge authentication
URL
http://www.notebookarchive.org/2024-04-b2sp6l8/
DOI
https://notebookarchive.org/2024-04-b2sp6l8
Date Added
2024-04-24
Date Last Modified
2024-04-24
File Size
312.07 kilobytes
Supplements
Rights
Redistribution rights reserved



Zero Knowledge Authentication
Zero Knowledge Authentication
An application of “ArmandoCruz/ZeroKnowledgeProofs” package for web authentication
Armando Cruz Hinojosa
Introduction
Introduction
Zero-knowledge proofs (zk-Proofs) are communication protocols by which a prover can demonstrate to a verifier that it possesses a solution to a given public problem without revealing the content of the solution.
Any computation can be transformed into an interactive zk-Proof so a prover can convince a verifier that a computation was executed correctly without the verifier having to
execute the computation itself and without knowledge of the inputs .
execute the computation itself and without knowledge of the inputs .
This has several applications:
◼
Decentralized consensus
◼
Digital currency and crypto
◼
Code review
◼
Authentication
Interactive proofs
Interactive proofs
In[]:=
PetersenGraph[]
Out[]=
In[]:=
{graphHomomorphism,cipherSolution}
Out[]=
,
| ||
Graph[cipherGraph,VertexCoordinatescoord[0.]] |
| ||
cipherSolutionFrame[0.] |
Disclaimers and considerations
Disclaimers and considerations
Notes on security
Notes on security
Disclaimer of Warranty . Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON - INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE . You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License .
ZeroKnowledgeAuthentication
ZeroKnowledgeAuthentication
Classical authentication vs ZeroKnowledge authentication
Classical authentication vs ZeroKnowledge authentication
Classical client demonstration
Classical client demonstration
Register a new user in the server.
In[]:=
URLExecute["localhost:18000/classical_authentication/register.wl",{"Username"->"Galois","Password"->"Evariste"}]
Out[]=
Successfully created new user Galois in the authentication server.
In[]:=
URLExecute["localhost:18000/classical_authentication/register.wl",{"Username"->"Wolfie","Password"->"Spikey"}];URLExecute["localhost:18000/classical_authentication/register.wl",{"Username"->"Ada","Password"->"Lovelace"}];
Authenticate to the server using the username and password.
In[]:=
URLExecute["localhost:18000/classical_authentication/login.wl",{"Username"->"Ada","Password"->"Lovelace"}]
Out[]=
Welcome back, Ada
ZeroKnowledge client demonstration
ZeroKnowledge client demonstration
In[]:=
PacletInstall["ArmandoCruz/ZeroKnowledgeProofs"]
Out[]=
PacletObject
|
In[]:=
Needs["ArmandoCruz`ZeroKnowledgeProofs`"]
Generate a new Zero Knowledge Proof.
In[]:=
zkProof=GenerateZeroKnowledgeProof["Isomorphism","Seed"->"SecretSeed"]
Out[]=
ZeroKnowledgePublicProblemZeroKnowledgePublicProblem
,ZeroKnowledgePrivateSolutionZeroKnowledgePrivateSolution
|
|
In[]:=
zkProof["ZeroKnowledgePublicProblem"]["PublicProblem"]
Out[]=
,
The first element of the returned collection is the answer or “proof” to the given public problem that must remain private, the public problem can be shared with anyone.
In[]:=
publicProblem=zkProof["ZeroKnowledgePublicProblem"]binaryPublicProblem=BinarySerialize@Compress[publicProblem]
Out[]=
ZeroKnowledgePublicProblem
|
Out[]=
ByteArray
|
Register a new user in the server.
In[]:=
URLExecute["http://localhost:18000/zero_knowledge_authentication/register.wl",{"Username"->"Armando","PublicProblem"->ExportString[binaryPublicProblem,"Byte"]}]
Out[]=
Successfully created new user Armando in the authentication server.
Login into the server
Login into the server
Generate a witness for the ZeroKnowledgeProof that will cipher the public problem and private solution into a list of 5 homomorphic cipher problems:
In[]:=
witness=GenerateZeroKnowledgeWitness[zkProof["ZeroKnowledgePrivateSolution"],"WitnessSize"->5]
Out[]=
ZeroKnowledgeCipherProblemZeroKnowledgeCipherProblem
,ZeroKnowledgeCipherSolutionZeroKnowledgeCipherSolution
|
|
Compress the cipher problem and split it in packages for the server:
In[]:=
binaryCipherProblem=BinarySerialize@Compress[witness["ZeroKnowledgeCipherProblem"]]partition=ByteArray/@Partition[Normal[binaryCipherProblem],UpTo[2000]]
Out[]=
ByteArray
|
Out[]=
ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
,ByteArray
|
|
|
|
|
|
|
|
|
|
|
Send the homomorphic cipher problem to the verifier server and get a query:
In[]:=
URLExecute["localhost:18000/zero_knowledge_authentication/login/problem.wl",{"Username"->"Armando","Reset"->True}];URLExecute["localhost:18000/zero_knowledge_authentication/login/problem.wl",{"Username"->"Armando","CipherProblem"->ExportString[#,"Byte"]}]&/@partition;query=BinaryDeserialize@ByteArray@ImportString[URLExecute["localhost:18000/zero_knowledge_authentication/login/query.wl",{"Username"->"Armando","Query"->True}],"Byte"]
Out[]=
ZeroKnowledgeQuery
|
Answer the query using the knowledge og the cipher solution:
In[]:=
response=AnswerZeroKnowledgeQuery[witness["ZeroKnowledgeCipherSolution"],query]binaryResponse=BinarySerialize@Compress[response]
Out[]=
ZeroKnowledgeResponse
|
Out[]=
ByteArray
|
Send the answer to the server for the final verification:
In[]:=
query["Query"]
Out[]=
{0,0,1,0,0}
In[]:=
verification=VerifyZeroKnowledgeProof[zkProof["ZeroKnowledgePublicProblem"],witness["ZeroKnowledgeCipherProblem"],"query"->query,"response"->response]
Out[]=
{True,True,True,True,True}
In[]:=
And@@verification
Out[]=
True
My Variables
My Variables
Run this section before executing the notebook.
In[]:=
exampleGraph=PetersenGraph[5,2];
In[]:=
cipherGraph=PetersenGraph[5,2,GraphLayout"CircularEmbedding"];
In[]:=
vertexCoordinates1=AbsoluteOptions[exampleGraph,VertexCoordinates][[1,2]];vertexCoordinates2=AbsoluteOptions[cipherGraph,VertexCoordinates][[1,2]];coord[t_]:=vertexCoordinates2+(vertexCoordinates1-vertexCoordinates2)*tgraphHomomorphism=Animate[Graph[cipherGraph,VertexCoordinates->coord[t]],{t,0,1},AnimationRunning->False];
In[]:=
coloring=<|1->Red,2->Red,8->Red,10->Red,3->Yellow,4->Yellow,6->Yellow,5->Purple,7->Purple,9->Purple|>;cipherSolutionFrame[t_]:=Graph[Graph[cipherGraph,VertexStyle->Normal@coloring,VertexSize->Large],VertexStyle->Opacity[t]];cipherSolution=Animate[cipherSolutionFrame[t],{t,0,1},AnimationRunning->False];
In[]:=
input=<|"c1"->1,"c2"->2,"c3"->3,"c4"->2,"c5"->3|>;colors=<|1->Red,2->Yellow,3->Green|>;exampleGraph2=Graph[{"c1","c2","c3","c4","c5"},{"c1"<->"c2","c1"<->"c3","c1"<->"c4","c1"<->"c5","c2"<->"c5","c2"<->"c3","c3"<->"c4","c4"<->"c5"},VertexLabels->Placed["Name",Center],VertexSize->Medium,VertexLabelStyle->14,EdgeStyle->Black,EdgeShapeFunction->"Line",VertexStyle->Normal@(colors/@input)];
In[]:=
f[c1_,c2_,c3_,c4_,c5_]:=(c1-c2)(c1-c3)(c1-c4)(c1-c5)(c2-c5)(c2-c3)(c3-c4)(c4-c5)
In[]:=
Needs["ArmandoCruz`ZeroKnowledgeProofs`"]compilation=CompileArithmeticCircuit[f[c1,c2,c3,c4,c5],input];circuit=compilation["circuit"];
In[]:=
qap=CompileQuadraticArithmeticProgram[compilation];polynomialC2=N@qap["v"]["c2"];


Cite this as: Armando Cruz Hinojosa, "Zero Knowledge Authentication" from the Notebook Archive (2024), https://notebookarchive.org/2024-04-b2sp6l8

Download

