# 加密货币考试押题整理

81

0

2020年7月29日21:37:41 评论 115 20606字阅读68分41秒

## mock题目

### 交易数据如何存储到区块链的

To save some data we just encode it and use it as an address to send a transaction to. By doing so, the data is stored in the blockchain.
The transaction data will be verified by all nodes and then it will be stored in a new block as a leaf of a merkle tree. The new block also will be verified by all nodes.

### 矿工的作用

Generally, the role of miners is to provide calculation power.
1. When bitcoin miners add a new block of transactions to the blockchain, part of their job is to make sure that those transactions are accurate.
2. In particular, bitcoin miners make sure that bitcoin is not being duplicated, a unique quirk of digital currencies called “double-spending.”

### 比特币数量有限制

1. In a fully decentralized monetary system, there is no central authority that regulates the monetary base. The Bitcoin generation algorithm defines, in advance, how currency will be created and at what rate. Any currency that is generated by a malicious user that does not follow the rules will be rejected by the network and thus is worthless.
2. its final amount could not be increased or decreased to eliminate the risks of inflation and deflation caused by artificial printing of banknotes.

## 1. 散列hashing

### 1.1 定义

Converts a digital object of arbitrary length, like a document, an image into a single string of fixed length, called a hash.

### 1.2 性质：

1. not continuous, two similar documents result in very different hashes;
2. it is very hard to reverse engineer.

### 1.3 什么是SHA256和RIPEMD160

1. SHA256 is a novel hash functions computed with 32-bit words;
2. RIPEMD160 has a 160-bit hash value so it is used for shorted hash.

## 2 比特币相关

### 2.1 比特币地址Bitcoin address

#### 2.1.1 定义

a bitcoin address is a string of 26-35 alphanumeric characters in Base58Check encoding, begining with the number 1 or 3.

#### 2.1.2 如何获取比特币地址：

1. it is a hash of a public key------>P2PKH(Pay-to-Public-Key-Hash)。
2. Public Key 经过 SHA256 + RIPEMD160 得到Public Key Hash, 再经过Base58Check Encode得到Bitcoin address。
3. it is the hash of a script------>P2SH(Pay-to-Script=Hash)。

### 2.2 比特币基础知识

• 单位：1 satoshi = 10^{-8}Bitcoin，satoshi is smallest possible unit;
1 MilliBit = 0.001Bitcoin = 100,000 satoshis
• 比特币上限是固定的，有Almost 21 million BTC，2,099,999,997,690,000 satisgus
• 在2140年全部挖掘，共13.4million blocks
• 每十分钟出现一个新区快。每210,000个区块比特币的产出速率就会下降50%，目前是6.25bitcoin per block

### 2.3 比特币区块链的设计的目的

1. Decentralized electronic currency
2. Preventing double-spending when no one is in charge

### 2.4 比特币应用的新的技术

1. Technologies where transactions are witnessed and validated;
2. Participants share state of certain variables
3. Transactions are linked together to strengthen resistance to attack and fraudulent revision.

### 2.5 比特币编程语言——script

• 介绍：reverse-Polish notation stack-based execution language
• 堆栈操作：
1. Push:adds an item to the top of the stack;
2. pop:removes the item at the top of the stack.

#### 2.5.1 script优点：

1. Not hardware dependent
2. enables execution on devices with limited memory, like embedded devices
3. it is stateless. No state prior to execution and no state saved after execution.

#### 2.5.2 script不能循环的影响：

• Does not permit loops or complex program control features：
1. This means predictable execution times
2. precludes attacks
3. no infinite loops
4. not Turing-complete.

### 2.6 比特币区块链与CAP

• In bitcoin blockchain, the partition arises due to the P2P network.
• Bitcoin block chain opts for Availability.
• Consistency怎么办？:Has no master or central node to enforce Consistency
• needs a consensus algorithm, for nodes to vote on the true state of the database ( the blockchain)

### 2.7 比特币为什么不用使用simple majority voting：

1. Bicoin blockchain is open so cannot use simple majority voting;
2. No way to ensure that a majority is present;
3. No node has overall view of all other nodes;
4. A majority could be manipulated, like Sybil attack

### 2.8 为什么比特币最终连续：

• The older a block is, the more work is required to change it;
• The longest internal fork was 24 blocks in length
• No transaction more than 5 hours old has been reversed.

## 13 比特币分叉

### 13.1 内分叉Regular operations (or internal) fork

• 如何产生：The temporary existence of competing chains as miners process competing blocks
• 如何消除：Resolved through consensus protocol

### 13.2 软件分叉software fork

• 如何产生: In open-source software projects, a fork is a new software project trajectory that starts from an earlier project.

#### 13.2.1 软分叉Soft fork:

• 产生原因：The new version of the software is backwards-compatible. So nodes do not need to adopt the new version of the software. In a block chain, nodes can still recognize new blocks even if they are running the old software version.

#### 13.2.1 硬分叉Hard fork:

• 产生原因：The new version is not backwards compatible. Every nodes needs to adopt the new version of the software to recognize new blocks.
• 比特币的硬分叉产生了这些新的加密货币：

## 3 Merkle Tree

• 作用：To prove some transaction included in hash.
• 提供：交易的hash+交易的merkle path+Merkle root的hash，即可证明。

## 6 Wallets

### 6.1 什么是钱包？

1. Wallets is the primary user interface. Controls access to a user's bitcoin; Manages keys and address; Tracks current balance; Enables creation and signing or transactions.


- 钱包哪里？
1. May be held on client machine or on an exchange.

### 6.2 钱包的功能？

1. Wallets is the primary user interface. Controls access to a user's bitcoin; Manages keys and address; Tracks current balance; Enables creation and signing or transactions.
2. Wallets can keep a copy of the transaction; Can query the chain when needed.
3. Wallet also refers to the data structure used to store and manage a user's keys and address.


### 6.3 钱包在personal machine vs exchange

Wallet on personal machine is a software program in which you store Bitcoin; Wallet on exchange let you convert 'real money' like US dollars to Bitcoin. You don't have full control of this exchange wallet.


## 7 区块链的交易 transaction

### 7.2 交易的组成部分：

1. an amount of Bitcoin, denominated in satoshis;
2. A locking script which needs intended recipient to provide something to redeem it.


### 7.3 如何赎回locking的script？

1. They provide their signature and a hash of their public key or a hash of a script


### 7.4 根据赎回方式有五种交易标准：

1. Pay-to-Public-Key-Hash(P2PKH):a hash of a specific public key is needed to redeem.
2. Pay-to-Script-Hash(P2SH)
3. Pay-to-Public-Key(P2PK):Mostly used in coinbase transactions
4. Multiple-signature:limited to 15 keys
5. Data Output: 40 bytes of non-payment data to a Transaction output.


### 7.5 区块的第一笔交易basecoin trsansaction：

定义：the bitcoin earnt by mining are awarded via the first transaction of each new block.



## 8 UTXO

### 8.1 什么是UTXO?

Unspent Transaction Output (UTXO) is the output of a transaction which may be spent as an input in a subsequent transaction.


### 8.2 UTXO与交易什么关系？

'Sending' a recipient some bitcoin is done by creating some UTXO registered to their address.


### 8.3 UTXO的性质：

1. All the UTXO of the system is known by every node, held in a database called UTXO set or UTXO pool.
2. UTXO is locked to a specific address and may be scattered;


### 8.4 UTXO与wallet的关系：

1. a wallet will aggregate the UTXO belonging to a single address.


## 9 分散共识(四个部分)Decentralized consensus

### 9.1 节点如何验证一个交易

• Independen verification of each trasaction, by every full node.
• Independent aggregation of those transactions into new blocks by mining nodes together with demonstrated computation through a Proof-of-Work algorithm

### 9.2 节点如何验证一个新块

• Independent verification of the new blocks by every node and assembly into a chain
• independent selection, by every node, of the chain with the most cumulative computation demonstrated through Proof-of-Word.

## 10 拜占庭将军Byzantine Generals

### Byzantine faults

• 定义：faults which appear different to different observes. A general sends different messages to different colleagues.

### 10.3 什么是Byzantine Fault Tolerance:

• A system designed to withstand such attacks

### 10.4 为什么比特币区块链可以做到Byzantine Fault Tolerance:

1. Because it makes it costly to send false messages.
2. Nodes have to do Work to have a block successfully included in chain.


## 11 数据库Database

### 11.2 大数据库的挑战

• 有什么
1. Relational database use SQL(Structured Query Language)
2. Alternatives to relational databases is NoSQL databases
• 不支持全部的ACID
1. Usually Consistency is relaxed
2. Inconsistencies resolved when data is read

### 11.3 为什么选择分布式数据库而不是集中式数据库

• Technically correct but who holds this database? How is it paid for?Who can be trusted not to exploit it? Risk of attach?
• Anti-trust laws: Preclude any member of a partnership holding commercial data from competitors so a centralized database needs to be held by a third-party host. However, A third-party host is more expensive and it might be able to monetize the shared data.

### 11.4 集中数据库的强化技巧：

• A private network closed to entites without permision
• Digital signatures like public keys and private keys for secure identity
• Encryption of messages between participants
• Each participants holding relevant data in their own database
• A consensus mechanism
• To ensure immutatibility, periodic hashing of database contents to a public blockchain.

## 12 CAP理论

### 12.1 什么是CAP:

• We have a design challenge for distributed databases, expresses by the CAP Theorem: Only two of the following 3 properties are possible to achieve simultaneously:
1. Consistency of data
2. Availability of data
3. Partition-tolerance: how the data is stored or distributed

### 12.2 这个理论对于分布式系统有什么指导意义？

- Designers cannot forgo partition-tolerance, so much choose between Consistency or Availability.
- choice will depend on the requirements of the domain:
- if speed of response is not an issue, then choose Consistency;
- if response needs to be immediate, then choose Availability.


### 12.3 比特币区块链与CAP

• In bitcoin blockchain, the partition arises due to the P2P network.
• Bitcoin block chain opts for Availability.
• Consistency怎么办？:Has no master or central node to enforce Consistency
• needs a consensus algorithm, for nodes to vote on the true state of the database ( the blockchain)

### 12.4 比特币为什么不用使用simple majority voting：

1. Bicoin blockchain is open so cannot use simple majority voting;
2. No way to ensure that a majority is present;
3. No node has overall view of all other nodes;
4. A majority could be manipulated, like Sybil attack

### 12.5 为什么比特币最终连续：

• The older a block is, the more work is required to change it;
• The longest internal fork was 24 blocks in length
• No transaction more than 5 hours old has been reversed.

## 14 以太坊Ethereum

### 14.1 以太坊基础知识

• 图灵完备：Lauguage for Bitcoin Blockchain (Script) is limited while Ethereum Blockchain platform with a full language Solidity and its language is Turing-complete.
• 地址：Ethereum Foundation is HQ in Zug, Switzerland.
• 特点
1. Ethereum is a public distributed ledger with an external cryptocurrency Ether
2. Uses proof-of-work
3. Main intended application : programmable DL (smart contracts). Images a state-transition machine which exists on all the full nodes of the network, where smart contracts act to change the state of the machine.

### 14.3 以太坊气体 Ethereum Gas（为什么要有Gas）

• To ensure programmers pay for the cost of processing smart contracts
• To decouple payment for processing from the market value of the currency
• To eliminate infinite loops and hinder DoS attacks since eventually an infinite program will run out of finite gas.
• The more complex the programming commands requested, the more gas the initiator needs to offer.

### 14.4 以太坊虚拟机EVM Ethereum Virtual Machine

• EVM Runtime environment for smart contracts and has 256-bit register stack
• isolated from the network and from the file systems of clients
• Implemented in multiple programming language like C++,Go,Java,Python
• The platform is designed so that Smart Contracts, when processed by miners, will change the state of the EVM.

## 15 共识协议Pow,PoS

### 15.1 什么是Consensus protocol以及为什么需要这个：

A consensus protocol, which is the core of the distributed ledger, performs two tasks: it guarantees that the next block of the network is the only version of the truth, and it protects the network from adversarial influences on the nodes and the network

### 15.2 Proof of Work (PoW)

• 缺点
1. Power usage
2. Asics and dedicated clusters
3. large miners & mining pools
• 目的：Proof-of-Work is designed to create a hurdle to mining
• 避免了什么问题(优点)
1. nodes might spin-up multiple sock-puppet nodes to win the reward
2. a form of Sybil attack
• PoW的数学问题：Find the hash a specified object with a nonce parameter which is less than sum pre-specified total.
对block header进行两次SHA256运算，得到的值小于目标值即可。
block header：version+previous_block_hash+merkle_root+time+target_bits+nonce
• 这个数学问题的特点
1. Problem designed to be hard to do and easy to check
2. Can only be solved by trial and error.
• 哪些未记录的transaction可以进入candidate block
1. Prioritized by age(how many blocks since the UTXO was recorded)
2. Size of transaction(1 bitcoin, aged 1 day)

### 15.3 Proof of Stake (PoS)

- PoS可能存在的问题

- PoS的优点
- PoS consumes less energy than PoW. PoS also actively penalizes dishonesty, deterring fraudulent behavior among validators.

### 15.4 Proof of Authority

• 优点
By harnessing the computing power of a vaster network of machines, PoA can handle faster transaction speeds with a much-reduced energy consumption.
• 缺点
PoA is still in its infancy and needs to prove its resilience through the early phases until network adoption gains traction.
• 内容
• 应用场合

### 15.5 其他的一些turn-taking protocols

• PoET的优点
• Node will rest, so more energy efficient
• Trust Intel, require dedicated hardware
• PoET的缺点
Breaking a single piece of trusted hardware enables the attacker to always win the lottery. Both Sawtooth and REM argue that a statistical analysis of newly minted blocks sufﬁces to detect whether a chip can be compromised. Second, the stale chip problem highlights that it is advantageous to collect chips as this increases the probability of minting a new block (i.e., every new chips is an additional lottery ticket).

## 16 money

### 16.1 定义

• model definition:Coin and Notes
• legal definition:
• Top-Down:Money is whatever the Government says it is
• Bottom-Up:Money is whatever people accept in payment

### 16.2 货币的种类Type of money

1. Commodity money：Money whose value arises from the intrinsic value of the material used to make it, which typically a metal.
2. Representative Money: Money whose value arises from an underlying commodity which it represents.
3. Fait money:Money without any intrinsic value and without an underlying commodity. Its value arises from user acceptance

### 16.3 代表货币与法定货币的区别

Fiat money is physical money, like paper money and coins, while representative money is something that represents the intent to pay such as a check.

### 16.5 货币的价值

• 人们的接受程度：if fiat currency, value depends on people's willingness to accept it in payment
• 基于人们的态度：depend on people's attitudes to the government which issues it or to the monetary policies of the issuing authority.
• 基于对通货膨胀的预期：if the people expect inflation, they may believe money will not keep its value.

### 16.6 货币的流动性

• 定义：The speed and ease with which an asset can be turned into cash without lowering its price.

### 16.7 如何发行货币issuing money

• In most countries, only a Central Bank owned by Government is allowed to issue money
• Minting coins;Printing notes;Putting electronic deposits into accounts of commercial banks

### 16.8.1 货币政策的目的：

1. To keep inflation below a target threshold;
2. To maximize employment
3. To moderate long term interest rates

### 16.8.2 如何影响货币数量：

1. by issuing money
2. by requiring commercial banks to lodge security funds ar the central bank
3. by setting base interest rates
4. by Open-Market Operations(OMO), like buying and selling bonds which releases or withdraws money from economy.

### 16.9.1 通货膨胀造成原因：

1. If banks issue too much money or make lending too easy, then there is more money available than goods to be purchased so the price of goods rises because demand for them exceeds supply. Therefore the average price of goods rises and we get inflation.


#### 16.9.2 超级通货膨胀Hyperinflation

• When inflation rate exceeds 50%per month.

### 16.10 加密货币的货币功能

• a medium of exchange
• a common measure of value and a unit of account
• a store of value
• a means of anonymous payments
• a means of deferred payments
• 但是没有以下的功能：
• Its usefulness for buying or selling real-world goods and services will be proportional to its stability.
• As a stone of value, a cryptocurrency may be particularly valuable for people moving assets across national borders.

### 16.11 加密货币的使用者

• Criminals and people laundering money
• Governments and people evading international sanctions
• People in countries with capital export controls, hyperinflation or with high levels of corruption
• Anyone having a need for money for any legal or illegal purpose
• People purchasing the cryptocurrency to sell it later.

### 16.12 为什么加密货币2017年非常火爆

• increased use by rogue states
• Use of digital cryptocurrencies for some other application
• A tipping point of users
• copying others
• Pump scams and Ponzi schemes: Scammer solicits investment in a fund, promising fast and high return. Then early investors receive returns paid from investments by later investors.

### 16.13 如何判断加密货币的价值

• Is the supply fixed?
• Can the supply be altered easily? new Bitcoins are issued according to an algorithm
• Is the supply under the countrol of the community or of a smaller group?
• 下面是需求方面的考虑：
• Is there an underlying application that would create a demand?
• If there is an underlying application, what is the demand likely to be ?
• Is there any demand from investors
• what are the prices of other, similar cryptocurrencies?

## 17 如何进行融资——ICO

### 17.1 一般获得融资的方式

• Founders,Friends and Family
• Angel investor
• Government grants and loans
• Commercial lenders
• Venture Capital firms
• Initial Public Offers

### 17.2 传统融资方式的弊端

• issus a Prospectus: A document presenting the opportunity, the terms and conditions and the risks
• Strict rules in most countries
• May also be industry-specific regulators

### 17.3 融资的新方式

• 传统的方式：Savers place deposits into banks, building societies, credit union and then banks aggregate the savings. Then lend larger amounts to borrowers.
• Crowd funding: Aggregation done via a web-site or a crowd-funding service.Large number of investors invest a small amount each.
• Peer-to-Peer lending:Lenders connect directly to borrowers.An intermediary may match borrowers and lenders.
• ICO:presale of tokens.

### 17.4 ICO对投资者的检查（KYC/AMY）

• KYC：Know Your Customer regulation, like identity, location, wealth and assets and other investments.
• AMY:Anti-Money Laundering：source of fund.

### 17.5 Howey Test

• 用处:Under the Howey Test, a transaction is an investment contract for securities if four conditions are satisfied.
1. It is an investment of money
1. There is an expectation of profits from the investment
1. The investment of money is in a common enterprise
1. Any profit comes from the efforts of a promoter or third party.

### 17.8 发行ICO的经典结构

• A charitable foundation initials the ICO and receives the funds.
• A software development first develops the idea and the white paper.
• Foundation often registered in regulation-friendly jurisdictions like Swizerland,Gibraltar,Singapore
• Software company registered elsewhere, like UK, USA

### 17.9 ICO的风险

• Risk of any business investment. Investment may fail. Market demand may not be present. Scams and fraud.
• Risks of investments in new technologies. Technology may move on. Shortage of skilled people. Competition may arise. Network effects and path dependence.
• Risks particular to ICOs:
• Tech is new and immature, and not yet well understood
• Regulatory risks
• May be a Ponzi scheme
• Class-action suits by investors.

### 17.10 DAO被攻击的相关情况

• 解释如何利用递归代码：The attack is a recursive calling vulnerability, where an attacker called the “split” function, and then calls the split function recursively inside of the split, thereby collecting ether many times over in a single transaction.

## 18 Corda

### 18.1 基本内容：

- projectinitiated by a consortium of banks. HQ in New York and main work in London and Dublin.
- Established 2015 to develop distributed ledger technologies for banking and financial applications
- created platform called CORDA, an Open-source DL platform released 30 November 2016.


### 18.2 解决面向的问题 Between 2+ financial entities：

- Legal document
- Shared facts are just between the entities
- visible to appropriate regulators
- CAP theorem. Different users may prioritise consistency over availability.


### 18.3 如何设计：

- Consensus:Just partis to a transaction, not the entire community
- Validaton:Just legitimate stakeholders, not the entire community
- Use of Independent notaries:For time-stamping and prevention of replayed transactions
- Focus on inter-operability withlegal code and legacy IT systems.


### 18.4 CORDA的特色：

- Transaction are private to the parties involved。 Only participants to a transaction can view it. Not even fact of transaction is seen by others.
- No single chain
- No global state
- No native crypto-currency
- Records an explicit link between legal code and smart contracts
- Supports a variety of consensus mechanisms
- Can include transaction within arbitrary workflows.


## 18 区块链/分布式分类账

### 18.1 分布式分类账的应用Distributed Ledger Technologies appropriate for:

• Cryptocurrency transactions
• currency transactions
• transaction involving exchanges of wonership of assets
• records of information
• promises and commitments

### 18.2 区块链/DLT主要的好处：

• Shared state. Different organizations needing the same data. Eliminates the need for data reconciliation between companies.
• Stateful and history kept
• Immutability of stored data
• Unique allocations and co-ordinated allocation, which is a solution to double-spend problem
• Witnessing of transactions
• immediate settlement for digital assets

### 18.3 每个好处对应的使用场景

• Shared state->Cross-organizational workflows
• Stateful->provenance tracking
• Immutability of stored data->oermanent records and Provenance tracking
• Unique allocations and co-ordinated allocation->solution to double-spend problem
• Witnessing->Multi-party aggregation

### 18.4 交易的四种类型

• Record keeping:Indentity records;
• Records of transactions: Exchanges of ownership of assets; Chains of custody; A global protocol.
• Promises and commitments
• Smart contracts:self-executing programs; A local protocol.

### 18.5 区块链面临的挑战（最完整）：

• 研究方面的挑战
• Conceptual framework:
• What is the space of possible design?
• What is the fit between designs and applications?
• Technical:
• Platforms and tools still immature
• scale
• speed
• Appropriate designs
• Verification Robustness against attack
• Privacy on public networks
• 实施方面的挑战Implementation Challenges
• Organizational challenges:
• Managing stakeholders;
• Managing revocation and cancellation;
• Business Process Engineering
• Governance of the Distributed Ledger
• Legal and Regulatory aspects
• Technical"
• User friendliness
• Managing multiple DLs
• Integration with legacy systems
• Production readiness

### 18.6 关键的技术挑战Scaling：

• Current DLT Blockchain not adequate for most financial applications: Number of Bitcoin transactions per daya;\
• 两种scaling的方法
• Sharding： split the space of accounts into sub-spaces; Each sub-space gets its own set of witnesses
• Side-chains:private blockchains with occasional posting to a larger chain.

### 18.7 为什么选择分布式数据库而不是集中式数据库

• Technically correct but who holds this database? How is it paid for?Who can be trusted not to exploit it? Risk of attach?
• Anti-trust laws: Preclude any member of a partnership holding commercial data from competitors so a centralized database needs to be held by a third-party host. However, A third-party host is more expensive and it might be able to monetize the shared data.

### 18.8 从smart objects to smart societies

• smart contracts:self-ececuting futures contracts
• Programmable combinations of existence records, smart contracts, transaction records for multiple participants
• Autonomic and self-organizing systems like self-monitoring, slef-repairing, self-optimizing.

## 各种缺点套用模板：

• The technology is still immature and functionalities are limited, like scalability is still an unknown
• Dev Tools are still immature
• Development experience is limited. Bitcoin Blockchain and Ethereum are still the only large-scale deployment of DLT technology. There are still no large-scale commercial applications.

## 比特币的各种具体应用

#### RegTech-Regulation Technology

• 本文由 发表于 2020年7月29日21:37:41
• 转载请务必保留本文链接：http://helloworld2020.net/686/

## ASHRAE KAGGLE大能源预测（前三名方案总结+相关知识点讲解+python实现）

1 概述 先上第一名分析的图 2 处理思想学习 2.1 移除异常值 Long steaks of constant values 1. 恒定值的长条纹 Large positive/negative ...

## 第十七名 百度无人车目标检测 项目文档

password:42134 1. 比赛概述 对于自动驾驶的汽车来说，附近汽车的位置是一个非常关键的问题，这也是这次比赛的目标。 近年来，无人驾驶汽车已经有了很大的发展，但是并不是完美无缺的。消费者和...