This commit is contained in:
parent
395a75390e
commit
88a2a6d087
2 changed files with 50 additions and 105 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
(* Packed Signature *)
|
|
||||||
|
|
||||||
open Bin_type
|
|
||||||
open Hash
|
open Hash
|
||||||
|
module Taler_signatures = Include.Taler_signatures
|
||||||
|
|
||||||
module Aliases = struct
|
module Aliases = struct
|
||||||
module Timestamp = struct
|
module Timestamp = struct
|
||||||
|
|
@ -64,6 +62,53 @@ end
|
||||||
|
|
||||||
open Aliases
|
open Aliases
|
||||||
|
|
||||||
|
let int32_size = 4
|
||||||
|
let int64_size = 8
|
||||||
|
|
||||||
|
module Bytes32 = struct
|
||||||
|
type t = string
|
||||||
|
|
||||||
|
let bin = Bin.bytes 32
|
||||||
|
end
|
||||||
|
|
||||||
|
module Bytes64 = struct
|
||||||
|
type t = string
|
||||||
|
|
||||||
|
let bin = Bin.bytes 64
|
||||||
|
end
|
||||||
|
|
||||||
|
module TransferSecretP = Bytes64
|
||||||
|
module LinkSecretP = Bytes64
|
||||||
|
module EncryptedLinkSecretP = Bytes64
|
||||||
|
module BlindingMasterSeed = Bytes32
|
||||||
|
module BlindingMasterSecret = Bytes32
|
||||||
|
module WireTransferIdentifierRawP = Bytes32
|
||||||
|
module PublicRefreshCoinNonceP = Bytes64
|
||||||
|
module DenominationBlindingKeyP = Bytes32
|
||||||
|
module RefreshCommitmentP = Bytes64
|
||||||
|
|
||||||
|
module UUID = struct
|
||||||
|
type t = string
|
||||||
|
|
||||||
|
let size = 4 * int32_size
|
||||||
|
let bin = Bin.bytes size
|
||||||
|
end
|
||||||
|
|
||||||
|
module WadId = struct
|
||||||
|
type t = string
|
||||||
|
|
||||||
|
let size = 6 * int32_size
|
||||||
|
let bin = Bin.bytes size
|
||||||
|
end
|
||||||
|
|
||||||
|
module AgeMask = struct
|
||||||
|
type t = int32
|
||||||
|
|
||||||
|
let bin = Bin.beint32
|
||||||
|
end
|
||||||
|
|
||||||
|
(* --- *)
|
||||||
|
|
||||||
(* EccSignaturePurpose *)
|
(* EccSignaturePurpose *)
|
||||||
module Purpose = struct
|
module Purpose = struct
|
||||||
type t = {
|
type t = {
|
||||||
|
|
@ -96,6 +141,8 @@ module Purpose = struct
|
||||||
let field purpose = Bin.field bin (fun _t -> purpose)
|
let field purpose = Bin.field bin (fun _t -> purpose)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
(* --- Packed Signatures --- *)
|
||||||
|
|
||||||
module MK (R : sig
|
module MK (R : sig
|
||||||
type r
|
type r
|
||||||
|
|
||||||
|
|
|
||||||
102
src/bin_type.ml
102
src/bin_type.ml
|
|
@ -1,102 +0,0 @@
|
||||||
(* https://docs.taler.net/core/api-common.html#binary-formats
|
|
||||||
|
|
||||||
numeric values are in network byte order (big endian) *)
|
|
||||||
|
|
||||||
(* structs that are 'packed' and do not contain pointers and are
|
|
||||||
thus suitable for hashing or similar operations are distinguished
|
|
||||||
by adding a 'P' at the end of the name.
|
|
||||||
(NEW) Note that this convention does not hold for the GNUnet-structs (yet).
|
|
||||||
|
|
||||||
structs that are used with a purpose for signatures,
|
|
||||||
additionally get an 'S' at the end of the name.
|
|
||||||
|
|
||||||
(from https://docs.taler.net/taler-developer-manual.html) *)
|
|
||||||
|
|
||||||
(* TODO
|
|
||||||
- correctly handle endianness
|
|
||||||
- check that our struct are well packed
|
|
||||||
- it looks like Bin only define packed structs
|
|
||||||
- we don't need to worry about struct having "P" suffix
|
|
||||||
remove them
|
|
||||||
- test them
|
|
||||||
- union: not sure what to do of them
|
|
||||||
not needed or relevant i think
|
|
||||||
- some purpose (`TALER_SIGNATURE_XXX`) are missing
|
|
||||||
- exchange and gana master branch are not in sync
|
|
||||||
and we should use a specific git tag instead
|
|
||||||
- outdated doc(?)
|
|
||||||
- some missing struct documentation
|
|
||||||
|
|
||||||
- better way to have module aliases?
|
|
||||||
*)
|
|
||||||
|
|
||||||
module Taler_signatures = Include.Taler_signatures
|
|
||||||
|
|
||||||
let int32_size = 4
|
|
||||||
let int64_size = 8
|
|
||||||
|
|
||||||
module Bytes32 = struct
|
|
||||||
type t = string
|
|
||||||
|
|
||||||
let bin = Bin.bytes 32
|
|
||||||
end
|
|
||||||
|
|
||||||
module Bytes64 = struct
|
|
||||||
type t = string
|
|
||||||
|
|
||||||
let bin = Bin.bytes 64
|
|
||||||
end
|
|
||||||
|
|
||||||
(* -- Cryptographic primitives -- *)
|
|
||||||
|
|
||||||
(* --- Various --- *)
|
|
||||||
|
|
||||||
module TransferSecretP = Bytes64
|
|
||||||
module LinkSecretP = Bytes64
|
|
||||||
module EncryptedLinkSecretP = Bytes64
|
|
||||||
module BlindingMasterSeed = Bytes32
|
|
||||||
module BlindingMasterSecret = Bytes32
|
|
||||||
module WireTransferIdentifierRawP = Bytes32
|
|
||||||
module PublicRefreshCoinNonceP = Bytes64
|
|
||||||
|
|
||||||
(* TODO ? need to use/save a specific nonce for cryptographic blinding *)
|
|
||||||
(* Secret for blinding/unblinding.
|
|
||||||
An RSA blinding secret, which is basically
|
|
||||||
a 256-bit nonce, converted to Crockford `Base32`.
|
|
||||||
|
|
||||||
type DenominationBlindingKeyP = string; *)
|
|
||||||
module DenominationBlindingKeyP = Bytes32
|
|
||||||
module RefreshCommitmentP = Bytes64
|
|
||||||
|
|
||||||
(* -- TODO better: -- *)
|
|
||||||
module UUID = struct
|
|
||||||
(* uint32t value[4]; *)
|
|
||||||
type t = { value: string }
|
|
||||||
|
|
||||||
let size = 4 * int32_size
|
|
||||||
|
|
||||||
let bin =
|
|
||||||
let open Bin in
|
|
||||||
record (fun value -> { value })
|
|
||||||
|+ field (bytes size) (fun t -> t.value)
|
|
||||||
|> sealr
|
|
||||||
end
|
|
||||||
|
|
||||||
module WadId = struct
|
|
||||||
(* uint32t value[6]; *)
|
|
||||||
type t = { raw: string }
|
|
||||||
|
|
||||||
let size = 6 * int32_size
|
|
||||||
|
|
||||||
let bin =
|
|
||||||
let open Bin in
|
|
||||||
record (fun raw -> { raw }) |+ field (bytes size) (fun t -> t.raw) |> sealr
|
|
||||||
end
|
|
||||||
|
|
||||||
module AgeMask = struct
|
|
||||||
type t = { mask: int32 }
|
|
||||||
|
|
||||||
let bin =
|
|
||||||
let open Bin in
|
|
||||||
record (fun mask -> { mask }) |+ field beint32 (fun t -> t.mask) |> sealr
|
|
||||||
end
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue