Skip to content

Make sure the noisy matrices are noninvertible#9

Closed
mbenke wants to merge 8 commits intomasterfrom
mbenke/noninvertible
Closed

Make sure the noisy matrices are noninvertible#9
mbenke wants to merge 8 commits intomasterfrom
mbenke/noninvertible

Conversation

@mbenke
Copy link
Contributor

@mbenke mbenke commented Sep 19, 2019

No description provided.

@mbenke mbenke requested a review from kubkon September 19, 2019 11:59
@kubkon
Copy link
Contributor

kubkon commented Sep 23, 2019

For the future, it'd be good if you could specify whether any PR builds on any other. For instance, it seems that this one builds on #8, so naturally, we should first work on #8 before touching this PR.

Copy link
Contributor

@kubkon kubkon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

const MODULUSI32: i32 = 2147483647i32;
const MODULUSI64: i64 = 2147483647i64;
const MODULUSU64: u64 = 2147483647u64;
const MAGIC229: usize = 536870912; // (MODULUS+1) / 4 = 2^29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a note/comment explaining why such value and not something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment referring to try_sqrt

/// Try to solve the equation x^2 = a in our modular arithmetic
/// Since MODULUS = 3 (mod 4), the solution, if exists, is x = a^((MODULUS+1)/4)
pub fn try_sqrt(a: Mod231) -> Option<Mod231> {
let x = num_traits::pow::pow(a, MAGIC229);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering, could we use checked_pow instead perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we don't want to check for overflow, as we are using modular arithmetic

@mbenke mbenke requested a review from kubkon September 23, 2019 13:11
@mbenke
Copy link
Contributor Author

mbenke commented Sep 24, 2019

For the future, it'd be good if you could specify whether any PR builds on any other. For instance, it seems that this one builds on #8, so naturally, we should first work on #8 before touching this PR.

This PR is independent - can be applied on master as well as #8

Created #10 as an independent variant of this PR, in case we want to apply it before #8.

kubkon pushed a commit that referenced this pull request Nov 4, 2019
#10)

* Make sure the noisy matrices are noninvertible

* Comment MAGIC229
@kubkon
Copy link
Contributor

kubkon commented Nov 4, 2019

Since #10 landed, I'll close this PR as it covers the same ground but with #8 as a dependency. If you feel I missed something though, please feel free to reopen this PR.

@kubkon kubkon closed this Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants