.problem solving

To gather my comments on solving problems in general, inspired by the training that I has attended last week. I will skip the two steps of 1) Problem statement and 2) Formalize problem. These steps are crucial for solving any problem, but will not be covered here.

In my view, many problems can be seen as finding input $latex X$ such that output $latex Y = F(X)$ satisfies certain conditions. For example, essentially, root cause analysis for a problem of f(X) = incorrect (in contrast to f(X) = expected) is to identify subset of $latex X$ that causes the incorrect results.

Note that the problem statement and formalization is important as it will determine how $latex X$ should be represented:

  • Linear: vectors / matrix
  • Convolution: complex data structure / layers

Solving approach: I think there are two main approaches:

  • Analytical
    • Logical analysis: based on the logical rules of causality $latex X \rightarrow Y$ is known. For given output Y, one can identify possible root causes X and do back-testing using the rules to validate. Known as: fish-bone techniques.
    • Differential thinking: one does not know about the blackbox function $latex X \rightarrow Y$ but knows how Y changes when X changes by a $latex \Delta X$
    • Recursive thinking: one does not know about the blackbox function $latex X_n \rightarrow Y_n$ but know how to link the problem to $latex X_{n-1} \rightarrow Y_{n-1}$ and can solve the problem at certain lower level. Known as: divide-and-conquer.
    • Equivalent mapping: one can relate this problem to a equivalent, more familiar and solvable problems.
  • Stochastic
    • Mix and match solutions coming from different related problems under different domains.
    • (to be continued…)

.blockchain – a closer look

(to continue the previous blog)

Which problems that blockchain has tackled?

  • Distributed ledger/database of ownership: remove completely the role of centralize custodian
  • Time-stamping (double-spending): a mechanism to avoid A transfer same “coin” to both B and C. Without centralized trusted custodians, due to the nature of digital communication, it is more feasible to happen. Imagine: without centralized custodian, how to sell same house to two different buyers?
  • Consensus via proof-of-work: Once a transaction (ownership transfer) is submitted (broadcasting), it must be validated and recorded in the “distributed ledger” database. Assume everyone owns the same ledger copies, now some receive a broadcast of transferring from A to B: $latex Coin_{k+1}=Sign(Hash(Coin_k, P_B), S_A)$ and some receive a broadcast of transferring to C: $latex Coin_{k+1}=Sign(Hash(Coin_k, P_C), S_A)$. How everyone reach a consensus of which transfer comes first and invalidating the second one?

First, each new transaction, once validated, will be in a new block that linked to previous blocks in a recursive manner. The new block has a header hash that is created based on the new transaction & a random number (nounce) & the hash of previous block. In this way, the blocks are linked sequentially. It means that if one ledger is tampered in any block, one can recompute its hash and verify with other ledgers to identify its invalidity.

Another trick is that the random number is mined such that the hash begins with certain 0-zeros. Meaning that there are computational effort spent to create new block, i.e., proof of work. Also, in some ways, the one who spent efforts to create new block, i.e., validator node, will be rewarded with new coins as incentives. There will be a “race” among node validating the same or different block of new transactions to find “the nounce”.

Lastly, once one validator node successfully creates a new block, it will broadcasting the new hash (and block?) so that other can update their ledger with this new node and move on the validating the new block. One principle is that the longer chain should be considered as a “truth”. It implies that if one tries to tamper the existing block, it would need to create blocks faster against the “race” of other honest nodes. If the “race” is fierce, the chain quickly gets longer, dimishing the chance to tamper data.

Imagine: we have 10 personels as validators. I announce to all the network that I will sell my house to B (message 1) and at the same time sell to C (message 2). Assuming that at one time, 6 personels are validating message 1 and remained 4 personels validating message 2. All can validate that I own the house based on the current state of ledger, hence accepting both message 1 or 2, just the matter of which one comes first (time-stamping). The proof of work is that a validator need to do 100 push-up before accepting my message. Only who does the job fastest (physical limit) will be able to convince other validator and be rewarded. Later if one want to change record that I transfer the house to C instead by compromising one validator, this one needs to convince (all) other validators to agree to his up-to-date and longest ledger. The longer the chain means he would need to do push up more times and still the fastest! The proof of work is to make this task impossible, statistically.

One question remained is how to validate a transaction against the current state of ledger? Meaning that if I hear A transfer to B, how can I validate A’s ownership of the asset against my best knowledge? To be explored.

Second concern is exactly on the modification of existing data. How would that be achieved? By B transfer back to A and then A to C again?

Lastly, enhancing the ownership hash to something more complex while keeping blockchain as the infrastructure, we get to smart contract and more fancy stuffs.

(*) mainly after reading the original paper “Bitcoin: A peer-to-peer electronic cash system” by Satoshi Nakamoto

.blockchain – cryptocurrency

I was confused at first to understand the two concepts of bitcoin and blockchain. Slowly, I start to realized the two pillars of bitcoin (or any blockchain applications would required): crytocurrency & blockchain (*)

Which problems that crytocurrency has tackled?

  • Ownership without custodian/ centralized party
  • Based on the application of public-key cryptography: system that uses pairs of keys: public keys that may be disseminated widely paired with private keys which are known only to the owner.
  • There are two functions that can be achieved: 1) using a public key to verify the sender (digital signature); or 2) encrypting a message with a public key to ensure that only the holder of the paired private key can decrypt it (public encryption).
  • Example: Transfering from A to B of digital coin $latex Coin_{k+1}=Sign(Hash(Coin_k, P_B), S_A)$ in which $latex P_B$, $latex S_A$ are the public key and private key of B and A respectively. Imagine it is like you put the receipient name on a dollar note and sign on it to transfer the ownership.
  • By this mechanism, everyone can verify A transfer to B “something” using A’s public key and only B can decrypt and hash/sign next time if B wants to transfer to C.
  • Not sure how but we need to also ensure that everyone can validate that this asset no longer belongs to A but owned by B by querying the ledger?

 

(*) mainly after reading the original paper “Bitcoin: A peer-to-peer electronic cash system” by Satoshi Nakamoto