From 05401ea36bbd7926fbdc0f792542135f551d3c0b Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 5 May 2014 12:02:55 +0200 Subject: Define #sth{} and have sth() return those. --- src/plop.erl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') 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 = <>, + 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_() -> -- cgit v1.1