Skip to content

Commit

Permalink
Fix mul_without_reduce when self is a constant (#36)
Browse files Browse the repository at this point in the history
* fix

* fix
  • Loading branch information
weikengchen authored Feb 6, 2021
1 parent cf70d14 commit dbe5657
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/nonnative_field_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,19 @@ impl<TargetField: PrimeField, BaseField: PrimeField> NonNativeFieldVar<TargetFie
other: &Self,
) -> R1CSResult<NonNativeFieldMulResultVar<TargetField, BaseField>> {
match self {
Self::Constant(c) => Ok(NonNativeFieldMulResultVar::Constant(*c)),
Self::Constant(c) => match other {
Self::Constant(other_c) => Ok(NonNativeFieldMulResultVar::Constant(*c * other_c)),
Self::Var(other_v) => {
let self_v =
AllocatedNonNativeFieldVar::<TargetField, BaseField>::new_constant(
self.cs(),
c,
)?;
Ok(NonNativeFieldMulResultVar::Var(
other_v.mul_without_reduce(&self_v)?,
))
}
},
Self::Var(v) => {
let other_v = match other {
Self::Constant(other_c) => {
Expand Down

0 comments on commit dbe5657

Please sign in to comment.