PositiveSecret {{ public double getResult(Claim claim, List replies){ if(replies.length() == 3){ ProvideResponse provideResponse = (ProvideResponse)replies.lookup(0); if(provideResponse.getInstance() == null){ provideResponse.getInstance().finishParse(); } CSPInstance i = (CSPInstance)provideResponse.getInstance().getInstance(); SolveResponse bobsolveResponse = (SolveResponse)replies.lookup(1); Solution bobSolution = bobsolveResponse.getSolution(); if(bobSolution.getSolution() == null){ bobSolution.finishParse(); } SolveResponse alicesolveResponse = (SolveResponse)replies.lookup(2); Solution aliceSolution = alicesolveResponse.getSolution(); if(aliceSolution.getSolution() == null){ aliceSolution.finishParse(); } if(i.valid(bobSolution) ==0 && i.valid(aliceSolution) == 0) return 0; if(i.valid(bobSolution) ==0 ) return 1; if(i.valid(aliceSolution) ==0 ) return -1; if(i.quality(aliceSolution) >= (i.quality(bobSolution) * claim.getQuality())) return 1; //Alice win else return -1; //Bob win } return 0; // protocol is not complete } public ProtocolSpec getProtocolSpec(){ return PositiveSecret.protocolSpec; } static ProtocolSpec protocolSpec; static{ try{ ProtocolSpec.parse( "instance from Bob " + "solution of 0 from Bob " + "solution of 0 from Alice " ); }catch(Exception ex){ ex.printStackTrace(); } } }} NegativeSecret {{ public double getResult(Claim claim, List replies){ if(replies.length() == 3){ ProvideResponse provideResponse = (ProvideResponse)replies.lookup(0); if(provideResponse.getInstance() == null){ provideResponse.getInstance().finishParse(); } CSPInstance i = (CSPInstance)provideResponse.getInstance().getInstance(); SolveResponse alicesolveResponse = (SolveResponse)replies.lookup(1); Solution aliceSolution = alicesolveResponse.getSolution(); if(aliceSolution.getSolution() == null){ aliceSolution.finishParse(); } SolveResponse bobsolveResponse = (SolveResponse)replies.lookup(2); Solution bobSolution = bobsolveResponse.getSolution(); if(bobSolution.getSolution() == null){ bobSolution.finishParse(); } if(i.valid(bobSolution) ==0 && i.valid(aliceSolution) == 0) return 0; if(i.valid(aliceSolution) ==0 ) return -1; if(i.valid(bobSolution) ==0 ) return 1; if(i.quality(bobSolution) >= (i.quality(aliceSolution) * claim.getQuality())) return -1; //Bob win else return 1; //Alice win } return 0; // protocol is not complete } public ProtocolSpec getProtocolSpec(){ return NegativeSecret.protocolSpec; } static ProtocolSpec protocolSpec; static{ try{ ProtocolSpec.parse( "instance from Alice " + "solution of 0 from Alice " + "solution of 0 from Bob " ); }catch(Exception ex){ ex.printStackTrace(); } } }}