-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update eoa sig keygen message (#580)
* Update eoa sig keygen message * changeset * Update eoaSigKeygen.ts Signed-off-by: Daniel Park <[email protected]> * warn * update text * this -> your * Update eoaSigKeygen.ts Signed-off-by: Daniel Park <[email protected]> --------- Signed-off-by: Daniel Park <[email protected]>
- Loading branch information
1 parent
0471a55
commit b69ac2e
Showing
3 changed files
with
19 additions
and
9 deletions.
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,5 @@ | ||
--- | ||
"@nocturne-xyz/frontend-sdk": patch | ||
--- | ||
|
||
Update signing eoa keygen message |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import { ethers } from "ethers"; | ||
|
||
const SPEND_KEY_FIXED_MESSAGE = Buffer.from( | ||
"Sign this message to generate your Nocturne Spending Key. This key lets the application spend your funds in Nocturne.\n\nIMPORTANT: ONLY SIGN THIS MESSAGE IF YOU TRUST THE APPLICATION." | ||
); | ||
// ! ⚠️⚠️⚠️ THIS MESSAGE CANNOT BE CHANGED! KEY DERIVATION IS DICTATED BY THE EXACT TEXT ⚠️⚠️⚠️ | ||
const SPEND_KEY_FIXED_MESSAGE = | ||
`Sign to generate your Nocturne spending key. This key will secure your funds in Nocturne. | ||
By signing this message, I assert that | ||
1. I trust the application | ||
2. I have safely stored the private key (or seed phrase from which the private key was derived) for the connected Ethereum account | ||
3. The only way I can recover access to my Nocturne account is by signing this message again with the same Ethereum account mentioned in #2.` as const; | ||
|
||
export async function generateNocturneSpendKeyFromEoaSig( | ||
signer: ethers.Signer | ||
signer: ethers.Signer, | ||
): Promise<string> { | ||
return ethers.utils.keccak256( | ||
await signer.signMessage(SPEND_KEY_FIXED_MESSAGE) | ||
await signer.signMessage(Buffer.from(SPEND_KEY_FIXED_MESSAGE)), | ||
); | ||
} |