Commit Graph

14 Commits

Author SHA1 Message Date
therealyingtong 52f53f3425 Remove IsIdentity trait from public EccInstructions.
We only need is_identity() in tests and can implement it on the
concrete EccPoint type. This method is flagged off by #[cfg(test)].

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-09-28 20:31:32 +01:00
therealyingtong 8ad3003e27 Remove Point::new() API and introduce is_identity() instruction.
Also remove the q_point selector and gate from the circuit.
2021-09-28 13:13:25 -06:00
therealyingtong 258fe5796b ecc::chip: Propagate changes to sub-chips.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-09-28 13:13:25 -06:00
therealyingtong 90b59baca5 mul_fixed: Remove unused selectors and duplicate gates.
Selectors previously used in the witness_scalar_* APIs, such as
q_scalar_fixed and q_scalar_fixed_short, are now removed. The
remaining selectors have been renamed for clarity.

The coordinates check for scalars decomposed using a running sum
has been moved into the mul_fixed.rs file, instead of being
duplicated in both mul_fixed::base_field_elem and mul_fixed::short.

The decompose_scalar_fixed() method is now only used in
mul_fixed::full_width, and has been moved there.
2021-07-18 00:10:15 +08:00
therealyingtong 32f3068886 ecc.rs: Add MulFixedBaseField type.
In the Orchard protocol, only the NullifierK fixed base in used in
scalar multiplication with a base field element.

The mul_fixed_base_field_elem() API does not have to accept fixed
bases other than NullifierK; conversely, NullifierK does not have
to work with the full-width mul_fixed() API.
2021-07-15 20:51:52 +08:00
therealyingtong 426f954b1d gadget::ecc.rs: Inline witness_scalar_* APIs.
Witness a scalar in the region where it is used for multiplication,
instead of witnessing it separately and then copying it in.
2021-07-15 20:46:46 +08:00
therealyingtong e2ea443fad mul_fixed::*::tests: Witness expected point and constrain result to be equal. 2021-07-08 15:06:47 +08:00
therealyingtong 22ec16f129 Minor refactors, cleanups, clippy fixes, docfixes.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-07-08 13:31:56 +08:00
therealyingtong 96863c9f73 mul_fixed::*: Use a separate region for complete addition assignment.
The mul_fixed regions use complete addition on the last window,
and incomplete addition on all other windows. However, the complete
addition does not depend on any offsets in the incomplete addition
region, and can be separated into a disjoint region. Since incomplete
addition uses only four advice columns, while complete addition uses
nine, separating the regions would allow the layouter to optimise
their placement.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-07-08 12:04:43 +08:00
therealyingtong b69094036c chip::mul_fixed.rs: Make q_mul_fixed a selector instead of fixed column. 2021-07-07 23:12:31 +08:00
therealyingtong 2d343af068 Update mul_fixed_* APIs to take Layouter instead of Region.
These APIs are not called internally.
2021-07-07 23:10:59 +08:00
therealyingtong d550e156d9 mul_fixed_*::tests: Constrain zero outputs in mul_fixed tests.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-07-07 23:10:59 +08:00
therealyingtong 09b4da197d base_field_elem.rs: Support fixed-base mul using base field element.
In Orchard nullifier derivation, we multiply the fixed base
K^Orchard by a value encoded as a base field element. This commit
introduces an API that allows using a base field element as the
"scalar" in fixed-base scalar multiplication.

The API currently assumes that the base field element is output by
another instruction (i.e. there is no instruction to directly
witness it).
2021-07-07 23:10:59 +08:00
therealyingtong ae25310385 chip::mul_fixed.rs: Implement fixed-base scalar mul instruction.
Fixed-base scalar mul makes use of the add_incomplete and add
instructions internally. The full-width and short signed share
some common logic, which is captured in chip::mul_fixed.rs.

The signed short variant introduces additional logic to handle
the scalar's sign. This is done in the submodule mul_fixed::short.
2021-07-07 23:10:59 +08:00