Skip to content

Commit

Permalink
Session key fixes and test
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Nov 12, 2024
1 parent 44793de commit 45bf96b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions integration/tengateway/tengateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,13 @@ func testSessionKeys(t *testing.T, _ int, httpURL, wsURL string, w wallet.Wallet
user0, err := NewGatewayUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL)
require.NoError(t, err)
testlog.Logger().Info("Created user with encryption token", "t", user0.tgClient.UserID())
// register the user so we can call the endpoints that require authentication
err = user0.RegisterAccounts()
require.NoError(t, err)

var amountToTransfer int64 = 1_000_000_000_000_000_000
// Transfer some funds to user1 to be able to make transactions
_, err = transferETHToAddress(user0.HTTPClient, user0.Wallets[0], user0.Wallets[0].Address(), amountToTransfer)
require.NoError(t, err)

// call BalanceAt - fist call should be successful
_, err = user0.HTTPClient.BalanceAt(context.Background(), user0.Wallets[0].Address(), nil)
require.NoError(t, err)

Expand Down
10 changes: 10 additions & 0 deletions tools/walletextension/services/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Implement session keys - guide for app developers

If the user selects "no-click UX" (or something) when the game starts, do the following:

1) call eth_getStorageAt with the address 0x0000000000000000000000000000000000000003 (the other parameters don't matter). This will return the address of the session key.
2) Create a transaction that transfers some eth to this address. (Maybe you ask the user to decide how many moves they want to prepay or something). The user has to sign this in their wallet. Then submit the tx.
3) Once the receipt is received you call eth_getStorageAt with 0x0000000000000000000000000000000000000004 . This means that you tell the gateway to activate the session key.
4) All the moves made by the user now can be sent with eth_sendRawTransaction or eth_sendTransaction unsigned. They will be signed by the gateway with the session key.
5) When the game is finished create a tx that moves the funds back from the SK to the main address. This will get singed with the SK by the gateeway
6) Call: eth_getStorageAt with 0x0000000000000000000000000000000000000005 - this deactivates the key.

0 comments on commit 45bf96b

Please sign in to comment.