Releases: OpenCryptoProject/JCMathLib
Releases · OpenCryptoProject/JCMathLib
JCMathLib 2.0
This release focuses on maintainability, compatibility with more smartcards, and enhanced performance using algorithms introduced in JavaCard API 3.0.5.
Notable changes
- Integration within JavaCard gradle template, allowing for easy usage with modern IDEs and better unit testing.
- Simplified code, unified API, and introduced new conventions:
- The API now conforms to Java naming conventions.
- Eliminated code duplication (
shift_lesserandsmaller,times_add_shiftandadd_carry,times_minusandsubtract). mod*operations always outputBigNatwith the same size asmod.sqandmultoperations may change the size of aBigNat.addandsubtractkeep the size of an inputBigNat.- Unified calling convention for
multandmodMultwith the rest of the library.
- New features and performance improvements:
- Implementation of SEC1 point encoding and decoding (
encode(),decode()). - Reimplementation of
BigNatto a right-aligned internal representation for faster resizing. - An alternative implementation of
BigNatutilizing nativeinttype for cards that support it (branchints). - A new approach to
mult()andmodMult()requiring one less RSA invocation. ALG_EC_PACE_GMfor efficient point addition (optionally combined with scalar multiplication viamultAdd()method).ALG_EC_SVDP_DH_PLAIN_XYfor a more efficient scalar multiplication.
- Implementation of SEC1 point encoding and decoding (
- Compatibility with new smartcard models:
- NXP JCOP3 P60
- NXP JCOP4 P71
- Infineon SECORA SPA1
- Updated simulator (supporting
ALG_EC_PACE_GM). - New packaging tool:
- A Python script for packaging of JCMathLib into a single file for easy integration with your code.
- Allows for filtering of included source code files to achieve a lesser memory footprint.
Migration tips
Package the new version of JCMathLib using the packaging tool. Select the curve definitions that you need using -c switch, and input the name of your package using switch -p. Include the output jcmathlib.java file in your applet source code.
python package.py -p 'your_package' -c 'your_curve' -o jcmathlib.java
Make the following changes in your code:
- Replace
ECConfigwithResourceManager. - Change the initialization of
ECCurveto pass in aResourceManagerinstance and remove thebCopyArgsargument. - Rename
BignattoBigNat. - Pass
ResourceManagerinstead ofBignat_HelpertoBigNatinitialization. - Remove
ECPoint_HelperfromECPointinitialization (ResourceManageris obtained from theECCurveparameter). - Reflect new naming conventions for all method calls (now in camelCase). For example, instead of
mod_mult(), usemodMult(). - Rename some method calls. For example, use
resize()instead ofdeepResize()(new resize is much cheaper due to right-aligned representation). - Change
mult()andmodMult()calls to use the new unified interface. Instead ofresult.mult(x, y), first copy the value ofxintoresultand callresult.mult(y). Instead ofx.mult(x, y), simply usex.mult(y). - Change arguments to
fromByteArray()calls according to the new interface. Some were removed, and others were reordered to match other JavaCard functions. - Method
as_byte_array()was removed to allow for better encapsulation ofBigNatinternal representation (and allow for simple swap for int-based implementation). It is no longer possible to provide direct access to the internal array. Instead, usecopyToByteArray()orprependZeros()orappendZeros()when reading, andfromByteArray()when writing. - New resizing conventions after performing certain operations should make the API easier to use, and you may be able to remove some resizing calls in your code.
Full Changelog: v1.1.0...v2.0
JCMathLib 1.1.0
Added following new functions and improvements:
- gcd() method
- is_coprime() method
- restore point from Bignat and array
- is_y_even() method
- secp256k1 curve domian parameters
- version tag into compressed jcmathlib.java file
- Integer class into compressed jcmathlib.java file
- fix addition of a same point
Usage:
- Cherrypick the functionality you need from sources or take bundled jcmathlib.java file
- Remove the functionality you don't need to decrease your memory consumption
- Include
import your_package.jcmathlib.*into your project
JCMathLib 1.0.1
- Added support for ECKey methods in ECPoint class
- Created compact single file version of library (jcmathlib.java) - copy single file to your projects and 'import your_package.jcmathlib.*;'
JCMathLib v1.0
Initial release of library with Bignat and ECPoint support for Java Card platform as presented on BlackHat 2017.