Skip to content

Commit

Permalink
fix: reuse same expires timestamp in both payload and signature
Browse files Browse the repository at this point in the history
  • Loading branch information
kamikazechaser committed Dec 17, 2024
1 parent 0a6a753 commit 1baf781
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/ens/ens.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ func NewProvider(signingKey *ecdsa.PrivateKey) *ENS {
}

func (e *ENS) SignPayload(sender common.Address, request []byte, result common.Address) (string, error) {
payload := encodePayload(sender, expiryTimestamp(), request, result)
expires := expiryTimestamp()

payload := encodePayload(sender, expires, request, result)

sig, err := crypto.Sign(payload.Bytes(), e.signingKey)
if err != nil {
return "0x", err
}
sig = sig[:64]

resp, err := encodeABIParameters(common.LeftPadBytes(result.Bytes(), 32), expiryTimestamp(), sig)
resp, err := encodeABIParameters(common.LeftPadBytes(result.Bytes(), 32), expires, sig)
if err != nil {
return "0x", err
}
Expand Down

0 comments on commit 1baf781

Please sign in to comment.