Compare commits
	
		
			8 Commits 
		
	
	
		
			master
			...
			voting-boo
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 24d00a89fb | |
|  | ce2fe0e8f2 | |
|  | dadf301fcf | |
|  | 8ace24677b | |
|  | 95700f360e | |
|  | 9db8d8708a | |
|  | b9613ed693 | |
|  | 19a7d5731c | 
|  | @ -36,3 +36,5 @@ testem.log | |||
| bundle.js | ||||
| bundle.d.ts | ||||
| 
 | ||||
| /voting-booth-gui/meerkat_election_params_tempfile.dat | ||||
| /voting-booth-gui/meerkat_booth_system_messages.dat | ||||
|  |  | |||
|  | @ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME | |||
| distributionPath=wrapper/dists | ||||
| zipStoreBase=GRADLE_USER_HOME | ||||
| zipStorePath=wrapper/dists | ||||
| distributionUrl=https://services.gradle.org/distributions/gradle-4.2.1-all.zip | ||||
| distributionSha256Sum=7897b59fb45148cd8a79f078e5e4cef3861a252dd1a1af729d0c6e8a0a8703a8 | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip | ||||
| distributionSha256Sum=a0af75d3d35799a90f56255a24de69c53cd9aea90f0b532586c8f818668e1734 | ||||
|  |  | |||
|  | @ -0,0 +1 @@ | |||
| sdk.dir=C\:/Users/Laura/AppData/Local/Android/sdk | ||||
|  | @ -81,6 +81,12 @@ message BallotSecrets { | |||
| 
 | ||||
|     EncryptionRandomness encryption_randomness = 2; | ||||
|     RandomnessGenerationProof proof = 3; | ||||
|     uint64 serial_number = 4; // Ballot serial number | ||||
| } | ||||
| 
 | ||||
| message SignedBallotSecrets { | ||||
|     BallotSecrets ballot_secrets = 1; | ||||
|     Signature signature = 2; | ||||
| } | ||||
| 
 | ||||
| message BoothParams { | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ For future compatibility, each ciphertext actually written to disk is encoded as | |||
| Ciphertexts are serialized using the [ElGamalCiphertext](concrete_crypto.proto) message, with fields "c1" and "c2" for the first and second group elements. | ||||
| 
 | ||||
| ### EC Group elements | ||||
| Group elements use the [GroupElement](concrete_crypto.proto) message. Its only field is "data", which should be an ASN.1-encoded curve point with compression (see section 4.3.6 of  [X9.62-1998](https://www.security-audit.com/files/x9-62-09-20-98.pdf) "Public Key Cryptography For The Financial Services Industry: The Elliptic Curve Digital  Signature Algorithm (ECDSA)") | ||||
| Group elements use the [GroupElement](concrete_crypto.proto) message. It's only field is "data", which should be an ASN.1-encoded curve point with compression (see section 4.3.6 of  [X9.62-1998](https://www.security-audit.com/files/x9-62-09-20-98.pdf) "Public Key Cryptography For The Financial Services Industry: The Elliptic Curve Digital  Signature Algorithm (ECDSA)") | ||||
| 
 | ||||
| ### EC-ElGamal Key Format | ||||
| The ECElGamal Key is stored in the [ElGamalPublicKey](concrete_crypto.proto) message that contains a standard DER-encoded SubjectPublicKeyInfo as in [RFC 3279](https://tools.ietf.org/html/rfc3279)  (note that this encoding includes the elliptic-curve group parameters). | ||||
|  |  | |||
|  | @ -41,6 +41,11 @@ message ScannedBallot { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| //Container for auditing messages | ||||
| message ScannedAudit { | ||||
|     SignedBallotSecrets signed_ballot_secrets = 1; | ||||
| } | ||||
| 
 | ||||
| // Container for error messages | ||||
| message ScanError { | ||||
|     string msg = 1; | ||||
|  | @ -49,12 +54,14 @@ message ScanError { | |||
| 
 | ||||
| // Container for scanned data | ||||
| message ScannedData { | ||||
|     uint64 serial = 1; // Serial number of the message | ||||
|     bytes scannerId = 2; // hash of the scannerPK | ||||
|     oneof data { | ||||
|         ScannedBallot ballot = 2; | ||||
|         ScanError error = 3; | ||||
|         ScannedBallot ballot = 3; | ||||
|         ScanError error = 4; | ||||
|         ScannedAudit audit_ballot = 5; | ||||
|     } | ||||
|     uint64 serial = 4; // Serial number of the message | ||||
|     bytes scannerId = 5; // hash of the scannerPK | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| message SignedScannedData { | ||||
|  |  | |||
|  | @ -31,8 +31,8 @@ public class ChannelChoiceController { | |||
|     String questionText; | ||||
| 
 | ||||
|     @FXML ToggleGroup answerGroup; | ||||
|     @FXML private Text question; | ||||
|     @FXML private Text warningMsg; | ||||
| //    @FXML private Text question;
 | ||||
| //    @FXML private Text warningMsg;
 | ||||
|     @FXML private Pane questionPane; | ||||
| 
 | ||||
|     @FXML | ||||
|  | @ -72,13 +72,17 @@ public class ChannelChoiceController { | |||
| 
 | ||||
|     private void showCodeSelection() { | ||||
|         questionText = "Here we show code pad."; | ||||
|         question.setText(questionText); | ||||
|         questionPane.getChildren().clear(); | ||||
|         Text txt = new Text(); | ||||
|         questionPane.getChildren().add(txt); | ||||
|         txt.setText(questionText); | ||||
| //        question.setText(questionText);
 | ||||
|     } | ||||
| 
 | ||||
|     private void showQuestion() { | ||||
|             Voting.BallotQuestion ballotQuestion = questions.get(index); | ||||
|             questionText = "Please answer this question before voting:"; | ||||
|             question.setText(questionText); | ||||
| //            question.setText(questionText);
 | ||||
|             answerGroup.getToggles().clear(); | ||||
|             VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup); | ||||
|             questionPane.getChildren().clear(); | ||||
|  | @ -87,8 +91,10 @@ public class ChannelChoiceController { | |||
| 
 | ||||
|     private void showError() { | ||||
|         questionText = "There was an error reading the channel, please go back to polling station."; | ||||
|         question.setText(questionText); | ||||
| 
 | ||||
| //        question.setText(questionText);
 | ||||
|         questionPane.getChildren().clear(); | ||||
|         Text txt = new Text(); | ||||
|         questionPane.getChildren().add(txt); | ||||
|     } | ||||
| 
 | ||||
|     @FXML | ||||
|  | @ -97,6 +103,8 @@ public class ChannelChoiceController { | |||
|             String s = answerGroup.getSelectedToggle().getUserData().toString(); | ||||
|             answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s)); | ||||
|         } else { | ||||
|             Text warningMsg = new Text(); | ||||
|             questionPane.getChildren().add(0,warningMsg); | ||||
|             warningMsg.setText("(Please give an answer to continue)"); | ||||
|         } | ||||
|         if (answers.size()!=0) { | ||||
|  |  | |||
|  | @ -4,9 +4,14 @@ package meerkat.voting.gui.controllersFX; | |||
|  * Created by Laura on 12/16/2016. | ||||
|  */ | ||||
| import javafx.fxml.FXML; | ||||
| import javafx.geometry.Insets; | ||||
| import javafx.scene.Node; | ||||
| import javafx.scene.Parent; | ||||
| import javafx.scene.layout.Background; | ||||
| import javafx.scene.layout.BackgroundFill; | ||||
| import javafx.scene.layout.CornerRadii; | ||||
| import javafx.scene.layout.StackPane; | ||||
| import javafx.scene.paint.Color; | ||||
| import meerkat.protobuf.Voting; | ||||
| import meerkat.voting.controller.callbacks.VoterCancelThrowable; | ||||
| import meerkat.voting.gui.ui.CommandPend; | ||||
|  | @ -38,6 +43,7 @@ public class MainController { | |||
|      * @param node the vista node to be swapped in. | ||||
|      */ | ||||
|     public void setVista(Node node) { | ||||
| //        vistaHolder.setBackground(new Background(new BackgroundFill(Color.web("#D1B6E1"), CornerRadii.EMPTY, Insets.EMPTY)));
 | ||||
|         vistaHolder.getChildren().setAll(node); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,16 +6,19 @@ package meerkat.voting.gui.controllersFX; | |||
| import javafx.embed.swing.SwingFXUtils; | ||||
| import javafx.fxml.FXML; | ||||
| import javafx.scene.Node; | ||||
| import javafx.scene.control.*; | ||||
| import javafx.scene.control.Label; | ||||
| import javafx.scene.image.Image; | ||||
| import javafx.scene.image.ImageView; | ||||
| import javafx.scene.layout.StackPane; | ||||
| import javafx.scene.layout.VBox; | ||||
| import javafx.scene.control.ScrollPane; | ||||
| import javafx.scene.text.Text; | ||||
| import meerkat.voting.gui.ui.CommandPend; | ||||
| import meerkat.voting.gui.ui.uicommands.UICommand; | ||||
| 
 | ||||
| import javax.imageio.ImageIO; | ||||
| import java.awt.*; | ||||
| import java.awt.image.BufferedImage; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
|  | @ -26,10 +29,9 @@ import java.io.InputStream; | |||
| public class PrinterController { | ||||
| 
 | ||||
|     /** Holder of vista. */ | ||||
|     @FXML | ||||
|     private VBox vBox; | ||||
|     @FXML | ||||
|     private Text content; | ||||
|     @FXML private VBox vBox; | ||||
|     @FXML private ScrollPane scrollPane; | ||||
|     @FXML private Text content; | ||||
| 
 | ||||
| 
 | ||||
|     public void clean() { | ||||
|  | @ -40,6 +42,7 @@ public class PrinterController { | |||
|         Text txt = new Text(s); | ||||
|         vBox.getChildren().add(txt); | ||||
|         vBox.getScene().getWindow().sizeToScene(); | ||||
|         adjustScrolling(vBox); | ||||
|     } | ||||
| 
 | ||||
|     public void addContent(BufferedImage i) { | ||||
|  | @ -50,6 +53,20 @@ public class PrinterController { | |||
| //        String old_content = content.getText();
 | ||||
| //        content.setText(old_content+"\n"+s);
 | ||||
|         vBox.getScene().getWindow().sizeToScene(); | ||||
|         adjustScrolling(vBox); | ||||
|     } | ||||
| 
 | ||||
|     private void adjustScrolling(VBox content) { | ||||
|         scrollPane.setContent(content); | ||||
|         scrollPane.setFitToHeight(true); | ||||
|     } | ||||
| 
 | ||||
|     public void addSeparator() { | ||||
|         Separator sep = new Separator(); | ||||
|         sep.setMaxWidth(vBox.getPrefWidth()); | ||||
|         vBox.getChildren().add(sep); | ||||
|         adjustScrolling(vBox); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -170,6 +170,19 @@ public class VistaNavigator { | |||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Prints an horizontal separator into the printer application layout. | ||||
|      */ | ||||
|     public static void printFXSeparator() { | ||||
|         Platform.runLater(new Runnable() { | ||||
|                               @Override | ||||
|                               public void run() { | ||||
|                                   printerController.addSeparator(); | ||||
|                               } | ||||
|                           } | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Loads the 'LOADING' vista | ||||
|      * vistaHolder pane of the main application layout. | ||||
|  |  | |||
|  | @ -1,11 +1,21 @@ | |||
| package meerkat.voting.gui.controllersFX; | ||||
| 
 | ||||
| import javafx.fxml.FXML; | ||||
| import javafx.geometry.HPos; | ||||
| import javafx.geometry.Pos; | ||||
| import javafx.scene.control.Button; | ||||
| import javafx.scene.control.ScrollPane; | ||||
| import javafx.scene.control.Separator; | ||||
| import javafx.scene.control.ToggleGroup; | ||||
| import javafx.scene.layout.HBox; | ||||
| import javafx.scene.layout.Pane; | ||||
| import javafx.scene.layout.VBox; | ||||
| import javafx.scene.text.Font; | ||||
| import javafx.scene.text.FontWeight; | ||||
| import javafx.scene.text.Text; | ||||
| import javafx.scene.text.TextAlignment; | ||||
| import meerkat.protobuf.Voting; | ||||
| import meerkat.voting.VotingBooth; | ||||
| import meerkat.voting.controller.callbacks.VoterCancelThrowable; | ||||
| import meerkat.voting.gui.ui.UIUtils; | ||||
| import meerkat.voting.gui.ui.uicommands.RaceVotingUICommand; | ||||
|  | @ -31,13 +41,16 @@ public class VotingController { | |||
|     RaceVotingUICommand command = (RaceVotingUICommand) VistaNavigator.getCurrentCommand(); | ||||
| 
 | ||||
|     @FXML ToggleGroup answerGroup; | ||||
|     @FXML private Text question; | ||||
|     @FXML private Pane questionPane; | ||||
|     @FXML private Text currentPage; | ||||
|     @FXML private Text totalPage; | ||||
|     @FXML private ScrollPane questionPane; | ||||
|     @FXML private Button nextButton; | ||||
| 
 | ||||
|     @FXML | ||||
|     public void initialize() { | ||||
|         questions = command.getQuestions(); | ||||
|         answerGroup = new ToggleGroup(); | ||||
|         totalPage.setText(""+(questions.size()+1)); | ||||
|         showQuestion(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -53,23 +66,70 @@ public class VotingController { | |||
|             answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s)); | ||||
|             index++; | ||||
|         } | ||||
|         if (nextButton.getText().equals("Confirm")) { | ||||
|             index++; | ||||
|         } | ||||
|         if (index < questions.size()) { | ||||
|             showQuestion(); | ||||
|         } else { | ||||
|             if (index == questions.size()) { | ||||
|                 showSummary(); | ||||
|             } else { | ||||
|                 //return answers to main threads
 | ||||
|                 nextPane(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void showQuestion() { | ||||
|             Voting.BallotQuestion ballotQuestion = questions.get(index); | ||||
|             question.setText("This is question n. "+index); | ||||
|             //question.setText("This is question n. "+index);
 | ||||
|             currentPage.setText("Page "+(index+1)); | ||||
|             answerGroup.getToggles().clear(); | ||||
|             VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup); | ||||
|             questionPane.getChildren().clear(); | ||||
|             questionPane.getChildren().addAll(vbox); | ||||
|             nextButton.setText("Next"); | ||||
|             questionPane.setContent(vbox); | ||||
|             questionPane.setFitToHeight(true); | ||||
|             //questionPane.getChildren().clear();
 | ||||
| //            questionPane.getChildren().addAll(vbox);
 | ||||
|     } | ||||
| 
 | ||||
|     private void showSummary() { | ||||
| //        Voting.BallotQuestion ballotQuestion = questions.get(index);
 | ||||
|         currentPage.setText("Page "+(index+1)); | ||||
|         answerGroup.getToggles().clear(); | ||||
|         VBox vbox = new VBox();//VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup);
 | ||||
|         vbox.setPrefWidth(questionPane.getPrefWidth()-30); | ||||
|         /*Set title of summary*/ | ||||
|         Text title = new Text("Almost done!"); | ||||
|         title.setFont(Font.font("System", FontWeight.BOLD, 24)); | ||||
|         vbox.getChildren().add(title); | ||||
|         /*Set subtitle of summary*/ | ||||
|         Text subtitle = new Text("Review your selections. If you are satisfied, press confirm."); | ||||
|         subtitle.setFont(Font.font("System", FontWeight.BOLD, 18)); | ||||
|         subtitle.setStyle("-fx-margin: 0 0 70 0;"); | ||||
|         vbox.getChildren().add(subtitle); | ||||
|         /*Create summery*/ | ||||
|         for (int i=0; i<questions.size(); i++) { | ||||
|             String qst = UIUtils.bytesToString(questions.get(i).getQuestion().getData()); | ||||
|             int a_i = (int) answers.get(i).getAnswer(0); | ||||
|             String ans = UIUtils.bytesToString(questions.get(i).getAnswer(a_i-1).getData()); | ||||
|             Text qst_txt = new Text((i+1)+". "+qst); | ||||
|             Text ans_txt = new Text(ans); | ||||
|             Separator sep = new Separator(); | ||||
|             sep.setMaxWidth(vbox.getPrefWidth()); | ||||
|             vbox.getChildren().add(sep); | ||||
|             vbox.getChildren().add(qst_txt); | ||||
|             vbox.getChildren().add(ans_txt); | ||||
|         } | ||||
|         vbox.setAlignment(Pos.CENTER); | ||||
|         nextButton.setText("Confirm"); | ||||
|         questionPane.setContent(vbox); | ||||
|         questionPane.setFitToHeight(true); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     @FXML | ||||
|     private void goBack() throws VoterCancelThrowable{ | ||||
|         if (index == 0) { | ||||
|  |  | |||
|  | @ -6,11 +6,9 @@ import com.google.zxing.WriterException; | |||
| import meerkat.protobuf.Crypto.EncryptionRandomness; | ||||
| import meerkat.protobuf.Crypto.RandomnessGenerationProof; | ||||
| import meerkat.protobuf.PollingStation; | ||||
| import meerkat.protobuf.PollingStation.ScannedData; | ||||
| import meerkat.protobuf.Voting; | ||||
| import meerkat.protobuf.Voting.BallotSecrets; | ||||
| import meerkat.protobuf.Voting.PlaintextBallot; | ||||
| import meerkat.protobuf.Voting.SignedEncryptedBallot; | ||||
| import meerkat.rest.Constants; | ||||
| import meerkat.voting.gui.controllersFX.VistaNavigator; | ||||
| import meerkat.voting.output.AsyncRunnableOutputDevice; | ||||
| import meerkat.voting.output.outputcommands.AuditOutputCommand; | ||||
|  | @ -20,7 +18,6 @@ import meerkat.voting.output.outputcommands.CommitOutputCommand; | |||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| import javax.ws.rs.client.Entity; | ||||
| import java.awt.image.BufferedImage; | ||||
| import java.io.IOException; | ||||
| import java.util.Base64; | ||||
|  | @ -49,7 +46,7 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
|         ByteString channel = command.getChannelIdentifierByteString(); | ||||
|         printPlainText(plaintextBallot, channel); | ||||
| 
 | ||||
|         printEncryptedText(plaintextBallot, command); | ||||
|         printCommitBallot(plaintextBallot, command); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -60,11 +57,11 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
|      */ | ||||
|     public void doAudit(AuditOutputCommand command) { | ||||
|         logger.debug("entered method doAudit"); | ||||
|         String msg = "Auditing"; | ||||
|         VistaNavigator.printFX(msg); | ||||
|         VistaNavigator.printFXSeparator(); | ||||
|         BallotSecrets ballotSecrets = command.getBallotSecrets(); | ||||
|         printEncryptionRandomness(ballotSecrets.getEncryptionRandomness()); | ||||
|         printRandomnessGenerationProof (ballotSecrets.getProof()); | ||||
| //        printEncryptionRandomness(ballotSecrets.getEncryptionRandomness());
 | ||||
| //        printRandomnessGenerationProof (ballotSecrets.getProof());
 | ||||
|         printAuditBallot(ballotSecrets); | ||||
|         command.getCallback().onSuccess(null); | ||||
|     } | ||||
| 
 | ||||
|  | @ -105,19 +102,15 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
|         VistaNavigator.printFX(toPrint); | ||||
|     } | ||||
| 
 | ||||
|     private void printEncryptedText(PlaintextBallot plaintextBallot, CommitOutputCommand command) { | ||||
|         String encryptedText; | ||||
|         SignedEncryptedBallot signedEncryptedBallot = command.getSignedEncryptedBallot(); | ||||
|         long encryptedSerialNumber = signedEncryptedBallot.getEncryptedBallot().getSerialNumber(); | ||||
|         long plaintextSerialNumber = plaintextBallot.getSerialNumber(); | ||||
| 
 | ||||
|     private void printCommitBallot(PlaintextBallot plaintextBallot, CommitOutputCommand command) { | ||||
|         String toPrint = ""; | ||||
|         toPrint+="Commitment of Ballot #" + encryptedSerialNumber + " (ciphertext):"; | ||||
|         toPrint+="Commitment of Ballot #" + command.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber() + " (ciphertext):"; | ||||
|         toPrint+="\n"; | ||||
|         VistaNavigator.printFX(toPrint); | ||||
|         if (plaintextSerialNumber != encryptedSerialNumber) { | ||||
| 
 | ||||
|         if (plaintextBallot.getSerialNumber() != command.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber()) { | ||||
|             logger.error("plaintext and encryption serial numbers do not match!! plaintext# = " + | ||||
|                     plaintextSerialNumber + ", ciphertext# = " + encryptedSerialNumber); | ||||
|                     plaintextBallot.getSerialNumber() + ", ciphertext# = " + command.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber()); | ||||
|         } | ||||
| 
 | ||||
|         PollingStation.ScannedBallot scannedBallot = PollingStation.ScannedBallot.newBuilder() | ||||
|  | @ -125,15 +118,15 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
|                 .setSignedEncryptedBallot(command.getSignedEncryptedBallot()) | ||||
|                 .build(); | ||||
| 
 | ||||
|         System.out.println(scannedBallot.getSerializedSize()); | ||||
|         encryptedText = Base64.getEncoder().encodeToString(scannedBallot.toByteArray()); | ||||
|         logger.info("ScannedBallot serialized size: "+scannedBallot.getSerializedSize()); | ||||
|         String encryptedText = Base64.getEncoder().encodeToString(scannedBallot.toByteArray()); | ||||
| 
 | ||||
|         try { | ||||
|             PollingStation.ScannedBallot result = PollingStation.ScannedBallot.parseFrom(Base64.getDecoder().decode(encryptedText.getBytes())); | ||||
|             System.out.println(result.getChannel()); | ||||
|             System.out.println(command.getChannelIdentifierByteString()); | ||||
|         } catch (InvalidProtocolBufferException e) { | ||||
|             e.printStackTrace(); | ||||
|             command.getCallback().onFailure(e); | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|  | @ -147,10 +140,43 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void printQRCode(String toQRCode, int size) throws IOException, WriterException { | ||||
|         BufferedImage image = null; | ||||
|         image = GenerateQRCode.createQRImage(toQRCode, size); | ||||
|         VistaNavigator.printFX(image); | ||||
|     private void printAuditBallot(BallotSecrets ballotSecrets) { | ||||
|         String toPrint = ""; | ||||
|         toPrint+="Audit of Ballot";// + command.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber() + " (ciphertext):";
 | ||||
|         toPrint+="\n"; | ||||
|         VistaNavigator.printFX(toPrint); | ||||
| 
 | ||||
|         //generate the PollingStation.<protobuf> corresponding to [ballotID, plaintext, randomness, Signed(ballotID, plaintext, randomness)]
 | ||||
|         PollingStation.ScannedAudit scannedAudit = PollingStation.ScannedAudit.newBuilder() | ||||
|                 .setSignedBallotSecrets(ballotSecrets); | ||||
| //        PollingStation.ScannedBallot scannedBallot = PollingStation.ScannedBallot.newBuilder()
 | ||||
| //                .setChannel(command.getChannelIdentifierByteString())
 | ||||
| //                .setSignedEncryptedBallot(command.getSignedEncryptedBallot())
 | ||||
| //                .build();
 | ||||
| 
 | ||||
|         //encode to String
 | ||||
| //        logger.info("ScannedAudit serialized size: "+scannedBallot.getSerializedSize());
 | ||||
| //        String auditText = Base64.getEncoder().encodeToString(scannedBallot.toByteArray());
 | ||||
| 
 | ||||
|         //check that decoding encoded gives same as original
 | ||||
| //        try {
 | ||||
| //            PollingStation.ScannedBallot result = PollingStation.ScannedBallot.parseFrom(Base64.getDecoder().decode(auditText.getBytes()));
 | ||||
| //            System.out.println(result.getChannel());
 | ||||
| //            System.out.println(command.getChannelIdentifierByteString());
 | ||||
| //        } catch (InvalidProtocolBufferException e) {
 | ||||
| //            command.getCallback().onFailure(e);
 | ||||
| //        }
 | ||||
| 
 | ||||
|         //print to FX
 | ||||
| //        try {
 | ||||
| //            printQRCode(auditText, 250);
 | ||||
| //            command.getCallback().onSuccess(null);
 | ||||
| //        } catch (IOException e) {
 | ||||
| //            command.getCallback().onFailure(e);
 | ||||
| //        } catch (WriterException e) {
 | ||||
| //            command.getCallback().onFailure(e);
 | ||||
| //        }
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void printEncryptionRandomness (EncryptionRandomness encryptionRandomness) { | ||||
|  | @ -167,6 +193,16 @@ public class FXWindowOutputDevice extends AsyncRunnableOutputDevice { | |||
|         VistaNavigator.printFX(msg); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Creates an image of the QRcode with the String toQRCode in it and displays it to the virtual printer (FX window) | ||||
|      * @param toQRCode a String that contains the text to encode into the QRcode | ||||
|      * @param size the size of the QRcode (we use 250 for testing) | ||||
|      */ | ||||
|     private void printQRCode(String toQRCode, int size) throws IOException, WriterException { | ||||
|         BufferedImage image = null; | ||||
|         image = GenerateQRCode.createQRImage(toQRCode, size); | ||||
|         VistaNavigator.printFX(image); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * Returns the UTF8 decoding of byte-string data | ||||
|  |  | |||
|  | @ -2,13 +2,10 @@ | |||
| 
 | ||||
| <?import javafx.scene.control.Button?> | ||||
| <?import javafx.scene.layout.Pane?> | ||||
| <?import javafx.scene.text.Text?> | ||||
| 
 | ||||
| <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.ChannelChoiceController"> | ||||
|    <children> | ||||
|       <Button layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="39.0" prefWidth="109.0" text="Next" /> | ||||
|       <Text fx:id="question" layoutX="84.0" layoutY="89.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Channel selection:" wrappingWidth="431.3046875" /> | ||||
|       <Pane fx:id="questionPane" layoutX="84.0" layoutY="97.0" prefHeight="234.0" prefWidth="422.0" /> | ||||
|       <Text fx:id="warningMsg" fill="#ee0909" layoutX="82.0" layoutY="64.0" strokeType="OUTSIDE" strokeWidth="0.0" wrappingWidth="431.3046875" /> | ||||
|       <Pane fx:id="questionPane" layoutX="1.0" layoutY="-1.0" prefHeight="326.0" prefWidth="600.0" /> | ||||
|    </children> | ||||
| </Pane> | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| <?import javafx.scene.layout.VBox?> | ||||
| <?scenebuilder-stylesheet vista.css?> | ||||
| 
 | ||||
| <VBox prefHeight="709.0" prefWidth="1259.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.MainController"> | ||||
| <VBox prefHeight="709.0" prefWidth="1259.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.MainController"> | ||||
|     <children> | ||||
|         <Label fx:id="headerLabel" maxWidth="1.7976931348623157E308" prefHeight="70.0" prefWidth="1162.0" text="Header of Election" textFill="#939090" VBox.vgrow="NEVER"> | ||||
|          <VBox.margin> | ||||
|  | @ -15,6 +15,9 @@ | |||
|         <StackPane fx:id="vistaHolder" prefHeight="553.0" prefWidth="1259.0" VBox.vgrow="ALWAYS"> | ||||
|          <VBox.margin> | ||||
|             <Insets bottom="70.0" /> | ||||
|          </VBox.margin></StackPane> | ||||
|          </VBox.margin> | ||||
|          <padding> | ||||
|             <Insets bottom="30.0" left="30.0" right="30.0" top="30.0" /> | ||||
|          </padding></StackPane> | ||||
|     </children> | ||||
| </VBox> | ||||
|  |  | |||
|  | @ -1,10 +1,20 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| 
 | ||||
| <?import javafx.scene.control.ScrollPane?> | ||||
| <?import javafx.scene.layout.Pane?> | ||||
| <?import javafx.scene.layout.VBox?> | ||||
| <?scenebuilder-stylesheet vista.css?> | ||||
| 
 | ||||
| <VBox fx:id="vBox" prefHeight="200.0" prefWidth="350.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.PrinterController"> | ||||
| <Pane prefHeight="486.0" prefWidth="352.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.PrinterController"> | ||||
|    <children> | ||||
|       <ScrollPane fx:id="scrollPane" prefHeight="486.0" prefWidth="352.0"> | ||||
|          <content> | ||||
|             <VBox fx:id="vBox" prefHeight="479.0" prefWidth="350.0" style="-fx-background-color: white;"> | ||||
|                 <children> | ||||
| 
 | ||||
|     </children> | ||||
|             </VBox> | ||||
|          </content> | ||||
|       </ScrollPane> | ||||
|    </children> | ||||
| </Pane> | ||||
|  |  | |||
|  | @ -1,14 +1,22 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| 
 | ||||
| <?import javafx.scene.Group?> | ||||
| <?import javafx.scene.control.Button?> | ||||
| <?import javafx.scene.control.ScrollPane?> | ||||
| <?import javafx.scene.layout.Pane?> | ||||
| <?import javafx.scene.text.Text?> | ||||
| 
 | ||||
| <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.VotingController"> | ||||
|    <children> | ||||
|       <Button layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextQuestion" text="Next" /> | ||||
|       <Text fx:id="question" layoutX="84.0" layoutY="89.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Click 'Next' to see the first question." wrappingWidth="431.3046875" /> | ||||
|       <Pane fx:id="questionPane" layoutX="84.0" layoutY="97.0" prefHeight="234.0" prefWidth="422.0" /> | ||||
|       <Button layoutX="84.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#goBack" text="Back" /> | ||||
|       <Button fx:id="nextButton" layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextQuestion" text="Next" /> | ||||
|       <Button layoutX="74.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#goBack" text="Back" /> | ||||
|       <Group layoutX="220.0" layoutY="369.0"> | ||||
|          <children> | ||||
|             <Text fx:id="currentPage" layoutX="-16.0" strokeType="OUTSIDE" strokeWidth="0.0" text="XXX" textAlignment="RIGHT" wrappingWidth="112.30468860268593" /> | ||||
|             <Text fx:id="question111" layoutX="99.0" strokeType="OUTSIDE" strokeWidth="0.0" text="/" wrappingWidth="12.304688602685928" /> | ||||
|             <Text fx:id="totalPage" layoutX="109.0" strokeType="OUTSIDE" strokeWidth="0.0" text="YYY" wrappingWidth="46.30468860268593" /> | ||||
|          </children> | ||||
|       </Group> | ||||
|       <ScrollPane fx:id="questionPane" layoutY="1.0" prefHeight="322.0" prefWidth="600.0" /> | ||||
|    </children> | ||||
| </Pane> | ||||
|  |  | |||
|  | @ -1,104 +1,33 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| 
 | ||||
| <?import javafx.scene.text.*?> | ||||
| <?import javafx.scene.control.*?> | ||||
| <?import java.lang.*?> | ||||
| <?import javafx.scene.layout.*?> | ||||
| <?import javafx.geometry.Insets?> | ||||
| <?import javafx.scene.control.Button?> | ||||
| <?import javafx.scene.layout.AnchorPane?> | ||||
| <?import javafx.scene.layout.VBox?> | ||||
| <?import javafx.scene.text.Font?> | ||||
| <?import javafx.scene.text.Text?> | ||||
| 
 | ||||
| <GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.WelcomeScreenController"> | ||||
|   <columnConstraints> | ||||
|     <ColumnConstraints /> | ||||
|       <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> | ||||
|   </columnConstraints> | ||||
|   <rowConstraints> | ||||
|     <RowConstraints /> | ||||
|     <RowConstraints maxHeight="129.0" minHeight="10.0" prefHeight="47.0" vgrow="SOMETIMES" /> | ||||
|     <RowConstraints maxHeight="222.0" minHeight="10.0" prefHeight="201.0" vgrow="SOMETIMES" /> | ||||
|       <RowConstraints maxHeight="170.0" minHeight="10.0" prefHeight="129.0" vgrow="SOMETIMES" /> | ||||
|   </rowConstraints> | ||||
| 
 | ||||
| <AnchorPane xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.WelcomeScreenController"> | ||||
|    <children> | ||||
|       <GridPane GridPane.columnIndex="1" GridPane.rowIndex="1"> | ||||
|         <columnConstraints> | ||||
|           <ColumnConstraints hgrow="SOMETIMES" maxWidth="185.0" minWidth="10.0" prefWidth="185.0" /> | ||||
|             <ColumnConstraints hgrow="SOMETIMES" maxWidth="334.0" minWidth="10.0" prefWidth="258.0" /> | ||||
|           <ColumnConstraints hgrow="SOMETIMES" maxWidth="194.0" minWidth="10.0" prefWidth="124.0" /> | ||||
|         </columnConstraints> | ||||
|         <rowConstraints> | ||||
|           <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||||
|         </rowConstraints> | ||||
|       <VBox alignment="CENTER" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||||
|          <children> | ||||
|             <BorderPane prefHeight="200.0" prefWidth="200.0"> | ||||
|                <center> | ||||
|                   <Label text="Organization Logo" BorderPane.alignment="CENTER" /> | ||||
|                </center> | ||||
|             </BorderPane> | ||||
|             <BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2"> | ||||
|                <center> | ||||
|                   <Label text="Date" BorderPane.alignment="CENTER" /> | ||||
|                </center> | ||||
|             </BorderPane> | ||||
|          </children> | ||||
|       </GridPane> | ||||
|       <GridPane GridPane.columnIndex="1" GridPane.rowIndex="1"> | ||||
|         <columnConstraints> | ||||
|           <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> | ||||
|         </columnConstraints> | ||||
|         <rowConstraints> | ||||
|           <RowConstraints maxHeight="74.0" minHeight="10.0" prefHeight="74.0" vgrow="SOMETIMES" /> | ||||
|           <RowConstraints maxHeight="123.0" minHeight="10.0" prefHeight="93.0" vgrow="SOMETIMES" /> | ||||
|           <RowConstraints maxHeight="59.0" minHeight="10.0" prefHeight="29.0" vgrow="SOMETIMES" /> | ||||
|         </rowConstraints> | ||||
|       </GridPane> | ||||
|       <GridPane GridPane.columnIndex="1" GridPane.rowIndex="2"> | ||||
|         <columnConstraints> | ||||
|           <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> | ||||
|         </columnConstraints> | ||||
|         <rowConstraints> | ||||
|           <RowConstraints maxHeight="75.0" minHeight="10.0" prefHeight="75.0" vgrow="SOMETIMES" /> | ||||
|           <RowConstraints maxHeight="107.0" minHeight="10.0" prefHeight="107.0" vgrow="SOMETIMES" /> | ||||
|           <RowConstraints maxHeight="56.0" minHeight="10.0" prefHeight="27.0" vgrow="SOMETIMES" /> | ||||
|         </rowConstraints> | ||||
|          <children> | ||||
|             <BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1"> | ||||
|                <center> | ||||
|                   <Button mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="50.0" prefWidth="170.0" text="Start Here" BorderPane.alignment="CENTER"> | ||||
|             <Text fx:id="electionName" strokeType="OUTSIDE" strokeWidth="0.0" text="Name of the Election" textAlignment="CENTER" wrappingWidth="343.205078125"> | ||||
|                <font> | ||||
|                   <Font name="System Bold" size="24.0" /> | ||||
|                </font> | ||||
|             </Text> | ||||
|             <Text fx:id="electionLocation" layoutX="138.0" layoutY="191.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Location" textAlignment="CENTER" wrappingWidth="343.205078125"> | ||||
|                <VBox.margin> | ||||
|                   <Insets bottom="70.0" /> | ||||
|                </VBox.margin> | ||||
|             </Text> | ||||
|             <Button mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="51.0" prefWidth="214.0" text="Start Here"> | ||||
|                <font> | ||||
|                   <Font size="24.0" /> | ||||
|                </font> | ||||
|             </Button> | ||||
|                </center> | ||||
|             </BorderPane> | ||||
|             <GridPane> | ||||
|               <columnConstraints> | ||||
|                 <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> | ||||
|               </columnConstraints> | ||||
|               <rowConstraints> | ||||
|                 <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||||
|                 <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> | ||||
|               </rowConstraints> | ||||
|                <children> | ||||
|                   <BorderPane prefHeight="200.0" prefWidth="200.0"> | ||||
|                      <center> | ||||
|                         <Label text="This is the name of the Election" BorderPane.alignment="CENTER"> | ||||
|                            <font> | ||||
|                               <Font size="18.0" /> | ||||
|                            </font> | ||||
|                         </Label> | ||||
|                      </center> | ||||
|                   </BorderPane> | ||||
|                   <BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1"> | ||||
|                      <top> | ||||
|                         <Label text="Location | Precinct" BorderPane.alignment="CENTER" /> | ||||
|                      </top> | ||||
|                   </BorderPane> | ||||
|          </children> | ||||
|             </GridPane> | ||||
|       </VBox> | ||||
|    </children> | ||||
|       </GridPane> | ||||
|       <BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="3"> | ||||
|          <center> | ||||
|             <Label fx:id="ErrorPanel" maxHeight="30.0" maxWidth="500.0" minHeight="30.0" minWidth="500.0" prefHeight="30.0" prefWidth="500.0" BorderPane.alignment="CENTER" /> | ||||
|          </center> | ||||
|       </BorderPane> | ||||
|    </children> | ||||
| </GridPane> | ||||
| </AnchorPane> | ||||
|  |  | |||
|  | @ -40,5 +40,5 @@ public interface VBCryptoManager { | |||
|     // TODO: do we seed the random here?
 | ||||
|     public EncryptionAndSecrets encrypt (PlaintextBallot plaintextBallot) throws SignatureException, IOException; | ||||
| 
 | ||||
| 
 | ||||
|     //TODO: Laura: there should be a method here to sign whatever I need to sign, no? Does it mean that I need to create a class for each type of thing I need to sign?
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue