Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/tagget_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
java-version: 1.8
- name: Publish to the Maven Central Repository
run: ./gradlew :publish -Prelease
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Prelease
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
Expand Down
15 changes: 7 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}

group = 'org.cryptimeleon'
Expand Down Expand Up @@ -149,15 +150,13 @@ publishing {
}
}
}
}

nexusPublishing {
repositories {
maven {
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
name = 'OSSRH'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
url = version.endsWith('SNAPSHOT') ? '' : releasesRepoUrl
sonatype {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public Vector<X> truncate(int newLength) {
public Vector<X> concatenate(Vector<? extends X> secondPart) {
ArrayList<X> result = new ArrayList<>(values.size() + secondPart.values.size());
result.addAll(values);
result.add((X) secondPart.values);
result.addAll(secondPart.values);

return instantiateWithSafeArray(result);
}
Expand Down
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;
}
}
23 changes: 23 additions & 0 deletions src/test/java/org/cryptimeleon/math/structures/VectorTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.cryptimeleon.math.structures;

import org.cryptimeleon.math.structures.cartesian.Vector;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class VectorTests {

/**
* Test that concatenation yields the correct result.
*/
@Test
void testConcatenation() {
Vector<Integer> firstVector = Vector.of(0, 1, 2, 3);
Vector<Integer> secondVector = Vector.of(4, 5, 6);
Vector<Integer> concatenation = firstVector.concatenate(secondVector);

assertEquals(concatenation.length(), firstVector.length() + secondVector.length());
for (int i = 0; i < concatenation.length(); i++)
assertEquals(concatenation.get(i), i);
}
}