User Authentication
User authentication in the LogX Network involves a series of steps that ensure secure access and interaction with the platform. This comprehensive guide explains the authentication process in detail.
Generate Authentication Session Data
The initial step involves generating the authentication session data using the user’s address. This includes creating a session key, sub-account ID, and public key.
Register Account
The user’s public key is registered with the platform. This requires generating a digital signature using the user’s private key and a session signature.
Send Authentication Request
The final step is sending an authentication request to the LogX Network’s auth API with the necessary data to receive API credentials.
Authentication Process Details
1. Generate Authentication Session Data
The authentication process starts by generating session data for the user:
sessionKey
: Generated using a new Ethereum walletsubAccountIdString
: Format:1_[ethAddress]_1
subAccountIdHash
: Created by hashing the subAccountIdStringpublicKey
: Derived from the session wallet
This session data forms the basis for subsequent steps and is crucial for establishing a secure session.
2. Register Account
The next step is to register the account on the LogX Network:
- A new Ethereum wallet is generated with a public key and a private key
- A
message
object is created containing details like:- sub-account ID
- user address
- session key
- expiry timestamp
- nonce
- chain ID
- The
domain
object contains domain-specific data:- contract name (“LogX”)
- version (“1”)
- chain ID
- verifying contract address
- The user signs the message with their Ethereum wallet to generate an
ethSignature
- The private key is used to sign the message again to produce a
signingSignature
3. Send Authentication Request
Finally, the authentication request is sent to the LogX Network’s API:
Upon successful registration, the API responds with a logx_key
and logx_secret
:
These credentials should be stored securely in local storage for future authentication.
Implementation Example
Here’s a JavaScript implementation of the authentication process:
Handling Credential Expiry
Since authentication credentials expire after 6 days, implement a check to verify if credentials are still valid:
Signing with EIP-712
The signing process uses EIP-712, a standard for typed structured data hashing and signing. It ensures that the signatures are both human-readable and secure, allowing for easier verification on the blockchain.
Benefits of EIP-712
- Ensures signatures are typechecked and structured
- Prevents signature replay attacks
- Provides better security than raw message signing
Message Types
LogX Network supports various message types for different operations:
Important Notes
- Authentication credentials expire after 6 days
- Store credentials securely and refresh before expiration
- Never share your
privateKey
orlogx_secret
with unauthorized parties - The session key is different from your main Ethereum wallet’s private key
- Always implement proper error handling for authentication failures