Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish Range proof coding #497

Merged
merged 20 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ifeq ($(OPERATING_SYSTEM),Darwin)
brew install cmake
brew install cppcheck
brew install clang-format
brew install include-what-you-use
# brew install include-what-you-use
brew install llvm
brew install ninja
test -f /usr/local/bin/clang-tidy || sudo ln -sf "$(shell brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
Expand Down
6 changes: 3 additions & 3 deletions apps/electionguard-cli/Generate/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ private async Task ExecuteInternal(GenerateOptions options)

var plaintextPath = Path.Combine(options.WorkingDir, "plaintext");
var encryptedPath = Path.Combine(options.WorkingDir, "encrypted_ballots");

var index = 0;
foreach (var ballot in plaintextBallots)
{
var ciphertext = encryptionMediator.Encrypt(ballot, false);
var ciphertext = encryptionMediator.Encrypt(ballot, options.BallotValidate);
if (Random.Shared.NextSingle() > options.SpoiledPercent / 100.0)
{
ciphertext.Cast();
Expand Down Expand Up @@ -71,7 +71,7 @@ private async Task ExecuteInternal(GenerateOptions options)
{
File.WriteAllText(Path.Combine(plaintextPath, $"{ballotCode}.json"), data);
}
Console.WriteLine($"Generated Ballot {ballotCode}.json");
Console.WriteLine($"Generated Ballot {index++} {ballotCode}.json");
ciphertext.Dispose();
}
var tallyJson = JsonConvert.SerializeObject(tally);
Expand Down
3 changes: 3 additions & 0 deletions apps/electionguard-cli/Generate/GenerateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ internal class GenerateOptions
[Option('c', "count", Required = false, HelpText = "Number of ballots to generate and encrypt. Defaults to 100.")]
public int BallotCount { get; set; } = 100;

[Option('v', "validate", Required = false, HelpText = "Validate the ballots when generating. Defaults to false.")]
public bool BallotValidate { get; set; } = false;

public void Validate()
{
ValidateDirectories();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ElectionGuard.Ballot;
using System.Text;
using ElectionGuard.Ballot;
using ElectionGuard.ElectionSetup.Extensions;

namespace ElectionGuard.Decryption.Tally;
Expand Down Expand Up @@ -82,7 +83,23 @@ public void Accumulate(CiphertextBallotContest contest)

if (!Selections.Keys.All(contestSelectionIds.Contains))
{
throw new ArgumentException("Selections do not match contest");
StringBuilder sb = new StringBuilder();
sb.AppendLine("selections keys");
foreach (var item in Selections.Keys)
{
sb.AppendLine(item);
}
sb.AppendLine("contest.Selections");
foreach (var item in contest.Selections)
{
sb.AppendLine(item.ObjectId + " " + item.IsPlaceholder);
}
sb.AppendLine("contestSelectionIds");
foreach (var item in contestSelectionIds)
{
sb.AppendLine(item);
}
throw new ArgumentException("Selections do not match contest " + sb.ToString());
}
foreach (var selection in ballotSelections)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public CiphertextTallySelection(ICiphertextSelection other)
public ElGamalCiphertext Accumulate(ICiphertextSelection selection)
{
return selection.ObjectId != ObjectId || selection.DescriptionHash != DescriptionHash
? throw new ArgumentException("Selection does not match")
? throw new ArgumentException($"Selection does not match tally: {ObjectId} {DescriptionHash} selection: {selection.ObjectId} {selection.DescriptionHash}")
: Accumulate(selection.Ciphertext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,34 +405,40 @@ CiphertextBallotSelection selection
{
var results = new List<VerificationResult>();

// Verification 4.1 - 𝑎0 = 𝑔^𝑣0 mod 𝑝 ⋅ 𝛼^𝑐0 mod 𝑝
using var gv0 = BigMath.PowModP(constants.G, selection.Proof.ZeroResponse);
using var ac0 = BigMath.PowModP(selection.Ciphertext.Pad, selection.Proof.ZeroChallenge);
using var gv0ac0 = BigMath.MultModP(gv0, ac0);
var consistent_gv0 = selection.Proof.ZeroPad.Equals(gv0ac0);
results.Add(new VerificationResult(consistent_gv0, $" - Verification 4.1: 𝑎0 = 𝑔^𝑣0 mod 𝑝 ⋅ 𝛼^𝑐0 mod 𝑝"));

// Verification 4.2 - 𝑎1 = 𝑔^𝑣1 mod 𝑝 ⋅ 𝛼^𝑐1 mod 𝑝
using var gv1 = BigMath.PowModP(constants.G, selection.Proof.OneResponse);
using var ac1 = BigMath.PowModP(selection.Ciphertext.Pad, selection.Proof.OneChallenge);
using var gv1ac1 = BigMath.MultModP(gv1, ac1);
var consistent_gv1 = selection.Proof.OnePad.Equals(gv1ac1);
results.Add(new VerificationResult(consistent_gv1, $" - Verification 4.2: 𝑎1 = 𝑔^𝑣1 mod 𝑝 ⋅ 𝛼^𝑐1 mod 𝑝"));

// Verification 4.3 - 𝑏0 = 𝐾^𝑣0 mod 𝑝 ⋅ 𝛽^𝑐0 mod 𝑝
using var kv0 = BigMath.PowModP(context.ElGamalPublicKey, selection.Proof.ZeroResponse);
using var bc0 = BigMath.PowModP(selection.Ciphertext.Data, selection.Proof.ZeroChallenge);
using var kv0bc0 = BigMath.MultModP(kv0, bc0);
var consistent_kv0 = selection.Proof.ZeroData.Equals(kv0bc0);
results.Add(new VerificationResult(consistent_kv0, $" - Verification 4.3: 𝑏0 = 𝐾^𝑣0 mod 𝑝 ⋅ 𝛽^𝑐0 mod 𝑝"));

// Verification 4.4 - 𝑏1 = 𝐾^w1 mod 𝑝 ⋅ 𝛽^𝑐1 mod 𝑝
using var w1 = BigMath.SubModQ(selection.Proof.OneResponse, selection.Proof.OneChallenge);
using var kw1 = BigMath.PowModP(context.ElGamalPublicKey, w1);
using var bc1 = BigMath.PowModP(selection.Ciphertext.Data, selection.Proof.OneChallenge);
using var kw1bc1 = BigMath.MultModP(kw1, bc1);
var consistent_kw1 = selection.Proof.OneData.Equals(kw1bc1);
results.Add(new VerificationResult(consistent_kw1, $" - Verification 4.4: 𝑏1 = 𝐾^w1 mod 𝑝 ⋅ 𝛽^𝑐1 mod 𝑝"));
var temp_internal_check_is_valid = selection.Proof.IsValid(
selection.Ciphertext,
context.ElGamalPublicKey,
context.CryptoExtendedBaseHash, Hash.Prefix_SelectionProof);
results.Add(new VerificationResult(temp_internal_check_is_valid.IsValid, $" - Verification 4.1, 4.2, 4.3, 4.4, 4.5, 4.A, 4.B, 4.C: temp internal check is valid"));

// // Verification 4.1 - 𝑎0 = 𝑔^𝑣0 mod 𝑝 ⋅ 𝛼^𝑐0 mod 𝑝
// using var gv0 = BigMath.PowModP(constants.G, selection.Proof.ZeroResponse);
// using var ac0 = BigMath.PowModP(selection.Ciphertext.Pad, selection.Proof.ZeroChallenge);
// using var gv0ac0 = BigMath.MultModP(gv0, ac0);
// var consistent_gv0 = selection.Proof.ZeroPad.Equals(gv0ac0);
// results.Add(new VerificationResult(consistent_gv0, $" - Verification 4.1: 𝑎0 = 𝑔^𝑣0 mod 𝑝 ⋅ 𝛼^𝑐0 mod 𝑝"));

// // Verification 4.2 - 𝑎1 = 𝑔^𝑣1 mod 𝑝 ⋅ 𝛼^𝑐1 mod 𝑝
// using var gv1 = BigMath.PowModP(constants.G, selection.Proof.OneResponse);
// using var ac1 = BigMath.PowModP(selection.Ciphertext.Pad, selection.Proof.OneChallenge);
// using var gv1ac1 = BigMath.MultModP(gv1, ac1);
// var consistent_gv1 = selection.Proof.OnePad.Equals(gv1ac1);
// results.Add(new VerificationResult(consistent_gv1, $" - Verification 4.2: 𝑎1 = 𝑔^𝑣1 mod 𝑝 ⋅ 𝛼^𝑐1 mod 𝑝"));

// // Verification 4.3 - 𝑏0 = 𝐾^𝑣0 mod 𝑝 ⋅ 𝛽^𝑐0 mod 𝑝
// using var kv0 = BigMath.PowModP(context.ElGamalPublicKey, selection.Proof.ZeroResponse);
// using var bc0 = BigMath.PowModP(selection.Ciphertext.Data, selection.Proof.ZeroChallenge);
// using var kv0bc0 = BigMath.MultModP(kv0, bc0);
// var consistent_kv0 = selection.Proof.ZeroData.Equals(kv0bc0);
// results.Add(new VerificationResult(consistent_kv0, $" - Verification 4.3: 𝑏0 = 𝐾^𝑣0 mod 𝑝 ⋅ 𝛽^𝑐0 mod 𝑝"));

// // Verification 4.4 - 𝑏1 = 𝐾^w1 mod 𝑝 ⋅ 𝛽^𝑐1 mod 𝑝
// using var w1 = BigMath.SubModQ(selection.Proof.OneResponse, selection.Proof.OneChallenge);
// using var kw1 = BigMath.PowModP(context.ElGamalPublicKey, w1);
// using var bc1 = BigMath.PowModP(selection.Ciphertext.Data, selection.Proof.OneChallenge);
// using var kw1bc1 = BigMath.MultModP(kw1, bc1);
// var consistent_kw1 = selection.Proof.OneData.Equals(kw1bc1);
// results.Add(new VerificationResult(consistent_kw1, $" - Verification 4.4: 𝑏1 = 𝐾^w1 mod 𝑝 ⋅ 𝛽^𝑐1 mod 𝑝"));

// Verification 4.5 - c = H(04,Q,K,α,β,a0,b0,a1,b1)
// using var recomputedHash = Hash.HashElems(
Expand All @@ -454,25 +460,25 @@ CiphertextBallotSelection selection


// Verification 4.A
var inBoundsAlpha = selection.Ciphertext.Pad.IsInBounds();
results.Add(new VerificationResult(inBoundsAlpha, $" - Verification 4.A: Alpha is in bounds"));
var inboundsBeta = selection.Ciphertext.Data.IsInBounds();
results.Add(new VerificationResult(inboundsBeta, $" - Verification 4.A: Beta is in bounds"));

// Verification 4.B
var inBoundsC0 = selection.Proof.ZeroChallenge.IsInBounds();
results.Add(new VerificationResult(inBoundsC0, $" - Verification 4.B: C0 is in bounds"));
var inBoundsC1 = selection.Proof.OneChallenge.IsInBounds();
results.Add(new VerificationResult(inBoundsC1, $" - Verification 4.B: C1 is in bounds"));
var inBoundsV0 = selection.Proof.ZeroResponse.IsInBounds();
results.Add(new VerificationResult(inBoundsV0, $" - Verification 4.B: V0 is in bounds"));
var inBoundsV1 = selection.Proof.OneResponse.IsInBounds();
results.Add(new VerificationResult(inBoundsV1, $" - Verification 4.B: V1 is in bounds"));

// Verification 4.C
using var c0c1 = BigMath.AddModQ(selection.Proof.ZeroChallenge, selection.Proof.OneChallenge);
var consistent_c = c0c1.Equals(selection.Proof.Challenge);
results.Add(new VerificationResult(consistent_c, $" - Verification 4.C: C = (c0 + c1) mod q"));
// var inBoundsAlpha = selection.Ciphertext.Pad.IsInBounds();
// results.Add(new VerificationResult(inBoundsAlpha, $" - Verification 4.A: Alpha is in bounds"));
// var inboundsBeta = selection.Ciphertext.Data.IsInBounds();
// results.Add(new VerificationResult(inboundsBeta, $" - Verification 4.A: Beta is in bounds"));

// // Verification 4.B
// var inBoundsC0 = selection.Proof.ZeroChallenge.IsInBounds();
// results.Add(new VerificationResult(inBoundsC0, $" - Verification 4.B: C0 is in bounds"));
// var inBoundsC1 = selection.Proof.OneChallenge.IsInBounds();
// results.Add(new VerificationResult(inBoundsC1, $" - Verification 4.B: C1 is in bounds"));
// var inBoundsV0 = selection.Proof.ZeroResponse.IsInBounds();
// results.Add(new VerificationResult(inBoundsV0, $" - Verification 4.B: V0 is in bounds"));
// var inBoundsV1 = selection.Proof.OneResponse.IsInBounds();
// results.Add(new VerificationResult(inBoundsV1, $" - Verification 4.B: V1 is in bounds"));

// // Verification 4.C
// using var c0c1 = BigMath.AddModQ(selection.Proof.ZeroChallenge, selection.Proof.OneChallenge);
// var consistent_c = c0c1.Equals(selection.Proof.Challenge);
// results.Add(new VerificationResult(consistent_c, $" - Verification 4.C: C = (c0 + c1) mod q"));

// note numbered Verification 4 in spec v1.5.3
// note numbered Verification 5 in spec v2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
var data = ElectionGenerator.GenerateFakeElectionData();
var mediator = new EncryptionMediator(
data.InternalManifest, data.Context, data.Device);
var precompute = new Precompute();

Check warning on line 81 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'Precompute' is obsolete

Check warning on line 81 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'Precompute' is obsolete

var ballot = BallotGenerator.GetFakeBallot(data.InternalManifest);

Expand All @@ -87,7 +87,7 @@
await Task.Delay(2000);

// encrypt a ballot using the default method (currently precompute = true)
var ciphertext = mediator.Encrypt(ballot);
var ciphertext = mediator.Encrypt(ballot, true, false);

var timestamp = ciphertext.Timestamp;
var nonce = ciphertext.Nonce;
Expand Down Expand Up @@ -404,7 +404,7 @@
var device = new EncryptionDevice(12345UL, 23456UL, 34567UL, "Location");
var mediator = new EncryptionMediator(internalManifest, context, device);

var compute = new Precompute();

Check warning on line 407 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'Precompute' is obsolete

Check warning on line 407 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'Precompute' is obsolete
compute.StartPrecomputeAsync(keypair.PublicKey);
TestHelpers.RunFor(TimeSpan.FromSeconds(precomputeTimeInS));
compute.StopPrecompute();
Expand All @@ -421,7 +421,7 @@
{
TestHelpers.PrintMemory();
var ciphertext = mediator.Encrypt(ballot);
new SubmittedBallot(ciphertext, BallotBoxState.Cast).Dispose();

Check warning on line 424 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'SubmittedBallot' is obsolete: 'This class is deprecated and will be removed in a future release. Use CiphertextBallot instead.'

Check warning on line 424 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

'SubmittedBallot' is obsolete: 'This class is deprecated and will be removed in a future release. Use CiphertextBallot instead.'

compute.StartPrecomputeAsync(keypair.PublicKey);
TestHelpers.RunFor(TimeSpan.FromSeconds(precomputeTimeInS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ int count
{
Console.WriteLine($"GetFakeBallots {count}");
var ballots = new List<PlaintextBallot>();
var batch = DateTime.Now.Ticks.ToString();
for (var i = 0; i < count; i++)
{
ballots.Add(GetFakeBallot(manifest, random, $"fake-ballot-{i}"));
ballots.Add(GetFakeBallot(manifest, random, $"fake-ballot-{i}-{batch}"));
}

return ballots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/// </summary>
public class BallotValidationResult : IValidationResult
{
public bool IsValid { get; set; }

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'

Check warning on line 13 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.IsValid'
public string Message { get; set; }

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

Check warning on line 14 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.Message'

public List<BallotValidationResult> Children { get; set; }

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

Check warning on line 16 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.Children'

List<IValidationResult> IValidationResult.Children => Children.Select(x => (IValidationResult)x).ToList();

public BallotValidationResult(

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'

Check warning on line 20 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, List<BallotValidationResult>)'
bool isValid,
List<BallotValidationResult> children = null)
{
Expand All @@ -26,7 +26,7 @@
Children = children ?? new List<BallotValidationResult>();
}

public BallotValidationResult(

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'

Check warning on line 29 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(string, List<BallotValidationResult>)'
string message,
List<BallotValidationResult> children = null)
{
Expand All @@ -35,7 +35,7 @@
Children = children ?? new List<BallotValidationResult>();
}

public BallotValidationResult(

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'

Check warning on line 38 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x64

Missing XML comment for publicly visible type or member 'BallotValidationResult.BallotValidationResult(bool, string, List<BallotValidationResult>)'
bool isValid,
string message,
List<BallotValidationResult> children = null)
Expand All @@ -45,7 +45,7 @@
Children = children ?? new List<BallotValidationResult>();
}

public override string ToString()

Check warning on line 48 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macOS

Missing XML comment for publicly visible type or member 'BallotValidationResult.ToString()'

Check warning on line 48 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-2022-msvc-latest-x86

Missing XML comment for publicly visible type or member 'BallotValidationResult.ToString()'

Check warning on line 48 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.ToString()'

Check warning on line 48 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / windows-os

Missing XML comment for publicly visible type or member 'BallotValidationResult.ToString()'

Check warning on line 48 in bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot/BallotValidationExtensions.cs

View workflow job for this annotation

GitHub Actions / macos-13-xcode-14.2

Missing XML comment for publicly visible type or member 'BallotValidationResult.ToString()'
{
if (IsValid)
{
Expand All @@ -72,18 +72,14 @@
/// </summary>
public static BallotValidationResult IsValid(
this CiphertextBallotSelection selection,
SelectionDescription description,
bool isPlaceholder = false)
SelectionDescription description)
{
return selection.ObjectId != description.ObjectId
? new BallotValidationResult(
$"Object Ids do not match for selection {selection.ObjectId} description {description.ObjectId}")
: selection.DescriptionHash != description.CryptoHash()
? new BallotValidationResult(
$"Description hashes do not match for selection {selection.ObjectId}")
: selection.IsPlaceholder != isPlaceholder
? new BallotValidationResult(
$"IsPlaceholder does not match for selection {selection.ObjectId}")
: new BallotValidationResult(true);
}

Expand Down Expand Up @@ -132,6 +128,8 @@
}
else
{
var placeholder = description.Placeholders
.FirstOrDefault(i => i.ObjectId == selectionDescription.ObjectId);
// validate the selection is valid
var result = selection.IsValid(selectionDescription);
if (!result.IsValid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class EncryptionMediator : DisposableBase
public CiphertextBallot Encrypt(
PlaintextBallot plaintext, bool verifyProofs = false)
{
// TODO: default to usePrecomputedValues: false
return Encrypt(plaintext, usePrecomputedValues: true, verifyProofs);
return Encrypt(plaintext, usePrecomputedValues: false, verifyProofs);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ public ElementModQ Nonce
/// <Summary>
/// The proof that demonstrates the selection is an encryption of 0 or 1, and was encrypted using the `nonce`
/// </Summary>
public DisjunctiveChaumPedersenProof Proof
public RangedChaumPedersenProof Proof
{
get
{
var status = External.GetProof(
Handle, out NativeInterface.DisjunctiveChaumPedersenProof.DisjunctiveChaumPedersenProofHandle value);
Handle, out var value);
status.ThrowIfError();
if (value.IsInvalid)
{
return null;
}
return new DisjunctiveChaumPedersenProof(value);
return new RangedChaumPedersenProof(value);
}
}

Expand Down Expand Up @@ -287,7 +287,7 @@ CiphertextBallotSelectionHandle handle
SetLastError = true)]
internal static extern Status GetProof(
CiphertextBallotSelectionHandle handle,
out NativeInterface.DisjunctiveChaumPedersenProof.DisjunctiveChaumPedersenProofHandle objectId
out NativeInterface.RangedChaumPedersenProof.RangedChaumPedersenProofHandle objectId
);

[DllImport(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ protected override bool Free()

var status = RangedChaumPedersenProof.Free(TypedPtr);
return status != Status.ELECTIONGUARD_STATUS_SUCCESS
? throw new ElectionGuardException($"DisjunctiveChaumPedersenProof Error Free: {status}", status)
? throw new ElectionGuardException($"RangedChaumPedersenProof Error Free: {status}", status)
: true;
}
}
Expand Down
Loading
Loading