diff --git a/src/binary_formats.ml b/src/binary_formats.ml index 6a7dfdfd..369908ec 100644 --- a/src/binary_formats.ml +++ b/src/binary_formats.ml @@ -95,6 +95,57 @@ module Blinded_coin_hash = MAKE_H (Hash_code) module Coin_pub_hash = MAKE_H (Hash_code) module Output_commitment_hash = MAKE_H (Hash_code) +module MAKE_EDDSA_PUB () = struct + type t = { eddsa_pub: string } + + let bin = + let open Bin in + record (fun eddsa_pub -> { eddsa_pub }) + |+ field (bytes 32) (fun t -> t.eddsa_pub) + |> sealr +end + +module MAKE_EDDSA_PRIV () = struct + type t = { eddsa_priv: string } + + let bin = + let open Bin in + record (fun eddsa_priv -> { eddsa_priv }) + |+ field (bytes 32) (fun t -> t.eddsa_priv) + |> sealr +end + +module MAKE_EDDSA_SIG () = struct + (* 64 bytes *) + type t = { eddsa_signature: string } + + let bin = + let open Bin in + record (fun eddsa_signature -> { eddsa_signature }) + |+ field (bytes 64) (fun t -> t.eddsa_signature) + |> sealr +end + +module MAKE_ECDHE_PUB () = struct + type t = { ecdhe_pub: string } + + let bin = + let open Bin in + record (fun ecdhe_pub -> { ecdhe_pub }) + |+ field (bytes 32) (fun t -> t.ecdhe_pub) + |> sealr +end + +module MAKE_ECDHE_PRIV () = struct + type t = { ecdhe_priv: string } + + let bin = + let open Bin in + record (fun ecdhe_priv -> { ecdhe_priv }) + |+ field (bytes 32) (fun t -> t.ecdhe_priv) + |> sealr +end + module Ecdh_ephemeral_public_key_p = struct type t = { ecdh_pub: string (* = uint8_t ecdh_pub[32] *) } @@ -105,75 +156,30 @@ module Ecdh_ephemeral_public_key_p = struct |> sealr end -module Reserve_public_key_p = struct - type t = { eddsa_pub: string } +module Reserve_public_key_p = MAKE_EDDSA_PUB () +module Reserve_private_key_p = MAKE_EDDSA_PRIV () +module Reserve_signature_p = MAKE_EDDSA_SIG () +module Merchant_public_key_p = MAKE_EDDSA_PUB () +module Merchant_private_key_p = MAKE_EDDSA_PRIV () +(*module Merchant_signature_p = MAKE_EDDSA_SIG ()*) - let bin = - let open Bin in - record (fun eddsa_pub -> { eddsa_pub }) - |+ field (bytes 32) (fun t -> t.eddsa_pub) - |> sealr -end +module Transfert_public_key_p = MAKE_ECDHE_PUB () +module Transfert_private_key_p = MAKE_ECDHE_PRIV () -module Reserve_private_key_p = struct - type t = { eddsa_priv: string } +(* +enum TALER_AmlDecisionState { + NORMAL, PENDING, FROZEN +}; +*) - let bin = - let open Bin in - record (fun eddsa_priv -> { eddsa_priv }) - |+ field (bytes 32) (fun t -> t.eddsa_priv) - |> sealr -end - -module Reserve_signature_p = struct - type t = { eddsa_signature: string } - - let bin = - let open Bin in - record (fun eddsa_signature -> { eddsa_signature }) - |+ field (bytes 64) (fun t -> t.eddsa_signature) - |> sealr -end - -module Merchant_public_key_p = struct - type t = { eddsa_pub: string } - - let bin = - let open Bin in - record (fun eddsa_pub -> { eddsa_pub }) - |+ field (bytes 32) (fun t -> t.eddsa_pub) - |> sealr -end - -module Merchant_private_key_p = struct - type t = { eddsa_priv: string } - - let bin = - let open Bin in - record (fun eddsa_priv -> { eddsa_priv }) - |+ field (bytes 32) (fun t -> t.eddsa_priv) - |> sealr -end - -module Transfert_public_key_p = struct - type t = { ecdhe_pub: string } - - let bin = - let open Bin in - record (fun ecdhe_pub -> { ecdhe_pub }) - |+ field (bytes 32) (fun t -> t.ecdhe_pub) - |> sealr -end - -module Transfert_private_key_p = struct - type t = { ecdhe_priv: string } - - let bin = - let open Bin in - record (fun ecdhe_priv -> { ecdhe_priv }) - |+ field (bytes 32) (fun t -> t.ecdhe_priv) - |> sealr -end +module Aml_officer_public_key_p = MAKE_EDDSA_PUB () +module Aml_officer_private_key_p = MAKE_EDDSA_PRIV () +module Exchange_public_key_p = MAKE_EDDSA_PUB () +module Exchange_private_key_p = MAKE_EDDSA_PRIV () +module Exchange_signature_p = MAKE_EDDSA_SIG () +module Master_public_key_p = MAKE_EDDSA_PUB () +module Master_private_key_p = MAKE_EDDSA_PRIV () +module Master_signature_p = MAKE_EDDSA_SIG () (* -- Signatures -- *)