Live data from Hacker News

Zcoin implementation bug enabled attacker to create over 500K Zcoins

makebitcoingreatagain.wordpress.com

211–220 of 223 posts

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#211
post #151
post #45

I always wonder how these "five conditions ANDed together in an if" make it past code review in general (i know thats not where the actual bug was). I don't care how brilliant a programmer you are, but mistakes in those are very difficult to grasp.

As convoluted as they can be, what alternatives are there other than nested conditions, which are equally convoluted? Surely if you need to logically compare five variable then you'll be doing it in some variation of 5 chained operations.

There is a couple of ways to do it. From storing your conditions in meaningful variables outside the conditional to pattern matching and more. If conditions aren't the only branching operators.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#212
post #16

Earlier quoted context omitted.

I recently spoke at an event where we talked about the crossover of cryptocurrency and the law with a bunch of attorneys present. Many attorneys spoke up during the Q and A to remind everyone that at the end of the day the legality of anything will be decided by either a jury or a judge. It's going to come down to the arguments both sides make, and I think any defense would have a hard time explaining how what they d…

Is there a recording of this discussion available online?

Unfortunately only a snippet that does not include the back and forth with the audience. https://twitter.com/amyywan/status/829614419671871488

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#213
post #100
post #71

The point I'm about to make in this comment is so old and has been said so many times that we all are tired of hearing it. But why do we use a language like C++ to implement something where we don't wish to have bugs? C++ is not memory-safe (no GC or whatever Rust does), it's not type safe (in the ML sense), it relies on writing to memory a lot (instead of having pure functions). Had this program been written in Ocam…

You are looking at a 1k LOC function in a 7k LOC file with a bug that can be easily spotted by -Wall and you think it's the fault of the programming language? The only thing irresponsible is putting your hard-earned money into the 100th Bitcoin fork maintained by some guy with an Anime avatar. Once you stop trusting the developers it essentially becomes an underhanded ... contest and no language wins.

> maintained by some guy with an Anime avatar

Bitcoin was also created by someone using a Japanese pseudonym, same place anime comes from.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#215
post #172

Earlier quoted context omitted.

Yep. I'd add that if it's a warning you're absolutely certain of, use the warning control pragmas to suppress them, and document why the warning's suppressed. Keep the compiler output clean so you can see where you need to examine.

Yup. I'm a big fan of -Wall -Wextra -Werror If these options are set before you write any code, then these problems don't arise.

Or if you're using clang you can just

  -Weverything
Which does actually turn on all warnings (so you'll probably want to add things like -Wno-unused -Wno-padded).

Under gcc, '-Wall -Wextra -Wpedantic' does not enable all warnings. There are still more than 40 flags you have to give if you really want all of them.

The reason why boggles my mind to this day.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#216

Earlier quoted context omitted.

Hello world in Rust is still 2.5MB if you statically compile all the libraries in since it doesn't strip unused functions. The tools and ecosystem are nowhere near what they are for C++

If this matters to you, it's not hard to get it down to something much smaller.

Of course it matters and I've tried. Using nostdlib wipes out everything, so it becomes all or nothing, which is the problem.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#217
post #201

Earlier quoted context omitted.

Hello world in Rust is still 2.5MB if you statically compile all the libraries in since it doesn't strip unused functions. The tools and ecosystem are nowhere near what they are for C++

> Hello world in Rust is still 2.5MB if you statically compile all the libraries in Still? Since when? Last I checked it was 661kB for Rust vs 829kB for C, and that was quite a while ago. http://stackoverflow.com/a/29461455/2343847

To be clear, you think that 829kB is the size of a statically linked C program that uses printf to print 'hello world'? In visual studio it is 25KB - 40KB. All of musl compiles to under 500KB.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#218

Earlier quoted context omitted.

There could be an important side-effect in condition. Isn't persistent state fun!?

Why have it in an if though?

I am not condoning it, so much as noting what goes wrong when it's easy ;)

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#219
post #192

Earlier quoted context omitted.

Properly unmanaged code will probably always be faster than managed code. But the point still stands. Code in a managed language, identify the hot spots and inject highly performant unmanaged code there. There is no need to go full C++ for 99.999% of all projects.

Like this? http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... How should /unsafe be set with .Net CORE csproj ?

I only knew the command line option which no longer worked. Once I found the project.json

    "buildOptions": {
        "allowUnsafe": true
    }
I was able to fake something for dotnet migrate and find the needed setting:

    
        
            true
        
    

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#220
post #123

Earlier quoted context omitted.

Didn't try, but I could imagine that running -Wall over that codebase produces huge amounts of noise rendering it practically useless, until somebody gets to fix all warnings which are not bugs.

> -Wall over that codebase produces huge amounts of noise rendering it practically useless As a c++ developer I would nope the hell out of there or spend a month fixing the warnings - depending on pay. No way would I work with something in that state long term. > until somebody gets to fix all warnings which are not bugs. Code that is filled with ignored warnings generally gets worse, not better. Having little to no…

Not only that, but using different compilers will also cover more possible warnings.

You can have code without any warnings in clang, gcc and msvc++ compilers and it is probably better than code tested with only one compiler.

Post reply on HN