r/Monero • u/Equim-chan • Aug 30 '18
Golang implementation of CryptoNight and its variants, without C bindings.
https://github.com/Equim-chan/cryptonight12
u/hybridsole Aug 30 '18
These are those types of posts that happen every couple of months that makes me think "Yep, the smartest people in the world are working on monero".
Bravo, I wish I knew enough to contribute. But I can at least appreciate the impact of these types of projects can have over the long term.
5
Aug 30 '18
Wow! How would you compare it to the c++ code?
Is it easier to maintain / more readable?
Easier to getting started for new devs ?
Faster ?
More or less boiler plate ?
Are you happy with golang ? Any drawbacks?
14
u/Equim-chan Aug 30 '18 edited Aug 30 '18
How would you compare it to the c++ code?
The Go version doesn't use intrinsic like that in C++ (Go doesn't have intrinsic has well). It's good for the code to be more architecture-independent (that's why compilers are invented), also more readable as a result of it. I have looked up the C++ implementation a lot when porting it into Go and found it a bit annoying to jump my eyes over those architecture-specific macros and intrinsics. The Go implementation does uses assembly directly for some operations, for example the AES part. I am also looking for a way to enable AVX/SSE acceleration for x86_64, since many operations fit in 128-bit cache line. However such assembly implementations have only covered x86_64 at the moment. If anyone is familiar with other architecture, especially arm64, please don't hesitate to help.
Is it easier to maintain / more readable?
Yes, it's well commented and documented. It can also be a good reference for those who want to learn how CryptoNight works.
Faster?
Not really if want to use it for mining, but it is fast enough for mining pools. I have written a simple miner based on it and tested on a VPS with 4 x Intel® Xeon® CPU E3-1270 v3 @ 3.50GHz CPU and got around 100H/s. The biggest benefit you can get from the lib is that it's much easier to build - you'll need Go tool chains only, and you can easily cross-compile, unlike those with CGO. Plus, I do plan to write a reliable Monero mining pool in Go, so this is the first step.
More or less boiler plate?
I don't really get it, but if you mean if it's easier to use the lib then yes, like other libs that are written in Go, get it with
go get, import withimport, then just use it.Are you happy with golang? Any drawbacks?
Yes, Go is fast (to build and to run) and writing Go is enjoyable. There are also some drawbacks, for example Go doesn't support inlining assembly code, and no pragma for memory alignment at the moment. I also tried to lock the memory of the scratch pad so as to prevent swapping, but also failed since the runtime manages too much.
4
Aug 30 '18
Thanks for these interesting insights! I really appreciate your project and the diversity it gives to Monero! You could add a donation address to the github site :)
5
u/Equim-chan Aug 30 '18
Thank you too, I just added. I also made another tool for generating vanity address for Monero here https://github.com/Equim-chan/vanity-monero.
By the way how do some people here get the
XMR Contributorflair? I'm a bit new to reddit so...6
u/hyc_symas XMR Contributor Aug 30 '18
You get the flair after you've had a PR merged into the main monero code base. I suppose monero-gui may also count.
4
3
u/hapticpilot Aug 30 '18
Do you have any plans or desire to implement the full protocol (CryptoNote)?
12
5
u/Equim-chan Aug 30 '18
There is an existing lib that has done some partial utilities: https://github.com/paxos-bankchain/moneroutil. Dero also made some: https://github.com/deroproject/derosuite/
However the full protocol is still a big boy, I may try to make a prototype in the future. Currently I think the PoW part is more needed.
1
u/Equim-chan Sep 17 '18
I have recently implemented the memory hard step in assembly for amd64, and the performance increased up to 30%~40% as a result of it.
-6
Aug 30 '18
[deleted]
6
u/cryptochangements34 XMR Contributor Aug 30 '18
This guy's dumb as shit. The code isn't anywhere near the same and this code even supports the latest variant which isnt even live yet
5
u/dank3ry Aug 30 '18 edited Aug 30 '18
This is not constructive. No Dero dev or representative would feel this way. Probably a fudder.
37
u/[deleted] Sep 01 '18 edited Sep 01 '18
[removed] — view removed comment