* [Bitcoin-development] BIP 38 NFC normalisation issue @ 2014-07-15 12:03 Mike Hearn 2014-07-15 13:07 ` Eric Winer 0 siblings, 1 reply; 22+ messages in thread From: Mike Hearn @ 2014-07-15 12:03 UTC (permalink / raw) To: Bitcoin Dev, Aaron Voisine; +Cc: Andreas Schildbach [-- Attachment #1: Type: text/plain, Size: 1932 bytes --] [+cc aaron] We recently added an implementation of BIP 38 (password protected private keys) to bitcoinj. It came to my attention that the third test vector may be broken. It gives a hex version of what the NFC normalised version of the input string should be, but this does not match the results of the Java unicode normaliser, and in fact I can't even get Python to print the names of the characters past the embedded null. I'm curious where this normalised version came from. Given that "pile of poo" is not a character I think any sane user would put into a passphrase, I question the value of this test vector. NFC form is intended to collapse things like umlaut control characters onto their prior code point, but here we're feeding the algorithm what is basically garbage so I'm not totally surprised that different implementations appear to disagree on the outcome. Proposed action: we remove this test vector as it does not represent any real world usage of the spec, or if we desperately need to verify NFC normalisation I suggest using a different, more realistic test string, like Zürich, or something written in Thai. Test 3: - Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK UPSILON WITH HOOK <http://codepoints.net/U+03D2>, COMBINING ACUTE ACCENT <http://codepoints.net/U+0301>, NULL <http://codepoints.net/U+0000>, DESERET CAPITAL LETTER LONG I <http://codepoints.net/U+10400>, PILE OF POO <http://codepoints.net/U+1F4A9>) - Encrypted key: 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn - Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF - Unencrypted private key (WIF): 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 - *Note:* The non-standard UTF-8 characters in this passphrase should be NFC normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before further processing [-- Attachment #2: Type: text/html, Size: 3885 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 12:03 [Bitcoin-development] BIP 38 NFC normalisation issue Mike Hearn @ 2014-07-15 13:07 ` Eric Winer 2014-07-15 13:19 ` Andreas Schildbach ` (2 more replies) 0 siblings, 3 replies; 22+ messages in thread From: Eric Winer @ 2014-07-15 13:07 UTC (permalink / raw) To: Mike Hearn; +Cc: Bitcoin Dev, Andreas Schildbach [-- Attachment #1: Type: text/plain, Size: 3543 bytes --] I don't know for sure if the test vector is correct NFC form. But for what it's worth, the Pile of Poo character is pretty easily accessible on the iPhone and Android keyboards, and in this string it's already in NFC form (f09f92a9 in the test result). I've certainly seen it in usernames around the internet, and wouldn't be surprised to see it in passphrases entered on smartphones, especially if the author of a BIP38-compatible app includes a (possibly ill-advised) suggestion to have your passphrase "include special characters". I haven't seen the NULL character on any smartphone keyboards, though - I assume the iOS and Android developers had the foresight to know how much havoc that would wreak on systems assuming null-terminated strings. It seems unlikely that NULL would be in a real-world passphrase entered by a sane user. On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net> wrote: > [+cc aaron] > > We recently added an implementation of BIP 38 (password protected private > keys) to bitcoinj. It came to my attention that the third test vector may > be broken. It gives a hex version of what the NFC normalised version of the > input string should be, but this does not match the results of the Java > unicode normaliser, and in fact I can't even get Python to print the names > of the characters past the embedded null. I'm curious where this normalised > version came from. > > Given that "pile of poo" is not a character I think any sane user would > put into a passphrase, I question the value of this test vector. NFC form > is intended to collapse things like umlaut control characters onto their > prior code point, but here we're feeding the algorithm what is basically > garbage so I'm not totally surprised that different implementations appear > to disagree on the outcome. > > Proposed action: we remove this test vector as it does not represent any > real world usage of the spec, or if we desperately need to verify NFC > normalisation I suggest using a different, more realistic test string, like > Zürich, or something written in Thai. > > > > Test 3: > > - Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK > UPSILON WITH HOOK <http://codepoints.net/U+03D2>, COMBINING ACUTE > ACCENT <http://codepoints.net/U+0301>, NULL > <http://codepoints.net/U+0000>, DESERET CAPITAL LETTER LONG I > <http://codepoints.net/U+10400>, PILE OF POO > <http://codepoints.net/U+1F4A9>) > - Encrypted key: > 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn > - Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF > - Unencrypted private key (WIF): > 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > - *Note:* The non-standard UTF-8 characters in this passphrase should > be NFC normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before > further processing > > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > [-- Attachment #2: Type: text/html, Size: 6035 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 13:07 ` Eric Winer @ 2014-07-15 13:19 ` Andreas Schildbach 2014-07-15 13:32 ` Michael Wozniak 2014-07-15 15:13 ` Brooks Boyd 2014-07-15 15:17 ` Jeff Garzik 2 siblings, 1 reply; 22+ messages in thread From: Andreas Schildbach @ 2014-07-15 13:19 UTC (permalink / raw) To: bitcoin-development I think generally control-characters (such as \u0000) should be disallowed in passphrases. (Even the use of whitespaces is very questionable.) I'm ok with allowing pile-of-poo's. On mobile phones there is keyboards just containing emoticons -- why not allow those? Assuming NFC works of course. On 07/15/2014 03:07 PM, Eric Winer wrote: > I don't know for sure if the test vector is correct NFC form. But for > what it's worth, the Pile of Poo character is pretty easily accessible > on the iPhone and Android keyboards, and in this string it's already in > NFC form (f09f92a9 in the test result). I've certainly seen it in > usernames around the internet, and wouldn't be surprised to see it in > passphrases entered on smartphones, especially if the author of a > BIP38-compatible app includes a (possibly ill-advised) suggestion to > have your passphrase "include special characters". > > I haven't seen the NULL character on any smartphone keyboards, though - > I assume the iOS and Android developers had the foresight to know how > much havoc that would wreak on systems assuming null-terminated strings. > It seems unlikely that NULL would be in a real-world passphrase entered > by a sane user. > > > On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net > <mailto:mike@plan99.net>> wrote: > > [+cc aaron] > > We recently added an implementation of BIP 38 (password protected > private keys) to bitcoinj. It came to my attention that the third > test vector may be broken. It gives a hex version of what the NFC > normalised version of the input string should be, but this does not > match the results of the Java unicode normaliser, and in fact I > can't even get Python to print the names of the characters past the > embedded null. I'm curious where this normalised version came from. > > Given that "pile of poo" is not a character I think any sane user > would put into a passphrase, I question the value of this test > vector. NFC form is intended to collapse things like umlaut control > characters onto their prior code point, but here we're feeding the > algorithm what is basically garbage so I'm not totally surprised > that different implementations appear to disagree on the outcome. > > Proposed action: we remove this test vector as it does not represent > any real world usage of the spec, or if we desperately need to > verify NFC normalisation I suggest using a different, more realistic > test string, like Zürich, or something written in Thai. > > > > Test 3: > > * Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK > UPSILON WITH HOOK <http://codepoints.net/U+03D2>, COMBINING > ACUTE ACCENT <http://codepoints.net/U+0301>, NULL > <http://codepoints.net/U+0000>, DESERET CAPITAL LETTER LONG I > <http://codepoints.net/U+10400>, PILE OF POO > <http://codepoints.net/U+1F4A9>) > * Encrypted key: > 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn > * Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF > * Unencrypted private key (WIF): > 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > * /Note:/ The non-standard UTF-8 characters in this passphrase > should be NFC normalized to result in a passphrase > of0xcf9300f0909080f09f92a9 before further processing > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > > > > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 13:19 ` Andreas Schildbach @ 2014-07-15 13:32 ` Michael Wozniak 0 siblings, 0 replies; 22+ messages in thread From: Michael Wozniak @ 2014-07-15 13:32 UTC (permalink / raw) To: Andreas Schildbach; +Cc: bitcoin-development I have a python implementation that seems to pass this test vector: https://github.com/wozz/electrum/blob/bip38_import/lib/bip38.py#L299 On Jul 15, 2014, at 9:19 AM, Andreas Schildbach <andreas@schildbach.de> wrote: > I think generally control-characters (such as \u0000) should be > disallowed in passphrases. (Even the use of whitespaces is very > questionable.) > > I'm ok with allowing pile-of-poo's. On mobile phones there is keyboards > just containing emoticons -- why not allow those? Assuming NFC works of > course. > > > On 07/15/2014 03:07 PM, Eric Winer wrote: >> I don't know for sure if the test vector is correct NFC form. But for >> what it's worth, the Pile of Poo character is pretty easily accessible >> on the iPhone and Android keyboards, and in this string it's already in >> NFC form (f09f92a9 in the test result). I've certainly seen it in >> usernames around the internet, and wouldn't be surprised to see it in >> passphrases entered on smartphones, especially if the author of a >> BIP38-compatible app includes a (possibly ill-advised) suggestion to >> have your passphrase "include special characters". >> >> I haven't seen the NULL character on any smartphone keyboards, though - >> I assume the iOS and Android developers had the foresight to know how >> much havoc that would wreak on systems assuming null-terminated strings. >> It seems unlikely that NULL would be in a real-world passphrase entered >> by a sane user. >> >> >> On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net >> <mailto:mike@plan99.net>> wrote: >> >> [+cc aaron] >> >> We recently added an implementation of BIP 38 (password protected >> private keys) to bitcoinj. It came to my attention that the third >> test vector may be broken. It gives a hex version of what the NFC >> normalised version of the input string should be, but this does not >> match the results of the Java unicode normaliser, and in fact I >> can't even get Python to print the names of the characters past the >> embedded null. I'm curious where this normalised version came from. >> >> Given that "pile of poo" is not a character I think any sane user >> would put into a passphrase, I question the value of this test >> vector. NFC form is intended to collapse things like umlaut control >> characters onto their prior code point, but here we're feeding the >> algorithm what is basically garbage so I'm not totally surprised >> that different implementations appear to disagree on the outcome. >> >> Proposed action: we remove this test vector as it does not represent >> any real world usage of the spec, or if we desperately need to >> verify NFC normalisation I suggest using a different, more realistic >> test string, like Zürich, or something written in Thai. >> >> >> >> Test 3: >> >> * Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK >> UPSILON WITH HOOK <http://codepoints.net/U+03D2>, COMBINING >> ACUTE ACCENT <http://codepoints.net/U+0301>, NULL >> <http://codepoints.net/U+0000>, DESERET CAPITAL LETTER LONG I >> <http://codepoints.net/U+10400>, PILE OF POO >> <http://codepoints.net/U+1F4A9>) >> * Encrypted key: >> 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn >> * Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >> * Unencrypted private key (WIF): >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >> * /Note:/ The non-standard UTF-8 characters in this passphrase >> should be NFC normalized to result in a passphrase >> of0xcf9300f0909080f09f92a9 before further processing >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> <mailto:Bitcoin-development@lists.sourceforge.net> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> >> >> >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 13:07 ` Eric Winer 2014-07-15 13:19 ` Andreas Schildbach @ 2014-07-15 15:13 ` Brooks Boyd 2014-07-15 18:20 ` Mike Hearn 2014-07-15 15:17 ` Jeff Garzik 2 siblings, 1 reply; 22+ messages in thread From: Brooks Boyd @ 2014-07-15 15:13 UTC (permalink / raw) To: Bitcoin Dev [-- Attachment #1: Type: text/plain, Size: 6290 bytes --] I was part of adding in that test vector, and I think it's a good test vector since it is an extreme edge-case of the current definition: If the BIP38 proposal allows any password that can be in UTF-8, NFC normalized form, those characters cover the various edge cases (combining characters, null character, astral range) that if your implementation doesn't handle, then it can't really be said to be "BIP38-compatible/compliant", right? The "passphrase" in the test vector is NOT in NFC form; that's the point. Whatever implementation gets designed has to assume the input is not already NFC-normalized and needs to handle/sanitize that input before further processing. To test your implementation for compliance, you should not be inputting the NFC-normalized bytestring as the password input, you should be entering the original passphrase as the test. My original pull request for this change (https://github.com/bitcoin/bips/pull/29) shows a Python and a NodeJS way to input that test vector password as intended. Some input devices may already handle the input as NFC, which is great, but per the BIP38 proposal, that shouldn't be assumed, so various implementations are cross-compatible. If one implementation assumes the input is already NFC, they may encode/decode the password incorrectly, and lock a user out of their wallet. Android allows different user keyboards to be used, so I'm guessing there's one somewhere that allows manual entry of unicode codepoints that could be used to enter a null character, and with the next version of iOS, Apple devices will also get custom keyboard options, too, so even if the default Apple keyboard does NFC-form properly, other developers' keyboards may not. So while it is an extreme edge case, that is not very likely to be used as a "real password" by any user, that's what test vectors are for: to test for the edge case that you might not have expected and handled in your implementation. Brooks On Tue, Jul 15, 2014 at 8:07 AM, Eric Winer <enwiner@gmail.com> wrote: > I don't know for sure if the test vector is correct NFC form. But for > what it's worth, the Pile of Poo character is pretty easily accessible on > the iPhone and Android keyboards, and in this string it's already in NFC > form (f09f92a9 in the test result). I've certainly seen it in usernames > around the internet, and wouldn't be surprised to see it in passphrases > entered on smartphones, especially if the author of a BIP38-compatible app > includes a (possibly ill-advised) suggestion to have your passphrase > "include special characters". > > I haven't seen the NULL character on any smartphone keyboards, though - I > assume the iOS and Android developers had the foresight to know how much > havoc that would wreak on systems assuming null-terminated strings. It > seems unlikely that NULL would be in a real-world passphrase entered by a > sane user. > > > On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net> wrote: > >> [+cc aaron] >> >> We recently added an implementation of BIP 38 (password protected private >> keys) to bitcoinj. It came to my attention that the third test vector may >> be broken. It gives a hex version of what the NFC normalised version of the >> input string should be, but this does not match the results of the Java >> unicode normaliser, and in fact I can't even get Python to print the names >> of the characters past the embedded null. I'm curious where this normalised >> version came from. >> >> Given that "pile of poo" is not a character I think any sane user would >> put into a passphrase, I question the value of this test vector. NFC form >> is intended to collapse things like umlaut control characters onto their >> prior code point, but here we're feeding the algorithm what is basically >> garbage so I'm not totally surprised that different implementations appear >> to disagree on the outcome. >> >> Proposed action: we remove this test vector as it does not represent any >> real world usage of the spec, or if we desperately need to verify NFC >> normalisation I suggest using a different, more realistic test string, like >> Zürich, or something written in Thai. >> >> >> >> Test 3: >> >> - Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK >> UPSILON WITH HOOK <http://codepoints.net/U+03D2>, COMBINING ACUTE >> ACCENT <http://codepoints.net/U+0301>, NULL >> <http://codepoints.net/U+0000>, DESERET CAPITAL LETTER LONG I >> <http://codepoints.net/U+10400>, PILE OF POO >> <http://codepoints.net/U+1F4A9>) >> - Encrypted key: >> 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn >> - Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >> - Unencrypted private key (WIF): >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >> - *Note:* The non-standard UTF-8 characters in this passphrase should >> be NFC normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before >> further processing >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > [-- Attachment #2: Type: text/html, Size: 9551 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 15:13 ` Brooks Boyd @ 2014-07-15 18:20 ` Mike Hearn 2014-07-15 22:23 ` Aaron Voisine 0 siblings, 1 reply; 22+ messages in thread From: Mike Hearn @ 2014-07-15 18:20 UTC (permalink / raw) To: Brooks Boyd; +Cc: Bitcoin Dev [-- Attachment #1: Type: text/plain, Size: 741 bytes --] Yes, we know, Andreas' code is indeed doing normalisation. However it appears the output bytes end up being different. What I get back is: cf9300*01*303430300166346139 vs cf9300*f0*909080f09f92a9 from the spec. I'm not sure why. It appears this is due to the character from the astral planes. Java is old and uses 16 bit characters internally - it wouldn't surprise me if there's some weirdness that means it doesn't/won't support this kind of thing. I recommend instead that any implementation that wishes to be compatible with JVM based wallets (I suspect Android is the same) just refuse any passphrase that includes characters outside the BMP. At least unless someone can find a fix. I somehow doubt this will really hurt anyone. [-- Attachment #2: Type: text/html, Size: 1308 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 18:20 ` Mike Hearn @ 2014-07-15 22:23 ` Aaron Voisine 2014-07-16 9:12 ` Mike Hearn 2014-07-16 9:17 ` Andreas Schildbach 0 siblings, 2 replies; 22+ messages in thread From: Aaron Voisine @ 2014-07-15 22:23 UTC (permalink / raw) To: Mike Hearn; +Cc: Bitcoin Dev If the user creates a password on an iOS device with an astral character and then can't enter that password on a JVM wallet, that sucks. If JVMs really can't support unicode NFC then that's a strong case to limit the spec to the subset of unicode that all popular platforms can support, but it sounds like it might just be a JVM string library bug that could hopefully be reported and fixed. I get the same result as in the test case using apple's CFStringNormalize(passphrase, kCFStringNormalizationFormC); Aaron Voisine breadwallet.com On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net> wrote: > Yes, we know, Andreas' code is indeed doing normalisation. > > However it appears the output bytes end up being different. What I get back > is: > > cf930001303430300166346139 > > vs > > cf9300f0909080f09f92a9 > > from the spec. > > I'm not sure why. It appears this is due to the character from the astral > planes. Java is old and uses 16 bit characters internally - it wouldn't > surprise me if there's some weirdness that means it doesn't/won't support > this kind of thing. > > I recommend instead that any implementation that wishes to be compatible > with JVM based wallets (I suspect Android is the same) just refuse any > passphrase that includes characters outside the BMP. At least unless someone > can find a fix. I somehow doubt this will really hurt anyone. > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 22:23 ` Aaron Voisine @ 2014-07-16 9:12 ` Mike Hearn 2014-07-16 9:17 ` Andreas Schildbach 1 sibling, 0 replies; 22+ messages in thread From: Mike Hearn @ 2014-07-16 9:12 UTC (permalink / raw) To: Aaron Voisine; +Cc: Bitcoin Dev [-- Attachment #1: Type: text/plain, Size: 2818 bytes --] I'm all for fixing bugs, but I know from bitter experience that outside the BMP dragons lurk. Browsers don't even expose Unicode APIs at all. You end up needing to ship an entire pure-js implementation, which can be too large for some use cases (too much time sunk on that issue in my last job). I'm hoping BIP 38 doesn't get widely used anyway, to be frank. People moving private keys around by hand has caused quite a few problems in the past, sometimes people lost money. It's better to work at the level of a wallet and ideally ask people to move money using regular transactions. Way less potential for errors. Regardless, I'll file a JVM bug and see what the outcome is. On Wed, Jul 16, 2014 at 12:23 AM, Aaron Voisine <voisine@gmail.com> wrote: > If the user creates a password on an iOS device with an astral > character and then can't enter that password on a JVM wallet, that > sucks. If JVMs really can't support unicode NFC then that's a strong > case to limit the spec to the subset of unicode that all popular > platforms can support, but it sounds like it might just be a JVM > string library bug that could hopefully be reported and fixed. I get > the same result as in the test case using apple's > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > > Aaron Voisine > breadwallet.com > > > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net> wrote: > > Yes, we know, Andreas' code is indeed doing normalisation. > > > > However it appears the output bytes end up being different. What I get > back > > is: > > > > cf930001303430300166346139 > > > > vs > > > > cf9300f0909080f09f92a9 > > > > from the spec. > > > > I'm not sure why. It appears this is due to the character from the astral > > planes. Java is old and uses 16 bit characters internally - it wouldn't > > surprise me if there's some weirdness that means it doesn't/won't support > > this kind of thing. > > > > I recommend instead that any implementation that wishes to be compatible > > with JVM based wallets (I suspect Android is the same) just refuse any > > passphrase that includes characters outside the BMP. At least unless > someone > > can find a fix. I somehow doubt this will really hurt anyone. > > > > > ------------------------------------------------------------------------------ > > Want fast and easy access to all the code in your enterprise? Index and > > search up to 200,000 lines of code with a free copy of Black Duck > > Code Sight - the same software that powers the world's largest code > > search on Ohloh, the Black Duck Open Hub! Try it now. > > http://p.sf.net/sfu/bds > > _______________________________________________ > > Bitcoin-development mailing list > > Bitcoin-development@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > [-- Attachment #2: Type: text/html, Size: 3880 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 22:23 ` Aaron Voisine 2014-07-16 9:12 ` Mike Hearn @ 2014-07-16 9:17 ` Andreas Schildbach 2014-07-16 9:29 ` Mike Hearn 1 sibling, 1 reply; 22+ messages in thread From: Andreas Schildbach @ 2014-07-16 9:17 UTC (permalink / raw) To: bitcoin-development Guys, you are always talking about the Unicode astral plane, but in fact its a plain old (ASCII) control character where this problem starts and likely ends: \u0000. Let's ban/filter ISO control characters and be done with it. Most control characters will never be enterable by any keyboard into a password field. Of course I assume that Character.isISOControl() works consistently across platforms. http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 On 07/16/2014 12:23 AM, Aaron Voisine wrote: > If the user creates a password on an iOS device with an astral > character and then can't enter that password on a JVM wallet, that > sucks. If JVMs really can't support unicode NFC then that's a strong > case to limit the spec to the subset of unicode that all popular > platforms can support, but it sounds like it might just be a JVM > string library bug that could hopefully be reported and fixed. I get > the same result as in the test case using apple's > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > > Aaron Voisine > breadwallet.com > > > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net> wrote: >> Yes, we know, Andreas' code is indeed doing normalisation. >> >> However it appears the output bytes end up being different. What I get back >> is: >> >> cf930001303430300166346139 >> >> vs >> >> cf9300f0909080f09f92a9 >> >> from the spec. >> >> I'm not sure why. It appears this is due to the character from the astral >> planes. Java is old and uses 16 bit characters internally - it wouldn't >> surprise me if there's some weirdness that means it doesn't/won't support >> this kind of thing. >> >> I recommend instead that any implementation that wishes to be compatible >> with JVM based wallets (I suspect Android is the same) just refuse any >> passphrase that includes characters outside the BMP. At least unless someone >> can find a fix. I somehow doubt this will really hurt anyone. >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 9:17 ` Andreas Schildbach @ 2014-07-16 9:29 ` Mike Hearn 2014-07-16 10:46 ` Andreas Schildbach 2014-07-16 12:38 ` Wladimir 0 siblings, 2 replies; 22+ messages in thread From: Mike Hearn @ 2014-07-16 9:29 UTC (permalink / raw) To: Andreas Schildbach; +Cc: Bitcoin Dev [-- Attachment #1: Type: text/plain, Size: 3905 bytes --] Yes sorry, you're right, the issue starts with the null code point. Python seems to have problems starting there too. It might work if we took that out. On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach <andreas@schildbach.de> wrote: > Guys, you are always talking about the Unicode astral plane, but in fact > its a plain old (ASCII) control character where this problem starts and > likely ends: \u0000. > > Let's ban/filter ISO control characters and be done with it. Most > control characters will never be enterable by any keyboard into a > password field. Of course I assume that Character.isISOControl() works > consistently across platforms. > > > http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 > > > On 07/16/2014 12:23 AM, Aaron Voisine wrote: > > If the user creates a password on an iOS device with an astral > > character and then can't enter that password on a JVM wallet, that > > sucks. If JVMs really can't support unicode NFC then that's a strong > > case to limit the spec to the subset of unicode that all popular > > platforms can support, but it sounds like it might just be a JVM > > string library bug that could hopefully be reported and fixed. I get > > the same result as in the test case using apple's > > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > > > > Aaron Voisine > > breadwallet.com > > > > > > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net> wrote: > >> Yes, we know, Andreas' code is indeed doing normalisation. > >> > >> However it appears the output bytes end up being different. What I get > back > >> is: > >> > >> cf930001303430300166346139 > >> > >> vs > >> > >> cf9300f0909080f09f92a9 > >> > >> from the spec. > >> > >> I'm not sure why. It appears this is due to the character from the > astral > >> planes. Java is old and uses 16 bit characters internally - it wouldn't > >> surprise me if there's some weirdness that means it doesn't/won't > support > >> this kind of thing. > >> > >> I recommend instead that any implementation that wishes to be compatible > >> with JVM based wallets (I suspect Android is the same) just refuse any > >> passphrase that includes characters outside the BMP. At least unless > someone > >> can find a fix. I somehow doubt this will really hurt anyone. > >> > >> > ------------------------------------------------------------------------------ > >> Want fast and easy access to all the code in your enterprise? Index and > >> search up to 200,000 lines of code with a free copy of Black Duck > >> Code Sight - the same software that powers the world's largest code > >> search on Ohloh, the Black Duck Open Hub! Try it now. > >> http://p.sf.net/sfu/bds > >> _______________________________________________ > >> Bitcoin-development mailing list > >> Bitcoin-development@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >> > > > > > ------------------------------------------------------------------------------ > > Want fast and easy access to all the code in your enterprise? Index and > > search up to 200,000 lines of code with a free copy of Black Duck > > Code Sight - the same software that powers the world's largest code > > search on Ohloh, the Black Duck Open Hub! Try it now. > > http://p.sf.net/sfu/bds > > > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > [-- Attachment #2: Type: text/html, Size: 5514 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 9:29 ` Mike Hearn @ 2014-07-16 10:46 ` Andreas Schildbach 2014-07-16 11:04 ` Andreas Schildbach 2014-07-16 12:38 ` Wladimir 1 sibling, 1 reply; 22+ messages in thread From: Andreas Schildbach @ 2014-07-16 10:46 UTC (permalink / raw) To: bitcoin-development I will change the bitcoinj implementation and propose a new test vector. On 07/16/2014 11:29 AM, Mike Hearn wrote: > Yes sorry, you're right, the issue starts with the null code point. > Python seems to have problems starting there too. It might work if we > took that out. > > > On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach > <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: > > Guys, you are always talking about the Unicode astral plane, but in fact > its a plain old (ASCII) control character where this problem starts and > likely ends: \u0000. > > Let's ban/filter ISO control characters and be done with it. Most > control characters will never be enterable by any keyboard into a > password field. Of course I assume that Character.isISOControl() works > consistently across platforms. > > http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 > > > On 07/16/2014 12:23 AM, Aaron Voisine wrote: > > If the user creates a password on an iOS device with an astral > > character and then can't enter that password on a JVM wallet, that > > sucks. If JVMs really can't support unicode NFC then that's a strong > > case to limit the spec to the subset of unicode that all popular > > platforms can support, but it sounds like it might just be a JVM > > string library bug that could hopefully be reported and fixed. I get > > the same result as in the test case using apple's > > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > > > > Aaron Voisine > > breadwallet.com <http://breadwallet.com> > > > > > > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net > <mailto:mike@plan99.net>> wrote: > >> Yes, we know, Andreas' code is indeed doing normalisation. > >> > >> However it appears the output bytes end up being different. What > I get back > >> is: > >> > >> cf930001303430300166346139 > >> > >> vs > >> > >> cf9300f0909080f09f92a9 > >> > >> from the spec. > >> > >> I'm not sure why. It appears this is due to the character from > the astral > >> planes. Java is old and uses 16 bit characters internally - it > wouldn't > >> surprise me if there's some weirdness that means it doesn't/won't > support > >> this kind of thing. > >> > >> I recommend instead that any implementation that wishes to be > compatible > >> with JVM based wallets (I suspect Android is the same) just > refuse any > >> passphrase that includes characters outside the BMP. At least > unless someone > >> can find a fix. I somehow doubt this will really hurt anyone. > >> > >> > ------------------------------------------------------------------------------ > >> Want fast and easy access to all the code in your enterprise? > Index and > >> search up to 200,000 lines of code with a free copy of Black Duck > >> Code Sight - the same software that powers the world's largest code > >> search on Ohloh, the Black Duck Open Hub! Try it now. > >> http://p.sf.net/sfu/bds > >> _______________________________________________ > >> Bitcoin-development mailing list > >> Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >> > > > > > ------------------------------------------------------------------------------ > > Want fast and easy access to all the code in your enterprise? > Index and > > search up to 200,000 lines of code with a free copy of Black Duck > > Code Sight - the same software that powers the world's largest code > > search on Ohloh, the Black Duck Open Hub! Try it now. > > http://p.sf.net/sfu/bds > > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > > > > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 10:46 ` Andreas Schildbach @ 2014-07-16 11:04 ` Andreas Schildbach 2014-07-16 21:06 ` Aaron Voisine 0 siblings, 1 reply; 22+ messages in thread From: Andreas Schildbach @ 2014-07-16 11:04 UTC (permalink / raw) To: bitcoin-development Damn, I just realized that I implement only the decoding side of BIP38. So I cannot propose a complete test vector. Here is what I have: Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER LONG I, PILE OF POO) Passphrase bytes after removing ISO control characters and NFC normalization: 0xcf933034303066346139 Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF Unencrypted private key (WIF): 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 Can someone calculate the encrypted key from it (using whatever implementation) and I will verify it decodes properly in bitcoinj? On 07/16/2014 12:46 PM, Andreas Schildbach wrote: > I will change the bitcoinj implementation and propose a new test vector. > > > > On 07/16/2014 11:29 AM, Mike Hearn wrote: >> Yes sorry, you're right, the issue starts with the null code point. >> Python seems to have problems starting there too. It might work if we >> took that out. >> >> >> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach >> <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: >> >> Guys, you are always talking about the Unicode astral plane, but in fact >> its a plain old (ASCII) control character where this problem starts and >> likely ends: \u0000. >> >> Let's ban/filter ISO control characters and be done with it. Most >> control characters will never be enterable by any keyboard into a >> password field. Of course I assume that Character.isISOControl() works >> consistently across platforms. >> >> http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 >> >> >> On 07/16/2014 12:23 AM, Aaron Voisine wrote: >> > If the user creates a password on an iOS device with an astral >> > character and then can't enter that password on a JVM wallet, that >> > sucks. If JVMs really can't support unicode NFC then that's a strong >> > case to limit the spec to the subset of unicode that all popular >> > platforms can support, but it sounds like it might just be a JVM >> > string library bug that could hopefully be reported and fixed. I get >> > the same result as in the test case using apple's >> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); >> > >> > Aaron Voisine >> > breadwallet.com <http://breadwallet.com> >> > >> > >> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net >> <mailto:mike@plan99.net>> wrote: >> >> Yes, we know, Andreas' code is indeed doing normalisation. >> >> >> >> However it appears the output bytes end up being different. What >> I get back >> >> is: >> >> >> >> cf930001303430300166346139 >> >> >> >> vs >> >> >> >> cf9300f0909080f09f92a9 >> >> >> >> from the spec. >> >> >> >> I'm not sure why. It appears this is due to the character from >> the astral >> >> planes. Java is old and uses 16 bit characters internally - it >> wouldn't >> >> surprise me if there's some weirdness that means it doesn't/won't >> support >> >> this kind of thing. >> >> >> >> I recommend instead that any implementation that wishes to be >> compatible >> >> with JVM based wallets (I suspect Android is the same) just >> refuse any >> >> passphrase that includes characters outside the BMP. At least >> unless someone >> >> can find a fix. I somehow doubt this will really hurt anyone. >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Want fast and easy access to all the code in your enterprise? >> Index and >> >> search up to 200,000 lines of code with a free copy of Black Duck >> >> Code Sight - the same software that powers the world's largest code >> >> search on Ohloh, the Black Duck Open Hub! Try it now. >> >> http://p.sf.net/sfu/bds >> >> _______________________________________________ >> >> Bitcoin-development mailing list >> >> Bitcoin-development@lists.sourceforge.net >> <mailto:Bitcoin-development@lists.sourceforge.net> >> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> >> > >> > >> ------------------------------------------------------------------------------ >> > Want fast and easy access to all the code in your enterprise? >> Index and >> > search up to 200,000 lines of code with a free copy of Black Duck >> > Code Sight - the same software that powers the world's largest code >> > search on Ohloh, the Black Duck Open Hub! Try it now. >> > http://p.sf.net/sfu/bds >> > >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> <mailto:Bitcoin-development@lists.sourceforge.net> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> >> >> >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 11:04 ` Andreas Schildbach @ 2014-07-16 21:06 ` Aaron Voisine 2014-07-16 22:02 ` Andreas Schildbach 0 siblings, 1 reply; 22+ messages in thread From: Aaron Voisine @ 2014-07-16 21:06 UTC (permalink / raw) To: Andreas Schildbach; +Cc: Bitcoin Development If I first remove \u0000, so the non-normalized passphrase is "\u03D2\u0301\U00010400\U0001F4A9", and then NFC normalize it, it becomes "\u03D3\U00010400\U0001F4A9" UTF-8 encoded this is: 0xcf93f0909080f09f92a9 (not the same as what you got, Andreas!) Encoding private key: 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 with this passphrase, I get a BIP38 key of: 6PRW5o9FMb4hAYRQPmgcvVDTyDtr6R17VMXGLmvKjKVpGkYhBJ4uYuR9wZ I recommend rather than simply removing control characters from the password that instead the spec require that passwords containing control characters are invalid. We don't want people trying to be clever and putting them in thinking they are adding to the password entropy. Also for UI compatibility across many platforms, I'm also in favor disallowing any character below U+0020 (space) I can submit a PR once we figure out why Andreas's passphrase was different than what I got. Aaron Voisine breadwallet.com On Wed, Jul 16, 2014 at 4:04 AM, Andreas Schildbach <andreas@schildbach.de> wrote: > Damn, I just realized that I implement only the decoding side of BIP38. > So I cannot propose a complete test vector. Here is what I have: > > > Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK > UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER > LONG I, PILE OF POO) > > Passphrase bytes after removing ISO control characters and NFC > normalization: 0xcf933034303066346139 > > Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF > > Unencrypted private key (WIF): > 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > > > Can someone calculate the encrypted key from it (using whatever > implementation) and I will verify it decodes properly in bitcoinj? > > > > On 07/16/2014 12:46 PM, Andreas Schildbach wrote: >> I will change the bitcoinj implementation and propose a new test vector. >> >> >> >> On 07/16/2014 11:29 AM, Mike Hearn wrote: >>> Yes sorry, you're right, the issue starts with the null code point. >>> Python seems to have problems starting there too. It might work if we >>> took that out. >>> >>> >>> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach >>> <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: >>> >>> Guys, you are always talking about the Unicode astral plane, but in fact >>> its a plain old (ASCII) control character where this problem starts and >>> likely ends: \u0000. >>> >>> Let's ban/filter ISO control characters and be done with it. Most >>> control characters will never be enterable by any keyboard into a >>> password field. Of course I assume that Character.isISOControl() works >>> consistently across platforms. >>> >>> http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 >>> >>> >>> On 07/16/2014 12:23 AM, Aaron Voisine wrote: >>> > If the user creates a password on an iOS device with an astral >>> > character and then can't enter that password on a JVM wallet, that >>> > sucks. If JVMs really can't support unicode NFC then that's a strong >>> > case to limit the spec to the subset of unicode that all popular >>> > platforms can support, but it sounds like it might just be a JVM >>> > string library bug that could hopefully be reported and fixed. I get >>> > the same result as in the test case using apple's >>> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); >>> > >>> > Aaron Voisine >>> > breadwallet.com <http://breadwallet.com> >>> > >>> > >>> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net >>> <mailto:mike@plan99.net>> wrote: >>> >> Yes, we know, Andreas' code is indeed doing normalisation. >>> >> >>> >> However it appears the output bytes end up being different. What >>> I get back >>> >> is: >>> >> >>> >> cf930001303430300166346139 >>> >> >>> >> vs >>> >> >>> >> cf9300f0909080f09f92a9 >>> >> >>> >> from the spec. >>> >> >>> >> I'm not sure why. It appears this is due to the character from >>> the astral >>> >> planes. Java is old and uses 16 bit characters internally - it >>> wouldn't >>> >> surprise me if there's some weirdness that means it doesn't/won't >>> support >>> >> this kind of thing. >>> >> >>> >> I recommend instead that any implementation that wishes to be >>> compatible >>> >> with JVM based wallets (I suspect Android is the same) just >>> refuse any >>> >> passphrase that includes characters outside the BMP. At least >>> unless someone >>> >> can find a fix. I somehow doubt this will really hurt anyone. >>> >> >>> >> >>> ------------------------------------------------------------------------------ >>> >> Want fast and easy access to all the code in your enterprise? >>> Index and >>> >> search up to 200,000 lines of code with a free copy of Black Duck >>> >> Code Sight - the same software that powers the world's largest code >>> >> search on Ohloh, the Black Duck Open Hub! Try it now. >>> >> http://p.sf.net/sfu/bds >>> >> _______________________________________________ >>> >> Bitcoin-development mailing list >>> >> Bitcoin-development@lists.sourceforge.net >>> <mailto:Bitcoin-development@lists.sourceforge.net> >>> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>> >> >>> > >>> > >>> ------------------------------------------------------------------------------ >>> > Want fast and easy access to all the code in your enterprise? >>> Index and >>> > search up to 200,000 lines of code with a free copy of Black Duck >>> > Code Sight - the same software that powers the world's largest code >>> > search on Ohloh, the Black Duck Open Hub! Try it now. >>> > http://p.sf.net/sfu/bds >>> > >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> _______________________________________________ >>> Bitcoin-development mailing list >>> Bitcoin-development@lists.sourceforge.net >>> <mailto:Bitcoin-development@lists.sourceforge.net> >>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> >>> >>> >>> _______________________________________________ >>> Bitcoin-development mailing list >>> Bitcoin-development@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 21:06 ` Aaron Voisine @ 2014-07-16 22:02 ` Andreas Schildbach 2014-07-16 22:22 ` Andreas Schildbach 2014-07-17 10:59 ` Mike Hearn 0 siblings, 2 replies; 22+ messages in thread From: Andreas Schildbach @ 2014-07-16 22:02 UTC (permalink / raw) To: bitcoin-development Please excuse me. I had a more thorough look at the original problem and found that the only problem with the original test case was that you cannot specify codepoints from the SMP using \u in Java. I always tried \u010400 but that doesn't work. Here is a fix for bitcoinj. The test now passes. https://github.com/bitcoinj/bitcoinj/pull/143 We can (and probably should) still need to filter control chars, I'll have a look at that now again. On 07/16/2014 11:06 PM, Aaron Voisine wrote: > If I first remove \u0000, so the non-normalized passphrase is > "\u03D2\u0301\U00010400\U0001F4A9", and then NFC normalize it, it > becomes "\u03D3\U00010400\U0001F4A9" > > UTF-8 encoded this is: 0xcf93f0909080f09f92a9 (not the same as what > you got, Andreas!) > > Encoding private key: 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > with this passphrase, I get a BIP38 key of: > 6PRW5o9FMb4hAYRQPmgcvVDTyDtr6R17VMXGLmvKjKVpGkYhBJ4uYuR9wZ > > I recommend rather than simply removing control characters from the > password that instead the spec require that passwords containing > control characters are invalid. We don't want people trying to be > clever and putting them in thinking they are adding to the password > entropy. > > Also for UI compatibility across many platforms, I'm also in favor > disallowing any character below U+0020 (space) > > I can submit a PR once we figure out why Andreas's passphrase was > different than what I got. > > Aaron Voisine > breadwallet.com > > > On Wed, Jul 16, 2014 at 4:04 AM, Andreas Schildbach > <andreas@schildbach.de> wrote: >> Damn, I just realized that I implement only the decoding side of BIP38. >> So I cannot propose a complete test vector. Here is what I have: >> >> >> Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK >> UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER >> LONG I, PILE OF POO) >> >> Passphrase bytes after removing ISO control characters and NFC >> normalization: 0xcf933034303066346139 >> >> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >> >> Unencrypted private key (WIF): >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >> >> >> Can someone calculate the encrypted key from it (using whatever >> implementation) and I will verify it decodes properly in bitcoinj? >> >> >> >> On 07/16/2014 12:46 PM, Andreas Schildbach wrote: >>> I will change the bitcoinj implementation and propose a new test vector. >>> >>> >>> >>> On 07/16/2014 11:29 AM, Mike Hearn wrote: >>>> Yes sorry, you're right, the issue starts with the null code point. >>>> Python seems to have problems starting there too. It might work if we >>>> took that out. >>>> >>>> >>>> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach >>>> <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: >>>> >>>> Guys, you are always talking about the Unicode astral plane, but in fact >>>> its a plain old (ASCII) control character where this problem starts and >>>> likely ends: \u0000. >>>> >>>> Let's ban/filter ISO control characters and be done with it. Most >>>> control characters will never be enterable by any keyboard into a >>>> password field. Of course I assume that Character.isISOControl() works >>>> consistently across platforms. >>>> >>>> http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 >>>> >>>> >>>> On 07/16/2014 12:23 AM, Aaron Voisine wrote: >>>> > If the user creates a password on an iOS device with an astral >>>> > character and then can't enter that password on a JVM wallet, that >>>> > sucks. If JVMs really can't support unicode NFC then that's a strong >>>> > case to limit the spec to the subset of unicode that all popular >>>> > platforms can support, but it sounds like it might just be a JVM >>>> > string library bug that could hopefully be reported and fixed. I get >>>> > the same result as in the test case using apple's >>>> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); >>>> > >>>> > Aaron Voisine >>>> > breadwallet.com <http://breadwallet.com> >>>> > >>>> > >>>> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net >>>> <mailto:mike@plan99.net>> wrote: >>>> >> Yes, we know, Andreas' code is indeed doing normalisation. >>>> >> >>>> >> However it appears the output bytes end up being different. What >>>> I get back >>>> >> is: >>>> >> >>>> >> cf930001303430300166346139 >>>> >> >>>> >> vs >>>> >> >>>> >> cf9300f0909080f09f92a9 >>>> >> >>>> >> from the spec. >>>> >> >>>> >> I'm not sure why. It appears this is due to the character from >>>> the astral >>>> >> planes. Java is old and uses 16 bit characters internally - it >>>> wouldn't >>>> >> surprise me if there's some weirdness that means it doesn't/won't >>>> support >>>> >> this kind of thing. >>>> >> >>>> >> I recommend instead that any implementation that wishes to be >>>> compatible >>>> >> with JVM based wallets (I suspect Android is the same) just >>>> refuse any >>>> >> passphrase that includes characters outside the BMP. At least >>>> unless someone >>>> >> can find a fix. I somehow doubt this will really hurt anyone. >>>> >> >>>> >> >>>> ------------------------------------------------------------------------------ >>>> >> Want fast and easy access to all the code in your enterprise? >>>> Index and >>>> >> search up to 200,000 lines of code with a free copy of Black Duck >>>> >> Code Sight - the same software that powers the world's largest code >>>> >> search on Ohloh, the Black Duck Open Hub! Try it now. >>>> >> http://p.sf.net/sfu/bds >>>> >> _______________________________________________ >>>> >> Bitcoin-development mailing list >>>> >> Bitcoin-development@lists.sourceforge.net >>>> <mailto:Bitcoin-development@lists.sourceforge.net> >>>> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>> >> >>>> > >>>> > >>>> ------------------------------------------------------------------------------ >>>> > Want fast and easy access to all the code in your enterprise? >>>> Index and >>>> > search up to 200,000 lines of code with a free copy of Black Duck >>>> > Code Sight - the same software that powers the world's largest code >>>> > search on Ohloh, the Black Duck Open Hub! Try it now. >>>> > http://p.sf.net/sfu/bds >>>> > >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Want fast and easy access to all the code in your enterprise? Index and >>>> search up to 200,000 lines of code with a free copy of Black Duck >>>> Code Sight - the same software that powers the world's largest code >>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>> http://p.sf.net/sfu/bds >>>> _______________________________________________ >>>> Bitcoin-development mailing list >>>> Bitcoin-development@lists.sourceforge.net >>>> <mailto:Bitcoin-development@lists.sourceforge.net> >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Want fast and easy access to all the code in your enterprise? Index and >>>> search up to 200,000 lines of code with a free copy of Black Duck >>>> Code Sight - the same software that powers the world's largest code >>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>> http://p.sf.net/sfu/bds >>>> >>>> >>>> >>>> _______________________________________________ >>>> Bitcoin-development mailing list >>>> Bitcoin-development@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 22:02 ` Andreas Schildbach @ 2014-07-16 22:22 ` Andreas Schildbach 2014-07-17 10:59 ` Mike Hearn 1 sibling, 0 replies; 22+ messages in thread From: Andreas Schildbach @ 2014-07-16 22:22 UTC (permalink / raw) To: bitcoin-development Ok, I just fixed the String filtering so that it can handle SMP chars and my implementation behaves exactly like in your modified testcase quoted below. Bitcoinj code available on this branch, in case we decide to change the spec: https://github.com/schildbach/bitcoinj/commits/bip38-normalize-control-characters On 07/17/2014 12:02 AM, Andreas Schildbach wrote: > Please excuse me. I had a more thorough look at the original problem and > found that the only problem with the original test case was that you > cannot specify codepoints from the SMP using \u in Java. I always tried > \u010400 but that doesn't work. > > Here is a fix for bitcoinj. The test now passes. > > https://github.com/bitcoinj/bitcoinj/pull/143 > > We can (and probably should) still need to filter control chars, I'll > have a look at that now again. > > > On 07/16/2014 11:06 PM, Aaron Voisine wrote: >> If I first remove \u0000, so the non-normalized passphrase is >> "\u03D2\u0301\U00010400\U0001F4A9", and then NFC normalize it, it >> becomes "\u03D3\U00010400\U0001F4A9" >> >> UTF-8 encoded this is: 0xcf93f0909080f09f92a9 (not the same as what >> you got, Andreas!) >> >> Encoding private key: 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >> with this passphrase, I get a BIP38 key of: >> 6PRW5o9FMb4hAYRQPmgcvVDTyDtr6R17VMXGLmvKjKVpGkYhBJ4uYuR9wZ >> >> I recommend rather than simply removing control characters from the >> password that instead the spec require that passwords containing >> control characters are invalid. We don't want people trying to be >> clever and putting them in thinking they are adding to the password >> entropy. >> >> Also for UI compatibility across many platforms, I'm also in favor >> disallowing any character below U+0020 (space) >> >> I can submit a PR once we figure out why Andreas's passphrase was >> different than what I got. >> >> Aaron Voisine >> breadwallet.com >> >> >> On Wed, Jul 16, 2014 at 4:04 AM, Andreas Schildbach >> <andreas@schildbach.de> wrote: >>> Damn, I just realized that I implement only the decoding side of BIP38. >>> So I cannot propose a complete test vector. Here is what I have: >>> >>> >>> Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK >>> UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER >>> LONG I, PILE OF POO) >>> >>> Passphrase bytes after removing ISO control characters and NFC >>> normalization: 0xcf933034303066346139 >>> >>> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >>> >>> Unencrypted private key (WIF): >>> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >>> >>> >>> Can someone calculate the encrypted key from it (using whatever >>> implementation) and I will verify it decodes properly in bitcoinj? >>> >>> >>> >>> On 07/16/2014 12:46 PM, Andreas Schildbach wrote: >>>> I will change the bitcoinj implementation and propose a new test vector. >>>> >>>> >>>> >>>> On 07/16/2014 11:29 AM, Mike Hearn wrote: >>>>> Yes sorry, you're right, the issue starts with the null code point. >>>>> Python seems to have problems starting there too. It might work if we >>>>> took that out. >>>>> >>>>> >>>>> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach >>>>> <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: >>>>> >>>>> Guys, you are always talking about the Unicode astral plane, but in fact >>>>> its a plain old (ASCII) control character where this problem starts and >>>>> likely ends: \u0000. >>>>> >>>>> Let's ban/filter ISO control characters and be done with it. Most >>>>> control characters will never be enterable by any keyboard into a >>>>> password field. Of course I assume that Character.isISOControl() works >>>>> consistently across platforms. >>>>> >>>>> http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 >>>>> >>>>> >>>>> On 07/16/2014 12:23 AM, Aaron Voisine wrote: >>>>> > If the user creates a password on an iOS device with an astral >>>>> > character and then can't enter that password on a JVM wallet, that >>>>> > sucks. If JVMs really can't support unicode NFC then that's a strong >>>>> > case to limit the spec to the subset of unicode that all popular >>>>> > platforms can support, but it sounds like it might just be a JVM >>>>> > string library bug that could hopefully be reported and fixed. I get >>>>> > the same result as in the test case using apple's >>>>> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); >>>>> > >>>>> > Aaron Voisine >>>>> > breadwallet.com <http://breadwallet.com> >>>>> > >>>>> > >>>>> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net >>>>> <mailto:mike@plan99.net>> wrote: >>>>> >> Yes, we know, Andreas' code is indeed doing normalisation. >>>>> >> >>>>> >> However it appears the output bytes end up being different. What >>>>> I get back >>>>> >> is: >>>>> >> >>>>> >> cf930001303430300166346139 >>>>> >> >>>>> >> vs >>>>> >> >>>>> >> cf9300f0909080f09f92a9 >>>>> >> >>>>> >> from the spec. >>>>> >> >>>>> >> I'm not sure why. It appears this is due to the character from >>>>> the astral >>>>> >> planes. Java is old and uses 16 bit characters internally - it >>>>> wouldn't >>>>> >> surprise me if there's some weirdness that means it doesn't/won't >>>>> support >>>>> >> this kind of thing. >>>>> >> >>>>> >> I recommend instead that any implementation that wishes to be >>>>> compatible >>>>> >> with JVM based wallets (I suspect Android is the same) just >>>>> refuse any >>>>> >> passphrase that includes characters outside the BMP. At least >>>>> unless someone >>>>> >> can find a fix. I somehow doubt this will really hurt anyone. >>>>> >> >>>>> >> >>>>> ------------------------------------------------------------------------------ >>>>> >> Want fast and easy access to all the code in your enterprise? >>>>> Index and >>>>> >> search up to 200,000 lines of code with a free copy of Black Duck >>>>> >> Code Sight - the same software that powers the world's largest code >>>>> >> search on Ohloh, the Black Duck Open Hub! Try it now. >>>>> >> http://p.sf.net/sfu/bds >>>>> >> _______________________________________________ >>>>> >> Bitcoin-development mailing list >>>>> >> Bitcoin-development@lists.sourceforge.net >>>>> <mailto:Bitcoin-development@lists.sourceforge.net> >>>>> >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>>> >> >>>>> > >>>>> > >>>>> ------------------------------------------------------------------------------ >>>>> > Want fast and easy access to all the code in your enterprise? >>>>> Index and >>>>> > search up to 200,000 lines of code with a free copy of Black Duck >>>>> > Code Sight - the same software that powers the world's largest code >>>>> > search on Ohloh, the Black Duck Open Hub! Try it now. >>>>> > http://p.sf.net/sfu/bds >>>>> > >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Want fast and easy access to all the code in your enterprise? Index and >>>>> search up to 200,000 lines of code with a free copy of Black Duck >>>>> Code Sight - the same software that powers the world's largest code >>>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>>> http://p.sf.net/sfu/bds >>>>> _______________________________________________ >>>>> Bitcoin-development mailing list >>>>> Bitcoin-development@lists.sourceforge.net >>>>> <mailto:Bitcoin-development@lists.sourceforge.net> >>>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Want fast and easy access to all the code in your enterprise? Index and >>>>> search up to 200,000 lines of code with a free copy of Black Duck >>>>> Code Sight - the same software that powers the world's largest code >>>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>>> http://p.sf.net/sfu/bds >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Bitcoin-development mailing list >>>>> Bitcoin-development@lists.sourceforge.net >>>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Want fast and easy access to all the code in your enterprise? Index and >>>> search up to 200,000 lines of code with a free copy of Black Duck >>>> Code Sight - the same software that powers the world's largest code >>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>> http://p.sf.net/sfu/bds >>>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> _______________________________________________ >>> Bitcoin-development mailing list >>> Bitcoin-development@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 22:02 ` Andreas Schildbach 2014-07-16 22:22 ` Andreas Schildbach @ 2014-07-17 10:59 ` Mike Hearn 2014-07-17 11:27 ` Andreas Schildbach 1 sibling, 1 reply; 22+ messages in thread From: Mike Hearn @ 2014-07-17 10:59 UTC (permalink / raw) To: Andreas Schildbach; +Cc: Bitcoin Dev [-- Attachment #1: Type: text/plain, Size: 11221 bytes --] Glad we got to the bottom of that. That's quite a nasty compiler/language bug I must say. Not even a warning. Still, python crashes when trying to print the name of a null character. It wouldn't surprise me if there are other weird issues lurking. Would definitely sleep better with a more restricted character set. On 17 Jul 2014 00:04, "Andreas Schildbach" <andreas@schildbach.de> wrote: > Please excuse me. I had a more thorough look at the original problem and > found that the only problem with the original test case was that you > cannot specify codepoints from the SMP using \u in Java. I always tried > \u010400 but that doesn't work. > > Here is a fix for bitcoinj. The test now passes. > > https://github.com/bitcoinj/bitcoinj/pull/143 > > We can (and probably should) still need to filter control chars, I'll > have a look at that now again. > > > On 07/16/2014 11:06 PM, Aaron Voisine wrote: > > If I first remove \u0000, so the non-normalized passphrase is > > "\u03D2\u0301\U00010400\U0001F4A9", and then NFC normalize it, it > > becomes "\u03D3\U00010400\U0001F4A9" > > > > UTF-8 encoded this is: 0xcf93f0909080f09f92a9 (not the same as what > > you got, Andreas!) > > > > Encoding private key: 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > > with this passphrase, I get a BIP38 key of: > > 6PRW5o9FMb4hAYRQPmgcvVDTyDtr6R17VMXGLmvKjKVpGkYhBJ4uYuR9wZ > > > > I recommend rather than simply removing control characters from the > > password that instead the spec require that passwords containing > > control characters are invalid. We don't want people trying to be > > clever and putting them in thinking they are adding to the password > > entropy. > > > > Also for UI compatibility across many platforms, I'm also in favor > > disallowing any character below U+0020 (space) > > > > I can submit a PR once we figure out why Andreas's passphrase was > > different than what I got. > > > > Aaron Voisine > > breadwallet.com > > > > > > On Wed, Jul 16, 2014 at 4:04 AM, Andreas Schildbach > > <andreas@schildbach.de> wrote: > >> Damn, I just realized that I implement only the decoding side of BIP38. > >> So I cannot propose a complete test vector. Here is what I have: > >> > >> > >> Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK > >> UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER > >> LONG I, PILE OF POO) > >> > >> Passphrase bytes after removing ISO control characters and NFC > >> normalization: 0xcf933034303066346139 > >> > >> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF > >> > >> Unencrypted private key (WIF): > >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > >> > >> > >> Can someone calculate the encrypted key from it (using whatever > >> implementation) and I will verify it decodes properly in bitcoinj? > >> > >> > >> > >> On 07/16/2014 12:46 PM, Andreas Schildbach wrote: > >>> I will change the bitcoinj implementation and propose a new test > vector. > >>> > >>> > >>> > >>> On 07/16/2014 11:29 AM, Mike Hearn wrote: > >>>> Yes sorry, you're right, the issue starts with the null code point. > >>>> Python seems to have problems starting there too. It might work if we > >>>> took that out. > >>>> > >>>> > >>>> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach > >>>> <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: > >>>> > >>>> Guys, you are always talking about the Unicode astral plane, but > in fact > >>>> its a plain old (ASCII) control character where this problem > starts and > >>>> likely ends: \u0000. > >>>> > >>>> Let's ban/filter ISO control characters and be done with it. Most > >>>> control characters will never be enterable by any keyboard into a > >>>> password field. Of course I assume that Character.isISOControl() > works > >>>> consistently across platforms. > >>>> > >>>> > http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 > >>>> > >>>> > >>>> On 07/16/2014 12:23 AM, Aaron Voisine wrote: > >>>> > If the user creates a password on an iOS device with an astral > >>>> > character and then can't enter that password on a JVM wallet, > that > >>>> > sucks. If JVMs really can't support unicode NFC then that's a > strong > >>>> > case to limit the spec to the subset of unicode that all popular > >>>> > platforms can support, but it sounds like it might just be a JVM > >>>> > string library bug that could hopefully be reported and fixed. > I get > >>>> > the same result as in the test case using apple's > >>>> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > >>>> > > >>>> > Aaron Voisine > >>>> > breadwallet.com <http://breadwallet.com> > >>>> > > >>>> > > >>>> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn <mike@plan99.net > >>>> <mailto:mike@plan99.net>> wrote: > >>>> >> Yes, we know, Andreas' code is indeed doing normalisation. > >>>> >> > >>>> >> However it appears the output bytes end up being different. > What > >>>> I get back > >>>> >> is: > >>>> >> > >>>> >> cf930001303430300166346139 > >>>> >> > >>>> >> vs > >>>> >> > >>>> >> cf9300f0909080f09f92a9 > >>>> >> > >>>> >> from the spec. > >>>> >> > >>>> >> I'm not sure why. It appears this is due to the character from > >>>> the astral > >>>> >> planes. Java is old and uses 16 bit characters internally - it > >>>> wouldn't > >>>> >> surprise me if there's some weirdness that means it > doesn't/won't > >>>> support > >>>> >> this kind of thing. > >>>> >> > >>>> >> I recommend instead that any implementation that wishes to be > >>>> compatible > >>>> >> with JVM based wallets (I suspect Android is the same) just > >>>> refuse any > >>>> >> passphrase that includes characters outside the BMP. At least > >>>> unless someone > >>>> >> can find a fix. I somehow doubt this will really hurt anyone. > >>>> >> > >>>> >> > >>>> > ------------------------------------------------------------------------------ > >>>> >> Want fast and easy access to all the code in your enterprise? > >>>> Index and > >>>> >> search up to 200,000 lines of code with a free copy of Black > Duck > >>>> >> Code Sight - the same software that powers the world's largest > code > >>>> >> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> >> http://p.sf.net/sfu/bds > >>>> >> _______________________________________________ > >>>> >> Bitcoin-development mailing list > >>>> >> Bitcoin-development@lists.sourceforge.net > >>>> <mailto:Bitcoin-development@lists.sourceforge.net> > >>>> >> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> >> > >>>> > > >>>> > > >>>> > ------------------------------------------------------------------------------ > >>>> > Want fast and easy access to all the code in your enterprise? > >>>> Index and > >>>> > search up to 200,000 lines of code with a free copy of Black > Duck > >>>> > Code Sight - the same software that powers the world's largest > code > >>>> > search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> > http://p.sf.net/sfu/bds > >>>> > > >>>> > >>>> > >>>> > >>>> > ------------------------------------------------------------------------------ > >>>> Want fast and easy access to all the code in your enterprise? > Index and > >>>> search up to 200,000 lines of code with a free copy of Black Duck > >>>> Code Sight - the same software that powers the world's largest > code > >>>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> http://p.sf.net/sfu/bds > >>>> _______________________________________________ > >>>> Bitcoin-development mailing list > >>>> Bitcoin-development@lists.sourceforge.net > >>>> <mailto:Bitcoin-development@lists.sourceforge.net> > >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> > >>>> > >>>> > >>>> > >>>> > ------------------------------------------------------------------------------ > >>>> Want fast and easy access to all the code in your enterprise? Index > and > >>>> search up to 200,000 lines of code with a free copy of Black Duck > >>>> Code Sight - the same software that powers the world's largest code > >>>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> http://p.sf.net/sfu/bds > >>>> > >>>> > >>>> > >>>> _______________________________________________ > >>>> Bitcoin-development mailing list > >>>> Bitcoin-development@lists.sourceforge.net > >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> Want fast and easy access to all the code in your enterprise? Index and > >>> search up to 200,000 lines of code with a free copy of Black Duck > >>> Code Sight - the same software that powers the world's largest code > >>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>> http://p.sf.net/sfu/bds > >>> > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> Want fast and easy access to all the code in your enterprise? Index and > >> search up to 200,000 lines of code with a free copy of Black Duck > >> Code Sight - the same software that powers the world's largest code > >> search on Ohloh, the Black Duck Open Hub! Try it now. > >> http://p.sf.net/sfu/bds > >> _______________________________________________ > >> Bitcoin-development mailing list > >> Bitcoin-development@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > ------------------------------------------------------------------------------ > > Want fast and easy access to all the code in your enterprise? Index and > > search up to 200,000 lines of code with a free copy of Black Duck > > Code Sight - the same software that powers the world's largest code > > search on Ohloh, the Black Duck Open Hub! Try it now. > > http://p.sf.net/sfu/bds > > _______________________________________________ > > Bitcoin-development mailing list > > Bitcoin-development@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > [-- Attachment #2: Type: text/html, Size: 16516 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-17 10:59 ` Mike Hearn @ 2014-07-17 11:27 ` Andreas Schildbach 0 siblings, 0 replies; 22+ messages in thread From: Andreas Schildbach @ 2014-07-17 11:27 UTC (permalink / raw) To: bitcoin-development Here is a good article that helped me with what's going wrong: http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html Basically, Java is stuck at 16 bits per char due to legacy reasons. They admit that for a new language, they would probably use 32 (or 24?) bits per char. \u literals express UTF-16 encoding, so you have to use 16 bits. I learned that for codepoint 0x010400, I could write "\uD801\uDC00", which is the UTF-16 encoding of that codepoint. Other languages have literals for codepoints. E.g. Python can use u"\U00010400" or HTML has 𐐀 Unfortunately, Java is missing such a construct (at least in Java6). On 07/17/2014 12:59 PM, Mike Hearn wrote: > Glad we got to the bottom of that. That's quite a nasty > compiler/language bug I must say. Not even a warning. Still, python > crashes when trying to print the name of a null character. It wouldn't > surprise me if there are other weird issues lurking. Would definitely > sleep better with a more restricted character set. > > On 17 Jul 2014 00:04, "Andreas Schildbach" <andreas@schildbach.de > <mailto:andreas@schildbach.de>> wrote: > > Please excuse me. I had a more thorough look at the original problem and > found that the only problem with the original test case was that you > cannot specify codepoints from the SMP using \u in Java. I always tried > \u010400 but that doesn't work. > > Here is a fix for bitcoinj. The test now passes. > > https://github.com/bitcoinj/bitcoinj/pull/143 > > We can (and probably should) still need to filter control chars, I'll > have a look at that now again. > > > On 07/16/2014 11:06 PM, Aaron Voisine wrote: > > If I first remove \u0000, so the non-normalized passphrase is > > "\u03D2\u0301\U00010400\U0001F4A9", and then NFC normalize it, it > > becomes "\u03D3\U00010400\U0001F4A9" > > > > UTF-8 encoded this is: 0xcf93f0909080f09f92a9 (not the same as what > > you got, Andreas!) > > > > Encoding private key: > 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > > with this passphrase, I get a BIP38 key of: > > 6PRW5o9FMb4hAYRQPmgcvVDTyDtr6R17VMXGLmvKjKVpGkYhBJ4uYuR9wZ > > > > I recommend rather than simply removing control characters from the > > password that instead the spec require that passwords containing > > control characters are invalid. We don't want people trying to be > > clever and putting them in thinking they are adding to the password > > entropy. > > > > Also for UI compatibility across many platforms, I'm also in favor > > disallowing any character below U+0020 (space) > > > > I can submit a PR once we figure out why Andreas's passphrase was > > different than what I got. > > > > Aaron Voisine > > breadwallet.com <http://breadwallet.com> > > > > > > On Wed, Jul 16, 2014 at 4:04 AM, Andreas Schildbach > > <andreas@schildbach.de <mailto:andreas@schildbach.de>> wrote: > >> Damn, I just realized that I implement only the decoding side of > BIP38. > >> So I cannot propose a complete test vector. Here is what I have: > >> > >> > >> Passphrase: ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK > >> UPSILON WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL > LETTER > >> LONG I, PILE OF POO) > >> > >> Passphrase bytes after removing ISO control characters and NFC > >> normalization: 0xcf933034303066346139 > >> > >> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF > >> > >> Unencrypted private key (WIF): > >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 > >> > >> > >> Can someone calculate the encrypted key from it (using whatever > >> implementation) and I will verify it decodes properly in bitcoinj? > >> > >> > >> > >> On 07/16/2014 12:46 PM, Andreas Schildbach wrote: > >>> I will change the bitcoinj implementation and propose a new test > vector. > >>> > >>> > >>> > >>> On 07/16/2014 11:29 AM, Mike Hearn wrote: > >>>> Yes sorry, you're right, the issue starts with the null code point. > >>>> Python seems to have problems starting there too. It might work > if we > >>>> took that out. > >>>> > >>>> > >>>> On Wed, Jul 16, 2014 at 11:17 AM, Andreas Schildbach > >>>> <andreas@schildbach.de <mailto:andreas@schildbach.de> > <mailto:andreas@schildbach.de <mailto:andreas@schildbach.de>>> wrote: > >>>> > >>>> Guys, you are always talking about the Unicode astral > plane, but in fact > >>>> its a plain old (ASCII) control character where this > problem starts and > >>>> likely ends: \u0000. > >>>> > >>>> Let's ban/filter ISO control characters and be done with > it. Most > >>>> control characters will never be enterable by any keyboard > into a > >>>> password field. Of course I assume that > Character.isISOControl() works > >>>> consistently across platforms. > >>>> > >>>> > http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl%28char%29 > >>>> > >>>> > >>>> On 07/16/2014 12:23 AM, Aaron Voisine wrote: > >>>> > If the user creates a password on an iOS device with an > astral > >>>> > character and then can't enter that password on a JVM > wallet, that > >>>> > sucks. If JVMs really can't support unicode NFC then > that's a strong > >>>> > case to limit the spec to the subset of unicode that all > popular > >>>> > platforms can support, but it sounds like it might just > be a JVM > >>>> > string library bug that could hopefully be reported and > fixed. I get > >>>> > the same result as in the test case using apple's > >>>> > CFStringNormalize(passphrase, kCFStringNormalizationFormC); > >>>> > > >>>> > Aaron Voisine > >>>> > breadwallet.com <http://breadwallet.com> > <http://breadwallet.com> > >>>> > > >>>> > > >>>> > On Tue, Jul 15, 2014 at 11:20 AM, Mike Hearn > <mike@plan99.net <mailto:mike@plan99.net> > >>>> <mailto:mike@plan99.net <mailto:mike@plan99.net>>> wrote: > >>>> >> Yes, we know, Andreas' code is indeed doing normalisation. > >>>> >> > >>>> >> However it appears the output bytes end up being > different. What > >>>> I get back > >>>> >> is: > >>>> >> > >>>> >> cf930001303430300166346139 > >>>> >> > >>>> >> vs > >>>> >> > >>>> >> cf9300f0909080f09f92a9 > >>>> >> > >>>> >> from the spec. > >>>> >> > >>>> >> I'm not sure why. It appears this is due to the > character from > >>>> the astral > >>>> >> planes. Java is old and uses 16 bit characters > internally - it > >>>> wouldn't > >>>> >> surprise me if there's some weirdness that means it > doesn't/won't > >>>> support > >>>> >> this kind of thing. > >>>> >> > >>>> >> I recommend instead that any implementation that wishes > to be > >>>> compatible > >>>> >> with JVM based wallets (I suspect Android is the same) just > >>>> refuse any > >>>> >> passphrase that includes characters outside the BMP. At > least > >>>> unless someone > >>>> >> can find a fix. I somehow doubt this will really hurt > anyone. > >>>> >> > >>>> >> > >>>> > ------------------------------------------------------------------------------ > >>>> >> Want fast and easy access to all the code in your > enterprise? > >>>> Index and > >>>> >> search up to 200,000 lines of code with a free copy of > Black Duck > >>>> >> Code Sight - the same software that powers the world's > largest code > >>>> >> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> >> http://p.sf.net/sfu/bds > >>>> >> _______________________________________________ > >>>> >> Bitcoin-development mailing list > >>>> >> Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > >>>> <mailto:Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net>> > >>>> >> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> >> > >>>> > > >>>> > > >>>> > ------------------------------------------------------------------------------ > >>>> > Want fast and easy access to all the code in your enterprise? > >>>> Index and > >>>> > search up to 200,000 lines of code with a free copy of > Black Duck > >>>> > Code Sight - the same software that powers the world's > largest code > >>>> > search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> > http://p.sf.net/sfu/bds > >>>> > > >>>> > >>>> > >>>> > >>>> > ------------------------------------------------------------------------------ > >>>> Want fast and easy access to all the code in your > enterprise? Index and > >>>> search up to 200,000 lines of code with a free copy of > Black Duck > >>>> Code Sight - the same software that powers the world's > largest code > >>>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> http://p.sf.net/sfu/bds > >>>> _______________________________________________ > >>>> Bitcoin-development mailing list > >>>> Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > >>>> <mailto:Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net>> > >>>> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> > >>>> > >>>> > >>>> > >>>> > ------------------------------------------------------------------------------ > >>>> Want fast and easy access to all the code in your enterprise? > Index and > >>>> search up to 200,000 lines of code with a free copy of Black Duck > >>>> Code Sight - the same software that powers the world's largest code > >>>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>>> http://p.sf.net/sfu/bds > >>>> > >>>> > >>>> > >>>> _______________________________________________ > >>>> Bitcoin-development mailing list > >>>> Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > >>>> > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> Want fast and easy access to all the code in your enterprise? > Index and > >>> search up to 200,000 lines of code with a free copy of Black Duck > >>> Code Sight - the same software that powers the world's largest code > >>> search on Ohloh, the Black Duck Open Hub! Try it now. > >>> http://p.sf.net/sfu/bds > >>> > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> Want fast and easy access to all the code in your enterprise? > Index and > >> search up to 200,000 lines of code with a free copy of Black Duck > >> Code Sight - the same software that powers the world's largest code > >> search on Ohloh, the Black Duck Open Hub! Try it now. > >> http://p.sf.net/sfu/bds > >> _______________________________________________ > >> Bitcoin-development mailing list > >> Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > ------------------------------------------------------------------------------ > > Want fast and easy access to all the code in your enterprise? > Index and > > search up to 200,000 lines of code with a free copy of Black Duck > > Code Sight - the same software that powers the world's largest code > > search on Ohloh, the Black Duck Open Hub! Try it now. > > http://p.sf.net/sfu/bds > > _______________________________________________ > > Bitcoin-development mailing list > > Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > <mailto:Bitcoin-development@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > > > > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-16 9:29 ` Mike Hearn 2014-07-16 10:46 ` Andreas Schildbach @ 2014-07-16 12:38 ` Wladimir 1 sibling, 0 replies; 22+ messages in thread From: Wladimir @ 2014-07-16 12:38 UTC (permalink / raw) To: Mike Hearn; +Cc: Bitcoin Dev, Andreas Schildbach On Wed, Jul 16, 2014 at 11:29 AM, Mike Hearn <mike@plan99.net> wrote: > Yes sorry, you're right, the issue starts with the null code point. Python > seems to have problems starting there too. It might work if we took that > out. Forbidding control characters, at least anything < 32 makes a lot of sense to me. Carriage returns, linefeeds, formfeeds, null characters, I see no valid reason to allow them and lots of reasons they could cause havoc. PILE OF POO or GRINNING CAT FACE WITH SMILING EYES should be allowed in this day and age though. Wladimir ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 13:07 ` Eric Winer 2014-07-15 13:19 ` Andreas Schildbach 2014-07-15 15:13 ` Brooks Boyd @ 2014-07-15 15:17 ` Jeff Garzik 2014-07-15 15:20 ` Mike Hearn 2014-07-15 15:32 ` Andreas Schildbach 2 siblings, 2 replies; 22+ messages in thread From: Jeff Garzik @ 2014-07-15 15:17 UTC (permalink / raw) To: Eric Winer; +Cc: Bitcoin Dev, Andreas Schildbach Unicode guarantees that null-terminated strings still work. U+0000 terminates a unicode (or C) string. strlen() gets the string byte count. mbstowcs() gets the character count. Whitespace can be problematic, but should be allowed. Control characters should be filtered. Emoticons probably cannot be filtered without substandard approaches such as character blacklists, a road you do not want to travel. (all this is simply standard practice) On Tue, Jul 15, 2014 at 9:07 AM, Eric Winer <enwiner@gmail.com> wrote: > I don't know for sure if the test vector is correct NFC form. But for what > it's worth, the Pile of Poo character is pretty easily accessible on the > iPhone and Android keyboards, and in this string it's already in NFC form > (f09f92a9 in the test result). I've certainly seen it in usernames around > the internet, and wouldn't be surprised to see it in passphrases entered on > smartphones, especially if the author of a BIP38-compatible app includes a > (possibly ill-advised) suggestion to have your passphrase "include special > characters". > > I haven't seen the NULL character on any smartphone keyboards, though - I > assume the iOS and Android developers had the foresight to know how much > havoc that would wreak on systems assuming null-terminated strings. It > seems unlikely that NULL would be in a real-world passphrase entered by a > sane user. > > > On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net> wrote: >> >> [+cc aaron] >> >> We recently added an implementation of BIP 38 (password protected private >> keys) to bitcoinj. It came to my attention that the third test vector may be >> broken. It gives a hex version of what the NFC normalised version of the >> input string should be, but this does not match the results of the Java >> unicode normaliser, and in fact I can't even get Python to print the names >> of the characters past the embedded null. I'm curious where this normalised >> version came from. >> >> Given that "pile of poo" is not a character I think any sane user would >> put into a passphrase, I question the value of this test vector. NFC form is >> intended to collapse things like umlaut control characters onto their prior >> code point, but here we're feeding the algorithm what is basically garbage >> so I'm not totally surprised that different implementations appear to >> disagree on the outcome. >> >> Proposed action: we remove this test vector as it does not represent any >> real world usage of the spec, or if we desperately need to verify NFC >> normalisation I suggest using a different, more realistic test string, like >> Zürich, or something written in Thai. >> >> >> >> Test 3: >> >> Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK UPSILON >> WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER LONG I, PILE >> OF POO) >> Encrypted key: 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn >> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >> Unencrypted private key (WIF): >> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >> Note: The non-standard UTF-8 characters in this passphrase should be NFC >> normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before >> further processing >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > -- Jeff Garzik Bitcoin core developer and open source evangelist BitPay, Inc. https://bitpay.com/ ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 15:17 ` Jeff Garzik @ 2014-07-15 15:20 ` Mike Hearn 2014-07-15 15:32 ` Andreas Schildbach 1 sibling, 0 replies; 22+ messages in thread From: Mike Hearn @ 2014-07-15 15:20 UTC (permalink / raw) To: Jeff Garzik; +Cc: Bitcoin Dev, Andreas Schildbach [-- Attachment #1: Type: text/plain, Size: 318 bytes --] > > Unicode guarantees that null-terminated strings still work. UTF-8 guarantees that. Other encodings do not, you can have null bytes in UTF-16 strings for example. Indeed most languages that use pascal-style encodings internally allow null characters in strings, it's just not a good idea to exploit that fact ... [-- Attachment #2: Type: text/html, Size: 545 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 15:17 ` Jeff Garzik 2014-07-15 15:20 ` Mike Hearn @ 2014-07-15 15:32 ` Andreas Schildbach 2014-07-15 15:53 ` Jeff Garzik 1 sibling, 1 reply; 22+ messages in thread From: Andreas Schildbach @ 2014-07-15 15:32 UTC (permalink / raw) To: bitcoin-development Can you provide the rationale for standard practice? For example, why should whitespace be allowed? I regularly use trim() on any passphrase (or other input ftm). So what's the action point? Should we amend the spec to filter control characters? That would get rid of the \u0000 problem. On 07/15/2014 05:17 PM, Jeff Garzik wrote: > Unicode guarantees that null-terminated strings still work. U+0000 > terminates a unicode (or C) string. strlen() gets the string byte > count. mbstowcs() gets the character count. > > Whitespace can be problematic, but should be allowed. Control > characters should be filtered. Emoticons probably cannot be filtered > without substandard approaches such as character blacklists, a road > you do not want to travel. > > (all this is simply standard practice) > > > On Tue, Jul 15, 2014 at 9:07 AM, Eric Winer <enwiner@gmail.com> wrote: >> I don't know for sure if the test vector is correct NFC form. But for what >> it's worth, the Pile of Poo character is pretty easily accessible on the >> iPhone and Android keyboards, and in this string it's already in NFC form >> (f09f92a9 in the test result). I've certainly seen it in usernames around >> the internet, and wouldn't be surprised to see it in passphrases entered on >> smartphones, especially if the author of a BIP38-compatible app includes a >> (possibly ill-advised) suggestion to have your passphrase "include special >> characters". >> >> I haven't seen the NULL character on any smartphone keyboards, though - I >> assume the iOS and Android developers had the foresight to know how much >> havoc that would wreak on systems assuming null-terminated strings. It >> seems unlikely that NULL would be in a real-world passphrase entered by a >> sane user. >> >> >> On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net> wrote: >>> >>> [+cc aaron] >>> >>> We recently added an implementation of BIP 38 (password protected private >>> keys) to bitcoinj. It came to my attention that the third test vector may be >>> broken. It gives a hex version of what the NFC normalised version of the >>> input string should be, but this does not match the results of the Java >>> unicode normaliser, and in fact I can't even get Python to print the names >>> of the characters past the embedded null. I'm curious where this normalised >>> version came from. >>> >>> Given that "pile of poo" is not a character I think any sane user would >>> put into a passphrase, I question the value of this test vector. NFC form is >>> intended to collapse things like umlaut control characters onto their prior >>> code point, but here we're feeding the algorithm what is basically garbage >>> so I'm not totally surprised that different implementations appear to >>> disagree on the outcome. >>> >>> Proposed action: we remove this test vector as it does not represent any >>> real world usage of the spec, or if we desperately need to verify NFC >>> normalisation I suggest using a different, more realistic test string, like >>> Zürich, or something written in Thai. >>> >>> >>> >>> Test 3: >>> >>> Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK UPSILON >>> WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER LONG I, PILE >>> OF POO) >>> Encrypted key: 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn >>> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >>> Unencrypted private key (WIF): >>> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >>> Note: The non-standard UTF-8 characters in this passphrase should be NFC >>> normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before >>> further processing >>> >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> _______________________________________________ >>> Bitcoin-development mailing list >>> Bitcoin-development@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> > > > ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Bitcoin-development] BIP 38 NFC normalisation issue 2014-07-15 15:32 ` Andreas Schildbach @ 2014-07-15 15:53 ` Jeff Garzik 0 siblings, 0 replies; 22+ messages in thread From: Jeff Garzik @ 2014-07-15 15:53 UTC (permalink / raw) To: Andreas Schildbach; +Cc: Bitcoin Dev On whitespace: Security UX testing I've seen shows it is mentally easier for some users to memorize and use longer passphrases, if they are permitted spaces. I've not seen anything written on use of tabs/NLs/FFs in passphrases. I can see the logic of some systems, that convert \s+ into ' ' for purposes of password hashing, even though that might frustrate a security nerd or two. http://security.stackexchange.com/questions/32691/why-not-allow-spaces-in-a-password I do think control characters should be filtered. On Tue, Jul 15, 2014 at 11:32 AM, Andreas Schildbach <andreas@schildbach.de> wrote: > Can you provide the rationale for standard practice? For example, why > should whitespace be allowed? I regularly use trim() on any passphrase > (or other input ftm). > > So what's the action point? Should we amend the spec to filter control > characters? That would get rid of the \u0000 problem. > > > On 07/15/2014 05:17 PM, Jeff Garzik wrote: >> Unicode guarantees that null-terminated strings still work. U+0000 >> terminates a unicode (or C) string. strlen() gets the string byte >> count. mbstowcs() gets the character count. >> >> Whitespace can be problematic, but should be allowed. Control >> characters should be filtered. Emoticons probably cannot be filtered >> without substandard approaches such as character blacklists, a road >> you do not want to travel. >> >> (all this is simply standard practice) >> >> >> On Tue, Jul 15, 2014 at 9:07 AM, Eric Winer <enwiner@gmail.com> wrote: >>> I don't know for sure if the test vector is correct NFC form. But for what >>> it's worth, the Pile of Poo character is pretty easily accessible on the >>> iPhone and Android keyboards, and in this string it's already in NFC form >>> (f09f92a9 in the test result). I've certainly seen it in usernames around >>> the internet, and wouldn't be surprised to see it in passphrases entered on >>> smartphones, especially if the author of a BIP38-compatible app includes a >>> (possibly ill-advised) suggestion to have your passphrase "include special >>> characters". >>> >>> I haven't seen the NULL character on any smartphone keyboards, though - I >>> assume the iOS and Android developers had the foresight to know how much >>> havoc that would wreak on systems assuming null-terminated strings. It >>> seems unlikely that NULL would be in a real-world passphrase entered by a >>> sane user. >>> >>> >>> On Tue, Jul 15, 2014 at 8:03 AM, Mike Hearn <mike@plan99.net> wrote: >>>> >>>> [+cc aaron] >>>> >>>> We recently added an implementation of BIP 38 (password protected private >>>> keys) to bitcoinj. It came to my attention that the third test vector may be >>>> broken. It gives a hex version of what the NFC normalised version of the >>>> input string should be, but this does not match the results of the Java >>>> unicode normaliser, and in fact I can't even get Python to print the names >>>> of the characters past the embedded null. I'm curious where this normalised >>>> version came from. >>>> >>>> Given that "pile of poo" is not a character I think any sane user would >>>> put into a passphrase, I question the value of this test vector. NFC form is >>>> intended to collapse things like umlaut control characters onto their prior >>>> code point, but here we're feeding the algorithm what is basically garbage >>>> so I'm not totally surprised that different implementations appear to >>>> disagree on the outcome. >>>> >>>> Proposed action: we remove this test vector as it does not represent any >>>> real world usage of the spec, or if we desperately need to verify NFC >>>> normalisation I suggest using a different, more realistic test string, like >>>> Zürich, or something written in Thai. >>>> >>>> >>>> >>>> Test 3: >>>> >>>> Passphrase ϓ␀𐐀💩 (\u03D2\u0301\u0000\U00010400\U0001F4A9; GREEK UPSILON >>>> WITH HOOK, COMBINING ACUTE ACCENT, NULL, DESERET CAPITAL LETTER LONG I, PILE >>>> OF POO) >>>> Encrypted key: 6PRW5o9FLp4gJDDVqJQKJFTpMvdsSGJxMYHtHaQBF3ooa8mwD69bapcDQn >>>> Bitcoin Address: 16ktGzmfrurhbhi6JGqsMWf7TyqK9HNAeF >>>> Unencrypted private key (WIF): >>>> 5Jajm8eQ22H3pGWLEVCXyvND8dQZhiQhoLJNKjYXk9roUFTMSZ4 >>>> Note: The non-standard UTF-8 characters in this passphrase should be NFC >>>> normalized to result in a passphrase of0xcf9300f0909080f09f92a9 before >>>> further processing >>>> >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Want fast and easy access to all the code in your enterprise? Index and >>>> search up to 200,000 lines of code with a free copy of Black Duck >>>> Code Sight - the same software that powers the world's largest code >>>> search on Ohloh, the Black Duck Open Hub! Try it now. >>>> http://p.sf.net/sfu/bds >>>> _______________________________________________ >>>> Bitcoin-development mailing list >>>> Bitcoin-development@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Want fast and easy access to all the code in your enterprise? Index and >>> search up to 200,000 lines of code with a free copy of Black Duck >>> Code Sight - the same software that powers the world's largest code >>> search on Ohloh, the Black Duck Open Hub! Try it now. >>> http://p.sf.net/sfu/bds >>> _______________________________________________ >>> Bitcoin-development mailing list >>> Bitcoin-development@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >>> >> >> >> > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development -- Jeff Garzik Bitcoin core developer and open source evangelist BitPay, Inc. https://bitpay.com/ ^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2014-07-17 11:28 UTC | newest] Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-07-15 12:03 [Bitcoin-development] BIP 38 NFC normalisation issue Mike Hearn 2014-07-15 13:07 ` Eric Winer 2014-07-15 13:19 ` Andreas Schildbach 2014-07-15 13:32 ` Michael Wozniak 2014-07-15 15:13 ` Brooks Boyd 2014-07-15 18:20 ` Mike Hearn 2014-07-15 22:23 ` Aaron Voisine 2014-07-16 9:12 ` Mike Hearn 2014-07-16 9:17 ` Andreas Schildbach 2014-07-16 9:29 ` Mike Hearn 2014-07-16 10:46 ` Andreas Schildbach 2014-07-16 11:04 ` Andreas Schildbach 2014-07-16 21:06 ` Aaron Voisine 2014-07-16 22:02 ` Andreas Schildbach 2014-07-16 22:22 ` Andreas Schildbach 2014-07-17 10:59 ` Mike Hearn 2014-07-17 11:27 ` Andreas Schildbach 2014-07-16 12:38 ` Wladimir 2014-07-15 15:17 ` Jeff Garzik 2014-07-15 15:20 ` Mike Hearn 2014-07-15 15:32 ` Andreas Schildbach 2014-07-15 15:53 ` Jeff Garzik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox