Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

beginTransaction & commitTransaction

JavaCard Applet Development Related Questions and Answers.
z535539710
Posts: 10
Joined: Fri Jan 06, 2017 3:28 am
Points :276
Contact:

beginTransaction & commitTransaction

Post by z535539710 » Thu Mar 16, 2017 5:32 am

Hi all

I wonder when should I use beginTransaction & commitTransaction functions during javacard applet developing? Any common scenes? :?

your answer is very appreciated :!:

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: beginTransaction & commitTransaction

Post by UNKNwYSHSA » Thu Mar 16, 2017 10:22 pm

For example, you write a wallet applet.
At the end of a transaction (consumption), you write new balance and a transaction log to NVM. Code as following:

Code: Select all

JCSystem.beginTransaction();
// Write new balance;
// Write the transaction log;
// Write other data related to this transaction;
JCSystem.endTransaction()

The write operation is atomically, both the new balance and the transaction log are written, or both not written.
sense and simplicity

tay00000
Posts: 161
Joined: Tue Sep 27, 2016 10:58 am
Points :2324
Contact:

Re: beginTransaction & commitTransaction

Post by tay00000 » Fri Mar 17, 2017 8:48 am

Imagine a scenario where you decide to write very important data. One example being provisioning a bunch of cryptographic keys to the cards and then you accidentally trip over the card reader and dislodge it from the host computer. Now you have half provisioned keys and you cannot assert their integrity.

The beginTransaction and commitTransaction is to ensure that either all the data are properly committed in an atomic manner or it would simply fail. Think along the line of database commits where the data entry either properly commits or fails gracefully. It is to ensure that in the event something happens, the data would fail gracefully and you won't have half baked data inside the card.

z535539710
Posts: 10
Joined: Fri Jan 06, 2017 3:28 am
Points :276
Contact:

Re: beginTransaction & commitTransaction

Post by z535539710 » Mon Mar 20, 2017 2:27 am

tay00000 wrote:Imagine a scenario where you decide to write very important data. One example being provisioning a bunch of cryptographic keys to the cards and then you accidentally trip over the card reader and dislodge it from the host computer. Now you have half provisioned keys and you cannot assert their integrity.

The beginTransaction and commitTransaction is to ensure that either all the data are properly committed in an atomic manner or it would simply fail. Think along the line of database commits where the data entry either properly commits or fails gracefully. It is to ensure that in the event something happens, the data would fail gracefully and you won't have half baked data inside the card.


thank you very much, your answer helps a lot

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 12 guests

JavaCard OS : Disclaimer