Skip to content

Instantly share code, notes, and snippets.

🌨️

zhangyaning u2

🌨️
Block or report user

Report or block u2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test.md
[3] pry(main)> privkey = CKB::Key.random_private_key
=> "0xa7bac6960b43f3da6d11963f571385751681f6c32fbfe10bac39f6bbd0f07ac2"
[4] pry(main)> api = CKB::API.new
=> #<API@http://localhost:8114>
[5] pry(main)> wallet = CKB::Wallet.from_hex(api, privkey)
=> #<CKB::Wallet:0x000000000157f700
 @api=#<API@http://localhost:8114>,
 @key=
  #<CKB::Key:0x00000000016e40c8
View lightning-rfc.md
revoked commitment transaction
@u2
u2 / withdraw.md
Created Apr 30, 2019
withdraw result
View withdraw.md
(env37) ➜  synapse git:(merkle_verify) ✗ python devtools/muta-cli/withdraw.py "0xaaa81ab1d9b41e2b740f3972f8b6b2132175afe4" 
['devtools/muta-cli/withdraw.py', '0xaaa81ab1d9b41e2b740f3972f8b6b2132175afe4']
0x19e49D3efD4e81Dc82943aD9791C1916e2229138
<- {'jsonrpc': '2.0', 'method': 'blockNumber', 'params': None, 'id': 1}
-> {'jsonrpc': '2.0', 'result': '0x22', 'error': None, 'id': 1}
<- {'jsonrpc': '2.0', 'method': 'blockNumber', 'params': None, 'id': 1}
-> {'jsonrpc': '2.0', 'result': '0x22', 'error': None, 'id': 1}
<- {'jsonrpc': '2.0', 'method': 'blockNumber', 'params': None, 'id': 1}
-> {'jsonrpc': '2.0', 'result': '0x22', 'error': None, 'id': 1}
@u2
u2 / block_withholding.md
Last active Mar 6, 2019
藏块解决方式
View block_withholding.md

藏块的解决方案

再次汇总下之前我们讨论的内容。对于account + plasma,藏块问题应该是唯一需要解决的问题。其他问题都是有解且可行,只是解决方案实现的难度的问题。我们认为解决藏块有几种方案:

  1. 投票
  2. 增加退出顺序
  3. reveal block挑战

退出即投票

GluonPlasma的方案引入了投票机制,但是我们认为这种投票机制有两个重大的缺陷:1. 需要layer1有一种额外的资产和投票机制,链上投票本身会有很多问题; 2. 投票资产和layer2没有直接利益关联,没有太强的激励。

@u2
u2 / sgx.md
Last active Feb 21, 2019
SGX 演示流程
View sgx.md

在这里演示下CITA SGX的隐私交易的处理流程。

当前以一个转帐合约为例,合约中存储的数据都是密文,SGX中存储了监管方的非对称私钥。

用户发送转帐交易中的金额为密文数据,SGX首先使用监管方的私钥解密出用户私钥,再使用用户的私钥解密出明文数据,

使用明文数据进行计算之后,再将结果使用用户的私钥加密,返回到区块链应用中。

整个解密,计算,加密过程都在SGX中进行,外部世界无法获取任何明文信息。

@u2
u2 / plasma_cash.md
Created Jan 18, 2019
plasma cash note
View plasma_cash.md

https://github.com/loomnetwork/plasma-paper

It should be noted that Plasma improves throughput1 rather than latency.

1 Related Work

Using a sidechain for scalability is thus limited by the security and decentralization tradeoffs introduced by increasing capacity and throughput.

Payment channels feature instant finality since

@u2
u2 / contract_update.md
Created Dec 26, 2018
智能合约升级方案
View contract_update.md

智能合约与传统应用程序有一个不同的地方在于智能合约一经发布于区块链上就无法篡改, 即使智能合约中有Bug需要修复或者业务逻辑变更, 它也不能直接在原有的合约上直接修改再重新发布。 因此在设计之初就需要结合业务场景考虑合理的升级机制。 传统的数据和接口分离的方法,设计难度比较大,需要预先考虑到未来可能的变化情况,比较难适应复杂多变的业务场景。

因此我们考虑了另外一种方案。合约升级可以看成区块链的一次硬分叉, 而在联盟链中可以通过切换新链的方式来进行(以太坊中在分片方案中也曾考虑过通过切换新链的方式)。

具体的方案如下:

View Merge.rs
pub trait Merge {
type Item: Default;
fn merge(&self, left: &Self::Item, right: &Self::Item) -> Self::Item;
}
View pr1420-genesis.json
{
"timestamp": 1540871226689,
"prevhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"0xffffffffffffffffffffffffffffffffff020000": {
"nonce": "1",
"code": "0x6080604052600436106101a05763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663102c2f7a81146101a557806328ccf1fd146101d65780632f68f233146101ed578063317b42ba146102025780633408e470146102175780633cf28466146102455780633fd244191461025a578063609522741461028357806363ffec6e146102aa5780636f25ac3f146102e35780636fbf656a146102f857806370bd1f9e146103185780637f131b8e1461032d57806381830593146103425780638ec1aaed14610357578063984dc34b1461036c5780639d77e42e14610381578063a32737b314610396578063abb1dc44146103ae578063b4a0e24c14610507578063bd755cd81461051c578063bdd5a0ee14610531578063c0c41f2214610546578063cabce7ac14610566578063d5cd402c1461057b578063d722b0bc146105ad578063dd12b51f14610637578063df51aa491461064c578063e077bbca14610661578063e19709e014610676578063e7f43c68146106
View 0-19-genesis.json
{
"timestamp": 1540781497524,
"prevhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"0xffffffffffffffffffffffffffffffffff020000": {
"nonce": "1",
"code": "0x60806040526004361061018a5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663102c2f7a811461018f5780632f68f233146101c0578063317b42ba146101d55780633408e470146101ea5780633cf28466146102185780633fd244191461022d57806363ffec6e146102565780636f25ac3f1461028f5780636fbf656a146102a457806370bd1f9e146102c65780637f131b8e146102db57806381830593146102f05780638ec1aaed14610305578063984dc34b1461032c5780639d77e42e14610341578063a32737b314610356578063abb1dc441461036e578063b4a0e24c146104c7578063bd755cd8146104dc578063bdd5a0ee146104f1578063c0c41f2214610506578063cabce7ac14610526578063d5cd402c1461053b578063d722b0bc1461056d578063dd12b51f146105f7578063df51aa491461060c578063e077bbca14610621578063e19709e014610636578063e7f43c681461064b578063ef5be54314610660578063f87f44b9146106
You can’t perform that action at this time.