edauterman / SafetyPin

Apache License 2.0
5 stars 1 forks source link

Optimization opportunity? #2

Open henrycg opened 4 years ago

henrycg commented 4 years ago

https://github.com/edauterman/hsm-impl/blob/66e816ca1900977520e4d34886c488f2c793af29/agent/shamir.cc#L215

It looks like Shamir_ValidateShares and Shamir_ReconstructShares are both doing the expensive polynomial interpolation. Instead, you could interpolate the polynomial once (in Shamir_ReconstructShares) and then pass the coefficients of that polynomial to Shamir_ValidateShares, which could check that all of the shares are point on that polynomial.

edauterman commented 4 years ago

Do you mean the lambda values? They're slightly different depending on if x = 0 to reconstruct or we're using the x from a share we're validating, so I'm not sure how to reuse this (I think this is the same question that I just emailed you about).