Skip to content

Commit

Permalink
Merge pull request #436 from JohnLCaron/typos
Browse files Browse the repository at this point in the history
Fix typos
  • Loading branch information
JohnLCaron committed Dec 7, 2023
2 parents 77aac7a + e21ae41 commit 03586ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 5 additions & 5 deletions docs/CommandLineInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ last update 11/22/2023
2. To run a keyceremony with remote guardians, see the webapps CLI.

4. **Create test input plaintext ballots**
1. Create fake input ballots for testing with [_RunGenerateInputBallots_ CLI](#create-fake-input-ballots).
1. Create fake input ballots for testing with [_RunCreateInputBallots_ CLI](#create-fake-input-ballots).
1. _electionguard.workflow.GenerateFakeBallots_ generates random test ballots.
2. Use existing fake ballots for testing in _egklib/src/commonTest/data/fakeBallots_.

Expand Down Expand Up @@ -123,7 +123,6 @@ Example:

````
/usr/lib/jvm/jdk-19/bin/java \
-Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 \
-classpath egkliball/build/libs/egklib-all.jar \
electionguard.cli.RunCreateElectionConfig \
-manifest egklib/src/commonTest/data/startManifestJson \
Expand Down Expand Up @@ -193,15 +192,15 @@ Options:
--inputDir, -in -> Directory containing input election record (always required) { String }
--ballotDir, -ballots -> Directory to read Plaintext ballots from (always required) { String }
--outputDir, -out -> Directory to write output election record { String }
--encryptDir, -encryptDir -> Write just encrypted ballots here { String }
--encryptDir, -eballots -> Write encrypted ballots here { String }
--invalidDir, -invalid -> Directory to write invalid input ballots to { String }
--check, -check [None] -> Check encryption { Value should be one of [none, verify, encrypttwice, decryptnonce] }
--nthreads, -nthreads [11] -> Number of parallel threads to use { Int }
--createdBy, -createdBy -> who created { String }
--device, -device -> voting device name (always required) { String }
--cleanOutput, -clean [false] -> clean output dir
--anonymize, -anon [false] -> anonymize ballot
--help, -h -> Usage info
--help, -h -> Usage info
````
You must specify outputDir or encryptDir. The former copies ElectionInit and writes encrypted ballots to standard election record.
The latter writes just the encrypted ballots to the specified directory.
Expand All @@ -228,6 +227,7 @@ Usage: RunAccumulateTally options_list
Options:
--inputDir, -in -> Directory containing input ElectionInitialized record and encrypted ballots (always required) { String }
--outputDir, -out -> Directory to write output election record (always required) { String }
--encryptDir, -eballots -> Read encrypted ballots here (optional) { String }
--name, -name -> Name of tally { String }
--createdBy, -createdBy -> who created { String }
--help, -h -> Usage info
Expand Down Expand Up @@ -263,7 +263,7 @@ Options:
--trusteeDir, -trustees -> Directory to read private trustees (always required) { String }
--outputDir, -out -> Directory to write output election record (always required) { String }
--createdBy, -createdBy -> who created { String }
--npresent, -npresent -> number of guardians present { Int }
--missing, -missing -> missing guardians' xcoord, comma separated, eg '2,4' { String }
--help, -h -> Usage info
````

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ open class KeyCeremonyTrustee(
// Call after all myShareOfOthers has been populated with all the other trustee's.
// The value P(i) == G_i’s share of the secret key s = (s1 + s2 + · · · + sn )
// == (P1 (ℓ) + P2 (ℓ) + · · · + Pn (ℓ)) mod q. spec 2.0.0, eq 65.
internal fun computeSecretKeyShare(): ElementModQ {
fun computeSecretKeyShare(): ElementModQ {
if (nguardians != myShareOfOthers.size + 1) {
throw RuntimeException("KeyCeremonyTrustee.computeSecretKeyShare: requires nguardians ${nguardians} but have ${myShareOfOthers.size + 1} shares")
}
Expand Down
14 changes: 10 additions & 4 deletions egklib/src/jvmMain/kotlin/electionguard/cli/RunMakeMixnetInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToStream
import java.io.FileOutputStream

/** Read the EG encypted ballots and create JSON encoded file for the mixnet. */
class RunMakeMixnetInput {

companion object {
val jsonReader = Json { explicitNulls = false; ignoreUnknownKeys = true; prettyPrint = true }

@JvmStatic
fun main(args: Array<String>) {
fun main(args: Array<String>): Int {
val parser = ArgParser("RunMakeMixnetInput")
val encryptedBallotsDir by parser.option(
ArgType.String,
Expand All @@ -33,20 +34,23 @@ class RunMakeMixnetInput {
val isJson by parser.option(
ArgType.Boolean,
shortName = "json",
description = "ENcrypted ballots are JSON"
description = "Encrypted ballots are JSON"
).default(true)
parser.parse(args)

// create output directory if needed
val outputDir = outputFile.substringBeforeLast("/")
createDirectories(outputDir)

runMakeMixnetInput(productionGroup(), encryptedBallotsDir, outputFile, isJson)
return runMakeMixnetInput(productionGroup(), encryptedBallotsDir, outputFile, isJson)
}

fun runMakeMixnetInput(group: GroupContext, encryptedBallotsDir: String, outputFile: String, isJson : Boolean) {
/** return number of ciphertexts in a row. */
fun runMakeMixnetInput(group: GroupContext, encryptedBallotsDir: String, outputFile: String, isJson : Boolean): Int {
val consumer = makeConsumer(group, encryptedBallotsDir, isJson)
val mixnetBallots = mutableListOf<MixnetBallot>()
var first = true
var countCiphertexts = 0
consumer.iterateEncryptedBallotsFromDir(encryptedBallotsDir, null).forEach { encryptedBallot ->
val ciphertexts = mutableListOf<ElGamalCiphertext>()
ciphertexts.add(encryptedBallot.encryptedSn!!) // always the first one
Expand All @@ -56,12 +60,14 @@ class RunMakeMixnetInput {
}
}
mixnetBallots.add(MixnetBallot(ciphertexts))
if (first) countCiphertexts = ciphertexts.size else require(countCiphertexts == ciphertexts.size)
}

val json = mixnetBallots.publishJson()
FileOutputStream(outputFile).use { out ->
jsonReader.encodeToStream(json, out)
}
return countCiphertexts
}
}
}

0 comments on commit 03586ea

Please sign in to comment.