Skip to content

Commit

Permalink
Make RingElementVector UniqueByteRepresentable.
Browse files Browse the repository at this point in the history
  • Loading branch information
this-kramer committed Oct 13, 2021
1 parent 71ec439 commit cafb09a
Showing 1 changed file with 12 additions and 2 deletions.
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;
}
}

0 comments on commit cafb09a

Please sign in to comment.