def reconstruct_shamir( shares, i, t=0 ): #Do we have to mention which additive share these backups belong to? i.e. need for 'i'? '''Verify first using VSS and then reconstruct, i is index of the additive share for vss_p, etc''' vss_q = fileOp.read_list("FvssQ")[0] vss_p = fileOp.read_list("FvssP")[0] gen = fileOp.read_list("FvssGen")[0] commitment_list = fileOp.read_list("FvssCommitmentList")[0] res = True for si in shares: if RSAFeldmanVSS.verify_share(si, gen[i], vss_p[i], commitment_list[i]) == False: res = False break if res == False: print("Share:", si, "invalid") raise Exception("Backup Reconstruction Failed") return else: return (ShamirSS.tncombine(shares, vss_q[i], t))
def threshold_additive_shares(shares, t, n): '''Divides all elements in the shares list into t-n threshold shares using Feldman VSS into n sub-shares with threshold t''' global sub_shares global vss_p global vss_q global gen global commitment_list sub_shares = [] commitment_list = [] vss_p = [] vss_q = [] gen = [] for i in shares: feld = RSAFeldmanVSS.feldmanvss(t, n, i) sub_shares.append(feld[0]) #Generate using VSS commitment_list.append(feld[1]) vss_p.append(feld[2]) vss_q.append(feld[3]) gen.append(feld[4]) return
def threshold_additive_shares(): '''Divides all elements in the shares list into t-n threshold shares using Feldman VSS into n sub-shares with threshold t''' shares = fileOp.read_list("FadditiveShares") t, n = 3, 5 #Generates a (3,5) threshold scheme FIX: Read from file sub_shares, commitment_list = [], [] vss_p, vss_q, gen = [], [], [] for i in shares: feld = RSAFeldmanVSS.feldmanvss(t, n, i) sub_shares.append(feld[0]) #Generate using VSS commitment_list.append(feld[1]) vss_p.append(feld[2]) vss_q.append(feld[3]) gen.append(feld[4]) fileOp.write_list("FvssP", vss_p) fileOp.write_list("FvssQ", vss_q) fileOp.write_list("FvssGen", gen) fileOp.write_list("FvssSubShares", sub_shares) fileOp.write_list("FvssCommitmentList", commitment_list) return