CCF
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
ccf::crypto::sharing Namespace Reference

Classes

struct  Share
 

Typedefs

using element = uint64_t
 

Functions

element ct_reduce (element x)
 
void sample_secret_and_shares (Share &raw_secret, const std::span< Share > &shares, size_t threshold)
 
void recover_unauthenticated_secret (Share &raw_secret, const std::span< Share const > &shares, size_t threshold)
 

Variables

constexpr size_t SHIFT_OFFSET = 31
 
constexpr element prime
 

Typedef Documentation

◆ element

Function Documentation

◆ ct_reduce()

element ccf::crypto::sharing::ct_reduce ( element  x)

◆ recover_unauthenticated_secret()

void ccf::crypto::sharing::recover_unauthenticated_secret ( Share raw_secret,
const std::span< Share const > &  shares,
size_t  threshold 
)

Using shares, recover secret, without authentication.

Parameters
[out]raw_secretRecovered secret value.
[in]sharesShares of raw_secret.
thresholdNumber of shares necessary to recover the secret.

Note that shares passed in excess of the threshold are ignored, and that recovery does not authenticate the shares or the threshold.

Exceptions
std::invalid_argumentif the number of shares is insufficient, or if two shares have the same x coordinate.

◆ sample_secret_and_shares()

void ccf::crypto::sharing::sample_secret_and_shares ( Share raw_secret,
const std::span< Share > &  shares,
size_t  threshold 
)

Sample a secret into raw_secret, and split it into shares. Enforces 1 < threshold <= number of shares.

Parameters
[out]raw_secretSampled secret value.
[out]sharesShares of raw_secret. Note that the size of the span determines the number of shares.
[in]thresholdNumber of shares necessary to recover the secret.

The secret is guaranteed to contain at least 256 bits of entropy. Note that is it not safe to use the secret as a key directly, and that a round of key derivation is necessary (Share::key()).

Variable Documentation

◆ prime

constexpr element ccf::crypto::sharing::prime
constexpr
Initial value:
=
(1UL << SHIFT_OFFSET) - 1UL
constexpr size_t SHIFT_OFFSET
Definition sharing.cpp:21

◆ SHIFT_OFFSET

constexpr size_t ccf::crypto::sharing::SHIFT_OFFSET = 31
constexpr