11 ms·
Show HN: SHAllenge – Compete to get the lowest hash
I've always had an appreciation for the properties of hashing. I especially like the concept of Proof of Work, so I tried to make a little competition out of it.
- chaz6 2y agoThis is my attempt in Rust. I am not a Rust programmer so it is probably horribly inefficient, but it works! https://gist.github.com/Chaz6/81523edaed6f31aa609daa919ff6b8cc https://gist.github.com/Chaz6/81523edaed6f31aa609daa919ff6b8...
- YaBa 2y agoI've made a few changes in my software, use Base64 instead of numerical values, now I'm getting the following error: "Nonce must be 1-64 characters long and consist only of Base64 characteres" Whih is really odd, since my string has only 51 chars and all chars are valid within the Base64 group. If I remove the padding ("=") then it's good to go, however, there is a string in the scoreboard with "=" in it (garethgeorge/AHQAAAHPe0Q=) Did the user bypassed the javascript check using curl or something? Also, this could use some adjustments: const nonceRegex = /^[A-Za-z0-9+/]{1,64}$/; if (!nonceRegex.test(nonce)) { alert('Nonce must be 1-64 characters long and consist only of Base64 characters'); return false; } Personally, I would use const nonceRegex = /^[A-Za-z0-9+/]{1,64}(={0,2})$/;
- jodrellblank 2y agoThe site owner changed equals from accidentally-allowed to forbidden, but left any existing solutions using it. See comment and reply here: https://news.ycombinator.com/item?id=40724707 https://news.ycombinator.com/item?id=40724707
- vkoskiv 2y agoWasn't expecting to stay in the top 100 for this long! Initial C implementation got me to ~70 for a short time, then very sloppy racy pthreads one kept me at the tail end for a bit longer, but my again very sloppy cuda program running on my GTX1070 has me at 35 at the time of writing. Rough calculation shows it to be doing 28.6MHashes/sec, and I suspect I could do a lot better than that if I knew anything about cuda programming. I didn't read enough to know how to pick good values for blocks/threads per block, so I just benchmarked all the combinations of powers of two to arrive at the best result. Really fun challenge! Would be fun to see the total amount of valid submissions, and maybe the number of leading zeroes of a hash for those of us that need a moment to figure it out from hex in their head :]
- korbin 2y agoI'm at about ~22GH/s per Xilinx VU9P UltraScale+ FPGA - at least 40GH/s is possible (for around 250W/device.) The nonce alphabet being limited makes the whole thing quite a bit more expensive.
- jffry 2y agoThat's a beefy FPGA! Wish I had access to one to revive my 2009 era FPGA coursework knowledge but it seems the dev boards start at 5 figures which is too rich for a side project.
- korbin 2y agoYou can obtain them on capable boards on eBay for $600-1000 - https://www.ebay.com/itm/326181455270 https://www.ebay.com/itm/326181455270
- kadajett2 2y agoJust got to 11 zeros with some beginner rust code! Gonna keep it running for a while to see if I can get higher than 24, but this was a ton of fun! And it was my first time doing parallel rust code! I couldn't get wgsl to work properly, as it would need to have a sha256 implementation, and that's a bit heavy for a buzzed coding session. So, I used the simd commands, and that got me up to around 7mh/s on the m1, and a whole lot more on my desktop. I will share the code once I get all the other optimizations I want in!
- neonz80 2y agoYou can probably get a 2x speedup by shortening the string so that it fits in one block.
- kadajett2 2y agoAh, nice! I will shorten it after I finish the simd addition! I didn't even think of that. I was just overcomplicating my thread partitions to avoid collisions.
- kadajett2 2y agoUsing simd properly(I think) and lowering the nonce text, I went from that 7MH/s to 10MH/s I have a bunch of other ideas to get me to my goal of 20, but I am happy to let this run for a bit! Thanks for the suggestion!
- kadajett2 2y agoAlso, Oi tudo bem @quirino?!? Will you be posting the number of competitors at any point? I would love to see how good my 24 is in the grand scheme!
- quirino 2y agoHey! Tudo bem :) Sorry for the late reply. I've added a "/data" endpoint where you can get the full database in json format.
- JSDevOps 2y agoQuirky and fun
- jimbobthrowawy 2y agoI like that you linked to a javascript miner. Makes it really easy to try instead of needing to write up some code. Design/colour scheme is nice too.
- quirino 2y agoThank you! Curiously most of the code for that JS miner was written on my phone, with the help of ChatGPT. I didn't have my laptop with me and was curious how fast a phone browser would be able to mine.
- Toutouxc 2y agoCoding and testing JS with the help of ChatGPT is several multitasking levels above what I’d be willing to even try on a phone. Android, I assume? Big screen? BT keyboard even?
- quirino 2y agoIt was actually much easier than I expected. Just asked for it as a single HTML page, copied the output to a file and opened it on Chrome. Did very few adjustments.
- logicallee 2y agoCan you share that ChatGPT conversation, please? (There is a share link in ChatGPT.) Thank you.
- NAHWheatCracker 2y agoI ran the javascript miner for like an hour, then I asked ChatGPT to write some go code that worked perfect (minus an unused variable error). The go program beat the javascript miner within seconds. Right now it's that easy to get into the top 10.
- quirino 2y ago
- londons_explore 2y agoAnyone got a guestimate as to the energy used to make that leaderboard?
- emigrantdd 2y agoit's just for fun? :)
- playingalong 2y agoFun or not, but I think the parent means electricity, i.e. how much kWh were wasted/spent on this
- NAHWheatCracker 2y agoChatGPT says a desktop CPU uses 105Wh for every hour of maxed computations. I think a hash with 8 leading zeros takes around an hour and every additional 0 takes 16x that. I'll ignore anything less than 8 0s and disregard how close the hashes are to gaining or losing a 0. There's 13 8s, so that's 1365Wh. 5 9s is 8400Wh, 2 10s is 53760Wh, 3 11s is 1290240Wh. Total that's ~1.35MWh, which might cost $100 to $180. Very weak estimate, though.
- quirino 2y agoThe top competitors are very likely using GPUs, I guess that would make this cost much much lower...
- jonas-w 2y agoAt least I'm not (second place currently), I'm using a single threaded rust program that chatgpt wrote for me. I'm getting 10-15 million hashes per second. But seletskiy is, as you can see in his nonce which tells us that he uses an RTX4090 and has 18 Giga Hashes per second. I'm really curious how he wrote that program, as I have a Rx 7900 XTX and would love to use it for this competition haha
- 2y ago
- playingalong 2y agoWould it make sense to have some partial/incremental SHA256 implementation? E.g. one that gives the first character only (in ASCII representation). So that you could have a cheaper money miner to narrow down the search space? Is it even possible to have cheaper first character SHA256 algorithm?
- NAHWheatCracker 2y agoSHA256 doesn't generate characters, it generates bytes that are usually rendered in hex form, which gives you the "first character". There isn't a known way to calculate just the first bytes of a SHA256 hash faster. Each step in SHA256 depends on the value of the previous step, so you have to calculate the whole thing through. SHA256 is meant for cryptography and would be considered vulnerable to attacks if a shortcut were known.
- Thorrez 2y ago>Is it even possible to have cheaper first character SHA256 algorithm? What would be the goal of that? Do you want a cryptographic hash function, or do you want something else?
- jjmarr 2y agoWell, such an algorithm existing would be a massive breakthrough in cryptography research. The answer should be no since that make it easier to do a preimage attack than brute-force.
- grishka 2y agoNo. Hash functions are specifically designed to make any shortcuts impossible. Essentially, they consist of many steps of scrambling the input bits, each step taking as its input the output of the previous one. If any such shortcut would be found, it would be considered a vulnerability, and the use of SHA256 for anything involving cryptography would be strongly discouraged.
- noman-land 2y agoThis is essentially how bitcoin's proof of work algorithm works. They maintain the difficulty by adding 0s as computers get faster.
- cyanydeez 2y agoIsn't the reason more about limiting currency. Most of the crypto bros all hate the money printers. The fact that faster hashers will come about just adds some natural competition, but it's still about limiting money supplies.
- quirino 2y agoThe hashing is about consensus. It's related how a low hash stands as proof of computational power, you can't just fake it. The "adding more zeros" is done automatically, according to an algorithm, so that the time between blocks is more or less the same. There's this incredible MIT course about all of this, it's where I got the idea for the site from: https://youtube.com/playlist?list=PLUl4u3cNGP61KHzhg3JIJdK08JLSlcLId https://youtube.com/playlist?list=PLUl4u3cNGP61KHzhg3JIJdK08...
- noman-land 2y agoThanks for the playlist! I've already been going through the later videos.
- bawolff 2y agoIts about preventing double spending of the same bitcoin.
- olalonde 2y agoThat's incorrect. The money supply is fixed irrespective of the hash rate.
- brokenmachine 2y agoBut it halves every so often.
- KomoD 2y agoFun, no way I'm beating any of the top 10 scores though.
- nzentzis 2y agoGetting into the top ten is still not too hard at this point, if you wanted to. I hacked together a super basic parallel CPU miner quickly before diving into CUDA, and the CPU one still gets a value that beats #7 within a few minutes.
- neonz80 2y agoI put my CPU code up here: https://github.com/neonz80/shallenge-x86 https://github.com/neonz80/shallenge-x86 . It requires an x86 CPU with the SHA256 extension. It manages 1.1 GH/s on an Intel i7-13700K.
- tln 2y agoSuggestion: close submissions after it leaves the front page :)
- lovasoa 2y agoVery fun ! I got to the first half of the leaderboard using Rust and ChatGPT.
- lovasoa 2y agoI am now second place, still running on CPU only on a laptop :)
- quirino 2y agoJust saw you got 12 zeroes! Second place! Did you start using a GPU or where you just insanely lucky?
- lovasoa 2y agoStill CPU only. This is my current solution: https://gist.github.com/lovasoa/9bb6c50feed7bb264c15ae65c6222b45 https://gist.github.com/lovasoa/9bb6c50feed7bb264c15ae65c622...
- paulgerhardt 2y agoAh this brings back fond memories of the EngineYard challenge that consumed HackerNews in 2009[1][2][3][4]. From what I recall it was a bunch of YC founders writing janky cuda code vs djb who proceeded to smoke us all. [1] https://news.ycombinator.com/item?id=704182 https://news.ycombinator.com/item?id=704182 [2] archive link to the dead link in [1] https://web.archive.org/web/20090717104634/http://www.engineyard.com/blog/2009/programming-contest-win-iphone-3gs-2k-cloud-credit/ https://web.archive.org/web/20090717104634/http://www.engine... [3] https://news.ycombinator.com/item?id=716851 https://news.ycombinator.com/item?id=716851 [4] https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=engineyard%20contest&sort=byPopularity&type=story https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
- asciii 2y ago> Win and iPhone 3GS Got a 404 but the title was a nice throwback, $2k in cloud credits too!
- Bluestein 2y agoMight as well ask, as tangentially (even so slightly) related: DAE know of a way to get/generate "vanity" (arbitrary or close) Bitcoin addresses?
- Exuma 2y agoI got an amazing one only to find out Zalgo is not supported EXỦMÂ :[
- grishka 2y agoHuh, I somehow got #32 with my very naive multithreaded thing I quickly wrote in C. One thing I'm kinda amazed about is how quickly the M1 Max goes through 2^32 hashes, it only takes about 80 seconds with 10 threads. edit: up to #28 ;)
- boyter 2y agoI managed to get #69 and then #42 with some Go code I repurposed since I was messing around with HashCash a while ago. Including the code below if anyone is curious. I managed to get a 9 zero hash in under an hour on a M2 Mac Mini using it. Its only about ~3.3 MH/s which is not very impressive, but it was very easy to write. https://gist.github.com/boyter/8600199cc6f4073dc9da380f3224ff25 https://gist.github.com/boyter/8600199cc6f4073dc9da380f3224f...
- grishka 2y agoHere's mine: https://gist.github.com/grishka/ed84e4bbfacfbcf4ddc5e63cfc966c69 https://gist.github.com/grishka/ed84e4bbfacfbcf4ddc5e63cfc96... I suppose the next step for me would be to make use of the GPU, which is a much better fit for this job and I'm sure would increase my hash rate by orders of magnitude, but I researched it for a bit and running code on the GPU on a Mac is cumbersome to say the least.
- boyter 2y agoI have always wanted to learn about GPU programming. Now might be the time.
- grishka 2y agoI couldn't resist, so here's the GPU hasher: https://gist.github.com/grishka/c1be1c035f39564debfd4b195bdfcac4 https://gist.github.com/grishka/c1be1c035f39564debfd4b195bdf... It gets around 232.5 MH/s on the M1 Max. There's also an optimization that exploits the fact that SHA256 is incremental, so the state for the common prefix could be pre-computed and then copied and only updated with the variable part. This yields around 30% performance boost.
- olalonde 2y agoFor comparison with Bitcoin: 00000000 000003da 5849ade5 e2112447 73478c46 5fcdc744 9e247df4 11e97b28 (#1 of leaderboard) 00000000 00000000 0002a2fa b0d010ce 270927e8 c9a698a3 4f5e3d6c 4dbcffd3 (latest mined block) Doesn't seem that impressive but keep in mind that it gets exponentially harder to find additional leading 0s and that the Bitcoin network currently finds such hashes every ~10 minutes.
- WatchDog 2y agoCould someone scan all the mined blocks, and find one that has a plaintext conforming to the submission requirements? Edit: Looking at the data structure for a bitcoin block, for multiple reasons such as magic numbers and length, none of them would be a valid submission.
- taxborn 2y agoThis would be roughly equivalent to finding a SHA256 collision then, right?
- WatchDog 2y agoBefore looking into the actual bitcoin block structure, and realizing this wasn't possible, I thought that maybe hashes were a hash of a hash. A hash is essentially just some random bytes, there is a small chance that the first hash bytes would randomly all be printable characters that fit the submission format, given that the bitcoin network has already done most of the work finding the small hashes, scanning through the blockchain trying to find a hash with a plaintext that fits the submission criteria, should be much less work.
- Retr0id 2y agoThey are hashes of hashes, and in fact I already did scan all* the blocks to check if any of them meet the constraints, just in case (they don't, and it would be extremely unlikely but not entirely out of the question). *as of a year or so ago (my archive is stale and I'm too lazy to update it)
- turbidimeter 2y agoI also find this concept fascinating and made something similar a while back [1][2] but came from a slightly different angle, where people can compete for the title text on the page, for colors and for pixels in a grid (like a small r/place). It uses Peer-2-Peer in the browser and I haven't touched it in a while, but it looks like it still works. :) [1] https://tropical.pages.dev/pow/ https://tropical.pages.dev/pow/ [2] https://news.ycombinator.com/item?id=38934607 https://news.ycombinator.com/item?id=38934607
- quirino 2y agoThanks for sharing! It's similar to mine in many ways.
- jodrellblank 2y agoJust lucked into 33rd place with 16 lines of single threaded C# doing ~1MH/sec. Bug: The site says "nonce: 1-64 characters from Base64 (a-zA-Z0-9+/)" but it accepts "=" as well. Reading the other answers about hand optimised CUDA and parallel Go and Rust, that's probably as high as I'll get.
- quirino 2y agoChose to fix that, but won't delete the submissions that used it. Thanks!
- jodrellblank 2y agoI used a classic cheat code to get a valid entry and a bit higher :D jodrellblank/710260141000+idkfa though why limit the filter to all zeroes, here's double-0 facade... jodrellblank/uhxbvhbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00FACADE F2036CC41D004F2EB0F35B079C589D724D5A49BD796363C9A13C27D8
- neonsunset 2y agoI wouldn't worry, Go is not as fast as everyone believes it to be, particularly for tasks like these, unlike C# - there's a reason Nethermind Ethereum client uses pure C# without ever having to touch C or ASM (the performance critical parts of Geth, another Ethereum client that uses Go, are implemented in C and Go's "asm" instead).
- anacrolix 2y agoI'm sitting on just under 40MH/s on an M1 Pro with a multithreaded Rust implementation I whipped up. I doubt I can go much faster without using the GPU.
- kadajett2 2y agoMan, I can't get higher than 8mh/s on my m1 Pro with multithreaded rust. I already got 11 zeros, but I am now more interested in beating at least 20mh/s. Time to comb through this code :D
- anacrolix 2y agoyeah I wonder what you could be doing differently. feel free to link it and I'll point out anything that could be the issue. I just started on a metal implementation and it's at 320MH/s
- anacrolix 2y agoTurning on the asm feature of sha2 has me on 230MH/s.
- zdimension 2y ago60 MH/s with parallel Rust code (rayon) on a 5900X. Got stuck on 8 zeroes, changed my nonce prefix and got lucky with 9 zeroes after 10 seconds! Currently sitting at #73 and pondering whether to write a GPU solution. https://gist.github.com/zdimension/63d3aa5f04573267f423520e481610ed https://gist.github.com/zdimension/63d3aa5f04573267f423520e4...
- stulentsev 2y agoThere are still some gains to be had on the CPU. I'm at ~570 MH/s on a 5950x
- neonz80 2y agoI'm a bit late to the game, but I managed to squeeze out about 1 GH/s on an i7-13700K.
- deleted 2y ago[deleted]