From 5f2ac2483ca7754bf4732ff9ae602bc7e5f80ae3 Mon Sep 17 00:00:00 2001
From: Steve Maier <82616727+SteveMaier-IRT@users.noreply.github.com>
Date: Thu, 14 Sep 2023 15:22:51 -0400
Subject: [PATCH] Fix/tally spoiled (#466)
* Removed check for spoiled ballot to be in tally
Added scrolling on the challeneged ballot display
Updated version number to allow for WASM
* Converting spoiled to challenged on import
---
.../Decryption/CiphertextDecryptionTally.cs | 5 -
.../ElectionGuard.UI/ElectionGuard.UI.csproj | 524 +++++++++---------
.../Platforms/Windows/Package.appxmanifest | 2 +-
.../ViewModels/BallotUploadViewModel.cs | 7 +-
.../Views/ChallengedPopup.xaml | 18 +-
5 files changed, 274 insertions(+), 282 deletions(-)
diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs
index a96d0a67..90b70610 100644
--- a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs
+++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs
@@ -114,11 +114,6 @@ public void AddBallot(CiphertextBallot ballot)
// add a spoiled ballot which will not be decrypted
public void AddSpoiledBallot(CiphertextBallot ballot)
{
- if (_tally.HasBallot(ballot.ObjectId))
- {
- throw new ArgumentException($"Tally {TallyId} already contains ballot {ballot.ObjectId}");
- }
-
if (!ballot.IsSpoiled)
{
throw new ArgumentException($"Tally {TallyId} Cannot add unspoiled ballot {ballot.ObjectId} {ballot.State.ToString()}");
diff --git a/src/electionguard-ui/ElectionGuard.UI/ElectionGuard.UI.csproj b/src/electionguard-ui/ElectionGuard.UI/ElectionGuard.UI.csproj
index 66324eb5..2d32b829 100644
--- a/src/electionguard-ui/ElectionGuard.UI/ElectionGuard.UI.csproj
+++ b/src/electionguard-ui/ElectionGuard.UI/ElectionGuard.UI.csproj
@@ -1,264 +1,264 @@
-
-
-
- net7.0-maccatalyst
- net7.0-windows10.0.19041.0
- Exe
- true
- true
- true
- enable
-
- ElectionGuard.UI
- en-us
- ElectionGuard Election Manager
-
-
- com.microsoft.electionguard.ui
- c0679a79-bc22-46ad-9c49-93de983e3fa2
-
-
- 1.91.14
- 14
-
- 15.3
- 10.0.19041.0
- 10.0.19041.0
- enable
- true
- PackageReference
-
- arm64;x64
- AnyCPU
- efb177b9-29c3-4df1-adaa-be7e64bdc8ce
-
-
-
- $(DefineConstants);APPCENTER_SECRET_MACOS=$(APPCENTER_SECRET_MACOS);APPCENTER_SECRET_UWP=$(APPCENTER_SECRET_UWP)
-
-
-
-
- false
- maccatalyst-arm64;maccatalyst-x64
-
-
-
- true
- maccatalyst-arm64;maccatalyst-x64
-
-
-
- false
- maccatalyst-x64
-
-
-
- false
- maccatalyst-x64
-
-
-
- false
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
- true
- false
-
- true
-
-
- false
- false
-
-
-
-
- Default
-
-
-
- enable
-
-
-
-
-
-
-
-
-
-
- true
- false
-
- true
-
-
- false
- false
-
-
-
-
- Default
-
- anycpu
-
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ContestControl.xaml
-
-
- True
- True
- AppResources.resx
-
+
+
+
+ net7.0-maccatalyst
+ net7.0-windows10.0.19041.0
+ Exe
+ true
+ true
+ true
+ enable
+
+ ElectionGuard.UI
+ en-us
+ ElectionGuard Election Manager
+
+
+ com.microsoft.electionguard.ui
+ c0679a79-bc22-46ad-9c49-93de983e3fa2
+
+
+ 1.91.15
+ 14
+
+ 15.3
+ 10.0.19041.0
+ 10.0.19041.0
+ enable
+ true
+ PackageReference
+
+ arm64;x64
+ AnyCPU
+ efb177b9-29c3-4df1-adaa-be7e64bdc8ce
+
+
+
+ $(DefineConstants);APPCENTER_SECRET_MACOS=$(APPCENTER_SECRET_MACOS);APPCENTER_SECRET_UWP=$(APPCENTER_SECRET_UWP)
+
+
+
+
+ false
+ maccatalyst-arm64;maccatalyst-x64
+
+
+
+ true
+ maccatalyst-arm64;maccatalyst-x64
+
+
+
+ false
+ maccatalyst-x64
+
+
+
+ false
+ maccatalyst-x64
+
+
+
+ false
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ true
+ false
+
+ true
+
+
+ false
+ false
+
+
+
+
+ Default
+
+
+
+ enable
+
+
+
+
+
+
+
+
+
+
+ true
+ false
+
+ true
+
+
+ false
+ false
+
+
+
+
+ Default
+
+ anycpu
+
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ContestControl.xaml
+
+
+ True
+ True
+ AppResources.resx
+
NetworkPopup.xaml
-
-
- CreateElectionAdminPage.xaml
-
-
- ChallengedPopup.xaml
-
-
- TallyProcessPage.xaml
-
-
- ViewKeyCeremonyPage.xaml
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- AppResources.Designer.cs
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
-
-
- MSBuild:Compile
-
-
- MSBuild:Compile
-
-
- MSBuild:Compile
-
-
-
- ..\..\..\data
- ..\..\..\build\libs
- ..\..\..\scripts
-
-
- $(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
-
-
- $(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
-
-
-
+
+
+ CreateElectionAdminPage.xaml
+
+
+ ChallengedPopup.xaml
+
+
+ TallyProcessPage.xaml
+
+
+ ViewKeyCeremonyPage.xaml
+
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ AppResources.Designer.cs
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+
+ ..\..\..\data
+ ..\..\..\build\libs
+ ..\..\..\scripts
+
+
+ $(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
+
+
+ $(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+
+
diff --git a/src/electionguard-ui/ElectionGuard.UI/Platforms/Windows/Package.appxmanifest b/src/electionguard-ui/ElectionGuard.UI/Platforms/Windows/Package.appxmanifest
index d38be749..e41aeb5a 100644
--- a/src/electionguard-ui/ElectionGuard.UI/Platforms/Windows/Package.appxmanifest
+++ b/src/electionguard-ui/ElectionGuard.UI/Platforms/Windows/Package.appxmanifest
@@ -4,7 +4,7 @@
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap">
-
+
diff --git a/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs b/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs
index ebf17aed..2278da78 100644
--- a/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs
+++ b/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs
@@ -97,6 +97,11 @@ private async Task Cancel()
return await stream.ReadToEndAsync(cancellationToken);
}
+ private static string RemoveSpoiled(string ballotData)
+ {
+ return ballotData.Replace("\"state\":3,", "\"state\":2,");
+ }
+
[RelayCommand(CanExecute = nameof(CanUpload))]
private async Task Upload()
{
@@ -164,7 +169,7 @@ await Parallel.ForEachAsync(ballots, async (currentBallot, cancellationToken) =>
{
var filename = Path.GetFileName(currentBallot);
var ballotData = await ReadFileAsync(currentBallot, cancellationToken);
- using var ballot = new CiphertextBallot(ballotData);
+ using var ballot = new CiphertextBallot(RemoveSpoiled(ballotData));
if (ballot.Timestamp < startDate)
{
diff --git a/src/electionguard-ui/ElectionGuard.UI/Views/ChallengedPopup.xaml b/src/electionguard-ui/ElectionGuard.UI/Views/ChallengedPopup.xaml
index 31e28284..16ba18ac 100644
--- a/src/electionguard-ui/ElectionGuard.UI/Views/ChallengedPopup.xaml
+++ b/src/electionguard-ui/ElectionGuard.UI/Views/ChallengedPopup.xaml
@@ -43,26 +43,18 @@
Text="{Binding SearchText}"
TextColor="{StaticResource Gray950}" />
-
-
-
-
-
+ SelectionMode="Single"
+ VerticalScrollBarVisibility="Always">