Git Product home page Git Product logo

Comments (4)

oleganza avatar oleganza commented on August 24, 2024

Good point.

My interpretation of BIP was this: if i = X yields an invalid key, user should proceed with i = X + 1.

Alternatively, if the library silently returns a key for X + 1, then when the user supplies i = X + 1 himself, he'll get exactly the same key which may not be expected or could be dangerous (in a protocol where keys must never be reused).

Interestingly, I haven't found a single implementation that does ++i in such case. Some do explicitly wrap private key around curve order, others do nothing. I think it's generally safer to return nil, crash or force user to deal with it than to accidentally produce a duplicate key. Another option is to standardize the way to retry, but in a safer way.

Keep in mind that this case will never be triggered in practice, but even if it does, current implementation will not compromise user's security. I would prefer to have a standard way to resolve this issue, but doing ++i does not look safe to me.

from corebitcoin.

Jud avatar Jud commented on August 24, 2024

@oleganza -- that is a valid interpretation, I went back and forth. For reference, here's an implementation that does ++1:

https://github.com/bitcoinjs/bitcoinjs-lib/blob/ca0c56fa3bba142d0fb590186ac1496f6f89fc8a/src/hdnode.js#L230

Of course, other interpretations raise or return nil:

https://github.com/BitVault/money-tree/blob/00cce46fb58ffa337895c96150942db02f42e525/lib/money-tree/node.rb#L88

from corebitcoin.

oleganza avatar oleganza commented on August 24, 2024

So what do you think we should do? Mind that in 99,99..99% of cases it does not matter what we do. In the remaining 0.00..001% we may silently compromise user's security or privacy by reusing the key when it's not expected.

I would personally follow Nick Szabo's advice to "leave small holes unplugged" (http://blog.oleganza.com/post/69174500046/leaving-small-holes-unplugged) and keep things as they are until we have a really good argument for ++i. Even better, to guarantee that we won't have nasty effects if the user forgets to check for nil result, I'd rather throw an exception to guarantee shutdown.

from corebitcoin.

Jud avatar Jud commented on August 24, 2024

@oleganza Agreed -- I meant to show the bitcoin-js lib that does ++i, which is where I initially started wondering what CoreBitcoin did in that case. Was only showing the money-tree library as a reference to another implementation that doesn't ++i. Not suggesting to throw exceptions.

I say leave everything as is.

from corebitcoin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.