Skip to content

Commit

Permalink
refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Jan 13, 2025
1 parent 6d70942 commit 41e8984
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions runs/age-zkp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
'urn:example:age'('urn:example:simulation1', 50).

% person age
'urn:example:personAge'(Simulation, Name, Age) :-
'urn:example:personAge'(Simulation, [Name, Age]) :-
'urn:example:birthDay'(Name, [Yb, Mb, Db]),
'urn:example:date'(Simulation, [Yl, Ml, Dl]),
Age is Yl-Yb+(Ml-Mb)/12+(Dl-Db)/365.

% prover demonstrates that persons are above some duration using a hash
'urn:example:zeroKnowledgeProof'(Simulation, Name, Result, Hash) :-
'urn:example:personAge'(Simulation, Name, PersonAge),
'urn:example:zeroKnowledgeProof'(Simulation, [Name, Result, Hash]) :-
'urn:example:personAge'(Simulation, [Name, PersonAge]),
'urn:example:age'(Simulation, SimulationAge),
write_term_to_chars(PersonAge > SimulationAge, [], Chars),
crypto_data_hash(Chars, Hash, [algorithm(sha3_512)]),
Expand All @@ -34,8 +34,8 @@
).

% Challenger checking the proof using the hash
'urn:example:challengeProof'(Simulation, Name, Result, Hash) :-
'urn:example:personAge'(Simulation, Name, PersonAge),
'urn:example:challengeProof'(Simulation, [Name, Result, Hash]) :-
'urn:example:personAge'(Simulation, [Name, PersonAge]),
'urn:example:age'(Simulation, SimulationAge),
write_term_to_chars(PersonAge > SimulationAge, [], Chars),
crypto_data_hash(Chars, ProofHash, [algorithm(sha3_512)]),
Expand All @@ -45,10 +45,10 @@
).

% queries
query('urn:example:zeroKnowledgeProof'('urn:example:simulation1', 'urn:example:Mary', _, _)).
query('urn:example:zeroKnowledgeProof'('urn:example:simulation1', 'urn:example:Pat', _, _)).
query('urn:example:challengeProof'('urn:example:simulation1', 'urn:example:Mary', _, "6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e821")).
query('urn:example:challengeProof'('urn:example:simulation1', 'urn:example:Pat', _, "4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8")).
query('urn:example:zeroKnowledgeProof'('urn:example:simulation1', ['urn:example:Mary', _, _])).
query('urn:example:zeroKnowledgeProof'('urn:example:simulation1', ['urn:example:Pat', _, _])).
query('urn:example:challengeProof'('urn:example:simulation1', ['urn:example:Mary', _, "6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e821"])).
query('urn:example:challengeProof'('urn:example:simulation1', ['urn:example:Pat', _, "4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8"])).

run :-
query(Q),
Expand Down
8 changes: 4 additions & 4 deletions runs/output/age-zkp.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'urn:example:zeroKnowledgeProof'('urn:example:simulation1','urn:example:Mary',"proof failed: less than 50 years and not entitled to work 80% per week","6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e822").
'urn:example:zeroKnowledgeProof'('urn:example:simulation1','urn:example:Pat',"proof verified: more than 50 years old and entitled to work 80% per week","4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8").
'urn:example:challengeProof'('urn:example:simulation1','urn:example:Mary',"challenge failed: the proof is invalid","6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e821").
'urn:example:challengeProof'('urn:example:simulation1','urn:example:Pat',"challenge successful: the proof is valid","4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8").
'urn:example:zeroKnowledgeProof'('urn:example:simulation1',['urn:example:Mary',"proof failed: less than 50 years and not entitled to work 80% per week","6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e822"]).
'urn:example:zeroKnowledgeProof'('urn:example:simulation1',['urn:example:Pat',"proof verified: more than 50 years old and entitled to work 80% per week","4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8"]).
'urn:example:challengeProof'('urn:example:simulation1',['urn:example:Mary',"challenge failed: the proof is invalid","6151e3412bc493063a9be0aadd3ecaaae9ebdca0f5d65441192fd14660f1ef91918cd29181414d8b48ade139d11d33156618878df03cdaab9e9296370b00e821"]).
'urn:example:challengeProof'('urn:example:simulation1',['urn:example:Pat',"challenge successful: the proof is valid","4ac8666fbe3e7a9206d453134ca6c38d8fa740b1e589a73c2a767c3679ac682c6e5919434a931e8b37ef62ed0ad942dab41c61e7960061dc1715bc10c0e525a8"]).

0 comments on commit 41e8984

Please sign in to comment.