废柴的我该如何谈恋爱?

一亩三分地论坛

 找回密码
 Sign Up 注册获取更多干货
坐标湾区
DreamCraft创始团队
招聘游戏开发工程师
游戏初创公司招聘工程师、UIUX Designer和游戏策划
码农求职神器Triplebyte:
不用海投
内推多家公司面试
前Google华人高管创立
面试offer一键直通
Leap.ai助你进入热门独角兽
查看: 1069|回复: 4
收起左侧

请教作业咋做-Bitcoin

[复制链接] |试试Instant~
我的人缘0
mysongofjoy 发表于 2018-6-30 07:35:24 | 显示全部楼层 |阅读模式
本楼: 【顶】   0% (0)
 
 
100% (6)   【踩】
全局: 顶  62% (22)
 
 
37% (13)  踩

[Coursera]Bitcoin and Cryptocurrency Technologies #1 - 2018-07-09@Princeton

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?Sign Up 注册获取更多干货

x
第一课 聊了一下,居然作业我都看不懂,到底我该作什么?这个不是为了求职,是看旁边的人炒币,想学一下,没料到这么复杂,求帮助!

Bitcoin and Cryptocurrency Technologies
Assignment 1: ScroogeCoin
In ScroogeCoin (Lecture 1), the central authority Scrooge receives transactions from users. You will
implement the logic used by Scrooge to process transactions and produce the ledger. Scrooge
organizes transactions into time periods or blocks. In each block, Scrooge will receive a list of
transactions, validate the transactions he receives, and publish a list of validated transactions.
Note that a transaction can reference another in the same block. Also, among the transactions
received by Scrooge in a single block, more than one transaction may spend the same output. This
would of course be a double-spend, and hence invalid. This means that transactions can’t be validated
in isolation; it is a tricky problem to choose a subset of transactions th at are together valid.
You will be provided with a Transaction class that represents a ScroogeCoin transaction and has
inner classes Transaction.Output and Transaction.Input .
A transaction output consists of a value and a public key to which it is being paid. For the public keys,
we use the built-in Java PublicKey class.
A transaction input consists of the hash of the transaction that contains the corresponding output, the
index of this output in that transaction (indices are simply integers starting from 0), and a digital
signature. For the input to be valid, the signature it contains must be a valid signature over the
current transaction with the public key in the spent output.
More specifically, the raw data that is signed is obtained from the getRawDataToSign(int
index) method. To verify a signature, you will use the verifySignature() method included in the
provided file Crypto.java:
public static boolean verifySignature(PublicKey pubKey, byte[] message,
byte[] signature)
This method takes a public key, a message and a signature, and returns true if and only signature
correctly verifies over message with the public key pubKey .
Note that you are only given code to verify signatures, and this is all that you will need for this
assignment. The computation of signatures is done outside the Transaction class by an entity that
knows the appropriate private keys.
A transaction consists of a list of inputs, a list of outputs and a unique ID (see the getRawTx()
method). The class also contains methods to add and remove an input, add an output, compute
digests to sign/hash, add a signature to an input, and compute and store the hash of the transaction
once all inputs/outputs/signatures have been added.
You will also be provided with a UTXO class that represents an unspent transaction output. A UTXO
contains the hash of the transaction from which it originates as well as its index within that
transaction. We have included equals , hashCode , and compareTo functions in UTXO that allow the
testing of equality and comparison between two UTXO s based on their indices and the contents of
their txHash arrays.
Further, you will be provided with a UTXOPool class that represents the current set of outstanding
UTXO s and contains a map from each UTXO to its corresponding transaction output. This class
contains constructors to create a new empty UTXOPool or a copy of a given UTXOPool , and methods
to add and remove UTXO s from the pool, get the output corresponding to a given UTXO , check if a
UTXO is in the pool, and get a list of all UTXO s in the pool.
You will be responsible for creating a file called TxHandler.java that implements the following API:
public class TxHandler {
/** Creates a public ledger whose current UTXOPool (collection of unspent
* transaction outputs) is utxoPool. This should make a defensive copy of
* utxoPool by using the UTXOPool(UTXOPool uPool) constructor.
*/
public TxHandler (UTXOPool utxoPool);
/** Returns true if
* (1) all outputs claimed by tx are in the current UTXO pool,
* (2) the signatures on each input of tx are valid,
* (3) no UTXO is claimed multiple times by tx,
* (4) all of tx’s output values are non-negative, and
* (5) the sum of tx’s input values is greater than or equal to the sum of
its output values; and false otherwise.
*/
public boolean isValidTx (Transaction tx);
/** Handles each epoch by receiving an unordered array of proposed
* transactions, checking each transaction for correctness,
* returning a mutually valid array of accepted transactions,
* and updating the current UTXO pool as appropriate.
*/
public Transaction[] handleTxs (Transaction[] possibleTxs);
}
Your implementation of handleTxs() should return a mutually valid transaction set of maximal size
(one that can’t be enlarged simply by adding more transactions). It need not compute a set of
maximum size (one for which there is no larger mutually valid transaction set).
Based on the transactions it has chosen to accept, handleTxs should also update its internal
UTXOPool to reflect the current set of unspent transaction outputs, so that future calls to
handleTxs() and isValidTx() are able to correctly process/validate transactions that claim
outputs from transactions that were accepted in a previous call to handleTxs() .
Extra Credit: Create a second file called MaxFeeTxHandler.java whose handleTxs() method
finds a set of transactions with maximum total transaction fees -- i.e. maximize the sum over all
transactions in the set of (sum of input values - sum of output values)).

Assignment1.pdf

94.8 KB, 下载次数: 15, 下载积分: 大米 -1 升


上一篇:[刷书] Java Concurrent in Practice
下一篇:Introduction to Crypto and Cryptocurrencies开课,召集感兴趣的同学~
我的人缘0
 楼主| mysongofjoy 发表于 2018-7-1 01:57:18 来自手机 | 显示全部楼层
本楼: 【顶】   0% (0)
 
 
100% (2)   【踩】
全局: 顶  62% (22)
 
 
37% (13)  踩
好吧,接受批评。问题是讲课内容泛泛而谈,并没有提到要Java,作业
回复

使用道具 举报

全球28万学生4.7分推荐
我的人缘0
wowmomsos 发表于 2018-6-30 09:54:17 | 显示全部楼层
本楼: 【顶】   100% (2)
 
 
0% (0)   【踩】
全局: 顶  73% (84)
 
 
26% (31)  踩
应该好好学习java先。
其次,mooc有honor code准则的
回复

使用道具 举报

我的人缘2
instant_dev 发表于 2018-6-30 10:38:48 | 显示全部楼层
本楼: 【顶】   100% (1)
 
 
0% (0)   【踩】
全局: 顶  64% (18)
 
 
35% (10)  踩
你应该提出具体的问题,而不是上来就问大家怎么做

评分

参与人数 2大米 +8 收起 理由
charcoal_ + 5 给你点个赞!
JYcommon + 3 给你点个赞!

查看全部评分

回复

使用道具 举报

我的人缘0
codemonk 发表于 2018-7-2 14:40:10 | 显示全部楼层
本楼: 【顶】   0% (0)
 
 
0% (0)   【踩】
全局: 顶  94% (71)
 
 
5% (4)  踩
GitHub找别人写的看看 看懂了自己再单独写。。。
回复

使用道具 举报

游客
请先登录

本版积分规则

提醒:发帖可以选择内容隐藏,部分板块支持匿名发帖。请认真读完以下全部说明:

■隐藏内容方法: [hide=200]你想要隐藏的内容比如面经[/hide]
■意思是:用户积分低于200则看不到被隐藏的内容
■可以自行设置积分值,不建议太高(200以上太多人看不到),也不建议太低(那就没必要隐藏了)
■建议只隐藏关键内容,比如具体的面试题目、涉及隐私的信息,大部分内容没必要隐藏。
■微信/QQ/电子邮件等,为防止将来被骚扰甚至人肉,以论坛私信方式发给对方最安全。
■匿名发帖的板块和方法:http://www.1point3acres.com/bbs/thread-405991-1-1.html

手机版|小黑屋|一亩三分地论坛声明

GMT+8, 2018-9-21 21:42

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表