Skip to content

Releases: OpenCryptoProject/JCMathLib

JCMathLib 2.0

19 Jul 11:41
0e53ada
Compare
Choose a tag to compare

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 and smaller, times_add_shift and add_carry, times_minus and subtract).
    • mod* operations always output BigNat with the same size as mod.
    • sq and mult operations may change the size of a BigNat.
    • add and subtract keep the size of an input BigNat.
    • Unified calling convention for mult and modMult 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 native int type for cards that support it (branch ints).
    • A new approach to mult() and modMult() requiring one less RSA invocation.
    • ALG_EC_PACE_GM for efficient point addition (optionally combined with scalar multiplication via multAdd() method).
    • ALG_EC_SVDP_DH_PLAIN_XY for a more efficient scalar multiplication.
  • 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 with ResourceManager.
  • Change the initialization of ECCurve to pass in a ResourceManager instance and remove the bCopyArgs argument.
  • Rename Bignat to BigNat.
  • Pass ResourceManager instead of Bignat_Helper to BigNat initialization.
  • Remove ECPoint_Helper from ECPoint initialization (ResourceManager is obtained from the ECCurve parameter).
  • Reflect new naming conventions for all method calls (now in camelCase). For example, instead of mod_mult(), use modMult().
  • Rename some method calls. For example, use resize() instead of deepResize() (new resize is much cheaper due to right-aligned representation).
  • Change mult() and modMult() calls to use the new unified interface. Instead of result.mult(x, y), first copy the value of x into result and call result.mult(y). Instead of x.mult(x, y), simply use x.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 of BigNat 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, use copyToByteArray() or prependZeros() or appendZeros() when reading, and fromByteArray() 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

26 Jul 09:12
615978a
Compare
Choose a tag to compare

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

26 Oct 15:10
Compare
Choose a tag to compare
  • 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

26 Jul 22:49
Compare
Choose a tag to compare

Initial release of library with Bignat and ECPoint support for Java Card platform as presented on BlackHat 2017.