<commit_before><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" /> 
  <title>Helios Voting System -- Verifier</title>
  <link rel="stylesheet" type="text/css" href="css/booth.css" />
  <link rel="stylesheet" type="text/css" href="css/forms.css" />
  <script language="javascript" src="js/jscrypto/jsbn.js"></script>
  <script language="javascript" src="js/jscrypto/jsbn2.js"></script>
  <script language="javascript" src="js/jscrypto/sjcl.js"></script>
  <script language="javascript" src="js/underscore-min.js"></script> 
  <script language="javascript" src="js/jquery-1.2.2.min.js"></script>
  <script language="javascript" src="js/jquery-jtemplates.js"></script>
  <script language="javascript" src="js/jquery.query-2.1.5.js"></script>
  <script language="javascript" src="js/jquery.json.min.js"></script>

  <script language="javascript">
    // required for jscrypto library
    var JSCRYPTO_HOME = document.location.pathname.replace("verify.html", "js/jscrypto");
  </script>

  <script language="javascript" src="js/jscrypto/class.js"></script>  
  <script language="javascript" src="js/jscrypto/bigint.js"></script>
  <script language="javascript" src="js/jscrypto/random.js"></script>
  <script language="javascript" src="js/jscrypto/elgamal.js"></script>
  <script language="javascript" src="js/jscrypto/sha1.js"></script>
  <script language="javascript" src="js/jscrypto/sha2.js"></script>
  <script language="javascript" src="js/jscrypto/helios.js"></script>

<script language="javascript">
$(document).ready(function() {
    BigInt.setup(function() {
       $('#verifier_loading').hide();
       $('#verifier').show();
    }, function() {
       alert('sorry, in-browser verification requires Java Support at this time.');
    });
});    

function result_append(str) {
    $('#results').append(str).append("<br />");
}

function pretty_result(result) {return result? "VERIFIED" : "FAIL";}

function load_ballots(election_url, ballot_list, ballots, final_callback) {
    // the ballots array is the place where we build up the list of ballots

    // end of the iteration?
    if (ballot_list.length == ballots.length) {
        final_callback(ballots);
        return;
    }
    
    result_append("loading ballot for voter #" + (ballots.length + 1));
        
    // get the next ballot
    $.get(election_url + "/ballots/" + ballot_list[ballots.length].uuid + '/last', function(result) {
        var new_ballot = jQuery.secureEvalJSON(result);
        ballots.push(new_ballot);
        if (new_ballot.vote == null)
          result_append("no ballot for this voter #" + ballots.length);
        else
          result_append("FOUND a ballot for voter #" + ballots.length);
        load_ballots(election_url, ballot_list, ballots, final_callback);
    });
}

// load the ballot list in increments of 50, for long ballots
function load_ballot_list(election_url, ballot_list, after, final_callback) {
    var url = election_url + "/voters/?limit=50";
    if (after)
        url+= "&after=" + after;
        
    $.get(url, function(result) {
        var new_ballot_list = jQuery.secureEvalJSON(result);

        // done, no more ballots?
        if (new_ballot_list.length == 0)
            return final_callback(ballot_list);
            
        // not done, add to the list
        ballot_list = ballot_list.concat(new_ballot_list);
        after = ballot_list[ballot_list.length - 1].uuid;
        
        // and iterate
        load_ballot_list(election_url, ballot_list, after, final_callback);
    });
}

function load_election_and_ballots(election_url) {
        
    result_append("<h3>Election</h3>");
    result_append("loading election...");

    var overall_result = true;
    
    // the hash will be computed within the setup function call now
    $.get(election_url, function(raw_json) {
        election = HELIOS.Election.fromJSONString(raw_json);
        result_append("loaded election: " + election.name);
        result_append("election fingerprint: " + election.get_hash());
        
        var tally = [];

        $(election.questions).each(function(qnum, q) {
            if (q.tally_type != "homomorphic") {
              result_append("PROBLEM: this election is not a straight-forward homomorphic-tally election. As a result, Helios cannot currently verify it. Try the <a href='https://github.com/RunasSudo/helios-server-mixnet/tree/master/verifymix'>standalone python mixnet verifier</a> instead.");
              return;
            }

            tally[qnum] = $(q.answers).map(function(anum, a) {
                return 1;
            });
        });

        result_append("loading list of voters...");
        
        // load voter list
        load_ballot_list(election_url, [], null, function(ballot_list) {
            result_append("loaded voter list, now loading ballots for each..");
            
            // load all ballots
            load_ballots(election_url, ballot_list, [], function(ballots) {
                result_append("");<commit_msg>Python has a capital letter<commit_after><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" /> 
  <title>Helios Voting System -- Verifier</title>
  <link rel="stylesheet" type="text/css" href="css/booth.css" />
  <link rel="stylesheet" type="text/css" href="css/forms.css" />
  <script language="javascript" src="js/jscrypto/jsbn.js"></script>
  <script language="javascript" src="js/jscrypto/jsbn2.js"></script>
  <script language="javascript" src="js/jscrypto/sjcl.js"></script>
  <script language="javascript" src="js/underscore-min.js"></script> 
  <script language="javascript" src="js/jquery-1.2.2.min.js"></script>
  <script language="javascript" src="js/jquery-jtemplates.js"></script>
  <script language="javascript" src="js/jquery.query-2.1.5.js"></script>
  <script language="javascript" src="js/jquery.json.min.js"></script>

  <script language="javascript">
    // required for jscrypto library
    var JSCRYPTO_HOME = document.location.pathname.replace("verify.html", "js/jscrypto");
  </script>

  <script language="javascript" src="js/jscrypto/class.js"></script>  
  <script language="javascript" src="js/jscrypto/bigint.js"></script>
  <script language="javascript" src="js/jscrypto/random.js"></script>
  <script language="javascript" src="js/jscrypto/elgamal.js"></script>
  <script language="javascript" src="js/jscrypto/sha1.js"></script>
  <script language="javascript" src="js/jscrypto/sha2.js"></script>
  <script language="javascript" src="js/jscrypto/helios.js"></script>

<script language="javascript">
$(document).ready(function() {
    BigInt.setup(function() {
       $('#verifier_loading').hide();
       $('#verifier').show();
    }, function() {
       alert('sorry, in-browser verification requires Java Support at this time.');
    });
});    

function result_append(str) {
    $('#results').append(str).append("<br />");
}

function pretty_result(result) {return result? "VERIFIED" : "FAIL";}

function load_ballots(election_url, ballot_list, ballots, final_callback) {
    // the ballots array is the place where we build up the list of ballots

    // end of the iteration?
    if (ballot_list.length == ballots.length) {
        final_callback(ballots);
        return;
    }
    
    result_append("loading ballot for voter #" + (ballots.length + 1));
        
    // get the next ballot
    $.get(election_url + "/ballots/" + ballot_list[ballots.length].uuid + '/last', function(result) {
        var new_ballot = jQuery.secureEvalJSON(result);
        ballots.push(new_ballot);
        if (new_ballot.vote == null)
          result_append("no ballot for this voter #" + ballots.length);
        else
          result_append("FOUND a ballot for voter #" + ballots.length);
        load_ballots(election_url, ballot_list, ballots, final_callback);
    });
}

// load the ballot list in increments of 50, for long ballots
function load_ballot_list(election_url, ballot_list, after, final_callback) {
    var url = election_url + "/voters/?limit=50";
    if (after)
        url+= "&after=" + after;
        
    $.get(url, function(result) {
        var new_ballot_list = jQuery.secureEvalJSON(result);

        // done, no more ballots?
        if (new_ballot_list.length == 0)
            return final_callback(ballot_list);
            
        // not done, add to the list
        ballot_list = ballot_list.concat(new_ballot_list);
        after = ballot_list[ballot_list.length - 1].uuid;
        
        // and iterate
        load_ballot_list(election_url, ballot_list, after, final_callback);
    });
}

function load_election_and_ballots(election_url) {
        
    result_append("<h3>Election</h3>");
    result_append("loading election...");

    var overall_result = true;
    
    // the hash will be computed within the setup function call now
    $.get(election_url, function(raw_json) {
        election = HELIOS.Election.fromJSONString(raw_json);
        result_append("loaded election: " + election.name);
        result_append("election fingerprint: " + election.get_hash());
        
        var tally = [];

        $(election.questions).each(function(qnum, q) {
            if (q.tally_type != "homomorphic") {
              result_append("PROBLEM: this election is not a straight-forward homomorphic-tally election. As a result, Helios cannot currently verify it. Try the <a href='https://github.com/RunasSudo/helios-server-mixnet/tree/master/verifymix'>standalone Python mixnet verifier</a> instead.");
              return;
            }

            tally[qnum] = $(q.answers).map(function(anum, a) {
                return 1;
            });
        });

        result_append("loading list of voters...");
        
        // load voter list
        load_ballot_list(election_url, [], null, function(ballot_list) {
            result_append("loaded voter list, now loading ballots for each..");
            
            // load all ballots
            load_ballots(election_url, ballot_list, [], function(ballots) {
                result_append("");
{'fraction_non_alphanumeric': 0.15027900711949202, 'fraction_numerical': 0.005964979796036175, 'mean_word_length': 3.1663326653306614, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 95, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7027635', 'n_tokens_mistral': 3306, 'n_tokens_neox': 3184, 'n_words': 653}