Skip to content

Commit

Permalink
Add PickANumber example
Browse files Browse the repository at this point in the history
  • Loading branch information
cacay committed Feb 14, 2022
1 parent 03fc892 commit 158b338
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/inputs/synchronization/PickANumber-alice.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
1 change: 1 addition & 0 deletions examples/inputs/synchronization/PickANumber-bob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
41
1 change: 1 addition & 0 deletions examples/outputs/synchronization/PickANumber-alice.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
false
1 change: 1 addition & 0 deletions examples/outputs/synchronization/PickANumber-bob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
false
16 changes: 16 additions & 0 deletions examples/src/main/viaduct/synchronization/PickANumber.via
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 158b338

Please sign in to comment.