Skip to content

Commit

Permalink
Merge pull request #37 from wolfmcnally/master
Browse files Browse the repository at this point in the history
Unexport needlessly public functions. Strengthen validation of threshold.
  • Loading branch information
wolfmcnally committed Aug 18, 2021
2 parents abc24ba + c67d102 commit a006e04
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 25 deletions.
2 changes: 0 additions & 2 deletions src/bc-shamir.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
extern "C" {
#endif

#include "hazmat.h"
#include "interpolate.h"
#include "shamir.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/interpolate.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* values[i] = | | -------------
* j != i (xc[i]-xc[j])
*/
void
static void
hazmat_lagrange_basis(uint8_t *values,
uint8_t n,
const uint8_t *xc,
Expand Down
21 changes: 0 additions & 21 deletions src/interpolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,6 @@

#include "hazmat.h"

/*
* calculate the lagrange basis coefficients for the lagrange polynomial
* defined byt the x coordinates xc at the value x.
*
* inputs: values: pointer to an array to write the values
* n: number of points - length of the xc array, 0 < n <= 32
* xc: array of x components to use as interpolating points
* x: x coordinate to evaluate lagrange polynomials at
*
* After the function runs, the values array should hold data satisfying
* the following:
* --- (x-xc[j])
* values[i] = | | -------------
* j != i (xc[i]-xc[j])
*/
void
hazmat_lagrange_basis(uint8_t *values,
uint8_t n,
const uint8_t *xc,
uint8_t x);

/**
* safely interpolate the polynomial going through
* the points (x0 [y0_0 y0_1 y0_2 ... y0_31]) , (x1 [y1_0 ...]), ...
Expand Down
1 change: 1 addition & 0 deletions src/shamir-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
#define SHAMIR_ERROR_CHECKSUM_FAILURE (-104)
#define SHAMIR_ERROR_SECRET_TOO_SHORT (-105)
#define SHAMIR_ERROR_SECRET_NOT_EVEN_LEN (-106)
#define SHAMIR_ERROR_INVALID_THRESHOLD (-107)

#endif /* SHAMIR_CONSTANTS_H */
2 changes: 2 additions & 0 deletions src/shamir.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ int32_t split_secret(
) {
if(shard_count > SHAMIR_MAX_SHARD_COUNT) {
return SHAMIR_ERROR_TOO_MANY_SHARDS;
} else if(threshold < 1 || threshold > shard_count) {
return SHAMIR_ERROR_INVALID_THRESHOLD;
} else if(secret_length > SHAMIR_MAX_SECRET_SIZE) {
return SHAMIR_ERROR_SECRET_TOO_LONG;
} else if(secret_length < SHAMIR_MIN_SECRET_SIZE) {
Expand Down
2 changes: 1 addition & 1 deletion src/shamir.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uint8_t* create_digest(
*
* returns: the number of shards created, or a negative value if there was an error
*
* inputs: threshold: number of shards required to recover secret
* inputs: threshold: number of shards required to recover secret. Must be 1 <= threshold <= shard_count.
* shard_count: number of shards to generate
* secret: array of bytes representing the secret
* secret_length: length of the secret array. must be >= 16, <= 32 and even.
Expand Down

0 comments on commit a006e04

Please sign in to comment.