Try it Live
Run SIWE examples in the interactive playground
Signing
EIP-191 message hash generation for SIWE messages.getMessageHash
Get EIP-191 personal sign message hash for signing.Signature
Parameters
message- BrandedMessage to hash
Returns
32-byte Keccak-256 hash with EIP-191 prefixEIP-191 Format
\x19Ethereum Signed Message:\n{length}
Message: EIP-4361 formatted message
Hash: Keccak-256 of concatenated bytes
Example
Process
-
Format Message: Convert message to EIP-4361 string
-
Encode to Bytes: UTF-8 encode message text
-
Build Prefix: Create EIP-191 prefix
-
Concatenate: Combine prefix + message
-
Hash: Keccak-256 hash
Usage Patterns
Client-Side Signing
Server-Side Verification
Manual Signing (Testing)
Instance Method
EIP-191 Specification
EIP-191 defines three types of signed data. SIWE uses personal sign format:0x19 (25 decimal)
Identifier: "Ethereum Signed Message:\n"
Length: ASCII decimal length of message
Message: Raw message bytes (UTF-8 encoded)
Common Mistakes
Don’t Double-Hash
Use Correct Encoding
Length as String
Security Considerations
- Prefix prevents signature reuse: EIP-191 prefix ensures message can’t be interpreted as transaction
- Length prevents manipulation: Including length prevents message truncation attacks
- UTF-8 encoding: Ensures consistent byte representation across platforms
- Keccak-256: Same hash function as Ethereum transactions
- Deterministic: Same message always produces same hash
Performance
- Formatting: O(n) where n = message size
- Encoding: O(n) UTF-8 encoding
- Hashing: O(n) Keccak-256 hash
- Total: Linear in message size, typically less than 1ms
See Also
- EIP-191: Signed Data Standard
- Siwe.format - Message formatting
- Siwe.verify - Signature verification
- Message Format - EIP-4361 specification

