diff --git a/Sources/TorusUtils/Extensions/TorusUtils+extension.swift b/Sources/TorusUtils/Extensions/TorusUtils+extension.swift index 45dee324..989ccbe2 100644 --- a/Sources/TorusUtils/Extensions/TorusUtils+extension.swift +++ b/Sources/TorusUtils/Extensions/TorusUtils+extension.swift @@ -230,6 +230,40 @@ extension TorusUtils { + private func reconstructKey(decryptedShares: [Int: String], thresholdPublicKey: KeyAssignment.PublicKey) throws -> String? { + + // run lagrange interpolation on all subsets, faster in the optimistic scenario than berlekamp-welch due to early exit + let allCombis = kCombinations(s: decryptedShares.count, k: 3) + var returnedKey: String? = nil + + for j in 0..