-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add signature verification for all client actions via relay ser…
…vice (#167) * feat: add signature verification for all client actions via relay service * feat: per-message signatures and integration with network layer * feat: add message recovery in webworker * Update packages/services/cmd/ecs-relay/main.go Co-authored-by: ludens <ludens@lattice.xyz> Co-authored-by: alvrs <alvarius@lattice.xyz> Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> Co-authored-by: ludens <ludens@lattice.xyz>
- Loading branch information
1 parent
44a8676
commit 7920d6e
Showing
17 changed files
with
930 additions
and
316 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Message } from "@latticexyz/services/protobuf/ts/ecs-relay/ecs-relay"; | ||
import { keccak256 } from "ethers/lib/utils"; | ||
|
||
// Message payload to sign and use to recover signer | ||
export function messagePayload(msg: Message) { | ||
return `(${msg.version},${msg.id},${keccak256(msg.data)},${msg.timestamp})`; | ||
} |
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,10 @@ | ||
import { Message } from "@latticexyz/services/protobuf/ts/ecs-relay/ecs-relay"; | ||
import { expose } from "threads"; | ||
import { verifyMessage } from "ethers/lib/utils"; | ||
import { messagePayload } from "../utils"; | ||
|
||
function recoverAddress(msg: Message) { | ||
return verifyMessage(messagePayload(msg), msg.signature); | ||
} | ||
|
||
expose({ recoverAddress }); |
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,4 +1,5 @@ | ||
i.DS_Store | ||
/bin | ||
/snapshots | ||
docs | ||
docs | ||
FaucetStore |
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
Oops, something went wrong.