Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ game main() {

// Host hides the car (compiler generates commitment);
// if Host does not play, Guest gets the entire pot
yield Host(car: hidden door) || { Guest -> 40 };
commit Host(car: door) || { Guest -> 40 };

// Guest makes a public choice
yield Guest(d: door) || { Host -> 40 };
Expand Down
6 changes: 3 additions & 3 deletions Vegas.g4
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ typeExp
| name=typeId # IdTypeExp
;

ext : kind=('join' | 'yield' | 'reveal' | 'random') query+ ';' ext # ReceiveExt
| 'withdraw' outcome # WithdrawExt
ext : kind=('join' | 'yield' | 'reveal' | 'commit' | 'random') query+ ';' ext # ReceiveExt
| 'withdraw' outcome # WithdrawExt
;

query : role=roleId ('(' (decls+=varDec (',' decls+=varDec)*)? ')')? ('$' deposit=INT)? ('where' cond=exp)? ('||' handler=outcome)? ;
Expand Down Expand Up @@ -60,7 +60,7 @@ exp
| 'let!' dec=varDec '=' init=exp 'in' body=exp # LetExp
;

varDec : name=varId ':' hidden='hidden'? type=typeExp;
varDec : name=varId ':' type=typeExp;

typeId: LOWER_ID ;
varId : LOWER_ID;
Expand Down
2 changes: 1 addition & 1 deletion examples/AtomicSwap.vg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ game main() {
join Alice() $ 10 Bob() $ 10;

// Alice commits to the pre-image (the secret key)
yield Alice(secret: hidden int) || { Bob -> 20 };
commit Alice(secret: int) || { Bob -> 20 };

// Bob inspects the commitment (abstractly) and funds the contract
yield Bob(fund: bool) || { Alice -> 20 };
Expand Down
2 changes: 1 addition & 1 deletion examples/GasPriceAuction.vg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type bid = {0 .. 8}
game main() {
join Miner() $ 100 Client() $ 100;

yield Miner(t: hidden thr) || { Client -> 200 };
commit Miner(t: thr) || { Client -> 200 };
yield Client(b: bid) || { Miner -> 200 };
yield Miner(accept: bool) || { Client -> 200 };
reveal Miner(t: thr);
Expand Down
2 changes: 1 addition & 1 deletion examples/HiddenReserve.vg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type reserve = {3 .. 7}
game main() {
join Seller() $ 100 Buyer() $ 100;

yield Seller(r: hidden reserve) || { Buyer -> 200 };
commit Seller(r: reserve) || { Buyer -> 200 };
yield Buyer(b: price) || { Seller -> 200 };
yield Seller(accept: bool) || { Buyer -> 200 };
reveal Seller(r: reserve);
Expand Down
2 changes: 1 addition & 1 deletion examples/MontyHall.vg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type door = {0, 1, 2}
game main() {
join Host() $ 20;
join Guest() $ 20;
yield Host(car: hidden door) || { Guest -> 40 };
commit Host(car: door) || { Guest -> 40 };
yield Guest(d: door) || { Host -> 40 };
yield Host(goat: door) where Host.goat != Guest.d || { Guest -> 40 };
yield Guest(switch: bool) || { Host -> 40 };
Expand Down
2 changes: 1 addition & 1 deletion examples/MontyHallChance.vg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type door = {0, 1, 2}
game main() {
random Host() $ 100;
join Guest() $ 100;
yield Host(car: hidden door);
commit Host(car: door);
yield Guest(d: door) || { Host -> 200 };
yield Host(goat: door) where Host.goat != Guest.d && Host.goat != Host.car;
yield Guest(switch: bool) || { Host -> 200 };
Expand Down
4 changes: 2 additions & 2 deletions examples/RPSLS.vg
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ macro p1Wins(h1: hand, h2: hand): bool = (mod5(h1 - h2 + 5) == 1 || mod5(h1 - h2
game main() {
join P1() $ 100 P2() $ 100;

yield P1(h: hidden hand) || { P2 -> 200 };
yield P2(h: hidden hand) || { P1 -> 200 };
commit P1(h: hand) || { P2 -> 200 };
commit P2(h: hand) || { P1 -> 200 };

reveal P1(h: hand) || { P2 -> 200 };
reveal P2(h: hand) || { P1 -> 200 };
Expand Down
5 changes: 2 additions & 3 deletions examples/RandomLeader.vg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
game main() {
join V1() $ 100 V2() $ 100 V3() $ 100;

yield V1(b: hidden bool) V2(b: hidden bool) V3(b: hidden bool);

reveal V1(b: bool) V2(b: bool) V3(b: bool);
// Simultaneous yield auto-expands to commit+reveal with front-running protection
yield V1(b: bool) V2(b: bool) V3(b: bool);

withdraw (V1.b != null && V2.b != null && V3.b != null) ?
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Simple.vg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
game main() {
join A() $ 6;
join B() $ 6;
yield A(c: hidden bool) || { B -> 12 };
commit A(c: bool) || { B -> 12 };
yield B(c: bool) || { A -> 12 };
reveal A(c: bool);
withdraw { A -> (A.c != B.c) ? 9 : 3 ; // Fair play: winner gets 9, loser gets 3
Expand Down
2 changes: 1 addition & 1 deletion examples/StakeAndVote.vg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
game main() {
join V1() $ 100 V2() $ 100 Protocol() $ 100;

yield Protocol(correct: hidden bool);
commit Protocol(correct: bool);

yield V1(v: bool) V2(v: bool);

Expand Down
6 changes: 3 additions & 3 deletions examples/VickreyAuction.vg
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ game main() {

// Bids are hidden to prevent price matching/adjusting
// Sequential yields with handlers - if a bidder quits, they forfeit their deposit to Seller
yield B1(b: hidden bid) || { Seller -> 200; B2 -> 100; B3 -> 100 };
yield B2(b: hidden bid) || { Seller -> 200; B1 -> 100; B3 -> 100 };
yield B3(b: hidden bid) || { Seller -> 200; B1 -> 100; B2 -> 100 };
commit B1(b: bid) || { Seller -> 200; B2 -> 100; B3 -> 100 };
commit B2(b: bid) || { Seller -> 200; B1 -> 100; B3 -> 100 };
commit B3(b: bid) || { Seller -> 200; B1 -> 100; B2 -> 100 };

reveal B1(b: bid);
reveal B2(b: bid);
Expand Down
Loading