diff --git a/README.md b/README.md index 4ef6c297..addfb882 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ElectionGuard-Kotlin-Multiplatform -_last update 10/23/2023_ +_last update 12/13/2023_ ElectionGuard-Kotlin-Multiplatform (EGK) is a [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html) implementation of @@ -13,7 +13,7 @@ Our GitHub repository is now hosted by [VotingWorks](https://www.voting.works/). Currently we have ~88% LOC code coverage on the common and jvm core library (7024/7995 LOC). We are focusing on just the JVM implementation, and will consider native and other implementations in the future. -Current library dependencies are summarized [here](dependencies.txt). +Library dependencies are summarized [here](dependencies.txt). Currently Java 17 is required. @@ -47,25 +47,12 @@ Currently Java 17 is required. _We are waiting for the 2.0 JSON serialization specification from Microsoft, before finalizing our serialization. For now, we are still mostly using the 1.9 serialization._ -EGK can use both JSON and [Protocol Buffers](https://en.wikipedia.org/wiki/Protocol_Buffers) for serialization. -Protobuf is a binary format that takes roughly half the space of JSON for the same information. -EGK includes `.proto` files for all the relevant data formats, which constitutes a well defined -and compact schema for EG serialization. +Support for [Protocol Buffers](https://en.wikipedia.org/wiki/Protocol_Buffers) has been moved to [this repo](https://github.com/JohnLCaron/egk-protobuf). -### Protobuf Serialization -* [Protobuf serialization 1.9](docs/ProtoSerializationSpec1.9.md) -* [Election Record serialization for private classes](docs/ProtoSerializationPrivate.md) -* [Preencryption Serialization](docs/PreencryptSerialization.md) -* [Election Record protobuf directory and file layout](docs/ElectionRecordProto.md) - -### JSON Serialization +### JSON Serialization specification * [JSON serialization 1.9](docs/JsonSerializationSpec1.9.md) * [Election Record JSON directory and file layout](docs/ElectionRecordJson.md) -### Previous Serialization specs -* [Protobuf serialization 1.53](docs/ProtoSerializationSpec1.53.md) -* [Protobuf serialization (ver 1) and comparison with JSON](docs/ProtoSerializationSpec1.md) - ## Validation * [Input Validation](docs/InputValidation.md) * [Tally Validation](docs/TallyValidation.md) diff --git a/dependencies.txt b/dependencies.txt index 70bed983..a9393387 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,14 +1,37 @@ 10/23/2023 +$ ./gradlew -q egklib:dependencies --configuration jvmRuntimeClasspath + ------------------------------------------------------------ -Project ':egklib' : just the electionguard classes. +Project ':egklib' ------------------------------------------------------------ jvmRuntimeClasspath - Runtime classpath of jvm/main. ++--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 +| +--- org.jetbrains:annotations:13.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0 -> 1.9.20 (c) +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0 -> 1.9.20 (c) ++--- com.michael-bull.kotlin-result:kotlin-result:1.1.18 +| \--- com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.18 +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10 -> 1.9.20 +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20 +| \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 (*) ++--- org.jetbrains.kotlinx:kotlinx-cli:0.3.6 +| \--- org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.6 +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 -> 1.9.20 (*) ++--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 +| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 +| +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4 +| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 (c) +| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 (c) +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.9.20 (*) ++--- org.jetbrains.kotlinx:kotlinx-datetime:0.4.1 +| \--- org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.4.1 +| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 -> 1.9.20 (*) +--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 | \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.10 -| | \--- org.jetbrains:annotations:13.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.20 (*) | +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 | | +--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 (c) | | +--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 (c) @@ -16,100 +39,72 @@ jvmRuntimeClasspath - Runtime classpath of jvm/main. | | \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 (c) | \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 | \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.10 (*) +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.20 (*) | \--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 (*) -+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 -| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 -| +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4 -| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 (c) -| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 (c) -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.9.10 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10 -| \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 (*) +--- io.github.oshai:kotlin-logging:5.1.0 | \--- io.github.oshai:kotlin-logging-jvm:5.1.0 -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.10 (*) -+--- org.jetbrains.kotlinx:kotlinx-datetime:0.4.1 -| \--- org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.4.1 -| \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 -> 1.9.10 (*) -+--- pro.streem.pbandk:pbandk-runtime:0.14.2 -| \--- pro.streem.pbandk:pbandk-runtime-jvm:0.14.2 -| +--- pro.streem.pbandk:pbandk-protos:0.14.2 -| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32 -> 1.9.10 (*) -| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32 -> 1.9.10 (*) -| \--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0-RC -> 1.6.0 (*) -+--- org.jetbrains.kotlinx:kotlinx-cli:0.3.6 -| \--- org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.6 -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 (*) -+--- com.michael-bull.kotlin-result:kotlin-result:1.1.18 -| \--- com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.18 -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10 -> 1.9.10 (*) -\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.20 (*) +\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20 (*) + +(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree. +(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation. ================================================================================== -./gradlew -q egkliball:dependencies --configuration runtimeClasspath +$ ./gradlew -q egkliball:dependencies --configuration runtimeClasspath ------------------------------------------------------------ -Project ':egkliball' : the electionguard classes, all dependencies, and logback. +Project ':egkliball' ------------------------------------------------------------ runtimeClasspath - Runtime classpath of null/main. -+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 -| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10 -| | \--- org.jetbrains:annotations:13.0 -| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10 -| \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 (*) ++--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 +| +--- org.jetbrains:annotations:13.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0 -> 1.9.10 (c) +| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.20 (c) +| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0 -> 1.9.10 (c) +--- com.michael-bull.kotlin-result:kotlin-result:1.1.18 | \--- com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.18 -| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10 -> 1.9.10 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.10 -> 1.9.10 -+--- pro.streem.pbandk:pbandk-runtime:0.14.2 -| \--- pro.streem.pbandk:pbandk-runtime-jvm:0.14.2 -| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.32 -> 1.9.10 -| +--- pro.streem.pbandk:pbandk-protos:0.14.2 -| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32 -> 1.9.10 (*) -| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32 -> 1.9.10 (*) -| \--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0-RC -> 1.6.0 -| \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.10 (*) -| +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 -| | +--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 (c) -| | +--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 (c) -| | +--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 (c) -| | \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 (c) -| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0 -> 1.9.10 -| \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 -| \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.10 (*) -| +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0 -> 1.9.10 -+--- io.github.oshai:kotlin-logging:5.1.0 -| \--- io.github.oshai:kotlin-logging-jvm:5.1.0 -| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.10 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22 -> 1.9.10 -+--- ch.qos.logback:logback-classic:1.4.11 -| +--- ch.qos.logback:logback-core:1.4.11 -| \--- org.slf4j:slf4j-api:2.0.7 +| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10 -> 1.9.10 +| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 -> 1.9.20 (*) +| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10 +| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 -> 1.9.20 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.10 -> 1.9.20 +| \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.20 (*) +--- org.jetbrains.kotlinx:kotlinx-cli:0.3.6 | \--- org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.6 | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10 -+--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10 -> 1.9.20 (*) ++--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 +| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 +| +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4 +| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 (c) +| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 (c) +| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.9.10 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21 -> 1.9.20 (*) +--- org.jetbrains.kotlinx:kotlinx-datetime:0.4.1 | \--- org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.4.1 -| +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 -> 1.9.10 (*) -| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.21 -> 1.9.10 -\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 - \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 - +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4 - | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 (c) - | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 (c) - +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.9.10 (*) - \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21 -> 1.9.10 +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 -> 1.9.20 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.21 -> 1.9.20 (*) ++--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 +| \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.20 (*) +| +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 +| | +--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 (c) +| | +--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.0 (c) +| | +--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 (c) +| | \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 (c) +| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0 -> 1.9.20 (*) +| \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0 +| \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 -> 1.9.20 (*) +| +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0 -> 1.9.20 (*) ++--- io.github.oshai:kotlin-logging:5.1.0 +| \--- io.github.oshai:kotlin-logging-jvm:5.1.0 +| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.10 (*) +| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22 -> 1.9.20 (*) +\--- ch.qos.logback:logback-classic:1.4.11 + +--- ch.qos.logback:logback-core:1.4.11 + \--- org.slf4j:slf4j-api:2.0.7 -(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree. -(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; -repeat occurrences only display the root of the subtree, followed by this annotation. diff --git a/egklib/build.gradle.kts b/egklib/build.gradle.kts index 3f5b34c3..89751f00 100644 --- a/egklib/build.gradle.kts +++ b/egklib/build.gradle.kts @@ -9,7 +9,7 @@ repositories { } group = "electionguard-kotlin-multiplatform" -version = "2.0.2-SNAPSHOT" +version = "2.0.3-SNAPSHOT" kotlin { jvm { @@ -36,30 +36,6 @@ kotlin { } } - /* -val hostOs = System.getProperty("os.name") -val isMingwX64 = hostOs.startsWith("Windows") -val arch = System.getProperty("os.arch") -val nativeTarget = - when { - hostOs == "Mac OS X" && arch == "aarch64" -> macosArm64("native") - hostOs == "Mac OS X"-> macosX64("native") - hostOs == "Linux" -> linuxX64("native") - isMingwX64 -> mingwX64("native") - else -> throw GradleException("Host OS '$hostOs' arch '$arch' is not supported.") - } - -nativeTarget.apply { - binaries { - sharedLib() { - baseName = "ekm" // on Linux and macOS - // baseName = "libekm // on Windows - } - } -} - - */ - sourceSets { all { languageSettings.optIn("kotlin.RequiresOptIn") } @@ -100,34 +76,6 @@ nativeTarget.apply { jvmToolchain(17) } -// val protoGenSource by extra("build/generated/source/proto") - -/* -protoc --pbandk_out=./egklib/src/commonMain/kotlin/ --proto_path=./egklib/src/commonMain/proto \ - common.proto encrypted_ballot.proto encrypted_tally.proto \ - election_record.proto manifest.proto \ - plaintext_ballot.proto decrypted_tally.proto \ - trustees.proto - */ -val compileProtobuf = - tasks.register("compileProtobuf") { - doLast { - print("* Compiling protobuf *\n") - /* project.exec { - * commandLine = "rm -f ./src/commonMain/kotlin/electionguard/protogen".split(" - * ") - * } */ - // TODO lame - val commandLineStr = - "protoc --pbandk_out=./egklib/src/commonMain/kotlin/ --proto_path=./egklib/src/commonMain/proto " + - "common.proto encrypted_ballot.proto encrypted_tally.proto " + - "election_record.proto manifest.proto " + - "plaintext_ballot.proto decrypted_tally.proto " + - "trustees.proto" - project.exec { commandLine = commandLineStr.split(" ") } - } - } - tasks.withType { testLogging { showStandardStreams = true } } // LOOK some kind of javascript security thing, but may be causing coupled projects diff --git a/egklib/src/jvmMain/kotlin/electionguard/cli/RunVerifier.kt b/egklib/src/jvmMain/kotlin/electionguard/cli/RunVerifier.kt index e8fabffd..fd9e8c34 100644 --- a/egklib/src/jvmMain/kotlin/electionguard/cli/RunVerifier.kt +++ b/egklib/src/jvmMain/kotlin/electionguard/cli/RunVerifier.kt @@ -4,6 +4,7 @@ import electionguard.core.GroupContext import electionguard.util.Stats import electionguard.core.getSystemTimeInMillis import electionguard.core.productionGroup +import electionguard.publish.Consumer import electionguard.util.sigfig import electionguard.publish.readElectionRecord import electionguard.verifier.Verifier @@ -59,6 +60,23 @@ class RunVerifier { return allOk } + // RunVerifier.runVerifier(group, consumerIn, 11, true) + fun runVerifier(group: GroupContext, consumer: Consumer, nthreads: Int, showTime: Boolean = false): Boolean { + val starting = getSystemTimeInMillis() + + val electionRecord = readElectionRecord(consumer) + val verifier = Verifier(electionRecord, nthreads) + val stats = Stats() + val allOk = verifier.verify(stats, showTime) + if (showTime) { + stats.show() + } + + val tookAll = (getSystemTimeInMillis() - starting) + println("RunVerifier took $tookAll msecs OK = ${allOk}") + return allOk + } + fun verifyEncryptedBallots(group: GroupContext, inputDir: String, nthreads: Int) { val starting = getSystemTimeInMillis() diff --git a/egkliball/build.gradle.kts b/egkliball/build.gradle.kts index eb860c8d..02e04af5 100644 --- a/egkliball/build.gradle.kts +++ b/egkliball/build.gradle.kts @@ -9,7 +9,7 @@ repositories { } dependencies { - implementation(files("../egklib/build/libs/egklib-jvm-2.0.0-SNAPSHOT.jar")) // add the library to the fatJar + implementation(files("../egklib/build/libs/egklib-jvm-2.0.3-SNAPSHOT.jar")) // add the library to the fatJar implementation(libs.bundles.eglib) implementation(libs.logback.classic) }