summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plop.erl24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plop.erl b/src/plop.erl
index b8e8055..4b9d321 100644
--- a/src/plop.erl
+++ b/src/plop.erl
@@ -200,16 +200,18 @@ sth(PrivKey, Tree, #sth_signed{version = Version, timestamp = Timestamp_in}) ->
Treesize = ht:size(Tree),
Roothash = ht:tree_hash(Tree),
BinToSign =
- list_to_binary(serialise(#sth_signed{version = Version,
- signature_type = tree_hash,
- timestamp = Timestamp,
- tree_size = Treesize,
- root_hash = Roothash})),
+ list_to_binary(serialise(#sth_signed{
+ version = Version,
+ signature_type = tree_hash,
+ timestamp = Timestamp,
+ tree_size = Treesize,
+ root_hash = Roothash})),
Signature = signhash(BinToSign, PrivKey),
- STH = <<Treesize:64,
- Timestamp:64,
- Roothash/binary,
- Signature/binary>>,
+ STH = #sth{
+ treesize = Treesize,
+ timestamp = Timestamp,
+ roothash = Roothash,
+ signature = Signature},
io:format("STH: ~p~nBinToSign: ~p~nSignature: ~p~nTimestamp: ~p~n",
[STH, BinToSign, Signature, Timestamp]),
STH.
@@ -304,7 +306,8 @@ timestamp(Timestamp) ->
_ -> Timestamp
end.
--spec serialise(plop_entry() | timestamped_entry() | spt() | spt_signed() | mtl() | sth_signed()) -> iolist().
+-spec serialise(plop_entry() | timestamped_entry() | mtl() |
+ spt() | spt_signed() | sth() | sth_signed()) -> iolist().
serialise(#plop_entry{
type = TypeAtom,
data = Data
@@ -365,7 +368,6 @@ serialise(#sth_signed{ % Signed Tree Head.
Treesize:64,
Roothash/binary>>].
-
%%%%%%%%%%%%%%%%%%%%
%% Tests.
serialise_test_() ->