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: enable arbitrary data signing #3720

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

petertonysmith94
Copy link
Contributor

@petertonysmith94 petertonysmith94 commented Feb 19, 2025

Release notes

In this release, we:

  • Enabled hashing + signing of bytes, with signMessage and hashMessage now accepting a Uint8Array of bytes.

Summary

The following methods now accept a HashableMessage:

  • Signer.signMessage
  • WalletUnlocked.signMessage
  • hashMessage

The HashableMessage has two different formats:

  • Backwards compatibile format (string input)
// Will follow the same format as before for backwards compatibility: `sha256(toUtf8Bytes(<message))`
const message: HashedMessage = 'some-string';
  • EIP-191 format
// Will use the following format: `0x19 <0x46 (F)> <"uel Signed Message:\n" + len(message)> <message>`
let message: HashedMessage = { raw: new Uint8Array([0x01, 0x02]) };
message = { raw: 'some-string' };

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

Copy link

vercel bot commented Feb 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 7:45am
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 7:45am
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 7:45am

@petertonysmith94 petertonysmith94 self-assigned this Feb 19, 2025
@petertonysmith94 petertonysmith94 added the feat Issue is a feature label Feb 19, 2025
@petertonysmith94 petertonysmith94 changed the title Ps/feat/arbitrary data signing feat: enable arbitrary data signing Feb 19, 2025
@@ -26,7 +26,7 @@ describe('WalletUnlocked', () => {
const expectedAddress = '0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e';
const expectedMessage = 'my message';
const expectedSignedMessage =
'0x8eeb238db1adea4152644f1cd827b552dfa9ab3f4939718bb45ca476d167c6512a656f4d4c7356bfb9561b14448c230c6e7e4bd781df5ee9e5999faa6495163d';
'0x9a16a5452ae96c13732716682600a6054661ba43994c9c335a4655caf31e68f0b1ec2e7c7ffe304a1b9d30734e24bb8ef3a5076edbc4510f0a3de3d9dcba9667';

it('Instantiate a new wallet', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

we should ensure the current method does not work; a break change here can be catastrophic.

Like bako predicate, which uses the current sign message to verify ownership,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented a backward compatible approach.
c59c1db

All previous hashes remain unchanged

@petertonysmith94 petertonysmith94 changed the title feat!: enable arbitrary data signing feat: enable arbitrary data signing Feb 20, 2025
Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
77.15%(+0%) 70.85%(+0.16%) 75.23%(-0.07%) 77.15%(+0%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 ✨ packages/abi-coder/src/utils/scriptData.ts 0%
(+0%)
0%
(+0%)
0%
(+0%)
0%
(+0%)
🔴 packages/account/src/account.ts 81.03%
(+0.45%)
72%
(+0.77%)
82.5%
(+0%)
80.79%
(+0.45%)
🔴 packages/account/src/connectors/fuel-connector.ts 30%
(+1.43%)
100%
(+0%)
4.54%
(-0.22%)
30%
(+1.43%)
🔴 packages/account/src/connectors/fuel.ts 96.75%
(+0.02%)
90.66%
(+0%)
93.33%
(+0%)
96.87%
(+0.02%)
🔴 packages/account/src/providers/provider.ts 67.53%
(+0.58%)
59.8%
(+2.73%)
68.04%
(+0%)
67.29%
(+0.56%)
🔴 packages/errors/src/test-utils/expect-to-throw-fuel-error.ts 91.66%
(-0.34%)
88.88%
(+0%)
100%
(+0%)
91.66%
(-0.34%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement signed-type data
3 participants