Online Demo About Downloads Publications Case Studies

The Grade Protocol

Try it with APEX!

Background

Assume that a group of students has been graded and would like to find out the sum of all their grades, e.g. to compute the average. However, none wants to reveal their individual grade in the process. The task can be accomplished with the following randomised algorithm. Let S ∈ N be the number of students, and let {0, · · · , G − 1} (G ∈ N) be the set of grades. Define N = (G − 1) · S + 1. Further we assume that the students are arranged in a ring and that each pair of adjacent students shares a random integer between 0 and N − 1. Thus a student shares a number l with the student on the left and a number r with the student on the right, respectively. Denoting the student’s grade by g, the student announces the number (g + l − r) mod N . Because of the ring structure, each number will be reported twice, once as l and once as r, so the sum of all announcements (modulo N ) will be the same as the sum of all grades.

Anonymity of the grades

What we can verify is that only this sum can be gleaned from the announcements by a casual observer, i.e. the observer cannot gain access to any extra information about individual grades. This correctness condition can be formalised by a specification, in which the students make random announcements subject to the condition that their sum equals the sum of their grades. Correct protocol. To check correctness of the Grade protocol, we check if the automaton resulting from the implementation of the protocol is equivalent to the specification automaton. Both automata are presented in Figure 5 for G = 2 and S = 3. Both automata accept words which are sequences of grades and announcements. The words are accepted with the same probability as that of producing the announcements for the given grades. Adherence to specification can then be verified via language equivalence. In Figure 6 we report various data related to the performance of apex and the equivalence checking algorithms. The reported times tspec and tprot are those needed to construct the automata corresponding to specification and the pro- tocol respectively (we also give their sizes sspec , sprot ). The columns labelled by t←,rand , t←,det, t→,rand, t→,det give the running time of the language equivalence check of the respective automata using the four algorithms. The symbol − means that the computation timed out after 10 minutes. The running time of the deterministic backwards algorithm is higher than the one of the forward algorithm because the backwards algorithm constructs a different vector space with a higher number of dimensions.
// PRINTS OUT PAIRS (GRADE,ANNOUNCEMENT)
// ANONYMITY CAN BE VERIFIED BY CHECKING
// LANGUAGE EQUIVALENCE WITH SPECIFICATION (grade-spec.txt)

// number of students
//const STUDENTS:= 3;

// grades: 0,1,...,GRADES-1
//const GRADES:=2;

const N := STUDENTS*(GRADES-1)+1;

grade:int%GRADES, out:var%N |-
		     var%(STUDENTS+1) i;

		    var%N first;
                    first:=rand[N];

                    var%N right;
                    right:=first;

                    i:=0;
		    while(i<STUDENTS) do { 
                                         var%N left;
                                         i:=succ(i); 
                                         left :=  if (i=STUDENTS) then first else rand[N];
		                         out := (grade + left) - right;
                                         right := left;
                                         }
:com


// SPECIFICATION TO BE USED WITH grade-impl2.txt

//const STUDENTS:=10;
//const GRADES:=10;

const N := STUDENTS * (GRADES-1) + 1;

grade:int%GRADES, out:var%N |-

		    var%STUDENTS i;
		    var%N total;

                    i:=1;
		    while(i) do { 
                                         total := grade + total;
                                         var%N r;
                                         r := rand[N]; 
                                         out:=r;
                                         total := total - r;
                                         i:=succ(i)
                                };

                    out:= grade + total: com

GStspectprotsspecsprott←,randt←,dett←,randt←,det
2100.000.0220211020.000.410.000.02
2200.050.2480284020.1026.090.030.26
2501.756.465,002127,5028.081.2110.07
210025.3682.2620,0021,010,002240.9710.56159.39
2200396.5580,002
3100.020.1638338030.025.790.010.09
3200.221.641,56331,2030.69598.780.231.33
3506.9939.279,903495,00361.769.2963.16
3100102.4239,803
3200
4100.040.5656481240.0737.320.040.36
4200.535.472,32468,4442.250.774.95
45015.94142.5914,8041,102,604210.0030.27222.50
4100232.0759,604
4200
5100.091.4674514,0650.17164.870.100.68
5200.9616.393,085120,1255.361.9214.49
55028.81417.5819,7051,950,305508.8662.64335.01
5100100417.5979,405
5200

|| Specification automaton ||

|| Implementation automaton||

Faulty protocol

Moving to test cases for inequivalence checking, we compare the specification for the Grade Protocol with a faulty version of the protocol in which the students draw numbers between 0 and N − 2 (rather than N − 1, as in the original protocol). The running times and automata sizes are recorded in Figure 7. Both the deterministic and the randomised algorithms are decision algorithms for equivalence and can also generate counterexamples, which could serve, e.g., to repair a faulty protocol. We test counterexample generation on the faulty version of the protocol. The deterministic algorithm stores words in the work list which immediately yield a counterexample in case of inequivalence. In the context of the randomised algorithm (as described in Section 2.4), counterexample generation requires extra work: words need to be reconstructed using matrix vector multiplications. To quantify the runtime overhead, we record running times with counterexample generation switched on and off. The running time of the backward randomised algorithm with counterexample generation is denoted by t←,rand and analogously for the forward algorithm. The runtime overhead of counterexample generation remains below 12%.

Imprint/Impressum Data Protection/Datenschutzhinweis