Comments (4)
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.
@oleganza -- that is a valid interpretation, I went back and forth. For reference, here's an implementation that does ++1:
Of course, other interpretations raise or return nil:
from corebitcoin.
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.
@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)
- Restore Balance.
- Install issue
- how to create BTCKeychain by privateKeyAddress ? HOT 2
- testnet extended keys/watch only testing? HOT 3
- Enable Create transaction Raw for 3 series Segwit address? Also Transaction witness class missing? HOT 3
- CocoaPods:[!] The 'Pods-XXX' target has transitive dependencies that include static binaries:XXX HOT 2
- How to add multi address unspent output signature script in transaction input?
- Is there any func to encrypt the BTCMnemonic data (entropy、seed), or mnemonic words?
- Can I exchange USDT
- How to sig a P2SH script?
- How to create a new wallet
- How to BCH address By publicKey?
- Unable to send Litecoin Testnet Transaction?
- Does this lib support segwit multisig signing ?
- The function of the parameter password is used in the following methods ?
- How do I get a child address? You can tell me the specific method.
- Private key import, when trading,I have the private key string, but I need to derive the first 20 addresses based on the private key, so what do I need to do?
- msg = "min relay fee not met, 0 < 226 (code 66)"; HOT 1
- how to create Segwit address HOT 3
- 私钥生成的隔离见证地址和助记词生成的隔离见证地址不一样的吗?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corebitcoin.