-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tidying up * Fix json deserilization of mintdistribution and tweaks to `BakerKeys`. * Fix parsing bug in blocktransactionevents
- Loading branch information
1 parent
09c4a16
commit 4716ff2
Showing
46 changed files
with
676 additions
and
440 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
16 changes: 16 additions & 0 deletions
16
concordium-sdk/src/main/java/com/concordium/sdk/crypto/KeyJsonSerializer.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,16 @@ | ||
package com.concordium.sdk.crypto; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import org.apache.commons.codec.binary.Hex; | ||
|
||
import java.io.IOException; | ||
|
||
public class KeyJsonSerializer extends JsonSerializer<RawKey> { | ||
|
||
@Override | ||
public void serialize(RawKey value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writeString(Hex.encodeHexString(value.getRawBytes())); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
concordium-sdk/src/main/java/com/concordium/sdk/crypto/RawKey.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,9 @@ | ||
package com.concordium.sdk.crypto; | ||
|
||
/** | ||
* Interface for keys exposed in a raw format i.e. a byte array. | ||
*/ | ||
public interface RawKey { | ||
|
||
byte[] getRawBytes(); | ||
} |
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
35 changes: 0 additions & 35 deletions
35
...ium-sdk/src/main/java/com/concordium/sdk/crypto/bakertransactions/BakerKeysJniOutput.java
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
concordium-sdk/src/main/java/com/concordium/sdk/crypto/bls/BLSPublicKey.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,55 @@ | ||
package com.concordium.sdk.crypto.bls; | ||
|
||
import com.concordium.sdk.crypto.RawKey; | ||
import com.concordium.sdk.crypto.KeyJsonSerializer; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.codec.DecoderException; | ||
import org.apache.commons.codec.binary.Hex; | ||
|
||
import java.util.Arrays; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
@EqualsAndHashCode | ||
@JsonSerialize(using = KeyJsonSerializer.class) | ||
public class BLSPublicKey implements RawKey { | ||
/** | ||
* The bytes of the public key. | ||
*/ | ||
private final byte[] bytes; | ||
|
||
@JsonCreator | ||
public static BLSPublicKey from(String hexKey) { | ||
try { | ||
return from(Hex.decodeHex(hexKey)); | ||
} catch (DecoderException e) { | ||
throw new IllegalArgumentException("Cannot create BLSPublicKey", e); | ||
} | ||
} | ||
|
||
/** | ||
* Creates an BLS Public Key from {@link byte} Array. | ||
* | ||
* @param bytes Input Byte Array | ||
* @return Instance of {@link BLSPublicKey} | ||
*/ | ||
public static BLSPublicKey from(final byte[] bytes) { | ||
return new BLSPublicKey(Arrays.copyOf(bytes, bytes.length)); | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return Hex.encodeHexString(this.bytes); | ||
} | ||
|
||
@Override | ||
public byte[] getRawBytes() { | ||
return this.bytes; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
concordium-sdk/src/main/java/com/concordium/sdk/crypto/bls/BLSSecretKey.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,55 @@ | ||
package com.concordium.sdk.crypto.bls; | ||
|
||
import com.concordium.sdk.crypto.RawKey; | ||
import com.concordium.sdk.crypto.KeyJsonSerializer; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.codec.DecoderException; | ||
import org.apache.commons.codec.binary.Hex; | ||
|
||
import java.util.Arrays; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
@EqualsAndHashCode | ||
@JsonSerialize(using = KeyJsonSerializer.class) | ||
public class BLSSecretKey implements RawKey { | ||
/** | ||
* The bytes of the public key. | ||
*/ | ||
private final byte[] bytes; | ||
|
||
@JsonCreator | ||
public static BLSSecretKey from(String hexKey) { | ||
try { | ||
return from(Hex.decodeHex(hexKey)); | ||
} catch (DecoderException e) { | ||
throw new IllegalArgumentException("Cannot create BLSSecretKey", e); | ||
} | ||
} | ||
|
||
/** | ||
* Creates an BLS Public Key from {@link byte} Array. | ||
* | ||
* @param bytes Input Byte Array | ||
* @return Instance of {@link BLSSecretKey} | ||
*/ | ||
public static BLSSecretKey from(final byte[] bytes) { | ||
return new BLSSecretKey(Arrays.copyOf(bytes, bytes.length)); | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return Hex.encodeHexString(this.bytes); | ||
} | ||
|
||
@Override | ||
public byte[] getRawBytes() { | ||
return this.bytes; | ||
} | ||
} |
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
Oops, something went wrong.