-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strengthen specification for montgomery_reduce()
There are two uses of the generic Montgomery reduction `montgomery_reduce()` in the code base: - For modular multiplication with twiddles in `fqmul()` - For Montgomery reduction after accumulation in the base multiplication. Those two uses require different specifications for `montgomery_reduce()`. However, there does not appear to be a mechanism in CBMC to register more than one contract. To remedy, this commit moves the previous `montgomery_reduce()` into a static inline `montgomery_reduce_generic()`, and uses it in the definitions of `montgomery_reduce()` and `fqmul()`. The new `montgomery_reduce()` then makes bounds assumptions according to the use in base multiplication, while the call to `montgomery_reduce_generic()` provides stronger input bounds. Accordingly, the post-condition of `montgomery_reduce()` only guarantees coefficients < 3/2q, while `fqmul()` ensures < q. The CBMC contracts an proofs for `montgomery_reduce()` and `fqmul()` are adjusted accordingly. Signed-off-by: Hanno Becker <[email protected]>
- Loading branch information
1 parent
aecf6a4
commit 0a83f82
Showing
4 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters