syntax = "proto3";

package meerkat;

option java_package = "meerkat.protobuf";

import "meerkat/crypto.proto";
import "meerkat/voting.proto";


// Data sent (out-of-band) by the server that the client will require to set up a connection
message ConnectionServerData {
    // Web-API URL for the server
    string server_url = 1;

    // random nonce used for verification of the client.
    uint64 nonce = 2;
}

// Data sent by the client in order to set up a connection
message ConnectionClientData {

    oneof id {
        // Unique ID of the scanner (if not using signatures)
        bytes scannerId = 1;

        // Public Key used to sign future reports
        // If this is set, the ID is the certificate fingerprint.
        SignatureVerificationKey scannerPK = 2;
    }

    // Nonce sent by connection-server
    // (used to verify pairing)
    uint64 nonce = 3;
}

message ScannedBallot {
    bytes channel = 1;

    SignedEncryptedBallot signed_encrypted_ballot = 2;

}

// Container for error messages
message ScanError {
    string msg = 1;
}


// Container for scanned data
message ScannedData {
    oneof data {
        ScannedBallot ballot = 2;
        ScanError error = 3;
    }
    uint64 serial = 4; // Serial number of the message
    bytes scannerId = 5; // hash of the scannerPK
}

message SignedScannedData {
    ScannedData data = 1;
    Signature scannerSig = 2; // signature on the serialzed form of data.
}

