Tuesday, February 2, 2021

Blockchain : The Trusted and Secure Platform for a New World


Data stored inside databases forms the foundation of modern business—from bank balances to flight reservations and government identities. Because this data is highly valuable, bad actors target it. In traditional databases, stolen credentials allow attackers to modify records or delete security logs.

Enterprise blockchain addresses the data integrity problem by using append-only, cryptographically linked ledgers that make historical record tampering detectable and mathematically infeasible across a distributed network. However, robust security still depends on protecting private keys and smart contract logic, as stolen keys still grant bad actors authorization to execute unauthorized transactions.

1. Cryptographic Immutability and Auditability


Traditional databases permit CRUD operations (Create, Read, Update, Delete), meaning root administrators or compromised service accounts can alter historical records without leaving a clear trace. Enterprise blockchains function as append-only ledgers. Every transaction is cryptographically hashed, timestamped, and linked to the preceding block. This creates an unalterable audit trail that makes data tampering computationally infeasible and instantly detectable.

2. Dynamic Policy Enforcement via Smart Contracts


Rather than enforcing security policies solely at the application layer, enterprise blockchain platforms use self-executing smart contracts to govern data access and workflows at the state layer.

  • Deterministic Execution: Data is only written or shared when predefined, mathematically verifiable conditions are met.

  • Least-Privilege Automation: Access controls run transparently across organizational boundaries without relying on a centralized intermediary.


3. Privacy-Preserving Multi-Party Collaboration


Enterprise frameworks (such as Hyperledger Fabric and R3 Corda) replace public anonymity with permissioned, identity-verified nodes. Features like private channels, zero-knowledge proofs (ZKPs), and point-to-point state validation allow competing or sovereign entities to establish a single source of truth without exposing sensitive, underlying raw payload data.

FeatureLegacy DatabaseEnterprise Blockchain
Trust ModelCentralized authority / Admin trustDistributed cryptographic consensus
Data IntegrityErasable & mutable (CRUD)Append-only & immutable ledger
Audit CapabilitiesExternal system logs (alterable)Built-in, tamper-proof state history
Data SharingAPI duplication & bulk syncsNative shared ledger with private channels
By converging zero-trust governance with immutable data persistence, enterprise blockchain turns security from an external patch into an inherent property of the data estate.

Friday, October 2, 2020

Share your Google Calendar with a desktop app (written in node.js) using Google Calendar APIs

Use Case:

Alex is a busy social person and stores his calendar on Google calendar. He wants to be able to look at the highlights of what is coming up in text form. He is a geek and prefers command line interaction to view his calendar (his favorite editor is vi). He also wants to share his calendar with Sally. She is also a co-geek and wants to use a terminal to look at Alex's schedule. Alex want to be able to


   1) share his calendar with his pal Sally and only her

   2) viewable from a command line (say a terminal on my Macbook)


Google has made this fairly easy to do with a tutorial and clear instructions from the Google calendar API-enabler interface. Here is a quick walk of the process to enable Google calendar API.





Enable Google Calendar API

To start the process to enable Alex's calendar to be viewable by Sally (and in text form), Alex logs into his Google account and heads over to his Google cloud account (https://console.developers.google.com). He creates a new project, gives it a project name of "gcx". He decided that he will write the Google calendar client aka app - the reader from which he will invoke from the terminal - in Node.js for Sally. He follows the process to "enable Google Calendar API". This step will create credentials.json - which will have 1) Client ID and 2) Client Secret. This will help Google to know whose Google services to target - it this case, it will be Alb's.


Node.js App

To create the Node.js Google calendar reader, he found a useful sample code.  He sends that to Sally to use. Before she invokes it with "node index.js", she needs to use npm to install the Google calendar API SDK by typing "npm install googleapis@39 --save". If Sally skipped this step,  she will run into "Error: Cannot find module 'googleapis'".


App Asking Permission to Alex's Calendar

The first time the reader is invoked, it will contact Google. Google notes that this is an unverified application (a desk application via NODE.js to be specific) into Alex's calendar. Google wants to make sure that Alex is really ok sharing his social calendar with this reader. Google asks the user of the reader (Sally) to send to Alex a specific just created authentication link. That link will ask for Alex to log into his Google account to authorize the calendar reader to read his calendar. 


Alex Give Permission

Because Alex trusts Sally, he visits the link and clicks [v] View, then [Allow] to allow Sally's reader to use Google calendar API to read his calendar. Alb will receive an authorization code that he sends to Sally.  Sally will enter the authorization code, and viola, she can read Alb's calendar, on a terminal!


Conclusion 

Alex stores his social calendar in his Google calendar. He wants a way to share it with people he trusts (Sally), in the format they like to view in it (text on a terminal). Google calendar API can make this happen easily. 



Sunday, September 13, 2020

Makefile : the forgotten Unix command for build automation

1. Introduction:


A software program (or services, a term used nowadays to describe software that runs in the cloud instead of your on your computer) is usually created from multiple separate source files, libraries, etc. Multiple source files are compiled IN ORDER, and libraries are linked in, to make a software program. The compile step requires the multiple separate source code files to be compiled in sequence. 


You change a source file, you run one command, and all needed associated source files that is impacted by the change in the source file is recompiled. The end result is new, updated version of the software program with the latest source code change(s).

There are multiple build automation software for this, such as Ant, Maven, Gradle, etc. But before diving into these automation software, you can actually learn on your Unix based laptop, using a Unix command called "make". 



2. The anatomy of a Makefile


The Unix "make" command has been available since 1976.  The simple idea behind make is that:


   1) you have a bunch of source files

   2) you know how to compile the source files into final code

   3) you know how to run the final code


You "codify" these into a text file called Makefile. I won't go into the syntax of a Makefile here, but rather focus on what it does for now. Using a Hello java program. Let's look at a Makefile :


   --- Makefile ---

   target : <tab> dependency 

   <tab> command


Decoding the Makefile:


   target: the compiled file, such as Hello.class; this of this as the output of the command

   dependency : the source code that the compiled file (target) depends on, such as Hello.java

   command: how do you compile the dependency (source file) into the target (compiled file), 

                     such as javac Hello.java


So for the above example:


   Hello.class:    Hello.java

                          javac Hello.java


This says Hello.class depends on Hello.java. If Hello.class is older than Hello.java, invoke the command "javac Hello.java" to compile and update Hello.class.


3. A Real Example:


Let's use a simple working Hello java example:

class Hello {

   public static void main (String [] sin) {

      System.out.println("Hello!");

   

   }

}

   1) you have a bunch of source files (say Hello.java)

   2) you know how to compile the source files into final code (javac Hello.java)

   3) you know how to run the final code (java Hello.class)


If you want to try out a simple Unix command line way of building a Java application (just prints Hello), you can follow along:



----- Makefile -----


go:     Hello.class     

        java Hello



Hello.class:    Hello.java

        javac Hello.java


clean:

        rm -f Hello.class



---- using make to build & run, for the very first time  ---

%make -n # let's see what make will do, but don't do it, could have used --dry-run

ac-a01:0HelloWorld chiangal$ make -n


javac Hello.java

java Hello

%make # compile, run, but this time, do it for reals

ac-a01:0HelloWorld chiangal$ make


javac Hello.java

java Hello

Hello


%make # this time only run

ac-a01:0HelloWorld chiangal$ make


java Hello

Hello


%vi Hello.java # modify the source file Hello.java by adding ! to Hello

class Hello {

   public static void main (String [] sin) {

      System.out.println("Hello!");


   }

}

%make # because the source code Hello.java has been changed, make will re-compile, run

chiangal-a01:0HelloWorld chiangal$ make


javac Hello.java

java Hello

Hello!


%make -f clean; ls Hello.class # everything works, let's clean up and go to sleep, but let's look at command first

ac-a01:0HelloWorld chiangal$ make -n clean; ls Hello.class 


rm -f Hello.class

Hello.class


%make clean; ls Hello.class # looks good, let's do it : remove generated files

ac-a01:0HelloWorld chiangal$ make clean; ls Hello.class 


rm -f Hello.class

ls: Hello.class: No such file or directory



4. Conclusion:

The unix "make" command is a good way to learn about build automation on your own laptop that supports some flavor of Unix (like MacOS). In one command "make", the Unix will read the Makefile that you have created, knows what the final program is (Hello.class), reads the Makefile to find dependencies on how to build Hello.class (depends on Hello.java, the command to compile it is javac Hello.java).