oasis-core icon indicating copy to clipboard operation
oasis-core copied to clipboard

size is not the same as degree, but careless doc reader could make mistake

Open bennetyee opened this issue 1 year ago • 1 comments

https://github.com/oasisprotocol/oasis-core/blob/18da8bc49d92a543795246b8bb7fb574df070eec/secret-sharing/src/poly/univariate.rs#L89

because we don't trim high degree zeros, size does not return one more than the degree of the polynomial.

while this is not a bug, it feels like a potential foot gun for careless future users of this code.

bennetyee avatar Aug 26 '24 23:08 bennetyee

size does not return one more than the degree of the polynomial.

True. Size returns the size of the underlying vector, which is the same as the number of (zero and non-zero) coefficients in the polynomial. Again avoiding degree to have constant time operations.

    /// Returns the number of coefficients in the polynomial.
    pub fn size(&self) -> usize {

peternose avatar Aug 27 '24 08:08 peternose