A minimal C library for offline license verification. Drop it into your application to validate license files locally — no network calls required.
Copy these four files into your project:
Download Client Library (.tar)
lfg-license.h /* Client library header */ lfg-license.c /* Client library implementation */ monocypher.h /* Monocypher crypto header */ monocypher.c /* Monocypher crypto implementation */
Then include the header where needed:
#include "lfg-license.h"
Optionally, download lfg-license-defs.h from your project's settings page. This generated header provides named constants for your products and features:
#include "lfg-license.h" #include "lfg-license-defs.h" /* Generated: product & feature enums */
Each product has a unique Ed25519 signing keypair. You will need the public key for your product, available in the organization panel under Products.
lfg_license_keys_t keys; /* Copy your product's 32-byte public key */ memcpy(keys.public_key, my_public_key, 32);
Public key needed for license verification.
| Field | Type | Description |
|---|---|---|
public_key | uint8_t[32] | Ed25519 public signing key for your product |
Decoded license data, populated by lfg_license_verify().
| Field | Type | Description |
|---|---|---|
product_id | uint8_t | Product identifier |
license_type | uint8_t | LFG_LICENSE_TYPE_COMPUTER (1) or LFG_LICENSE_TYPE_NAMED_USER (2) |
expiry | uint32_t | Unix timestamp, or 0 for perpetual |
key | char[20] | License key string (XXXX-XXXX-XXXX-XXXX) |
computer_count | uint8_t | Number of activated computers |
computers[] | array | Each entry has .len and .uin (the computer's unique identifier) |
feature_count | uint8_t | Number of features |
features[] | array | Each entry has .id and .state (LFG_FEATURE_ENABLED or LFG_FEATURE_DISABLED) |
| Name | Value | Description |
|---|---|---|
LFG_LICENSE_TYPE_COMPUTER | 1 | Computer-locked license |
LFG_LICENSE_TYPE_NAMED_USER | 2 | Named user license |
LFG_FEATURE_ENABLED | 2 | Feature is enabled |
LFG_FEATURE_DISABLED | 1 | Feature is disabled |
lfg_license_error_t lfg_license_verify(const lfg_license_keys_t *keys, const char *base64_blob, lfg_license_t *out)
Verifies the Ed25519 signature on a base64-encoded license blob. On success, populates out with the decoded license data.
| Parameter | Description |
|---|---|
keys | Product public key |
base64_blob | Base64-encoded license file contents (from the /api/activate response) |
out | Pointer to lfg_license_t to receive decoded license data |
Returns: LFG_OK (0) on success, or an error code.
Helper functions for common license checks. All take a const lfg_license_t * pointer.
bool lfg_license_is_perpetual(const lfg_license_t *l)
Returns true if the license never expires (expiry is 0).
bool lfg_license_is_expired(const lfg_license_t *l)
Returns true if the license has passed its expiry date. Always returns false for perpetual licenses.
int lfg_license_days_to_expiry(const lfg_license_t *l)
Returns the number of days until expiry. Returns -1 for perpetual licenses, 0 if already expired.
bool lfg_license_has_feature(const lfg_license_t *l, uint8_t feature_id)
Returns true if the license contains the given feature (regardless of state).
bool lfg_license_feature_enabled(const lfg_license_t *l, uint8_t feature_id)
Returns true if the feature exists and is enabled. Returns false if the feature is missing or disabled.
bool lfg_license_has_computer(const lfg_license_t *l, const char *uin)
Returns true if the given computer UIN is present in the license’s activation list.
Returned by lfg_license_verify():
| Code | Value | Description |
|---|---|---|
LFG_OK | 0 | Success |
LFG_ERR_DECODE | 1 | Base64 decoding failed |
LFG_ERR_TOO_SHORT | 2 | Decoded blob is too short to be valid |
LFG_ERR_SIGNATURE | 3 | Ed25519 signature verification failed (wrong key or tampered data) |
LFG_ERR_PARSE | 4 | Binary payload is malformed |
Typical usage in an application startup routine:
#include "lfg-license.h"
#include <stdio.h>
/* Your product's keys (decoded from hex) */
static const lfg_license_keys_t my_keys = {
.public_key = { /* 32 bytes */ },
};
int
check_license(const char *license_blob, const char *my_computer_uin)
{
lfg_license_t lic;
lfg_license_error_t err = lfg_license_verify(&my_keys, license_blob, &lic);
if (err != LFG_OK)
{
fprintf(stderr, "License verification failed (error %d)\n", err);
return -1;
}
/* Check this computer is authorized */
if (!lfg_license_has_computer(&lic, my_computer_uin))
{
fprintf(stderr, "License not activated for this computer\n");
return -1;
}
/* Check expiry */
if (lfg_license_is_expired(&lic))
{
fprintf(stderr, "License has expired\n");
return -1;
}
if (!lfg_license_is_perpetual(&lic))
{
printf("License expires in %d days\n",
lfg_license_days_to_expiry(&lic));
}
/* Check features (using constants from lfg-license-defs.h) */
if (lfg_license_feature_enabled(&lic, LFG_FEATURE_MYAPP_PRO))
{
printf("Pro feature unlocked\n");
}
return 0; /* License is valid */
}
← API Reference · Home