Bitcoin Forum
April 18, 2024, 11:57:25 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: adg  (Read 1316 times)
Anonymous
Guest

adg
November 29, 2010, 07:34:59 PM
Last edit: September 11, 2011, 04:25:44 PM by davidonpda
 #1

adgadg
1713484645
Hero Member
*
Offline Offline

Posts: 1713484645

View Profile Personal Message (Offline)

Ignore
1713484645
Reply with quote  #2

1713484645
Report to moderator
1713484645
Hero Member
*
Offline Offline

Posts: 1713484645

View Profile Personal Message (Offline)

Ignore
1713484645
Reply with quote  #2

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

Posts: 1713484645

View Profile Personal Message (Offline)

Ignore
1713484645
Reply with quote  #2

1713484645
Report to moderator
1713484645
Hero Member
*
Offline Offline

Posts: 1713484645

View Profile Personal Message (Offline)

Ignore
1713484645
Reply with quote  #2

1713484645
Report to moderator
1713484645
Hero Member
*
Offline Offline

Posts: 1713484645

View Profile Personal Message (Offline)

Ignore
1713484645
Reply with quote  #2

1713484645
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


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, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


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, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!