Botan  1.10.9
tss.h
Go to the documentation of this file.
1 /*
2 * RTSS (threshold secret sharing)
3 * (C) 2009 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_RTSS_H__
9 #define BOTAN_RTSS_H__
10 
11 #include <botan/secmem.h>
12 #include <botan/hash.h>
13 #include <botan/rng.h>
14 #include <vector>
15 
16 namespace Botan {
17 
18 /**
19 * A split secret, using the format from draft-mcgrew-tss-03
20 */
21 class BOTAN_DLL RTSS_Share
22  {
23  public:
24  /**
25  * @param M the number of shares needed to reconstruct
26  * @param N the number of shares generated
27  * @param secret the secret to split
28  * @param secret_len the length of the secret
29  * @param identifier the 16 byte share identifier
30  * @param rng the random number generator to use
31  */
32  static std::vector<RTSS_Share>
33  split(byte M, byte N,
34  const byte secret[], u16bit secret_len,
35  const byte identifier[16],
37 
38  /**
39  * @param shares the list of shares
40  */
41  static SecureVector<byte>
42  reconstruct(const std::vector<RTSS_Share>& shares);
43 
45 
46  /**
47  * @param hex_input the share encoded in hexadecimal
48  */
49  RTSS_Share(const std::string& hex_input);
50 
51  /**
52  * @return hex representation
53  */
54  std::string to_string() const;
55 
56  /**
57  * @return share identifier
58  */
59  byte share_id() const;
60 
61  /**
62  * @return size of this share in bytes
63  */
64  size_t size() const { return contents.size(); }
65 
66  /**
67  * @return if this TSS share was initialized or not
68  */
69  bool initialized() const { return (contents.size() > 0); }
70  private:
71  SecureVector<byte> contents;
72  };
73 
74 }
75 
76 #endif
size_t size() const
Definition: tss.h:64
bool initialized() const
Definition: tss.h:69
unsigned char byte
Definition: types.h:22
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
unsigned short u16bit
Definition: types.h:27
std::string to_string(u64bit n, size_t min_len)
Definition: parsing.cpp:42