V reaches the dongle through the SDK’s flat C API with V’s dl module, loading the native library at run time on the first call: there is no #flag and nothing to link, so nothing sits in the path of the check that a customer could substitute for something more agreeable. No dependencies beyond V’s standard library. The keynub_licdongle module, V 0.5.2 or later, on Windows, Linux and macOS.
v install AB-KeyNub.licdongleCode language: CSS (css)
Reading a License
import ab_keynub.licdongle
fn license() ![]u8 {
mut d := licdongle.open('')! // first dongle, or open('<serial>')
defer {
d.close()
}
d.verify_genuine()! // an error unless genuine
d.open_session()!
defer {
d.close_session() // closed on every exit path
}
return d.read_record('license')!
}Code language: JavaScript (javascript)
What You Are Protecting
V software that is sold ships as a native executable: a command-line tool, a desktop utility, a service on a customer’s server. A check that returns a bool compiles to one conditional branch, and patching one of those in a release binary is a beginner exercise.
So the strong pattern is the one to reach for: the data the program needs only exists when the dongle is present.
// Weak: one patched branch.
if !d.is_genuine() {
exit(1)
}
// Strong: the parameters only exist with the dongle present.
d.open_session()!
defer {
d.close_session()
}
parameters := decode_parameters(d.app_decrypt(sealed_blob_shipped_with_your_program)!)Code language: PHP (php)
Every call that can fail returns a result: a failed dongle call gives a DongleError with the status (.no_device, .not_genuine, .auth_required, …), the raw code, the operation and the library’s detail, and a library that cannot be loaded gives a LibraryError; is_genuine fails closed. close and close_session return nothing, so they sit in a defer block as they are. The module calls the SDK’s flat companion API, the one designed for foreign function interfaces: integer handles and buffers, no hand-written structure layouts.
Shipping the Native Library with a V Application
The keynub_licdongle module calls the SDK’s flat API through V’s dl module from the library it loads at run time: there is no #flag, nothing is linked, and importing the module needs no library. v install AB-KeyNub.licdongle clones the SDK repository with its natives/ folder into the V modules folder, and the module finds the library there during development. A shipped executable takes keynub_licdongle_flat for its platform in natives/<platform>/ beside it, or names it with licdongle.set_library_path or KEYNUB_LICDONGLE_FLAT_LIBRARY.
The prebuilt libraries for every platform are in the SDK repository’s natives/<platform>/ folder, with a SHA-256 manifest: Windows x64, x86 and ARM64, Linux x86_64 and aarch64, and universal macOS binaries for Intel and Apple silicon. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.
Questions V Developers Ask
Which V Versions Does the Module Support?
V 0.5.2 and later, on Windows, Linux and macOS. The module has no dependencies beyond V’s standard library.
Does the V Module Link Against the Native Library?
No. It loads the library with V’s dl module on the first call, so there is no #flag and nothing to link, and importing the module needs no library.
Does a V Application Need Administrator Rights to Talk to the Dongle?
No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.
Does a V License Check Need an Internet Connection?
No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.
Who Can Read the License Records on a Dongle?
Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.
Can a License Written from V Be Read by a Program in Another Language?
Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.
Code
Runnable sample: v/verify_and_read.v. Binding source: bindings/v. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.
All supported languages · All industries · Buy a KeyNub · Ask us something