[BC/CWC] Wallet private key updates [1]#4068
Open
MichaelAJay wants to merge 36 commits intobitpay:masterfrom
Open
[BC/CWC] Wallet private key updates [1]#4068MichaelAJay wants to merge 36 commits intobitpay:masterfrom
MichaelAJay wants to merge 36 commits intobitpay:masterfrom
Conversation
…sses, & expose method with DeriverProxy
…sses and add passthrough on DeriverProxy
…t to expected form
kajoseph
reviewed
Jan 22, 2026
Collaborator
kajoseph
left a comment
There was a problem hiding this comment.
I think a better approach may be to auto migrate wallets with version < 2 to v2. That way we can avoid carve-outs while actively push better security.
loadWallet() {
const wallet = read wallet file;
if (wallet.version < 2) {
convert to v2 wallet;
backup wallet file to .bak;
overwrite wallet file with v2;
}
}
…loadWallet with 'raw' param
…t-privatekey-ref
…t-privatekey-ref
kajoseph
reviewed
Feb 4, 2026
kajoseph
reviewed
Feb 9, 2026
kajoseph
reviewed
Feb 12, 2026
| const decrypted = decipher.update(encHex, 'hex'); | ||
| const final = decipher.final(); | ||
| try { | ||
| return Buffer.concat([decrypted, final]); |
Collaborator
There was a problem hiding this comment.
Include the decipher.final() in the try.
try {
return Buffer.concat([decrypted, decipher.final()]);
| const final = decipher.final(); | ||
| const output = Buffer.concat([payload, final]); | ||
| try { | ||
| return toBuffer ? output : output.toString('hex'); |
Collaborator
There was a problem hiding this comment.
include decipher.final() in the try.
let final;
try {
final = decipher.final();
const output = Buffer.concat([payload, final]);
return toBuffer ? output : output.toString('hex');
} finally {
payload.fill(0);
final?.fill(0);
}
Not sure if defining final outside the try is necessary. If this code is going to error, it's highly likely that it's due to an invalid checksum/tag in the decipher.final() call, so it may be fine to just do Buffer.concat([payload, decipher.final()]);. Whatever is decided also applies to the other encrypt/decrypt buffer methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bitcore-client
Encryption
Storage
addKeysSafe- incoming keys' private key is encrypted, so not immediately available to be used to retrieve pubkey, which should be available anyway. Throws if missing a pubkeyWallet
createencrypts HDPrivateKey xprivkey and privateKey so they can be decrypted as buffers instead of serializing the whole masterKey and THEN encryptingimportKeysdoes the same for signing keyssignTxdecrypts to buffers then uses deriver for chain-aware decoding. In the next phase, this decoding should be made unnecessary by passing the buffer all the way through to use, if possibleTests
crypto-wallet-core
Derivation
privateKeyToBufferandprivateKeyBufferToNativePrivateKeyto IDeriver & implement for each Deriver - no need to override for any of the extending classes (UTXOs to AbstractBitcoreLibDeriver & EVM to EthDeriver)