From b477880a3b9c097b65b1e006d8116f3998cf013c Mon Sep 17 00:00:00 2001 From: Pascal Berrang Date: Thu, 23 Mar 2023 21:53:45 +0000 Subject: [PATCH] Fix base scalar multiplication (#117) --- CHANGELOG.md | 1 + src/groups/curves/short_weierstrass/mod.rs | 2 +- src/groups/mod.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 396764a..2f7fa41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG ## Pending +- [\#117](https://github.com/arkworks-rs/r1cs-std/pull/117) Fix result of `precomputed_base_scalar_mul_le` to not discard previous value. ### Breaking changes diff --git a/src/groups/curves/short_weierstrass/mod.rs b/src/groups/curves/short_weierstrass/mod.rs index 91eae94..b41d959 100644 --- a/src/groups/curves/short_weierstrass/mod.rs +++ b/src/groups/curves/short_weierstrass/mod.rs @@ -559,7 +559,7 @@ where .map(|(b, c)| (b.borrow().clone(), *c)) .unzip(); let base = bases[0]; - *self = Self::constant(base).scalar_mul_le(bits.iter())?; + *self += Self::constant(base).scalar_mul_le(bits.iter())?; Ok(()) } } diff --git a/src/groups/mod.rs b/src/groups/mod.rs index a02e303..fb8c746 100644 --- a/src/groups/mod.rs +++ b/src/groups/mod.rs @@ -134,7 +134,7 @@ pub trait CurveVar: // else, set self = self; result = bit.borrow().select(&self_plus_base, &result)?; } - *self = result; + *self += result; Ok(()) }