From 158b338130bbc5cf8b4b5d1018614e11625198fa Mon Sep 17 00:00:00 2001 From: Cosku Acay Date: Mon, 14 Feb 2022 01:09:51 -0500 Subject: [PATCH] Add PickANumber example --- .../inputs/synchronization/PickANumber-alice.txt | 1 + .../inputs/synchronization/PickANumber-bob.txt | 1 + .../synchronization/PickANumber-alice.txt | 1 + .../outputs/synchronization/PickANumber-bob.txt | 1 + .../main/viaduct/synchronization/PickANumber.via | 16 ++++++++++++++++ 5 files changed, 20 insertions(+) create mode 100644 examples/inputs/synchronization/PickANumber-alice.txt create mode 100644 examples/inputs/synchronization/PickANumber-bob.txt create mode 100644 examples/outputs/synchronization/PickANumber-alice.txt create mode 100644 examples/outputs/synchronization/PickANumber-bob.txt create mode 100644 examples/src/main/viaduct/synchronization/PickANumber.via diff --git a/examples/inputs/synchronization/PickANumber-alice.txt b/examples/inputs/synchronization/PickANumber-alice.txt new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/examples/inputs/synchronization/PickANumber-alice.txt @@ -0,0 +1 @@ +42 diff --git a/examples/inputs/synchronization/PickANumber-bob.txt b/examples/inputs/synchronization/PickANumber-bob.txt new file mode 100644 index 0000000000..87523dd7a0 --- /dev/null +++ b/examples/inputs/synchronization/PickANumber-bob.txt @@ -0,0 +1 @@ +41 diff --git a/examples/outputs/synchronization/PickANumber-alice.txt b/examples/outputs/synchronization/PickANumber-alice.txt new file mode 100644 index 0000000000..c508d5366f --- /dev/null +++ b/examples/outputs/synchronization/PickANumber-alice.txt @@ -0,0 +1 @@ +false diff --git a/examples/outputs/synchronization/PickANumber-bob.txt b/examples/outputs/synchronization/PickANumber-bob.txt new file mode 100644 index 0000000000..c508d5366f --- /dev/null +++ b/examples/outputs/synchronization/PickANumber-bob.txt @@ -0,0 +1 @@ +false diff --git a/examples/src/main/viaduct/synchronization/PickANumber.via b/examples/src/main/viaduct/synchronization/PickANumber.via new file mode 100644 index 0000000000..19742b1579 --- /dev/null +++ b/examples/src/main/viaduct/synchronization/PickANumber.via @@ -0,0 +1,16 @@ +host alice : {A} +host bob : {B & A<-} + +fun main() { + let $pick = input int from alice; + let $trusted_pick = endorse $pick from {A}; + + let $guess = input int from bob; + let $revealed_guess = declassify $guess to {A ⊓ B}; + + let $revealed_pick = declassify $trusted_pick to {A ⊓ B}; + let $bob_wins = $revealed_pick == $revealed_guess; + + output $bob_wins to alice; + output $bob_wins to bob; +}