This commit is contained in:
parent
bc29388ef1
commit
47684c67aa
4 changed files with 28 additions and 14 deletions
BIN
a.output
Normal file
BIN
a.output
Normal file
Binary file not shown.
BIN
b.output
Normal file
BIN
b.output
Normal file
Binary file not shown.
|
|
@ -451,15 +451,29 @@ module WithdrawConfirmationPS = struct
|
||||||
noreveal_index: int32;
|
noreveal_index: int32;
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = Purpose.size + HashPlanchetsP.size + int32_size
|
(*let size = Purpose.size + HashPlanchetsP.size + int32_size*)
|
||||||
let purpose = Purpose.make ~size Taler_signatures.exchange_confirm_withdraw
|
|
||||||
|
|
||||||
let bin =
|
open Bin
|
||||||
let open Bin in
|
|
||||||
record (fun _urpose h_planchets noreveal_index ->
|
let rec bin =
|
||||||
{ h_planchets; noreveal_index })
|
lazy
|
||||||
|+ field Purpose.bin (Fun.const purpose)
|
(record (fun _purpose h_planchets noreveal_index ->
|
||||||
|+ field HashPlanchetsP.bin (fun t -> t.h_planchets)
|
{ h_planchets; noreveal_index })
|
||||||
|+ field beint32 (fun t -> t.noreveal_index)
|
|+ field Purpose.bin (fun _t -> Lazy.force purpose)
|
||||||
|> sealr
|
|+ field HashPlanchetsP.bin (fun t -> t.h_planchets)
|
||||||
|
|+ field beint32 (fun t -> t.noreveal_index)
|
||||||
|
|> sealr)
|
||||||
|
|
||||||
|
and size =
|
||||||
|
lazy
|
||||||
|
(let size_t = Size.of_value (Size.size_of (Lazy.force bin)) in
|
||||||
|
match size_t with
|
||||||
|
| Static n -> n
|
||||||
|
| Dynamic _ | Unknown ->
|
||||||
|
Fmt.failwith "size_of failure: size is not Static")
|
||||||
|
|
||||||
|
and purpose =
|
||||||
|
lazy
|
||||||
|
(let size = Lazy.force size in
|
||||||
|
Purpose.make ~size Taler_signatures.exchange_confirm_withdraw)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,12 @@ let () =
|
||||||
let open Binary_formats.WithdrawConfirmationPS in
|
let open Binary_formats.WithdrawConfirmationPS in
|
||||||
let str64 = String.init 64 (fun i -> Char.unsafe_chr (i + 1)) in
|
let str64 = String.init 64 (fun i -> Char.unsafe_chr (i + 1)) in
|
||||||
let dummy_t = { h_planchets= { v= { v= str64 } }; noreveal_index= 0_l } in
|
let dummy_t = { h_planchets= { v= { v= str64 } }; noreveal_index= 0_l } in
|
||||||
|
let bin = Lazy.force bin in
|
||||||
|
let size = Lazy.force size in
|
||||||
let size' = Bin.size_of_value bin dummy_t |> Option.get in
|
let size' = Bin.size_of_value bin dummy_t |> Option.get in
|
||||||
assert (size = size');
|
assert (size = size');
|
||||||
assert (size = 76);
|
assert (size = 76);
|
||||||
|
|
||||||
(* for cmp test with signatures.c output
|
(* for cmp test with signatures.c output *)
|
||||||
let raw_str = Bin.to_string bin dummy_t in
|
let raw_str = Bin.to_string bin dummy_t in
|
||||||
Printf.printf "%s" raw_str;
|
Printf.printf "%s" raw_str; ()
|
||||||
*)
|
|
||||||
()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue