draft handshake
authorVolker Birk <vb@pep-project.org>
Tue, 03 May 2016 08:30:22 +0200
changeset 5636f0c0366fc63
parent 556 90576c91102b
child 564 6f958c76773d
draft handshake
sync/Makefile
sync/fsm.yml2
sync/sync.fsm
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sync/Makefile	Tue May 03 08:30:22 2016 +0200
     1.3 @@ -0,0 +1,2 @@
     1.4 +sync.xml: sync.fsm
     1.5 +	yml2proc -P sync.fsm -o sync.xml
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/sync/fsm.yml2	Tue May 03 08:30:22 2016 +0200
     2.3 @@ -0,0 +1,13 @@
     2.4 +// FSM Y language 1.0
     2.5 +
     2.6 +// Copyleft (c) 2016, p≡p foundation
     2.7 +
     2.8 +// Written by Volker Birk
     2.9 +
    2.10 +decl protocol @name;
    2.11 +decl fsm @name;
    2.12 +decl state @name;
    2.13 +decl event @name, on is event;
    2.14 +decl transition @target, go is transition;
    2.15 +decl action @name, do is action;
    2.16 +decl condition @flag, if is condition;
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/sync/sync.fsm	Tue May 03 08:30:22 2016 +0200
     3.3 @@ -0,0 +1,73 @@
     3.4 +// DeviceGroup protocol for p≡p
     3.5 +
     3.6 +// Copyleft (c) 2016, p≡p foundation
     3.7 +
     3.8 +// Written by Volker Birk
     3.9 +
    3.10 +include ./fsm.yml2
    3.11 +
    3.12 +protocol DeviceGroup {
    3.13 +    // all messages have a timestamp, time out and are removed after timeout
    3.14 +
    3.15 +    fsm DeviceState {
    3.16 +        on init {
    3.17 +            if (storedGroupKeys)
    3.18 +                go Grouped;
    3.19 +            go Sole;
    3.20 +        }
    3.21 +
    3.22 +        state Sole {
    3.23 +            on KeyGen
    3.24 +                do sendBeacon;
    3.25 +            on CannotDecrypt
    3.26 +                do sendBeacon; // cry, baby
    3.27 +            on Beacon(partner)
    3.28 +                do sendHandshakeRequest;
    3.29 +            on HandshakeRequest(identity partner) {
    3.30 +                do sendHandshakeRequest;
    3.31 +                go HandshakingSole(partner);
    3.32 +            }
    3.33 +        }
    3.34 +
    3.35 +        state HandshakingSole(identity partner) {
    3.36 +            on init
    3.37 +                do showHandshake(partner);
    3.38 +            on HandshakeRejected {
    3.39 +                do reject(partner);
    3.40 +                go Sole;
    3.41 +            }
    3.42 +            on HandshakeAccepted {
    3.43 +                if keyElectionWon(partner) {
    3.44 +                    storeOwnKeysAsGroupKeys;
    3.45 +                    sendGroupKeys(partner);
    3.46 +                    go Grouped;
    3.47 +                }
    3.48 +                go WaitForGroupKeys(partner);
    3.49 +            }
    3.50 +        }
    3.51 +    
    3.52 +        state WaitForGroupKeys(identity partner) {
    3.53 +            on ReceiveGroupKeys(partner) {
    3.54 +                storeGroupKeys(partner);
    3.55 +                go Grouped;
    3.56 +            }
    3.57 +        }
    3.58 +
    3.59 +        state Grouped {
    3.60 +            on KeyGen
    3.61 +                do sendOwnKeys;
    3.62 +            on HandshakeRequest(identity partner) {
    3.63 +                do sendHandshakeRequest;
    3.64 +                do showHandshake(partner);
    3.65 +            }
    3.66 +            on HandshakeRejected {
    3.67 +                do reject(partner);
    3.68 +                go Grouped;
    3.69 +            }
    3.70 +            on HandshakeAccepted {
    3.71 +
    3.72 +            }
    3.73 +        }
    3.74 +    }
    3.75 +}
    3.76 +