|
1 | 1 | package org.cryptimeleon.math.structures.rings.cartesian; |
2 | 2 |
|
3 | 3 | import org.cryptimeleon.math.expressions.exponent.ExponentConstantExpr; |
| 4 | +import org.cryptimeleon.math.hash.ByteAccumulator; |
| 5 | +import org.cryptimeleon.math.hash.UniqueByteRepresentable; |
4 | 6 | import org.cryptimeleon.math.serialization.ListRepresentation; |
5 | 7 | import org.cryptimeleon.math.serialization.Representable; |
6 | 8 | import org.cryptimeleon.math.serialization.Representation; |
|
17 | 19 | /** |
18 | 20 | * A vector of ring elements supporting element-wise ring operations with other ring element vectors. |
19 | 21 | */ |
20 | | -public class RingElementVector extends Vector<RingElement> implements Representable { |
| 22 | +public class RingElementVector extends Vector<RingElement> implements Representable, UniqueByteRepresentable { |
21 | 23 |
|
22 | 24 | public RingElementVector(RingElement... values) { |
23 | 25 | super(values); |
@@ -68,7 +70,7 @@ public RingElementVector pow(long exponent) { |
68 | 70 | } |
69 | 71 |
|
70 | 72 | public RingElementVector pow(Vector<?> exponents) { |
71 | | - return zip(exponents, (g,x) -> |
| 73 | + return zip(exponents, (g, x) -> |
72 | 74 | x instanceof Long ? g.pow((Long) x) |
73 | 75 | : g.pow((BigInteger) x), |
74 | 76 | RingElementVector::new); |
@@ -148,4 +150,12 @@ public ProductRingElement asElementInProductRing() { |
148 | 150 | public ExponentExpressionVector asExponentExpr() { |
149 | 151 | return map(v -> new ExponentConstantExpr(v.asInteger()), ExponentExpressionVector::new); |
150 | 152 | } |
| 153 | + |
| 154 | + @Override |
| 155 | + public ByteAccumulator updateAccumulator(ByteAccumulator accumulator) { |
| 156 | + for (RingElement e : this.values) { |
| 157 | + accumulator.escapeAndSeparate(e.getUniqueByteRepresentation()); |
| 158 | + } |
| 159 | + return accumulator; |
| 160 | + } |
151 | 161 | } |
0 commit comments