Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sign message #546

Merged
merged 11 commits into from
Jun 20, 2023
Merged

feat: sign message #546

merged 11 commits into from
Jun 20, 2023

Conversation

andreabadesso
Copy link
Contributor

@andreabadesso andreabadesso commented Jun 5, 2023

Acceptance Criteria

  • We should have a signMessageWIthAddress method on both facades

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@andreabadesso andreabadesso changed the base branch from dev to refactor/get-address-at-index June 5, 2023 16:32
@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Merging #546 (b8d00ff) into dev (eeca035) will increase coverage by 15.29%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              dev     #546       +/-   ##
===========================================
+ Coverage   62.64%   77.94%   +15.29%     
===========================================
  Files          67       67               
  Lines        5209     5227       +18     
  Branches     1103     1103               
===========================================
+ Hits         3263     4074      +811     
+ Misses       1853     1142      -711     
+ Partials       93       11       -82     
Impacted Files Coverage Δ
src/constants.ts 100.00% <100.00%> (ø)
src/models/network.ts 100.00% <100.00%> (ø)
src/new/wallet.js 95.63% <100.00%> (+59.97%) ⬆️
src/utils/crypto.ts 94.59% <100.00%> (+0.84%) ⬆️
src/wallet/wallet.ts 59.74% <100.00%> (+0.39%) ⬆️

... and 23 files with indirect coverage changes

@andreabadesso andreabadesso self-assigned this Jun 6, 2023
@andreabadesso andreabadesso force-pushed the feat/sign-message branch 2 times, most recently from 8df821d to 65a3d41 Compare June 12, 2023 02:00
@andreabadesso andreabadesso changed the base branch from refactor/get-address-at-index to dev June 12, 2023 13:21
src/new/wallet.js Outdated Show resolved Hide resolved
src/utils/crypto.ts Show resolved Hide resolved
__tests__/wallet/wallet.test.ts Outdated Show resolved Hide resolved
import { IEncryptedData } from '../types';

// Monkey-patch MAGIC_BYTES to use Hathor's
bitcore.Message.MAGIC_BYTES = Buffer.from(HATHOR_MAGIC_BYTES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use this Message class from bitcore for anything in the wallet service facade here in the lib?

I remember we were using it in the wallet service code before changing the library there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use bitcore-message to prove we own the xpub and the authXpub in wallet-service here

We can and probably should use the new utils/crypto.ts method, but I suggest we don't refactor it in this PR as we also need to change wallet-service to expect Hathor Signed Message\n instead of Bitcoin Signed Message\n it currently expect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can and probably should use the new utils/crypto.ts method, but I suggest we don't refactor it in this PR as we also need to change wallet-service to expect Hathor Signed Message\n instead of Bitcoin Signed Message\n it currently expect.

That's my main concern. If we changed the magic bytes for the lib, the current wallets we have in the wallet service wouldn't work anymore, right? Because they were generated using the old magic bytes, or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and this is indeed a problem, since we are monkey patching the Message class, it will affect the signMessage for the wallet-service.

I will merge this and work on a fix on the wallet-service side

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/new/wallet.js Outdated Show resolved Hide resolved
src/new/wallet.js Outdated Show resolved Hide resolved
src/new/wallet.js Outdated Show resolved Hide resolved
@andreabadesso andreabadesso force-pushed the feat/sign-message branch 2 times, most recently from 2ca2840 to d751ac0 Compare June 19, 2023 19:20
@andreabadesso andreabadesso merged commit b26e784 into dev Jun 20, 2023
@andreabadesso andreabadesso deleted the feat/sign-message branch June 20, 2023 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants