首页 > 其他分享 >CE235 Computer Security Bitcoin

CE235 Computer Security Bitcoin

时间:2024-12-09 20:23:50浏览次数:4  
标签:nonce CE235 Bitcoin signed number key signature Security block

Assignment 2: Blockchain and Mining with Proof-of-work for Bitcoin

CE235 Computer Security

  1. Introduction

1.1 Bitcoin Mining Bitcoin is a cryptocurrency. In the Bitcoin system Bitcoins are mined through proof-of-work mechanism.

Bitcoin miners are given technical puzzles to solve. There is only one puzzle at any time with a given difficultylevel, which is set by the system administrator. New puzzlesare created after the current one is solved.The first miner who solves the puzzle is awarded a specified number of bitcoins. The winner creates and sign anew block with digital signature technology and broadcast to other Bitcoin users. The signed block is linked to

the previous signed blocks. These blocks form a chain of blocks (called blockchain) as shown in the followingfigure. The new signed blocks are verified by others and could become mature after being confirmed by a givennumber of miners, which is measured by length of blocks linked to the new blocks.

1.2 Technical puzzle

The puzzle set in the proof-of-work is to find a specific integer number (called nonce), which together with afew other numbers (such as hash value of the previous block, the transactions to be included to the new block)are hashed with SHA-256 algorithm and the hashed value satisfies a given condition.The puzzle can be formulated as follows:where preHash is the hash value of the previous block, Tx is transaction of bitcoins. levelHard is a given number,usually controlledby requiring a consecutive number of most significant bits (MSB) being zeros, for examplethe first 30 MSBs being zero. The more MSB zeros required on levelHard, the more difficult to solve the puzzle(finding the nonce satisfying the condition). Below gives a binary number with the 15 MSB being zeros and 5least significant bits (LSB).

(MSB) 00000000000000011100000101111110011010101100000 (LSB)

1.3 Signing and verifying a new block The first miner solving the puzzle will create a new block, which includes a block header (storing the digital

signature of this new block, which will include the hash value of the block body) and a block body. The blockbody includes the hash value of the previous block, the foundnonce and transactions included in this block.代写CE235 Computer Security Bitcoin  Thedigital signature is created by encrypting the hash value of this new block with private key. The block is linkedto the last block of the existing blockchain and broadcast. The new block will then be verified by others using

he winning miner’s public key and checking the hash values of this and previous blocks.

Block n find nonce, subject to: hash(preHash, nonce, Tx) < levelHardThis assignment takes 18% of the marks (18 marks) of this module. The aim of the assignment is to write aPython program, which will implement a simplified version of Bitcoin mining and digital signature schemes asshown in the following figure, with additional task of protecting the confidentiality of the signed message (fromby encrypting/decrypting the signed message (such as with an extra RSA key pair for the validator).

2.1 Task1: Create a RSA public/private key pair with 1024 bits key length [1 mark]

o The RSA key pairs will be used in Task3 and Task4 of this assignment.

o The created RSA public {n,e} and private keys {n,d} need to be displayed with the followingformat:

2.2 Task2: Find a nonce with hash algorithm SHA-256, which is a hash value satisfying requirement of the 6 least significant bits (LSB) being zero [4 marks]. Produce a figure (or a table) which shows the computation time (denoted by T) used to find a valid nonce by your own computer against the number of required LSB being zero (denoted by N) changing from 1 to 8 [3 marks].

o Hint: you can extend Example 4 in the provided sample program to complete this task. Example 4

generates only one nonce and check if the nonce is valid.o You should try many random integers as nonce (with a loop) until you successfully find a noncethat meets therequirement. The only output from this task is the nonce, which needs to be displayedwith the following format (suppose the found nonce is 12345):

o You can use your program to produce the figure/table automatically, or you can record thecomputation times and create the figure/table using other software, then present it to the teachingstaff members during your demonstration. Not to submit the figure/table to Faser.

2.3 Task3: Digitally sign the nonce and your student number with the RSA private key [3 marks]

o The message to be signed is a string consisting of the nonce (found with 6 LSB being zero) andyour student number, which are separated by a space. For example, if the found nonce is 12345 andyour student number is 54321, then the message to be signed needs to be a string “12345 54321”

o You need to sign the message with RSA key pair generated in Task 1.

o The outputs of this Task3 include the hashed value of the message and the signature, which need tobe displayed with the following format.13Valid Nonce: 123452.4 Task4: Verify the signature [3 marks]

o The signature verification is to be achieved by decrypting the digital signature with public key{n,e} generated in Task 1 to get the hash value from the signature andcompare it to the oneobtained from hashing the signed message.

o The process of signature verification needs to output yes or no depending on the verificationoutcome.

2.5 Task5: Protect the confidentiality of the signed message from Task 3 by encrypting/decrypting

the signed message [4 marks]

o You should generate another RSA key pair for the validator.

o The signed message should be encrypted with a key of the validator by the user who signs themessage.

o The encrypted signed message should be decrypted with another key of the validator before thesignature validation by the validator.

  1. Sample ProgramWe provide a sample python program miningBitcoin_sample.py, which includes most of the needed

RSA encryption and digital signature functions to complete the above tasks. It can be run from integrateddevelopment environments (IDLE). It can also be run from the command line like this:python mingingBitcoin_sample.py

You should modify the sample python program to complete the tasks. Your own program should have a namelike cs_bitcoin_registrationnumber.py (replace registrationnumber by your own registration number). Forexample, if your registration number is 1234567, your filename will be:

cs_bitcoin_1234567.py

Your program must run from the command line like this:

python cs_bitcoin_1234567.pyThe outputs of your program are required to be displayed, following the specified format for marking purposes.

 

标签:nonce,CE235,Bitcoin,signed,number,key,signature,Security,block
From: https://www.cnblogs.com/BUS001/p/18594185

相关文章

  • 综述Security and Privacy Challenges of ✌Large Language Models A Survey
    文章较长,阅读时长警告⏰!欢迎大家多多支持&推荐!......
  • Spring Security集成JWT
    1.JWT基础1.1.JWT是什么:JWT(JSONWebToken)是一种用于在不同系统之间安全地传递信息的无状态令牌。它通常用于身份验证和授权,尤其在现代Web应用和API中非常常见。JWT是通过对传输的数据进行编码和签名来确保其完整性和安全性。JWT的特点:无状态:JWT不需要在服务器端保存状......
  • SpringSecurity - [01] 概述
    SpringSecurity是一个灵活且强大的工具,可以帮助你构建安全可靠的Spring应用程序。它不仅简化了认证和授权的过程,而且还提供了丰富的特性和扩展点,使得开发者可以根据项目的独特需求定制安全策略。无论是小型的内部工具还是大型的企业级应用,SpringSecurity都能提供必要的安全保......
  • 十、Spring Boot集成Spring Security之HTTP请求授权
    目录前言一、HTTP请求授权工作原理二、HTTP请求授权配置1、添加用户权限2、配置ExceptionTranslationFilter自定义异常处理器3、HTTP请求授权配置三、测试接口1、测试类2、测试四、总结前言本文介绍HTTP请求授权工作原理、配置及适用场景,配合以下内容观看效果更佳!!!什么是授权,授......
  • Spring-线程池执行save语句报错“ No SecurityManager accessible to the calling cod
    报错信息:Cause:org.apache.shiro.UnavailableSecurityManagerException:NoSecurityManageraccessibletothecallingcode,eitherboundtotheorg.apache.shiro.util.ThreadContextorasavmstaticsingleton.Thisisaninvalidapplicationconfiguration.ator......
  • Security, Privacy and Ethics
    Security,PrivacyandEthicsCoursework2B:EvaluatingthepotentialrisksandbenefitsofAItechnologiesonprivacyandpersonalLearningoutcomesassessed:dataC:UnderstandingtheimportanceoffairnessinAIsystemsanditsimplicationsOverview......
  • 九、Spring Boot集成Spring Security之授权概述
    目录前言一、授权概述二、用户权限三、用户授权流程三、SpringSecurity授权方式1、请求级别授权2、方法级别授权前言本文介绍什么是授权,SpringSecurity的授权配置有哪些,配合以下内容观看效果更佳!!!什么是授权,授权有哪些流程,SpringSecurity的授权配置有几种?请查看九、SpringB......
  • SpringSecurity用户登入认证
    Maven依赖<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.5</version></parent><dependencies><!--SpringBo......
  • Bitcoin;Schnorr签名;Schnorr签名聚合算法组成
    文章目录概要Schnorr聚合签名概要数字签名是Bitcoin的基本加密构建块,用于验证交易的有效性。当用户向Bitcoin主网提交交易时,数字签名用于满足以下三个关键功能:真实性:数字签名验证用户的身份和交易中包含的资金来源,以确保只有相应私钥的所有者才能授权使用相关资金。......
  • 重学SpringBoot3-集成Spring Security(三)
    更多SpringBoot3内容请关注我的专栏:《SpringBoot3》期待您的点赞......