forked from DNAProject/DNA-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookKeeper.java
More file actions
37 lines (30 loc) · 1.09 KB
/
Copy pathBookKeeper.java
File metadata and controls
37 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package DNA.Core;
import java.io.IOException;
import java.math.BigInteger;
import org.bouncycastle.math.ec.ECPoint;
import DNA.Helper;
import DNA.Cryptography.ECC;
import DNA.IO.BinaryReader;
import DNA.IO.BinaryWriter;
public class BookKeeper extends Transaction {
public ECPoint issuer;
public BookKeeperAction action;
public byte[] cert;
public BookKeeper() {
super(TransactionType.BookKeeper);
}
@Override
protected void deserializeExclusiveData(BinaryReader reader) throws IOException {
issuer = ECC.secp256r1.getCurve().createPoint(
new BigInteger(1,reader.readVarBytes()), new BigInteger(1,reader.readVarBytes()));
action = BookKeeperAction.valueOf(reader.readByte());
cert = reader.readVarBytes();
}
@Override
protected void serializeExclusiveData(BinaryWriter writer) throws IOException {
writer.writeVarBytes(Helper.removePrevZero(issuer.getXCoord().toBigInteger().toByteArray()));
writer.writeVarBytes(Helper.removePrevZero(issuer.getYCoord().toBigInteger().toByteArray()));
writer.writeByte(action.value());
writer.writeVarBytes(cert);
}
}