Skip to content

Commit df86266

Browse files
authored
Ensure signatures are correct length (#618)
Anti Abuse Oracle was dropping leading zeros (more than 1!) from the response
1 parent dc7fdd3 commit df86266

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

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)