JavaCard Applet Development Related Questions and Answers.
-
z535539710
- Posts: 10
- Joined: Fri Jan 06, 2017 3:28 am
- Points :276
-
Contact:
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

-
UNKNwYSHSA
- Posts: 630
- Joined: Thu May 21, 2015 4:05 am
- Points :3055
-
Contact:
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 :2326
-
Contact:
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:
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
Users browsing this forum: No registered users and 60 guests
JavaCard OS : Disclaimer
Board Disclaimer
The views and comments posted in these fora are personal and do not necessarily represent the those of the Management of JavaCard OS.
The Management of JavaCard OS does not, under any circumstances whatsoever, accept any responsibility for any advice, or recommentations, made by, or implied by, any member or guest vistor of JavaCard OS that results in any loss whatsoever in any manner to a member of JavaCard OS, or to any other person.
Furthermore, the Management of JavaCard OS is not, and cannot be, responsible for the content of any other Internet site(s) that have been linked to from JavaCard OS.