From d05ee80b346ade0a991d8b6c7b25830e3d40541c Mon Sep 17 00:00:00 2001 From: himanshu Date: Fri, 1 Sep 2023 13:11:09 +0800 Subject: [PATCH] use both zeropadding and pkcs7 decryption --- .../Extensions/TorusUtils+extension.swift | 86 ++++++++++++------- Tests/TorusUtilsTests/SapphireTest.swift | 3 +- 2 files changed, 57 insertions(+), 32 deletions(-) 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..