bitcoincashorg / spec

Technical specifications
112 stars 64 forks source link

Implemention questions about cash addresses #41

Closed afk11 closed 6 years ago

afk11 commented 6 years ago

Hi all,

Want to get ahead of the bitcoin cash address change, glad to see it's happening at last. I wanted to ask about the specification, as reading it, I can see there are indeed a couple of differences with bip173. So far yet to get my code reproducing test fixtures, but had some comments following a review of it vs bip173

If you check this line, it looks like a possible bug in the spec (though happy to have my error pointed out): https://github.com/Bitcoin-UAHF/spec/blame/master/cashaddr.md#L87

How could the final condition ever be true? ah, I guess by that point c can have all bits set, nevermind.

I was confused about why the field constants were changed at all - just means having to add more parameters to a bech32 implementation (the field constants, CSLEN and SEPARATOR from what I can tell) or just duplicate the whole thing.

Another minor point about the choice of ":" for the separator - double clicking the addresses will only select one half of it.. I think this should be a consideration whilst selecting characters for an address humans copy/paste around, but at the end of the day it's only a usability issue.

DesWurstes commented 6 years ago

0x01 = 0 * 16^1 + 1 * 16^0 = 2^0, 1st bit 0x02 = 0 * 16^1 + 2 * 16^0 = 2^1, 2nd bit 0x04 = 0 * 16^1 + 4 * 16^0 = 2^2, 3rd bit 0x08 = 0 * 16^1 + 8 * 16^0 = 2^3, 4th bit 0x10 = 1 * 16^1 + 0 * 16^0 = 2^4, 5th bit

So, no errors.

afk11 commented 6 years ago

Thanks, that cleared up my first question.

I've got it implemented and working now, one thing that bothers me is the need to use uint64_t here.. A lot of people have bech32 in their codebase, but if they want to support cashaddr, they need to move away from bitwise operations on primitive scalar values to working with a bigint library. You have to implement the entire thing from scratch even though it's 99% the same :/

DesWurstes commented 6 years ago

I agree with you on this point. Not all languages have unsigned and 64 bit integers, which causes problems and makes things harder. However, it looks like it's a bit late to change it, it would damage adoption.

deadalnix commented 6 years ago

You need 40 bits precision, so any language that has doubles can do it.