Skip to content

Commit ce333fd

Browse files
committed
made field elements serialize to json
1 parent e9da6f0 commit ce333fd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/main/java/de/rub/nds/protocol/crypto/ec/FieldElement.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
package de.rub.nds.protocol.crypto.ec;
1010

11+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
1112
import jakarta.xml.bind.annotation.XmlAccessType;
1213
import jakarta.xml.bind.annotation.XmlAccessorType;
1314
import java.io.Serializable;
@@ -22,6 +23,7 @@
2223
* All arithmetic operations are performed within the laws of the specified field.
2324
*/
2425
@XmlAccessorType(XmlAccessType.FIELD)
26+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
2527
public abstract class FieldElement implements Serializable {
2628

2729
/*
@@ -31,7 +33,13 @@ public abstract class FieldElement implements Serializable {
3133
private final BigInteger data;
3234
private final BigInteger modulus;
3335

34-
public FieldElement(BigInteger data, BigInteger modulus) {
36+
/** Default constructor for JAXB. */
37+
protected FieldElement() {
38+
this.data = null;
39+
this.modulus = null;
40+
}
41+
42+
protected FieldElement(BigInteger data, BigInteger modulus) {
3543
this.data = data;
3644
this.modulus = modulus;
3745
}

src/main/java/de/rub/nds/protocol/crypto/ec/FieldElementF2m.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public FieldElementF2m(BigInteger data, BigInteger modulus) {
3535
super(data, modulus);
3636
}
3737

38+
@SuppressWarnings("unused")
3839
private FieldElementF2m() {
3940
super(null, null);
4041
}

src/main/java/de/rub/nds/protocol/crypto/ec/FieldElementFp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public FieldElementFp(BigInteger data, BigInteger modulus) {
1818
super(data.mod(modulus), modulus);
1919
}
2020

21+
@SuppressWarnings("unused")
2122
private FieldElementFp() {
2223
super(null, null);
2324
}

0 commit comments

Comments
 (0)