Skip to content

Create ModNeg and CModNeg#1300

Merged
NoureldinYosri merged 16 commits intoquantumlib:mainfrom
NoureldinYosri:mod_subtraction
Aug 22, 2024
Merged

Create ModNeg and CModNeg#1300
NoureldinYosri merged 16 commits intoquantumlib:mainfrom
NoureldinYosri:mod_subtraction

Conversation

@NoureldinYosri
Copy link
Copy Markdown
Contributor

PS: ModSub and CModSub are ready but they depend on #1295

Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction_test.py
Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction_test.py
Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction.py Outdated
Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction.py Outdated
p = 13
b = MontgomeryModNeg(n, p)
target_cost = QECGatesCost()
cost: GateCounts = query_costs(b, [target_cost])[b][target_cost]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use get_cost_value

Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction.py Outdated
Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction.py Outdated
Comment thread qualtran/bloqs/mod_arithmetic/mod_subtraction_test.py
counts = get_cost_value(b, QECGatesCost()).total_t_and_ccz_count()

assert counts['n_t'] == 0, 'all toffoli'
assert counts['n_ccz'] == 3 * (n - 1) + 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add a note/comment with litinski fig/table 8

Copy link
Copy Markdown
Contributor Author

@NoureldinYosri NoureldinYosri Aug 21, 2024

Choose a reason for hiding this comment

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

I didn't notice this at first but I'm not using the controlled decomposition from litinski ... this is my own decomposition which matches the cost but for the wrong reason... they turn the CNOTs into toffolis which is not necessary. I just combine the old control qubit and outer control qubit into an ancilla qubit that controls addition ... the CNOTs are left as is
image


for the uncontrolled version we have $3n$ instead of $2n$ because we are not the measurement uncomputation part because as we discussed the measurement thing will add random phase flips.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is my own decomposition

This is important to capture somewhere in the docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

some final things, then lgtm

@NoureldinYosri NoureldinYosri enabled auto-merge (squash) August 21, 2024 18:00

References:
[How to compute a 256-bit elliptic curve private key with only 50 million Toffoli gates](https://arxiv.org/abs/2306.08585)
Fig 6b and 8
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if this doesn't match the reference, please provide a short description of how/why in the class docstring

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

@mpharrigan mpharrigan disabled auto-merge August 21, 2024 21:51
@NoureldinYosri
Copy link
Copy Markdown
Contributor Author

@mpharrigan I added the comments ... please take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants