First version of Threefish512-CTR with BLAKE3-MAC & a custom shamirs secret sharing port alongside C bridges with test vectors & Compilation instructions
This commit is contained in:
54
crypto/shamirs_secret_sharing/test_shamir.c
Normal file
54
crypto/shamirs_secret_sharing/test_shamir.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* before being able to run please provide python/c abi with where to find numpy
|
||||
set PYTHONHOME=C:\Users\wm\AppData\Local\Programs\Python\Python312
|
||||
set PYTHONPATH=%PYTHONHOME%\Lib;%PYTHONHOME%\Lib\site-packages*/
|
||||
// compiled w clang -o test_shamir.exe test_shamir.c -L.
|
||||
|
||||
// FULL REWORK NEEDED, CAN'T COMPILE NUMPY INTO CABI
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main() {
|
||||
HMODULE dll = LoadLibraryA("C:\\Users\\wm\\Documents\\projekt_payments.org.im\\crypto\\shamirs_secret_sharing\\shamir_bridge.dll");
|
||||
if (!dll) {
|
||||
printf("Failed to load DLL\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef char* (*split_func_t)(char** secret, int len, int shares, int threshold);
|
||||
typedef char* (*combine_func_t)(char** shares, int len);
|
||||
|
||||
split_func_t split_secret = (split_func_t)GetProcAddress(dll, "split_secret");
|
||||
combine_func_t combine_shares = (combine_func_t)GetProcAddress(dll, "combine_shares");
|
||||
|
||||
if (!split_secret || !combine_shares) {
|
||||
printf("Failed to get function addresses\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* secret_arr[1];
|
||||
secret_arr[0] = "test";
|
||||
|
||||
char* split_result = split_secret(secret_arr, 1, 3, 3);
|
||||
if (split_result) {
|
||||
printf("Split result: %s\n", split_result);
|
||||
} else {
|
||||
printf("split_secret returned NULL\n");
|
||||
}
|
||||
|
||||
char* shares_arr[3];
|
||||
shares_arr[0] = split_result;
|
||||
shares_arr[1] = split_result;
|
||||
shares_arr[2] = split_result;
|
||||
|
||||
char* combined = combine_shares(shares_arr, 3);
|
||||
if (combined) {
|
||||
printf("Combined result: %s\n", combined);
|
||||
} else {
|
||||
printf("combine_shares returned NULL\n");
|
||||
}
|
||||
|
||||
FreeLibrary(dll);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user