-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into generate/9a6c0845
- Loading branch information
Showing
11 changed files
with
215 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/algorand/algosdk/transaction/HeartbeatProof.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.algorand.algosdk.transaction; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.crypto.*; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
|
||
@JsonPropertyOrder(alphabetic = true) | ||
@JsonInclude(JsonInclude.Include.NON_DEFAULT) | ||
public class HeartbeatProof implements Serializable { | ||
@JsonProperty("s") | ||
public Signature sig = new Signature(); | ||
|
||
@JsonProperty("p") | ||
public Ed25519PublicKey pk = new Ed25519PublicKey(); | ||
|
||
@JsonProperty("p2") | ||
public Ed25519PublicKey pk2 = new Ed25519PublicKey(); | ||
|
||
@JsonProperty("p1s") | ||
public Signature pk1Sig = new Signature(); | ||
|
||
@JsonProperty("p2s") | ||
public Signature pk2Sig = new Signature(); | ||
|
||
public HeartbeatProof() {} | ||
|
||
public HeartbeatProof( | ||
Signature sig, | ||
Ed25519PublicKey pk, | ||
Ed25519PublicKey pk2, | ||
Signature pk1Sig, | ||
Signature pk2Sig | ||
) { | ||
this.sig = Objects.requireNonNull(sig, "sig must not be null"); | ||
this.pk = Objects.requireNonNull(pk, "pk must not be null"); | ||
this.pk2 = Objects.requireNonNull(pk2, "pk2 must not be null"); | ||
this.pk1Sig = Objects.requireNonNull(pk1Sig, "pk1Sig must not be null"); | ||
this.pk2Sig = Objects.requireNonNull(pk2Sig, "pk2Sig must not be null"); | ||
} | ||
|
||
@JsonCreator | ||
public HeartbeatProof( | ||
@JsonProperty("s") byte[] sig, | ||
@JsonProperty("p") byte[] pk, | ||
@JsonProperty("p2") byte[] pk2, | ||
@JsonProperty("p1s") byte[] pk1Sig, | ||
@JsonProperty("p2s") byte[] pk2Sig | ||
) { | ||
this.sig = new Signature(sig); | ||
this.pk = new Ed25519PublicKey(pk); | ||
this.pk2 = new Ed25519PublicKey(pk2); | ||
this.pk1Sig = new Signature(pk1Sig); | ||
this.pk2Sig = new Signature(pk2Sig); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
HeartbeatProof that = (HeartbeatProof) o; | ||
return Objects.equals(sig, that.sig) && | ||
Objects.equals(pk, that.pk) && | ||
Objects.equals(pk2, that.pk2) && | ||
Objects.equals(pk1Sig, that.pk1Sig) && | ||
Objects.equals(pk2Sig, that.pk2Sig); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
src/main/java/com/algorand/algosdk/transaction/HeartbeatTxnFields.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.algorand.algosdk.transaction; | ||
|
||
import java.io.Serializable; | ||
import java.math.BigInteger; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.crypto.*; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
@JsonPropertyOrder(alphabetic = true) | ||
@JsonInclude(JsonInclude.Include.NON_DEFAULT) | ||
public class HeartbeatTxnFields implements Serializable { | ||
@JsonProperty("a") | ||
public Address hbAddress = new Address(); | ||
|
||
@JsonProperty("prf") | ||
public HeartbeatProof hbProof = new HeartbeatProof(); | ||
|
||
@JsonProperty("sd") | ||
public byte[] hbSeed = new byte[32]; // committee.Seed | ||
|
||
@JsonProperty("vid") | ||
public ParticipationPublicKey hbVoteID = new ParticipationPublicKey(); | ||
|
||
@JsonProperty("kd") | ||
public BigInteger hbKeyDilution = BigInteger.valueOf(0); | ||
|
||
public HeartbeatTxnFields() {} | ||
|
||
public HeartbeatTxnFields( | ||
Address hbAddress, | ||
HeartbeatProof hbProof, | ||
byte[] hbSeed, | ||
ParticipationPublicKey hbVoteID, | ||
BigInteger hbKeyDilution | ||
) { | ||
this.hbAddress = Objects.requireNonNull(hbAddress, "hbAddress must not be null"); | ||
this.hbProof = Objects.requireNonNull(hbProof, "hbProof must not be null"); | ||
this.hbVoteID = Objects.requireNonNull(hbVoteID, "hbVoteID must not be null"); | ||
this.hbKeyDilution = Objects.requireNonNull(hbKeyDilution, "hbKeyDilution must not be null"); | ||
if (hbSeed == null) { | ||
throw new NullPointerException("hbSeed must not be null"); | ||
} | ||
System.arraycopy(hbSeed, 0, this.hbSeed, 0, this.hbSeed.length); | ||
} | ||
|
||
@JsonCreator | ||
public HeartbeatTxnFields( | ||
@JsonProperty("a") byte[] hbAddress, | ||
@JsonProperty("prf") HeartbeatProof hbProof, | ||
@JsonProperty("sd") byte[] hbSeed, | ||
@JsonProperty("vid") byte[] hbVoteID, | ||
@JsonProperty("kd") BigInteger hbKeyDilution | ||
) { | ||
if (hbAddress != null) { | ||
this.hbAddress = new Address(hbAddress); | ||
} | ||
if (hbProof != null) { | ||
this.hbProof = hbProof; | ||
} | ||
if (hbSeed != null) { | ||
System.arraycopy(hbSeed, 0, this.hbSeed, 0, this.hbSeed.length); | ||
} | ||
if (hbVoteID != null) { | ||
this.hbVoteID = new ParticipationPublicKey(hbVoteID); | ||
} | ||
if (hbKeyDilution != null) { | ||
this.hbKeyDilution = hbKeyDilution; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
HeartbeatTxnFields that = (HeartbeatTxnFields) o; | ||
return hbAddress.equals(that.hbAddress) && | ||
hbProof.equals(that.hbProof) && | ||
Arrays.equals(hbSeed, that.hbSeed) && | ||
hbVoteID.equals(that.hbVoteID) && | ||
hbKeyDilution.equals(that.hbKeyDilution); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters