<commit_before>var voterClient = function() {
var exports = {};
//////////////////////////////////////////////////////////////////////////////////////////////

var crypto = require('./cryptofunc');

// PARAMETERS

var TAG_ACCEPTED = "00"; // (hex encoded) tag 

// SHORTCUTS

var pair = crypto.concatenate;
var enc  = crypto.pke_encrypt;
var dec  = crypto.pke_decrypt;

// Returns a new voter client instance
exports.create = function(electionID, colServEncKey, colServVerifKey, mixServEncKeys)
{
    ///
    // Method createBallot
    //
    // Returns
    //          ENC_CS(electionID, innerBallot )
    //
    // where    innerBallot = 
	//  	ENC_mix1(electionID, ENC_Mix2( electionID, ... Enc_MixN(electionID, choice, receiptID) ...)
    //
    // Arguments:
    //   hexenc   	electionID
    //   hexenc   	colServEncKey
    //   hexenc[]	mixServEncKeys
    //   int      	choice
    //
    // Returns:
    //   object ballotInfo with fields: ballot, innerBallot, nonce
    //
    function createBallot (choice) {
        choice = crypto.int32ToHexString(choice);
        var nonce = crypto.nonce().slice(0,16);
        var innerBallot = pair(nonce, choice);
        // encrypt the innerBallot for the chain of mix servers
        for(i=mixServEncKeys.length-1; i>=0; --i) 
        	innerBallot=enc(mixServEncKeys[i], pair(electionID, innerBallot));
        //FIXME: to be removed when the collecting server changes
        var ballot = enc(colServEncKey, pair(electionID, innerBallot));

        return { ballot: ballot, nonce: nonce, innerBallot: innerBallot };
    }
    

    
    ///
    // Method validateReceipt
    //
    // Returns true if the given receipt is valid (w.r.t. the given
    // inner ballot and election id).
    //
    function validateReceipt (receipt, innerBallot) {
        message = pair(TAG_ACCEPTED, pair(electionID, innerBallot));
        return crypto.verifsig(colServVerifKey, message, receipt); 
    }

    return {createBallot: createBallot, validateReceipt: validateReceipt};
}

//////////////////////////////////////////////////////////////////////////////////////////////
return exports;
}();

if (typeof(module)!=='undefined' && module.exports) {
    module.exports = voterClient;
}
<commit_msg>space rm from voterClient<commit_after>var voterClient = function() {
var exports = {};
//////////////////////////////////////////////////////////////////////////////////////////////

var crypto = require('./cryptofunc');

// PARAMETERS

var TAG_ACCEPTED = "00"; // (hex encoded) tag 

// SHORTCUTS

var pair = crypto.concatenate;
var enc  = crypto.pke_encrypt;
var dec  = crypto.pke_decrypt;

// Returns a new voter client instance
exports.create = function(electionID, colServEncKey, colServVerifKey, mixServEncKeys)
{
    ///
    // Method createBallot
    //
    // Returns
    //          ENC_CS(electionID, innerBallot )
    //
    // where    innerBallot =
	//  	ENC_mix1(electionID, ENC_Mix2( electionID, ... Enc_MixN(electionID, choice, receiptID) ...)
    //
    // Arguments:
    //   hexenc   	electionID
    //   hexenc   	colServEncKey
    //   hexenc[]	mixServEncKeys
    //   int      	choice
    //
    // Returns:
    //   object ballotInfo with fields: ballot, innerBallot, nonce
    //
    function createBallot (choice) {
        choice = crypto.int32ToHexString(choice);
        var nonce = crypto.nonce().slice(0,16);
        var innerBallot = pair(nonce, choice);
        // encrypt the innerBallot for the chain of mix servers
        for(i=mixServEncKeys.length-1; i>=0; --i)
        	innerBallot=enc(mixServEncKeys[i], pair(electionID, innerBallot));
        //FIXME: to be removed when the collecting server changes
        var ballot = enc(colServEncKey, pair(electionID, innerBallot));

        return { ballot: ballot, nonce: nonce, innerBallot: innerBallot };
    }


    ///
    // Method validateReceipt
    //
    // Returns true if the given receipt is valid (w.r.t. the given
    // inner ballot and election id).
    //
    function validateReceipt (receipt, innerBallot) {
        message = pair(TAG_ACCEPTED, pair(electionID, innerBallot));
        return crypto.verifsig(colServVerifKey, message, receipt); 
    }

    return {createBallot: createBallot, validateReceipt: validateReceipt};
}

//////////////////////////////////////////////////////////////////////////////////////////////
return exports;
}();

if (typeof(module)!=='undefined' && module.exports) {
    module.exports = voterClient;
}

{'fraction_non_alphanumeric': 0.1932604329390761, 'fraction_numerical': 0.00490961838875251, 'mean_word_length': 1.9467455621301775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3367294', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1290, 'n_words': 315}