This folder contains a Java Card project that contains the implementation of
ElGamal-based threshold encryption support. The source code is divided between two
packages:

[elgamal]

Java Card Applet class: EGApplet
Source code origin: https://github.com/ASKGLab/DHApplet
Original author: [Thotheolh] (GitHub user)

Based on a refactored version of the project [DHApplet], this project implements 
ElGamal decryption based on the Java Card RSA functionality. The code in this package
corresponds to the first prototype. It does not contain threshold functionality nor 
is called by the other package.

[cat.urv.crises.smartcard.elgamal]

Java Card Applet class: ElGamalThresholdApplet
Source code origin: https://github.com/CRISES-URV/eVerification-2/source/thresholdLib
Original author: CRISES group

The original CRISES code supports the threshold cryptosystem described within the
same repository. Although some changes were made due to compatibility issues with the
existent Java Card, most of the changes occurred in the control application, rather
than the Java Card applet. The code fragments related to commitments were commented
and correspond to the original protocol.

Particularly remarkable is the class [MutableBigInteger], which is intended to mimic
(as long as it's possible) the behavior of the homonym Java class.

************************************************************
INSTALLATION
************************************************************

Java Card simulators are particularly limited in critical aspects. For instance, they
do not support random number generation and will produce cryptic errors. The best
alternative to test this applet is to install it within the card. The default process
is slow and requires calls for different applications. To reduce its effect, the
file [build.xml] contains an ANT task that compiles the source code, packs the compiled
result in a CAP file and installs it in the Java Card.

The ant file works when being executed from Eclipse on a computer running Windows 10.
Other platforms may require modifications. Technologies to keep in mind:
 - GlobalPlatform: enables basic interaction with the card. Installation, list 
   installed applets, send raw APDUs, etc.
 - ANT: classical software building automation tool based on XML.
 - ANT-JavaCard: Ant add-on that enables Java Card specific tasks.
 
The most arbitrary values of the script are the AIDs: arbitrary values that identify 
packages and applets. The specific numbers (expressed in hexadecimal) are meaningless, 
but it is required that the AID of the package is used as a prefix for the AID of the
applet.

The AID values chosen are:
Threshold.cap: 22 34 56 54 32
 cat.urv.crises.smartcard.elgamal.ElGamalThresholdApplet: 22 34 56 54 32 28 02
 
These values need to be used by the client application, since there might be several
applets within a card and the AIDs are the unique identifiers.

Once installed, the lifecycle of the applet is administered entirely by the client
application.

************************************************************
TO DO
************************************************************

A list of suggested functionality improvements is available at the client application's
README file.