Pointer to the pincode
Length of the pincode
Pointer to the device pin document
Length of the device pin document
The allocated securenet
Decrypt a devicepin
/// create key-pair with devicepin import tagion.hibon.HiBONRecord; import std.format; securenet_t my_keypair; string my_mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon"; string pincode = "1234"; uint8_t* device_buf; size_t device_len; int error_code = tagion_generate_keypair(&my_mnemonic[0], my_mnemonic.length, null, 0, &my_keypair, &pincode[0], pincode.length, &device_buf, &device_len); assert(error_code == ErrorCode.none); const _device_buf = device_buf[0..device_len].idup; const device_doc = Document(_device_buf); assert(device_doc.isRecord!DevicePIN, format("the doc was not of type %s", DevicePIN.stringof)); /// decrypt the devicepin securenet_t other_securenet; error_code = tagion_decrypt_devicepin(&pincode[0], pincode.length, device_buf, device_len, &other_securenet); assert(error_code == ErrorCode.none); /// try to login with wrong pin string wrong_pincode = "4321"; securenet_t false_securenet; error_code = tagion_decrypt_devicepin(&wrong_pincode[0], wrong_pincode.length, device_buf, device_len, &false_securenet); assert(error_code == ErrorCode.exception, "should give exception with wrong pin"); assert(false_securenet.securenet is null, "should not have created a securenet");
Decrypt and create a securenet from a devicepin and pincode