Bitcoin Forum
December 08, 2016, 07:57:27 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: adg  (Read 1084 times)
Anonymous
Guest

adg
November 29, 2010, 07:34:59 PM
 #1

adgadg
1481183847
Hero Member
*
Offline Offline

Posts: 1481183847

View Profile Personal Message (Offline)

Ignore
1481183847
Reply with quote  #2

1481183847
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481183847
Hero Member
*
Offline Offline

Posts: 1481183847

View Profile Personal Message (Offline)

Ignore
1481183847
Reply with quote  #2

1481183847
Report to moderator
1481183847
Hero Member
*
Offline Offline

Posts: 1481183847

View Profile Personal Message (Offline)

Ignore
1481183847
Reply with quote  #2

1481183847
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


View Profile
November 29, 2010, 07:54:04 PM
 #2

vb.net has a nice little json library for it at http://www.pozzware.com/pozzware/Corsi/Programmazione/VB.NET/JSON%20Library.aspx
Asp has some too http://code.google.com/p/aspjson/

Server grabs the getwork json from the bitcoind, and passes it onto the client software. I'm building a sqlite back (because that's what I use, not berekelydb, sorry) and it tracks usage based on the bitcoin address for near hits.

.net already has the libraries needed for sha256

Imports System.Security.Cryptography
hash = New SHA256Managed()
Dim hashinBytes As Byte()
hashinBytes = hash.ComputeHash(hashhere)

What would I take from the getwork and toss inside there?

The basic mining algorithm looks like this:  sha256(sha256(data)), where "data" is the "data" member returned by 'getwork' RPC.

However, one complication with standard sha256 library implementations is that they will byte-swap input data, to change the input data into big endian format, which is normally required for endian-neutral sha256 to work on all platforms.

To increase speed, bitcoin has already performed that byte-swapping for you.

Which means that, to use a standard library (.net or whatever) implementation of sha256, you need to byte-swap your data again, to change it to little endian, then let your .net sha256 byte-swap back into big endian.


Quote
I'm looking at jgarzik's little c miner, and hash1, data, etc, those all are fine, but what is the hash variable he is passing in there as well?

'hash' is the output of sha256(sha256(data)), ie. the sha256 hash.

Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


View Profile
November 29, 2010, 08:25:25 PM
 #3

The basic mining algorithm looks like this:  sha256(sha256(data)), where "data" is the "data" member returned by 'getwork' RPC.

However, one complication with standard sha256 library implementations is that they will byte-swap input data, to change the input data into big endian format, which is normally required for endian-neutral sha256 to work on all platforms.

To increase speed, bitcoin has already performed that byte-swapping for you.

Which means that, to use a standard library (.net or whatever) implementation of sha256, you need to byte-swap your data again, to change it to little endian, then let your .net sha256 byte-swap back into big endian.

That's simple enough. What about the nonce? data&nonce?

nonce is a 32-bit (4-byte) value patched directly into 'data' at a particular offset.


Quote
You've got one more question for me now though, what do I return to getwork[data] ? If I just return the found hash that meets the requirements, how will it know what nonce was used?

You return 'data', modified with a nonce that results in a hash containing a sufficient number of leading zero bits.

Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!