GithubHelp home page GithubHelp logo

danwallach / electionguard-typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xin128/electionguard-comp413

7.0 7.0 0.0 34.36 MB

TypeScript implementation of ElectionGuard (subset for ballot encryption)

License: MIT License

JavaScript 0.84% TypeScript 99.16%
cryptography electionguard

electionguard-typescript's People

Contributors

alexiland avatar danwallach avatar dependabot[bot] avatar djunge-w avatar shreyasminocha avatar xin128 avatar yanyuzhong avatar zihe-zhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

electionguard-typescript's Issues

PowRadix acceleration

Current on powRadixSpeedup branch. Possibly dependent on #8. If we had more vicious testing, we'd be more confident that the speedup was correct / bug-free.

Readme updates

The readme is currently a little verbose. Update to include usage instructions.

Handle overvoting?

Right now, if we're asked to encrypt an overvoted ballot, the resulting proofs will not correctly verify. Resolving this issue requires two things:

  • interpreting an overvoted contest down to a blank input
  • placing something meaningful into the extended data

The extended data is meant to hold write-in data, original (uninterpreted) votes, and other such things, all encrypted with hashed ElGamal but the spec doesn't provide detailed guidance on this.

add property-based tests

Using one of the TypeScript property-based testing libraries build tests equivalent to the tests that we have in other ElectionGuard implementations.

Support the EG 1.0 spec

We're currently supporting EG 0.95. We need to:

  • enumerate the changes from EG 0.95 to EG 1.0
  • support write-ins (hashed ElGamal stream cipher?)

Support tally testing

EnhancedVoting team provides manifests and contexts for encryption, and typescript team generates ballots with non-random patterns.
Then typescript team returns encrypted ballots and the expected tally result to EnhancedVoting team to complete the tests.

PlaintextBallots with contests that aren't present for the given ballot style?

Crazy thought: what are we supposed to do if we've been given a malformed PlaintextBallot? Or, with the asynchronous API, what are we supposed to do if we're given a PlaintextContest that isn't present in the claimed ballot style?

In the synchronous case, most likely, we should throw an error.

In the asynchronous case, where we have a function that returns void, I suppose we could do the same checks and throw an error eagerly, even though the encryption is delayed.

Whatever the case, it should be the case that whenever we produce a CiphertextContest, it has exactly all the contests specified in the ballot style. No more, no less.

Docstring review

Not anything specific, but we need to work through every single docstring and make sure they're consistent with the code behavior. In particular:

  • In any possible case where an error might be thrown, this needs to be described in detail.
  • Any time we're naming another class, method, or field, we should use the @link notation so we get working hyperlinks.
  • For the most part, the API we're providing deals with serialization and deserialization, but we might have a separate SERIALIZATION.md file that explains how we're using io-ts, how it works, and how to deal with its error handling.
  • When all the docstrings are converted to HTML, I think we get README.md as well, but we need to make sure other Markdown files we might write also get converted.

Suppress console logging

Default: code should be quiet on the console, but we still want to be able to enable verbose logging.

Serialization robustness & correctness

  • Deserialization --> what if a required field is missing? (@Transform annotations, e.g., in chaum-pedersen code)
  • Compatibility with the latest schema from Microsoft

Tests for build outputs

Would be nice to have automated tests that check that stuff is properly exported in each of our builds.

External interface

Write a top-level utility function that does everything EnhancedVoting
needs (they initialize us with JS objects that correspond to the manifest,
etc.). Where everything else is functional, this one would hide all the
state inside and would have an API similar to the encrypt-async code, where
you feed it individual bits of data and you eventually ask for the output.

rollup / packaging issues

Right now, when you run npm run test, it proceeds to start running the packaging process. Dunno why that's happening, but something's not right.

There are also warnings about circular dependencies and about this being rewritten to undefined, so I'm assuming that we've still got some effort to get this all buttoned up.

Improved deno support

We currently output a mod.js for deno and an index.d.ts for node. index.d.ts doesn't work with deno because (a) it doesn't have the types for our dependencies bundled, and (b) index.d.ts isn't referenced in mod.js, so deno wouldn't know where to find the types anyway.

Once we figure out the bundling of types for deno, we should also:

  • add a section about deno to the readme
  • add a deno example
  • potentially publish to deno.land/x

Also, mod.js currently includes, bundled-in, all our dependencies. Ideally it would import them.

Support Signing (TODO after first NPM package delivery)

A digital signature for detecting tempering ballots after spoiled or casted.
The signature needs to include the hash and the spoiled/casted state.
This is a required feature for a remote scenario, where it is needed to protect the spoiled/casted state.

Exports

Reduce the set of exports in index.ts to a minimal subset.

Circular dependency warnings while building for browsers

src/electionguard/index.ts โ†’ dist/electionguard.js, dist/electionguard.umd.js...
(!) Circular dependencies
node_modules/readable-stream/lib/_stream_readable.js -> node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/readable-stream/lib/_stream_readable.js
node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/readable-stream/lib/_stream_writable.js -> node_modules/readable-stream/lib/_stream_duplex.js
polyfill-node._stream_duplex.js -> polyfill-node._stream_readable.js -> polyfill-node._stream_duplex.js
polyfill-node._stream_duplex.js -> polyfill-node._stream_writable.js -> polyfill-node._stream_duplex.js

See discussion in #32.

Compatibility checker

We need a function that tests whether or not the platform supports ElectionGuard-TypeScript. We need to (somehow) figure out all the different features we're using and test for each of them. The function should return some kind of structure with string keys (names of the relevant features) and boolean values (supported or unsupported).

If everything is good, then it just returns true or whatever, so it's at least easy to check that there isn't a problem.

Related: understanding what "polyfill" libraries are available and whether they're good enough. I'm pretty sure we're going to require native bigint, but other stuff? We can get away with a lot before performance becomes an issue.

generated_test_inputs_ts

Fill directory with output from the Python code, commit changes so this repo can test itself without needing the Python code.

Also, add line(s) to package.json to automatically run the serialization test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.