Skip to content

Commit

Permalink
Update eoa sig keygen message (#580)
Browse files Browse the repository at this point in the history
* 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
panieldark authored Nov 8, 2023
1 parent 0471a55 commit b69ac2e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-suns-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nocturne-xyz/frontend-sdk": patch
---

Update signing eoa keygen message
8 changes: 4 additions & 4 deletions actors/balance-monitor/src/monitor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { NocturneConfig } from "@nocturne-xyz/config";
import { Address } from "@nocturne-xyz/core";
import * as ethers from "ethers";
import * as ot from "@opentelemetry/api";
import {
ActorHandle,
makeCreateObservableGaugeFn,
setupDefaultInstrumentation,
} from "@nocturne-xyz/offchain-utils";
import ERC20_ABI from "./abis/ERC20.json";
import * as ot from "@opentelemetry/api";
import * as ethers from "ethers";
import { Logger } from "winston";
import ERC20_ABI from "./abis/ERC20.json";

const ACTOR_NAME = "balance-monitor";
const COMPONENT_NAME = "monitor";
Expand Down Expand Up @@ -164,7 +164,7 @@ export class BalanceMonitor {
setTimeout(checkBalanceAndReport, 60_000);
};

checkBalanceAndReport();
void checkBalanceAndReport();
});

return {
Expand Down
15 changes: 10 additions & 5 deletions packages/frontend-sdk/src/eoaSigKeygen.ts
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)),
);
}

0 comments on commit b69ac2e

Please sign in to comment.