[区块链] Prerequisite: RSA, 数字签名(digital signature) 和数字证书( digital certificate)

This entry is part 1 of 1 in the [Project] Blockchain, bitcoin, and beyond

加密方法

密方法可以分为两大类。一类是对称加密(symmetric),还有一类叫做非对称加密(asymmetric)。前者的加密和解密过程都用同一密匙,后者的加密和解密用的是两个密钥。在对称加密的情况下,密钥只有一把,一旦密钥泄漏,密码也就被破解。在非对称加密的情况下,密钥有两把,一把是public,还有一把是private。区块链使用的是rsa非对称加密。对于非对称加密:

  • 公钥和私钥是一一对应的关系
  • 所有的(公钥, 私钥)对都是不同的
  • 用公钥可以解开私钥加密的信息,反之亦成立。
  • 同时生成公钥和私钥应该相对比较容易,但是从公钥推算出私钥,很困难或者是不可能的。

数字签名和数字证书

  1. 鲍勃有两把钥匙,一把是公钥,另一把是私钥。
  2. 鲍勃把公钥送给他的朋友们—-帕蒂、道格、苏珊—-每人一把。
  3. 苏珊要给鲍勃写一封保密的信。她写完后用鲍勃的公钥加密,就可以达到保密的效果。
  4. 鲍勃收信后,用私钥解密,就看到了信件内容。这里要强调的是,只要鲍勃的私钥不泄露,这封信就是安全的,即使落在别人手里,也无法解密。
  5. 鲍勃给苏珊回信,决定采用”数字签名”。他写完后先用Hash函数,生成信件的摘要(digest)。
  6. 然后,鲍勃使用私钥,对这个摘要加密,生成”数字签名”(signature)。
  7. 鲍勃将这个签名,附在信件下面,一起发给苏珊。
  8. 苏珊收信后,取下数字签名,用鲍勃的公钥解密,得到信件的摘要。由此证明,这封信确实是鲍勃发出的。
  9. 苏珊再对信件本身使用Hash函数,将得到的结果,与上一步得到的摘要进行对比。如果两者一致,就证明这封信未被修改过。
  10. 复杂的情况出现了。道格想欺骗苏珊,他偷偷使用了苏珊的电脑,用自己的公钥换走了鲍勃的公钥。此时,苏珊实际拥有的是道格的公钥,但是还以为这是鲍勃的公钥。因此,道格就可以冒充鲍勃,用自己的私钥做成”数字签名”,写信给苏珊,让苏珊用假的鲍勃公钥进行解密。
  11. 后来,苏珊感觉不对劲,发现自己无法确定公钥是否真的属于鲍勃。她想到了一个办法,要求鲍勃去找”证书中心”(certificate authority,简称CA),为公钥做认证。证书中心用自己的私钥,对鲍勃的公钥和一些相关信息一起加密,生成”数字证书”(Digital Certificate)。
  12. 鲍勃拿到数字证书以后,就可以放心了。以后再给苏珊写信,只要在签名的同时,再附上数字证书就行了。
  13. 苏珊收信后,用CA的公钥解开数字证书,就可以拿到鲍勃真实的公钥了,然后就能证明”数字签名”是否真的是鲍勃签的。【注意,这里即使道格用了鲍勃的数字证书也没有用,因为里面是鲍勃的共钥】

“数字证书”应用实例:https协议网页加密

  1. 首先,客户端向服务器发出加密请求。
  2. 服务器用自己的私钥加密网页以后,连同本身的数字证书,一起发送给客户端。
  3. 客户端(浏览器)的”证书管理器”,有”受信任的根证书颁发机构”(CA)列表。客户端会根据这张列表,查看解开数字证书的公钥是否在列表之内。【The public key of the CA(也就是说ca也有public key )is stored in the certificate of the CA. And this certificate is stored in the local trust store on the clients system. It is true that an attacker which has access to the local trust store could replace existing CA certificates or add new ones. But if the attacker has this kind of access he can do lot more harm anyway】
  4. 如果数字证书记载的网址,与你正在浏览的网址不一致,就说明这张证书可能被冒用,浏览器会发出警告。
  5. 如果这张数字证书不是由受信任的机构颁发的,浏览器会发出另一种警告。
  6. 如果数字证书是可靠的,客户端就可以使用证书中的服务器公钥,对信息进行加密,然后与服务器交换加密信息。

Getting Things Done by David Allen

This entry is part 1 of 3 in the [Project] Book Summary

The Five Key Ideas

  •  Anxiety and guilt don’t come from having too much to do; it comes from breaking agreements with yourself.
  • If an action will take less than two minutes, it should be done at the moment it is defined.
  • Mastering your workflow involves capturing what has your attention, clarifying what it means, putting it where it belongs, reviewing it frequently and engaging with it.
  • Getting things done requires defining what “done” means and what “doing” looks like.

Continue reading “Getting Things Done by David Allen”

Atomic Habits Summary by James Clear

This entry is part 2 of 3 in the [Project] Book Summary

The Five Big Ideas

  1. Habits are the compound interest of self-improvement.
  2. If you want better results, then forget about setting goals. Focus on your system instead.
  3. The most effective way to change your habits is to focus not on what you want to achieve, but on who you wish to become.
  4. The Four Laws of Behavior Change are a simple set of rules we can use to build better habits. They are (1) make it obvious, (2) make it attractive, (3) make it easy, and (4) make it satisfying.
  5. Environment is the invisible hand that shapes human behavior.

Chapter 1: The Surprising Power of Tiny Habits

“Success is the product of daily habits—not once-in-a-lifetime transformations.”

“You should be far more concerned with your current trajectory than with your current results.”

Continue reading “Atomic Habits Summary by James Clear”

How to win friends and influence people by Dale Carnegie

This entry is part 3 of 3 in the [Project] Book Summary

Techniques in Handling People

  1. Don’t criticize, condemn or complain.
  2. Give honest and sincere appreciation.
  3. Arouse in the other person an eager want.

Continue reading “How to win friends and influence people by Dale Carnegie”

Classes of Happiness: Positive Psychology at Harvard, and the Science of Well-Being at Yale

I am currently learning these two classes about Happiness, Well-being, and positiveness.  It certainly benefited me a lot, and all are free.

  • The first one is Positive Psychology, taught by Tal Ben-Shahar at Harvard university, which enters the history books as the most popular course in the history of Harvard University.

    The whole class (with Chinese closed caption) is available at Youtube Playlist: [Open Courses at Harvard] Positive Psychology

  • The second one is the Science of Well-Being of Yale university. The purpose of the course is to not only learn what psychological research says about what makes us happy but also to put those strategies into practice. I am learning it through Coursera “the science of well-being

A small donation

When I was driving home waiting at an intersection, I saw an old lady (apparently not in good condition) holding a sign saying she has some disease. Apparently she was looking for some donation. It was really cold outside. I wasn’t able to give money to her since she was beyond the reach.

When I was home I decided to run back to the intersection and give the money to her. I don’t know why but I just had that urge. Its just its so cold outside and people barely noticed her. I hope she can at least have a dinner.

Since I am starting the 100wishes project. Why don’t I just start with myself: I wish everyone have a safe place to stay and have enough food.

Connection between Stress and Cardiovascular Disease.

February is American Heart Month. Heart disease is the leading cause of disability (Stats: accounting for 1 in 4 deaths in the United States).

A recent study published in THE LANCET shows a connection between stress and cardiovascular disease.

“Our results provide a unique insight into how stress may lead to cardiovascular disease. This raises the possibility that reducing stress could produce benefits that extend beyond an improved sense of psychological wellbeing,” said lead author Dr Ahmed Tawakol, Massachusetts General Hospital and Harvard Medical School, USA. “Eventually, chronic stress could be treated as an important risk factor for cardiovascular disease, which is routinely screened for and effectively managed like other major cardiovascular disease risk factors.” Reference

Protect our heart by doing those small things:

  1. Pause, unwind, and relax;
  2. Excise regularly;
  3. Omega 3 is good for heart. Sources include salmon, walnuts, almond, chia, flaxseed, avocado;
  4. Reduce sugar intake.
salmon

Good and Bad Carbs

Carbs are essential and controversial. However, there are some commonly agreed guidelines -choose “whole” instead of “Refined”. Below are some example sources.

healthy carbs: barley, squash, whole-wheat bread, oatmeal, quinoa, sweet potato, broccoli, blue berry, spinach

refined carbs: sugar-sweetened beverage, fruit juice, pastries, white bread, white pasta, white rice.

If you consume a lot refined carbs, reducing them gradually might be an easy life change event.

Healthy carbs

 

refined carbs

Getting up early

I tried several times to make get-up-early a habit, but failed each time.  I did succeed from time to time, but could not make it consistent. I really want to be an early riser, and now officially make it a challenge. If I can rise between 6:30am-7:30am 30 days in a row, I consider it a success. This certainly is not easy. The first thing to do is to find the motivation.

What is my reason to jump out of bed in the cold morning? Things that immediately came up to my mind include believing in myself, more time for exercise, getting abs, no guilty feeling of wasting time, no headache, more energy, more time spent with positive people, the quiet neighborhood, the bird chirping, the beautiful sunrise, and the entrepreneurial spirit.

I will come back to this post and strikethrough each day if i succeed. Anyone is doing it together with me? Shoot me an email or leave a comment!

 2/12    2/13     2/14   2/15    2/16

2/17   2/18    2/19    2/20    2/21   2/22   2/23

2/24   2/25   2/26   2/27    2/28   3/1      3/2

3/3      3/4     3/5

Breaking the comfort zone

Stepping outside of our comfort zone is inevitably an uncomfortable experience, but it can yield a lot more growth. I used to be afraid of public speaking, but I joined a toastmaster to face my fear, and I can see the improvement every week. Now it’s even much easier I talk to a total stranger. Whenever we see the result, it serves as a positive feedback that will encourage us to try harder.

I totally agree that “outside of the comfort zone is where the magic happens”. Now i am challenging myself at a daily basis.

Finished my first full marathon!

When I saw the sun finally came out i was so excited (it has been raining for many days in my area), and decided to go for a marathon run. It’s kinda dangerous since I did’t have much training after the half marathon run 2 months ago.

When I arrived at the trail, it started raining. I hesitated if i should just go home since it was raining even harder. But when i saw some hardcore runners passing by and not giving a shit about the rain, i made a determination that i will be one of them and finish today’s run no matter what.

In the first half, it was ok and i was pretty fast. But in the second half my feet hurt a lot. I had to stop to do some stretching for every mile. Energy and endurance-wise i was totally fine, and didn’t even feel tired; but feet and legs hurt too much. In the last several miles, it was almost as slow as walking.

The number is pretty bad (about 5 hours if excluding the time used to hide from rain), but i do consider it a big success since i never imaged i can do this!

What is more important than a healthy body?

A healthy mind I guess.

Mindset is discovered by Stanford University psychologist Carol Dweck. At the heart of a “growth mindset” is that it creates a passion for learning rather than a hunger for approval. Below is the comparison.

mindset type

The diet from a neurogenesis point of view

In the book The Neurogenesis Diet and Lifestyle: Upgrade Your Brain, Upgrade Your Life, Dr. Brant Cortright presented great findings to boost our brain health at any age.  He suggested the following general principles of diet for neurohealth:

  • Plenty of fresh vegetables and fruits;
  • High quality fats: grass-fed meat, flaxseed, pasture-raised chicken, avocados, extra virgin coconut/olive oil, nuts and seeds, high quality fish, etc.
  • Cook at low temperature. Don’t eat burnt or charred meat.
  • Lower sugar and carbohydrates intake. Good carbohydrates comes with lots of fiber: summer squash, berries, kale, carrots, etc.

5-minute chia seed drink

Three reasons to make chia drinks yourself.

  • Chia seed, which is loaded with antioxidants and fiber, is naturally low-calorie. It helps to reduce weight, and has many health benefits.
  • Chia seed is low price (organic chia seed is around $4 lbs at whole food).  Compare to the price of those single serve bottles!
  • The jelly-like texture is unique. Adjust the taste with your choice of fruit.

Steps:

  • Mix up 3 teaspoons of chia seed and a cup of warm water.
  • Get 1/4 lemon and squeeze the juice in to add a taste.

Finished half mathoron

I finished 13 miles in 1 hour 56 mins, which is not too bad for the first-time try. I actually didn’t find it too difficult (thanks to the training of spin class) except that during the workout my thighs sore. I wasn’t at the best physical condition (worked out too much this week), and I expect to do even better next time.

Another thing i achieved today is that I got the “best table topic” award in the toastmaster meeting. This is not imaginable since I thought table topic is the most difficult task, and i simply can’t do it. It comes easily today :). I can, and I believe you can too!

Happy thanksgiving all!

img_3237

A list of challenges I believe I can do

It’s year end again. I am here listing 8 challenges to be achieved by end of 2016. I will check them off one by one if ever :).

  • Take two cold showers in the middle of winter. This is not extremely difficult since it is California!
  • Run a half marathon (On the day of writing I ran 10 miles). Done on Nov 23, 2016
  • 25 pullups in a row (On the day of writing I can do 12-15 in a row)
  • Reach out and make 2 new friends.
  • Initiate and have a meaningful and coherent conversation with a stranger.
  • Get up at 6:45am 5 days a week.
  • A 48-hour hackathon.

Today I ran 10 miles and had to take uber to get back home since it was raining. The uber driver was a very friendly and interesting lady. We had a great conversation about nutrition, fitness and president election :).  She said she really wanted to run but the gym membership is costly. I recommend some gym with reasonable price to her. Hopefully she will check it out and get started!