othiym23 / nonsense-benchmark

suite of servers that don't do anything very interesting, but do it very quickly (and asynchronously)
8 stars 15 forks source link

Clarification about nonce #11

Open halorgium opened 11 years ago

halorgium commented 11 years ago

Generally a nonce is a value which is only used one. I noticed the ruby eventmachine version used the same starting value for each new client.

Is this desired?

$ echo -n 'foo' |nc 127.0.0.1 1337; echo
ok
foo:83
$ echo -n 'foo' |nc 127.0.0.1 1337; echo
ok
foo:83
halorgium commented 11 years ago

Another clarification would be as to whether the last bytes should be NULL (\0) or 0 (\60)

othiym23 commented 11 years ago

I may be misusing the term "nonce"; it's merely a computed value that when combined with the input produces a hash with the desired characteristics.

Another clarification would be as to whether the last bytes should be NULL (\0) or 0 (\60)

To be precise, the proof of work that the servers are computing is a hex-encoded string representation of a SHA256 hash with x of the last hexadecimal digits being 0. Because x is currently 2, it just so happens that this means the last byte of the 32 bytes produced by SHA256 will be 0. Before I had x set to 3, which meant you couldn't take that shortcut (at least not without doing some bitmasking).

That said, the protocol sent over the wire is always ASCII.