Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMessageTooShort = errors.New("siwe: message needs at least 6 lines") ErrInvalidHeader = errors.New("siwe: message first line does not end in \" wants you to sign in with your Ethereum account:\"") ErrInvalidDomain = errors.New("siwe: domain in first line of message is not valid") ErrInvalidAddress = errors.New("siwe: wallet address is not a valid Ethereum address") ErrThirdLineNotEmpty = errors.New("siwe: third line must be empty") ErrInvalidURI = errors.New("siwe: URI is not valid") ErrInvalidIssuedAt = errors.New("siwe: Issued At is not a valid ISO8601 timestamp") ErrInvalidExpirationTime = errors.New("siwe: Expiration Time is not a valid ISO8601 timestamp") ErrInvalidNotBefore = errors.New("siwe: Not Before is not a valid ISO8601 timestamp") ErrMissingURI = errors.New("siwe: URI is not specified") ErrMissingIssuedAt = errors.New("siwe: Issued At is not specified") ErrIssuedAfterExpiration = errors.New("siwe: Issued At is after Expiration Time") ErrNotBeforeAfterExpiration = errors.New("siwe: Not Before is after Expiration Time") ErrInvalidChainID = errors.New("siwe: Chain ID is not valid") )
Static errors
Functions ¶
func IsValidDomain ¶
Types ¶
type SIWEMessage ¶
type SIWEMessage struct {
Raw string
Domain string
Address string
Statement *string
URI url.URL
Version string
ChainID string
Nonce string
IssuedAt time.Time
ExpirationTime *time.Time
NotBefore *time.Time
RequestID *string
Resources []*url.URL
}
SIWEMessage is the final structured form of a parsed SIWE message. REF: https://eips.ethereum.org/EIPS/eip-4361
func ParseMessage ¶
func ParseMessage(raw string) (*SIWEMessage, error)
func (*SIWEMessage) VerifySignature ¶
func (m *SIWEMessage) VerifySignature(signatureHex string) bool
VerifySignature validates that the signature was created by the private key corresponding to the address in the message. This performs ECDSA recovery which is computationally expensive, so it should be called only after ParseMessage has validated the message structure.
The signature must be a 65-byte hex string in the format: 0x{R}{S}{V} where R and S are 32 bytes each and V is 1 byte.
Returns true if the recovered address matches the message address (case-insensitive).
Click to show internal directories.
Click to hide internal directories.