Skip to content

Commit e84d1a6

Browse files
authored
Merge pull request #139 from cryptimeleon/feature/ring-element-vector-repr
Make RingElementVector UniqueByteRepresentable.
2 parents 71ec439 + cafb09a commit e84d1a6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/org/cryptimeleon/math/structures/rings/cartesian/RingElementVector.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.cryptimeleon.math.structures.rings.cartesian;
22

33
import org.cryptimeleon.math.expressions.exponent.ExponentConstantExpr;
4+
import org.cryptimeleon.math.hash.ByteAccumulator;
5+
import org.cryptimeleon.math.hash.UniqueByteRepresentable;
46
import org.cryptimeleon.math.serialization.ListRepresentation;
57
import org.cryptimeleon.math.serialization.Representable;
68
import org.cryptimeleon.math.serialization.Representation;
@@ -17,7 +19,7 @@
1719
/**
1820
* A vector of ring elements supporting element-wise ring operations with other ring element vectors.
1921
*/
20-
public class RingElementVector extends Vector<RingElement> implements Representable {
22+
public class RingElementVector extends Vector<RingElement> implements Representable, UniqueByteRepresentable {
2123

2224
public RingElementVector(RingElement... values) {
2325
super(values);
@@ -68,7 +70,7 @@ public RingElementVector pow(long exponent) {
6870
}
6971

7072
public RingElementVector pow(Vector<?> exponents) {
71-
return zip(exponents, (g,x) ->
73+
return zip(exponents, (g, x) ->
7274
x instanceof Long ? g.pow((Long) x)
7375
: g.pow((BigInteger) x),
7476
RingElementVector::new);
@@ -148,4 +150,12 @@ public ProductRingElement asElementInProductRing() {
148150
public ExponentExpressionVector asExponentExpr() {
149151
return map(v -> new ExponentConstantExpr(v.asInteger()), ExponentExpressionVector::new);
150152
}
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+
}
151161
}

0 commit comments

Comments
 (0)