Bug: verifyMessage invalid signature length
- Dominant language
- TypeScript
- Stars
- 172
- Forks
- 207
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
### Describe the bug
i use ios basewallet(29.76.5) Base Model sign text and verifySignature
### Steps
```
const handleSignMessage = async () => {
console.log('🔵 [signMessage] 开始签署消息...')
if (!walletClient.value || !account.value) return
error.value = null
signature.value = null
verifyResult.value = null
isSigning.value = true
try {
console.log('🔵 [signMessage] 消息内容:', message.value)
console.log('🔵 [signMessage] 账户地址:', account.value)
// 使用 viem 的 signMessage,它会自动处理消息格式
console.log('🔵 [signMessage] 请求钱包签名...')
const sig = await walletClient.value.signMessage({
account: account.value,
message: message.value
})
console.log('✅ [signMessage] 原始签名:', sig)
console.log('🔵 [signMessage] 签名类型:', typeof sig)
console.log('🔵 [signMessage] 签名长度:', sig.length, '字符')
signature.value = sig
console.log('✅ [signMessage] 签名成功,格式正确')
} catch (err: any) {
console.error('❌ [signMessage] 签名失败:', err)
console.error('❌ [signMessage] 错误详情:', {
name: err.name,
message: err.message,
code: err.code,
cause: err.cause
})
error.value = err.shortMessage || err.message || '签名失败'
} finally {
isSigning.value = false
}
}
const handleVerifyMessage = async () => {
console.log('🔵 [verifySignature] 开始验证签名...')
if (!account.value || !signature.value) return
error.value = null
isVerifying.value = true
try {
const isValid = await verifyMessage({
address: account.value,
message: message.value,
signature: signature.value as `0x${string}`
})
console.log('✅ [verifySignature] 验证结果:', isValid)
verifyResult.value = isValid
} catch (err: any) {
console.error('❌ [verifySignature] 验证失败:', err)
error.value = err.message || '验证失败'
} finally {
isVerifying.value = false
}
}
```
my address :0x17046ccf43e0d7f0d44e98be223f4ba25af0f59f
message test:
Hello, viem! 这是一条测试消息。
sign result:
0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041f71592b5fd91490f5c86b56bb2246b59eb099a6efadef8a882297d5f3e3d0b1a42229f5c2cd603695081cc18a90b69cd895dce707ce9d4a61618a27490afc7801c00000000000000000000000000000000000000000000000000000000000000
how can i verify sign result was my address:0x17046ccf43e0d7f0d44e98be223f4ba25af0f59f sign it
### Expected behavior
verifyMessage pass
### Version
29.76.5
### Additional info
_No response_
### Desktop
_No response_
### Smartphone
_No response_
Contributor guide
Research direction
Start by reproducing the signMessage and verifyMessage calls from the issue with the provided address, message, and signature, then inspect the SDK's message-signing and verification entry points. Compare the returned signature format with what verification accepts; done means the reported signature verifies successfully or the incompatibility is documented with a focused regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100