I think it would be a good idea to store the threshold in Share objects.
We would then be able to correctly recognize constants that end up being
Shares since their degree would be zero.
The rules for manipulating the degree seem simple: give the result
degree max(d1, d2) when adding Shares, and d1+d2 when multiplying them.
Opening would reset the degree to zero.
Making this change would make the logic simpler in Runtime.mul since we
could let Share.__mul__ take care of wrapping constants in Shares with
degree zero -- Runtime.mul would then only reshare if the degree of the
product exceeds the default threshold in the Runtime.
|