Bitcoin Forum
June 22, 2024, 05:08:37 PM *
News: Voting for pizza day contest
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN] Ħ [HODL] 5% Interest. No Staking Req. Term Deposits 10%. Solo Mining. on: July 01, 2017, 10:50:13 AM
1 GB is required for the lookup table. You can forgo a lookup table and calculate each time of course - if you can calculate faster than you can retrieve from memory, that'll be optimal, but I doubt it.

Anyway, interesting work you've done on this, but I'm skeptical of  - "I'd guestimate a further 10x as the room for improvment" - difficult to make accurate guesstimates like that.

In regards to my guesstimation: Of course it is not accurate... it's in the word. My way of thinking: A new graphics card simply delivers 2-3x more performance than my graphics card. There are AES implementations which are ~2x more performant than mine. I believe this is my first OpenCL code and therefore probably not as good as it gets... a further 2x may be possible here just by how you deploy the workload onto the graphics card. 2-3x * ~2x * 2x = 10x.

In regards to the lookuptable: You have ~250.000x 4KB (let's call them:) cache entrys. With the lookup table you have to calculate every cache entry once (256k calculations), which involves generating 64 SHA512 hashes per cache entry. If you calculate them on-the-fly, you have to calculate every cache entry (very worst case:) 16 times. Now that seems like a bad number at first, because it would take 16 times as long to calculate these cache entrys, but you have to put it in context! Or more specifically: what would be the overall performance decrease?

One way of doing it is mathematically, in which case you would compare
Code:
1GB Look Up Table: 256k*1*64 SHA512 calculations + 256k*15*(AES Key Expansion + 64 blocks *14 rounds of AES CBC encryption)
versus
Code:
No Look Up Table: 256k*16*64 SHA512 calculations + 256k*15*(AES Key Expansion + 64 blocks *14 rounds of AES CBC encryption)
Now the question is how expensive is that SHA512 compared to the AES CBC?

So instead I do it the other way... I implemented both algorithms (with and without Scratchpad) and these are the results I am measuring on CPU:
Code:
Built the 1GB look up table in (ms): 18376
Calculated 256k cache entrys in (ms): 233364
Total time (ms): 251740
versus
Code:
Calculated 256k cache entrys (without look up table) in (ms): 428187

So the penalty hit for not using a 1GB lookup table is 70% in this scenario! And this leaves things out like the fact, that the SHA-512 step has much more optimizations/parallelization possible than a AES-CBC, which would decrease the relative performance hit you would take, after optimization.
You end up with this trade off: Use 1GB of memory versus take a 70% (=0.7x) performance penalty (in the very, very worst case).

Just for a sake of completeness: I did these numbers on my non AES-NI CPU, in a single thread, using the native Java Crypto library, which is faster than my own AES implementation. The worse your AES implementation is, the lower the relative performance hit. The better your SHA implementation is, the lower the relative performance hit.

Conclusion:
Advertising the HOdl algorithm as ASIC proof is total bullshit... the performance penalty when calculating cache entrys on-the-fly opposed to storing them in the 1GB lookup table makes every ASIC builder and their grandmother laugh...


What I don't understand/what I would appreciate if some one would answer:
Where does the algorithm origin from? I don't mean stuff like "it is similiar to Cryptonight" or something like that, but who made this algo? Also there seems to be zero documentation about the algo except for the code itself, which is a bad thing.

All things are not lost, I guess... from what I understand one could make an update to the algorithm via an update? I would strongly suggest it, since as of now, the algo doesn't hold up what it promises imho.
Again: I am _not_ a crypto expert or mathematician. I am simply your average Joe software engineer. And when I see a problem like this... everyone taking a closer look will...

EDIT:
@FreeTrade: I just re-read your post: "if you can calculate faster than you can retrieve from memory, that'll be optimal, but I doubt it" - that is totally besides the point! It is not about what is faster! It is about what are the time/space requirements for the algorithm! Even if not using the lookup table is 0.7x slower, it requires 250000x less memory! This is a great trade off and makes ASICs possible, which still operate on an algorithm, which is 0.7x slower, but do so 1000x faster (=700x total - of course this is not an accurate number again, but you hopefully get the point)!
2  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN] Ħ [HODL] 5% Interest. No Staking Req. Term Deposits 10%. Solo Mining. on: June 28, 2017, 08:20:59 PM
I hope this is the right place to post this:

So I spend the last couple of days to program my first ever miner, which happens to be a HoDL Coin GPU miner... with not so great results. Here my findings so far:
- I am running a Core i3-3200 CPU without AES-NI. This gives me ~7 hash/s on the non-aes hodlminer per CPU thread(w0lf and optiminer keep crashing for me and I doubt they would improve performance as they mainly improve via AES-NI integration from what I understand)
- I started out implementing the hodlcoin algo on CPU and my implementation gave me ~3-4 hash/s per CPU thread
- I ported everything incl. a custom AES implementation to OpenCL (actually I didn't put the SHA stuff on GPU, but it is way less relevant than AES... for every sha execution there are at least 15 more AES executions)
- So my miner gives me now ~60 hash/s on an an rather old HD7850. It's 10-20x faster than the equivalent (unoptimized) CPU implementation. If I optimize the implementation, get something like a RX580 I'd guestimate a further 10x as the room for improvment, resulting in ~600 hash/s.
- and just to make it clear: the implementation _does_ work. I successfully submitted completed work to hodlcoin pool, which got accepted.

Conclusion so far: The GPU implementation as-is is good for people without AES-NI... on the other hand: you can get AES-NI nowadays for less than 50 USD. It may be possible to optimize the miner further, which would maybe even place it above an i7, but the improvement  would still be less than 50% in a rather good scenario. So a GPU miner may be feasable, but don't expect quantum leaps.

Another finding: The "1 GB space requirement" is complete nonsense. Give me 5kb memory and I give you an ASIC...
3  Bitcoin / Development & Technical Discussion / Re: Why does Bitcoin's SHA256 implementation work differently? on: June 23, 2017, 09:42:47 AM
@achow101: Thanks for clarifying... I think I looked at too many bits yesterday. This helps a lot!

@DannyHamilton: Thanks as well for putting in the effort to color it and everything. However you did fake your comment a little bit:
You wrote:
Quote
- snip -
//14508459...57e74b
I wrote:
Quote
//14508459...057e74b
See the additional zero there? That kind of bothers me still... Another implementation contains the zeros as well, so I think there is a problem with my Java implementation... I'll investigate...

EDIT: Simple problem... my Java code was swallowing leading zeros...
Bad code:
Code:
System.out.format("%x", c);
Good code:
Code:
System.out.format("%02x", c);

Thanks again to all here for helping me with this problem!

EDIT2: So just for completness sake in case someone googles this... this Java function seems to produce the same thing as Bitcoin's Hash(...) function:
Code:
static byte[] btcSha256d(byte[] memory) throws NoSuchAlgorithmException{
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] result = md.digest(md.digest(memory));
for(int i=0;i<result.length/2;i++){
byte temp = result[i];
result[i]=result[result.length-i-1];
result[result.length-i-1]=temp;
}
return result;
}
4  Bitcoin / Development & Technical Discussion / Re: Why does Bitcoin's SHA256 implementation work differently? on: June 22, 2017, 09:35:01 PM
Thanks for your reply, I still don't understand the problem though. The array consists of 80 bytes all being of value 0x00. This should be the same regardless of byte order, shouldn't it?

EDIT: I don't know really why, but I tested the byte order just to be sure... as expected it doesn't make a difference for the byte array in question.
5  Bitcoin / Development & Technical Discussion / Why does Bitcoin's SHA256 implementation work differently? on: June 22, 2017, 04:09:17 PM
Hi, I am new here, so if this is the wrong forum, please let me know where this post is better placed.

I was trying to write my own miner, but simply don't understand what the Hash() function in hash.h is doing.
This is my code:
Code:
// allocate 80 bytes of 0x00s
unsigned char* memory = (unsigned char*)malloc(80);
int* result = (unsigned int*)malloc(32);
memory,0,80);
memory,0,32);

seems to be doing hashes under the SHA-256 name
hash = Hash(memory, memory+80);
hash:%s\n",hash.GetHex().c_str());
//14508459...0e57e74b

However when I try to do this with _any_ other SHA256 implementation I always get a different result (I tried three, which gave me the same result). Here is my Java code:
Code:
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] digest = md.digest(ByteBuffer.allocate(80).array());
for(byte c : digest) {
System.out.format("%x", c);
}
//5b6fb58e61fa475939767d68a446f97f1bff2c0e5935a3ea8bb51e6515783d8

I thought maybe I have to double hash, but this leaves me with this:
Code:
MessageDigest md2 = MessageDigest.getInstance("SHA-256");
byte[] digest2 = md2.digest(md2.digest(ByteBuffer.allocate(80).array()));
for(byte c : digest2) {
System.out.format("%x", c);
}
//4be757e8f70eb93640c8468274ba759745a7aa2b7d25ab1e421b259845014

So the hash I get from the Bitcoin implementation differs from any other SHA256 implementation for some reason... what am I missing? Am I using the algorithm wrong? Is it initialized differently (other implementation don't give me a possibility to parametrize the function)? Does it simply work differently (not according to the standard)?

Any help would be appreciated
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!