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_lesser
andsmaller
,times_add_shift
andadd_carry
,times_minus
andsubtract
). mod*
operations always outputBigNat
with the same size asmod
.sq
andmult
operations may change the size of aBigNat
.add
andsubtract
keep the size of an inputBigNat
.- Unified calling convention for
mult
andmodMult
with the rest of the library.
- New features and performance improvements:
- Implementation of SEC1 point encoding and decoding (
encode()
,decode()
). - Reimplementation of
BigNat
to a right-aligned internal representation for faster resizing. - An alternative implementation of
BigNat
utilizing nativeint
type for cards that support it (branchints
). - A new approach to
mult()
andmodMult()
requiring one less RSA invocation. ALG_EC_PACE_GM
for efficient point addition (optionally combined with scalar multiplication viamultAdd()
method).ALG_EC_SVDP_DH_PLAIN_XY
for 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
ECConfig
withResourceManager
. - Change the initialization of
ECCurve
to pass in aResourceManager
instance and remove thebCopyArgs
argument. - Rename
Bignat
toBigNat
. - Pass
ResourceManager
instead ofBignat_Helper
toBigNat
initialization. - Remove
ECPoint_Helper
fromECPoint
initialization (ResourceManager
is obtained from theECCurve
parameter). - 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 ofx
intoresult
and 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 ofBigNat
internal 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.