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; +}