-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
petertonysmith94
wants to merge
20
commits into
master
Choose a base branch
from
ps/feat/arbitrary-data-signing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e30d691
allow passing of Uint8Array to the `hashMessage` function
petertonysmith94 15249b5
allow passing of Uint8Array to the `signMessage` function
petertonysmith94 ba22222
finalized all change for using sha256
petertonysmith94 e094e24
chore: favour `keccak256`
petertonysmith94 774e7b6
updated snippet
petertonysmith94 70a9dab
docs: updated signing docs
petertonysmith94 9aee5e3
chore: changeset
petertonysmith94 0539f93
breaking chnage
petertonysmith94 843af41
add EIP
petertonysmith94 075639e
Merge branch 'master' of github.com:FuelLabs/fuels-ts into ps/feat/ar…
petertonysmith94 3936944
changeset
petertonysmith94 9e9299f
Merge branch 'master' into ps/feat/arbitrary-data-signing
petertonysmith94 c59c1db
backward compatibility changes
petertonysmith94 30ab22d
changeset
petertonysmith94 e4f414d
changeset
petertonysmith94 c77e298
fix docs hash
petertonysmith94 3885c87
lintfix
petertonysmith94 a56d499
updated docs
petertonysmith94 a7168b6
Using `personalSign` as EIP-191 key
petertonysmith94 fa5e78a
Merge branch 'master' into ps/feat/arbitrary-data-signing
petertonysmith94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@fuel-ts/account": patch | ||
"@fuel-ts/hasher": patch | ||
--- | ||
|
||
feat: enable arbitrary data signing |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,4 +344,5 @@ WSL | |
XOR | ||
XORs | ||
YAML | ||
RESTful | ||
RESTful | ||
EIP |
This file contains 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
This file contains 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
25 changes: 25 additions & 0 deletions
25
apps/docs/src/guide/wallets/snippets/signing/sign-personal-message.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { hashMessage, Signer, WalletUnlocked } from 'fuels'; | ||
|
||
const wallet = WalletUnlocked.generate(); | ||
|
||
// #region signing-personal-message | ||
const message: string | Uint8Array = Uint8Array.from([0x01, 0x02, 0x03]); | ||
const signedMessage = await wallet.signMessage({ personalSign: message }); | ||
// Example output: 0x0ca4ca2a01003d076b4044e38a7ca2443640d5fb493c37e28c582e4f2b47ada7 | ||
|
||
const hashedMessage = hashMessage({ personalSign: message }); | ||
// Example output: 0x862e2d2c46b1b52fd65538c71f7ef209ee32f4647f939283b3dd2434cc5320c5 | ||
// #endregion signing-personal-message | ||
|
||
const recoveredAddress = Signer.recoverAddress(hashedMessage, signedMessage); | ||
|
||
console.log( | ||
'Expect the recovered address to be the same as the original wallet address', | ||
wallet.address.toB256() === recoveredAddress.toB256() | ||
); | ||
|
||
console.log( | ||
'Hashed message should be consistent', | ||
hashedMessage === | ||
'0x862e2d2c46b1b52fd65538c71f7ef209ee32f4647f939283b3dd2434cc5320c5' | ||
); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
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