|
2 | 2 |
|
3 | 3 | import org.cryptimeleon.math.expressions.Expression; |
4 | 4 | import org.cryptimeleon.math.expressions.Substitution; |
| 5 | +import org.cryptimeleon.math.expressions.exponent.ExponentEmptyExpr; |
5 | 6 | import org.cryptimeleon.math.expressions.exponent.ExponentExpr; |
6 | 7 | import org.cryptimeleon.math.expressions.exponent.ExponentSumExpr; |
7 | 8 | import org.cryptimeleon.math.structures.groups.GroupElement; |
@@ -74,10 +75,16 @@ public GroupOpExpr linearize() throws IllegalArgumentException { |
74 | 75 |
|
75 | 76 | if (baseHasVariables) { //hence exponent doesn't |
76 | 77 | GroupOpExpr baseLinear = base.linearize(); |
77 | | - return new GroupOpExpr(baseLinear.getLhs().pow(exponent), baseLinear.getRhs().pow(exponent)); |
| 78 | + if (baseLinear.getLhs() instanceof GroupEmptyExpr) //base is linear already, hence this PowExpr is linear |
| 79 | + return new GroupOpExpr(new GroupEmptyExpr(base.getGroup()), this); |
| 80 | + else //split base into linear and constant part |
| 81 | + return new GroupOpExpr(baseLinear.getLhs().pow(exponent), baseLinear.getRhs().pow(exponent)); |
78 | 82 | } else { //exponent has variables, base doesn't. |
79 | 83 | ExponentSumExpr exponentLinear = exponent.linearize(); |
80 | | - return new GroupOpExpr(base.pow(exponentLinear.getLhs()), base.pow(exponentLinear.getRhs())); |
| 84 | + if (exponentLinear.getLhs() instanceof ExponentEmptyExpr) //exponent is linear already, hence this PowExpr is linear |
| 85 | + return new GroupOpExpr(new GroupEmptyExpr(base.getGroup()), this); |
| 86 | + else //split exponent into linear and constant part |
| 87 | + return new GroupOpExpr(base.pow(exponentLinear.getLhs()), base.pow(exponentLinear.getRhs())); |
81 | 88 | } |
82 | 89 | } |
83 | 90 |
|
|
0 commit comments