Chapter 8 Secret Sharing Operations 309
Secret Sharing
Reconstructing the Secret
To reconstruct the secret, call B_DecryptUpdate for each share you are entering. You
need at least
threshold
number of shares; if you enter fewer, B_DecryptFinal will
return an error. Any combination of threshold shares will work.
Step 1: Creating An Algorithm Object
Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in
Chapter 4 of the Reference Manual, its address is the argument for
B_CreateAlgorithmObject:
Step 2: Setting The Algorithm Object
Use the same AI, AI_BSSecretSharing:
Step 3: Init
Initialize the algorithm with B_DecryptInit. Once again no key or algorithm chooser
is necessary. This function is very quick, so it is reasonable to pass a NULL_PTR for the
surrender context:
B_ALGORITHM_OBJ secretReconstructer = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject
(&secretReconstructer)) != 0)
break;
B_SECRET_SHARING_PARAMS secretSharingParams;
secretSharingParams.threshold = 2;
if ((status = B_SetAlgorithmInfo
(secretReconstructer, AI_BSSecretSharing,
(POINTER)&secretSharingParams)) != 0)
break;