Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.cryptimeleon.math.structures.rings.cartesian;

import org.cryptimeleon.math.expressions.exponent.ExponentConstantExpr;
import org.cryptimeleon.math.hash.ByteAccumulator;
import org.cryptimeleon.math.hash.UniqueByteRepresentable;
import org.cryptimeleon.math.serialization.ListRepresentation;
import org.cryptimeleon.math.serialization.Representable;
import org.cryptimeleon.math.serialization.Representation;
Expand All @@ -17,7 +19,7 @@
/**
* A vector of ring elements supporting element-wise ring operations with other ring element vectors.
*/
public class RingElementVector extends Vector<RingElement> implements Representable {
public class RingElementVector extends Vector<RingElement> implements Representable, UniqueByteRepresentable {

public RingElementVector(RingElement... values) {
super(values);
Expand Down Expand Up @@ -68,7 +70,7 @@ public RingElementVector pow(long exponent) {
}

public RingElementVector pow(Vector<?> exponents) {
return zip(exponents, (g,x) ->
return zip(exponents, (g, x) ->
x instanceof Long ? g.pow((Long) x)
: g.pow((BigInteger) x),
RingElementVector::new);
Expand Down Expand Up @@ -148,4 +150,12 @@ public ProductRingElement asElementInProductRing() {
public ExponentExpressionVector asExponentExpr() {
return map(v -> new ExponentConstantExpr(v.asInteger()), ExponentExpressionVector::new);
}

@Override
public ByteAccumulator updateAccumulator(ByteAccumulator accumulator) {
for (RingElement e : this.values) {
accumulator.escapeAndSeparate(e.getUniqueByteRepresentation());
}
return accumulator;
}
}