Skip to content

Commit 7b6a4be

Browse files
committed
Ensure signatures are correct length
1 parent c2ee6a9 commit 7b6a4be

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

api/v1_claim_rewards.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,17 @@ func getAntiAbuseOracleAttestation(args GetAntiAbuseOracleAttestationParams) (*S
115115
return nil, err
116116
}
117117

118-
// Pad the start if there's a missing leading zero
119-
signature := respBody.Result
120-
if len(signature)%2 == 1 {
121-
signature = "0" + signature
118+
// Ensure signature is exactly 130 hex characters (65 bytes for secp256k1 signature)
119+
signature := strings.TrimPrefix(respBody.Result, "0x")
120+
if len(signature) < 130 {
121+
signature = strings.Repeat("0", 130-len(signature)) + signature
122122
}
123-
signatureBytes, err := hex.DecodeString(strings.TrimPrefix(signature, "0x"))
123+
124+
signatureBytes, err := hex.DecodeString(signature)
124125
if err != nil {
125126
return nil, err
126127
}
128+
127129
attestation := SenderAttestation{
128130
EthAddress: common.HexToAddress(address),
129131
Message: message,

0 commit comments

Comments
 (0)