Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Make from_canvas return a Result #137

Open
franziskuskiefer opened this issue Aug 18, 2021 · 0 comments
Open

Make from_canvas return a Result #137

franziskuskiefer opened this issue Aug 18, 2021 · 0 comments

Comments

@franziskuskiefer
Copy link
Member

franziskuskiefer commented Aug 18, 2021

The problem is that from_canvas just forces the value into the scalar. Instead we have to check that the value is in [1, order-1] and return an error if not. We could do this in the P256 code. But it's a pretty common functionality such that I think it would make sense to have it in the library.

Originally posted by @franziskuskiefer in #134 (comment)

nat_mod should check that scalars are valid instead taking the remainder

pub fn from_canvas(x: $base) -> $name {
$name(x.rem($max))
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant