Skip to content

Commit

Permalink
v3: update wallet signature recovery with subdigest calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
shunkakinoki committed Mar 8, 2025
1 parent 0514111 commit 3780334
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sequence_test

import (
"context"
"log"
"math/big"
"sort"
"testing"
Expand Down Expand Up @@ -307,7 +308,7 @@ func TestWalletDeploy(t *testing.T) {
})
}

func TestWalletSignAndRecoverConfig(t *testing.T) {
func TestWalletSignAndRecoverConfigV(t *testing.T) {
t.Run("v1", func(t *testing.T) {
eoa, err := ethwallet.NewWalletFromRandomEntropy()
assert.NoError(t, err)
Expand Down Expand Up @@ -380,7 +381,13 @@ func TestWalletSignAndRecoverConfig(t *testing.T) {
s, err := v3.Core.DecodeSignature(sig)
assert.NoError(t, err)

recoveredWalletConfig, weight, err := s.Recover(context.Background(), core.Digest{Hash: common.BytesToHash(ethcoder.Keccak256([]byte(message)))}, wallet.Address(), wallet.GetChainID(), testChain.Provider)
digest := core.Digest{Hash: common.BytesToHash(ethcoder.Keccak256([]byte(message)))}
subDigest, err := sequence.SubDigest(wallet.GetChainID(), wallet.Address(), digest.Hash)
if err != nil {
log.Println("error", err)
}

recoveredWalletConfig, weight, err := s.Recover(context.Background(), core.Digest{Hash: common.BytesToHash(subDigest)}, wallet.Address(), wallet.GetChainID(), testChain.Provider)
assert.NoError(t, err)

assert.Equal(t, uint16(1), recoveredWalletConfig.Threshold_)
Expand Down

0 comments on commit 3780334

Please sign in to comment.