ecc::chip.rs: Make EccPoint.x, EccPoint.y private fields

Also add public getters x() and y().

Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
therealyingtong 2021-06-11 11:24:12 +08:00
parent 433791fcb0
commit aff56e6763
2 changed files with 13 additions and 3 deletions

View File

@ -459,7 +459,7 @@ mod tests {
// Test complete addition
{
super::chip::add::tests::test_add(
chip.clone(),
chip,
layouter.namespace(|| "complete addition"),
&zero,
p_val,

View File

@ -22,9 +22,9 @@ pub(super) mod witness_point;
#[derive(Clone, Debug)]
pub struct EccPoint<C: CurveAffine> {
/// x-coordinate
pub x: CellValue<C::Base>,
x: CellValue<C::Base>,
/// y-coordinate
pub y: CellValue<C::Base>,
y: CellValue<C::Base>,
}
impl<C: CurveAffine> EccPoint<C> {
@ -41,6 +41,16 @@ impl<C: CurveAffine> EccPoint<C> {
_ => None,
}
}
/// The cell containing the affine short-Weierstrass x-coordinate,
/// or 0 for the zero point.
pub fn x(&self) -> CellValue<C::Base> {
self.x
}
/// The cell containing the affine short-Weierstrass y-coordinate,
/// or 0 for the zero point.
pub fn y(&self) -> CellValue<C::Base> {
self.y
}
}
/// Configuration for the ECC chip