Reference: Modular Addition Qubricks¶
ModularAdd ¶
Bases: Qubrick
Modular addition: computes dst = (dst + rhs) % M, where M is a positive integer.
dst must store a value less than M.
rhs as type QUInt, QInt, and Qubits must store a value less than M. As type QInt, rhs must also store a value greater than -M. If rhs is of type int, it can store any value.
While this was implemented independently, it ended up similar to the one described in "How to compute a 256-bit elliptic curve private key with only 50 million Toffoli gates" (https://arxiv.org/abs/2306.08585 ⧉).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adder_qubrick
|
Qubrick or None
|
Qubrick to perform internal additions. Defaults to GidneyAdd. |
None
|
compute ¶
Computes dst = (dst + rhs) % M.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dst
|
QUInt
|
Register to add the number to. |
required |
rhs
|
QUInt | QInt | int
|
The number to add to |
required |
M
|
int
|
The modulo used for modular addition. |
required |
ctrl
|
Qubits | None
|
Optional quantum control. |
None
|
Note
dstis unsigned, and must store a value less than M.- If
rhsis a QInt or QUInt, it must store values less than M. - If
rhsis a QInt, it must store a value greater than -M. - If
rhsis an int, it may store any value.