Skip to content

Commit 8613dd2

Browse files
authored
Merge pull request #140 from cryptimeleon/develop
math release of version 3.0.1
2 parents 462090c + e84d1a6 commit 8613dd2

5 files changed

Lines changed: 44 additions & 12 deletions

File tree

.github/workflows/tagget_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
java-version: 1.8
1616
- name: Publish to the Maven Central Repository
17-
run: ./gradlew :publish -Prelease
17+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Prelease
1818
env:
1919
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
2020
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java-library'
33
id 'maven-publish'
44
id 'signing'
5+
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
56
}
67

78
group = 'org.cryptimeleon'
@@ -149,15 +150,13 @@ publishing {
149150
}
150151
}
151152
}
153+
}
154+
155+
nexusPublishing {
152156
repositories {
153-
maven {
154-
credentials {
155-
username = System.getenv("OSSRH_USERNAME")
156-
password = System.getenv("OSSRH_TOKEN")
157-
}
158-
name = 'OSSRH'
159-
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
160-
url = version.endsWith('SNAPSHOT') ? '' : releasesRepoUrl
157+
sonatype {
158+
username = System.getenv("OSSRH_USERNAME")
159+
password = System.getenv("OSSRH_TOKEN")
161160
}
162161
}
163162
}

src/main/java/org/cryptimeleon/math/structures/cartesian/Vector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public Vector<X> truncate(int newLength) {
329329
public Vector<X> concatenate(Vector<? extends X> secondPart) {
330330
ArrayList<X> result = new ArrayList<>(values.size() + secondPart.values.size());
331331
result.addAll(values);
332-
result.add((X) secondPart.values);
332+
result.addAll(secondPart.values);
333333

334334
return instantiateWithSafeArray(result);
335335
}

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
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.cryptimeleon.math.structures;
2+
3+
import org.cryptimeleon.math.structures.cartesian.Vector;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
public class VectorTests {
9+
10+
/**
11+
* Test that concatenation yields the correct result.
12+
*/
13+
@Test
14+
void testConcatenation() {
15+
Vector<Integer> firstVector = Vector.of(0, 1, 2, 3);
16+
Vector<Integer> secondVector = Vector.of(4, 5, 6);
17+
Vector<Integer> concatenation = firstVector.concatenate(secondVector);
18+
19+
assertEquals(concatenation.length(), firstVector.length() + secondVector.length());
20+
for (int i = 0; i < concatenation.length(); i++)
21+
assertEquals(concatenation.get(i), i);
22+
}
23+
}

0 commit comments

Comments
 (0)