Lurker News

Comments (102) 25 threads

inersha9 replies#
I wanted to understand how SHA-256 works, so I made a terminal animation that shows the bitwise operations at each step. I wrote a text guide in the README.md to explain what's going on. I think my technical terminology is okay.

I'm new to hash functions though, so I don't yet know why SHA-256 has been designed in the way it has (e.g. why exact numbers were chosen in the bitwise rotations).
As far as I understand, the Sigma functions promote diffusion of bits to help prevent collisions, and Choice/Majority/Addition help to make it a one-way function, but I'm not entirely sure. I'd be interested in learning more about the design if anyone has experience in this field.

baicunko1 reply#
This is a great idea of showing something that is at first very complex. Could be used in Discreet Mathematics to teach students!
m4r35n3571 reply#
Indiscreet mathematics?
perl4ever#
Somewhere I had the idea concrete math was a combination of continuous and discrete, but I seem to be mistaken.

"When DEK taught Concrete Mathematics at Stanford for the first time, he explained the somewhat strange title by saying that it was his attempt to teach a math course that was hard instead of soft. He announced that, contrary to the expectations of some of his colleagues, he was not going to teach the Theory of Aggregates, nor Stone's Embedding Theorem, nor even the Stone-Cech compactification. (Several students from the civil engineering department got up and quietly left the room.)"

ImJasonH#
This is super impressive, thanks for building and sharing it!
w0utert#
Like it a lot. Not sure how useful it is but just looking at it is mesmerizing, well done!
lewiscollard#
Nice work, and that is a very cool approach to learning new things!
mabbo1 reply#
> I wanted to understand how SHA-256 works, so I...

... taught everyone else how SHA-256 worked...
This is an awesome intro. And now I also want to know more about the things you mentioned wanted to learn more about.

tialaramex1 reply#
Without any doubt I do not properly understand anything I can't explain to someone else.

An exercise I go through constantly is figuring out how to explain a thing I think I know to a curious person with no relevant training. Often in the process I discover I need to go do more research or actually test things because I did not understand them as well as I'd maybe thought.
Mostly this is just an exercise. But every so often I actually get to use this in anger. A non-technical friend who works in a Computer Science department asked me on Facebook to explain a joke she'd seen which involved localhost addressing, and I was very pleased to be able to provide a concise explanation using analogies that I know hold up to scrutiny. Obviously a joke isn't very funny if you need it explained, and I can't fix that, but I can avoid the discomfort of her not understanding a joke other people are laughing at in her place of work.

bradjohnson4 replies#
I realize it's not what you're saying, but I don't like the idea that if you can't teach something to others, you don't understand it yourself. Teaching is a skill and it's something that I am aware that I struggle with. I can explain something in great detail to a captive audience and understand it myself personally, but teaching is about getting others to engage with the ideas you're presenting and identifying and elaborating on parts that they don't understand.

Given the content of knowledge sharing sessions that I sit through and the convoluted nature of some of them, I wish that people recognized that presenting information is not all that is required to teach. You can understand something perfectly, but teach it horribly.

Continue this thread — 4 replies

Zhyl3 replies#
1) I loved this video.

2) I did have to take a sip of tea and think about my life when I realised I was watching a video by a Welshman about mining.
3) Although having said this, 'Welsh Bitcoin Miner' is going to fit seamlessly into my West Country themed cyberpunk adventure 'Cider Punk'.

inersha#
1) Thank you.

2) It's certainly a combination I never anticipated.
3) I look forward to the book.

mystickphoenix#
You could call it CIDR Punk if you want to be a bit more on-the-nose ;)
hinkley#
I feel like this is some sort of James Watt reference but I can't be sure.
stan_rogers1 reply#
There's nothing particularly special about the constants. They needed a set of n constants to work with and the "cube root of first n primes, truncated" scheme is a "nothing up my sleeve"[0] construction. If they'd used magic numbers with no obvious generation scheme, you'd be left wondering if that was done as a way to put a back door in place.

[0] https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number

jmiserez#
That's also the explanation the author gives in chapter 4.

I'm more interested in how they came up with the parameters for the sigma functions. I'm sure it's described somewhere.

imoverclocked1 reply#
Congratulations on the worlds slowest and useful SHA-256 implementation! :)
jonathanzufi1 reply#
This is fantastic - and your YouTube video is also impressive. Thank you for doing this.
inersha#
No problem at all, thank you.
dnadler1 reply#
This is phenomenal. The animations at the top were way too quick for me to understand, but they pulled me in. The step-by-step explanations below (alongside the relevant parts of the animation) were very clear and interesting.

I had the big picture from the top of the page, and each section gave me a little more insight into what was going on. Great use of animation, and also very clearly written!
I also like the testimonials.

inersha#
Thank you for being so kind, it means a lot.
jonplackett7 replies#
I once heard about a meeting where someone did a presentation for the best part of an hour to a room full of Japanese people. They all nodded along, smiling as the presentation progressed. It wasn’t until the end that the presenter asked them what they thought. They all just kept smiling, but no answer. Someone at the front turned and talked to the room (in Japanese) then turned to the presented and said “they do not speak any English, but they are sure from this presentation that you are very, very intelligent”.

I feel like the Japanese people. I don’t understand what you’re doing here but I am convinced it is very clever.

ghoshbishakh#
You made my day
tamiral#
i just felt like i was in the matrix for a little bit and that was ok for me :)
jmiserez1 reply#
Did you see the README.md? It explains each of the steps.
rhacker#
Thanks for pointing that out - I kinda missed it until seeing your post. I went through each step - it's still a bit convoluted, but definitely helps me appreciate hashing functions. It's probably very easy for a poorly coded hash function to accidentally wipe important data or accidentally and a bunch of data with zeroes, so it's pretty cool to see a lot of ROT and XOR usage which does more interesting things with the original data.

Had no idea about the prime roots and multiplication, that's pretty clever too.

kebman#
That video is really, really awesome! And it won't leave you feeling "Japanese" either. (Which is a great people, btw. I'd really like to go there someday, mostly for the food and language and history. And Anime also, I'm forced to admit.)
chias1 reply#
There's a few things in there that are factually incorrect -- in particular, the false notion that "every input has a unique output" can be quite dangerous in some cryptographic settings.

That said, the purpose of this talk is about the mechanics of the function, and not its properties or how to use it safely. So don't let that detract from what is, really, an awesome presentation.

tridentboy11 replies#
I'm sorry, could you please elaborate? I was always under the assumption that hash functions have to be deterministic, and thus, that "every input has a unique output" was a correct statement.

AFAIK the contrary is invalid, so that "not every output is the result of one and only one input".

Continue this thread — 11 replies

tzs#
Anecdotally, based on experience with shipping software with an annoying bug to Japanese consumers, the Japanese people are way more patient than Americans.

I worked at an American company that made utility software for DOS/Windows. A major Japanese distributor liked our stuff, and made a distribution deal with us. They also helped with localization, and suggested feature changes to better fit what Japanese consumers wanted. Later this expanded to where they would also suggest new products they wanted for Japan and we'd develop them.
One product under development was very rarely causing a system lockup during installation. By "lockup" I mean it appears completely dead. No mouse motion. No keys worked. Hitting "CAPS LOCK" would not even toggle the light on the keyboard. Hard reset seemed to be the only way out.
It was rare enough that we always saw the install attempt after that hard reset work.
We just could not figure out what was causing this. The Japanese distributor decided we should go ahead and release, and their tech support people would deal with any complaints.
So we released...and their tech support got a lot of calls. People were hitting it a lot more than we had seen in testing.
...except they were not calling to complain about their system locking up. No, they were calling to complain about a slow install.
Apparently, when it became completely unresponsive all you had to do was wait 20-25 hours and it would complete the install.
I cannot imagine any American consumer whose PC has become completely unresponsive going 20-25 hours without giving up and resetting the thing. Not only were there such people in Japan, there were a lot of them. We didn't get one complaint about a lockup--all of the many many people who called called about it taking around a day to finish.
(Oh, and the knowledge that it was not a complete lockup was enough of a clue to let us figure it out. It suggested it was some sort of timeout, not a lockup. Our product needed to know what optical drives were available, and it turned out that the way it scanned for them did not get alone well with one particular brand of optical drive controller card, which could trigger about an hour timeout per drive checked for. We switched to a much more cautious drive scan, and the problem went away).

adrianmonk#
Lore from an old company of mine says that we had the opposite of this happen. We had an opportunity to expand from the US into China. So a dedicated team spent months localizing our English-only software into Chinese.

Our sales people traveled to a key meeting with execs at the Asian division of a multinational corporation (the potential customer). They did a big demo to show the software working in Chinese, hoping to impress the execs with how the software was ready to go.
The execs awkwardly said essentially, "Hey, that is probably great, but even though we handle the Chinese market, we don't speak Chinese; it's only our customers that do. So we couldn't tell what your software does, and we wouldn't be able to use this. Do you have an English version?"

tripzilch1 reply#
> “they do not speak any English, but they are sure from this presentation that you are very, very intelligent”

I kind of hope there's some nuance to this story and it didn't quite happened in the way you described.
If they think it's "polite" to let a person talk for an hour without understanding a word of it (while nodding and smiling), and then have the nerve to call it "intelligent", that's an insult to both the presentor and the concept of intelligence.
Cultural differences notwithstanding, the idea of "completely wasting someone's time while pretending to pay attention" shouldn't be too difficult to empathise with.

Sebb767#
It's probably mixed with avoiding confrontation and thinking that the other people understand it. I'd assume that calling it intelligent didn't have a belittling tone, but rather a 'still awesome, sad I didn't understand it' one
crousto2 replies#
Very nice!

This also has potential for landing in many movies where a hacker at work is involved.

kansi#
True, it has to be used as encryption cracking software! :D
aasasd#
Indeed, I'm hoping that it ends up in movies so they finally have actually relevant visuals. Someone send this to Hollywood.

Load more comments