refacto crypto: add eddsa.ml + rsa.ml
This commit is contained in:
parent
4e707b080a
commit
87f06339c8
16 changed files with 517 additions and 537 deletions
66
src/api.ml
66
src/api.ml
|
|
@ -7,8 +7,8 @@
|
|||
- payto_uri
|
||||
- uri *)
|
||||
|
||||
module DenominationHash = Hash.DenominationHash
|
||||
open Time
|
||||
open Crypto
|
||||
open Signatures
|
||||
|
||||
let encode jsont v = Jsont_bytesrw.encode_string jsont v
|
||||
|
|
@ -275,7 +275,7 @@ let config =
|
|||
module RsaDenominationKey = struct
|
||||
type t = {
|
||||
age_mask: int;
|
||||
rsa_pub: RsaPublicKey.t;
|
||||
rsa_pub: Rsa.pub;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
|
|
@ -284,7 +284,7 @@ module RsaDenominationKey = struct
|
|||
let rsa_pub v = v.rsa_pub in
|
||||
Jsont.Object.map ~kind:"RsaDenominationKey" make
|
||||
|> Jsont.Object.mem "age_mask" Jsont.int ~enc:age_mask
|
||||
|> Jsont.Object.mem "rsa_pub" RsaPublicKey.jsont ~enc:rsa_pub
|
||||
|> Jsont.Object.mem "rsa_pub" Rsa.pub_jsont ~enc:rsa_pub
|
||||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ end
|
|||
|
||||
module FutureSignKey = struct
|
||||
type t = {
|
||||
key: EddsaPublicKey.t;
|
||||
key: Eddsa.pub;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire: Timestamp.t;
|
||||
stamp_end: Timestamp.t;
|
||||
|
|
@ -326,7 +326,7 @@ module FutureSignKey = struct
|
|||
let stamp_end v = v.stamp_end in
|
||||
let signkey_secmod_sig v = v.signkey_secmod_sig in
|
||||
map ~kind:"FutureSignKey" make
|
||||
|> mem "key" EddsaPublicKey.jsont ~enc:key
|
||||
|> mem "key" Eddsa.pub_jsont ~enc:key
|
||||
|> mem "stamp_start" Timestamp.jsont ~enc:stamp_start
|
||||
|> mem "stamp_expire" Timestamp.jsont ~enc:stamp_expire
|
||||
|> mem "stamp_end" Timestamp.jsont ~enc:stamp_end
|
||||
|
|
@ -403,9 +403,9 @@ module FutureKeysResponse = struct
|
|||
type t = {
|
||||
future_denoms: FutureDenom.t list;
|
||||
future_signkeys: FutureSignKey.t list;
|
||||
master_pub: EddsaPublicKey.t;
|
||||
denom_secmod_public_key: EddsaPublicKey.t;
|
||||
signkey_secmod_public_key: EddsaPublicKey.t;
|
||||
master_pub: Eddsa.pub;
|
||||
denom_secmod_public_key: Eddsa.pub;
|
||||
signkey_secmod_public_key: Eddsa.pub;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
|
|
@ -429,17 +429,17 @@ module FutureKeysResponse = struct
|
|||
|> mem "future_signkeys"
|
||||
(Jsont.list FutureSignKey.jsont)
|
||||
~enc:future_signkeys
|
||||
|> mem "master_pub" EddsaPublicKey.jsont ~enc:master_pub
|
||||
|> mem "denom_secmod_public_key" EddsaPublicKey.jsont
|
||||
|> mem "master_pub" Eddsa.pub_jsont ~enc:master_pub
|
||||
|> mem "denom_secmod_public_key" Eddsa.pub_jsont
|
||||
~enc:denom_secmod_public_key
|
||||
|> mem "signkey_secmod_public_key" EddsaPublicKey.jsont
|
||||
|> mem "signkey_secmod_public_key" Eddsa.pub_jsont
|
||||
~enc:signkey_secmod_public_key
|
||||
|> finish
|
||||
end
|
||||
|
||||
module SignKeySignature = struct
|
||||
type t = {
|
||||
key: EddsaPublicKey.t;
|
||||
key: Eddsa.pub;
|
||||
master_sig: ExchangeSigningKeyValidity.t;
|
||||
}
|
||||
|
||||
|
|
@ -448,7 +448,7 @@ module SignKeySignature = struct
|
|||
let key v = v.key in
|
||||
let master_sig v = v.master_sig in
|
||||
map ~kind:"SignKeySignature" make
|
||||
|> mem "key" EddsaPublicKey.jsont ~enc:key
|
||||
|> mem "key" Eddsa.pub_jsont ~enc:key
|
||||
|> mem "master_sig" ExchangeSigningKeyValidity.jsont ~enc:master_sig
|
||||
|> finish
|
||||
end
|
||||
|
|
@ -511,7 +511,7 @@ module AuditorSetupMessage = struct
|
|||
type t = {
|
||||
auditor_url: string;
|
||||
auditor_name: string;
|
||||
auditor_pub: EddsaPublicKey.t;
|
||||
auditor_pub: Eddsa.pub;
|
||||
master_sig: MasterAddAuditor.t;
|
||||
validity_start: Timestamp.t;
|
||||
}
|
||||
|
|
@ -528,7 +528,7 @@ module AuditorSetupMessage = struct
|
|||
map ~kind:"AuditorSetupMessage" make
|
||||
|> mem "auditor_url" Jsont.string ~enc:auditor_url
|
||||
|> mem "auditor_name" Jsont.string ~enc:auditor_name
|
||||
|> mem "auditor_pub" EddsaPublicKey.jsont ~enc:auditor_pub
|
||||
|> mem "auditor_pub" Eddsa.pub_jsont ~enc:auditor_pub
|
||||
|> mem "master_sig" MasterAddAuditor.jsont ~enc:master_sig
|
||||
|> mem "validity_start" Timestamp.jsont ~enc:validity_start
|
||||
|> finish
|
||||
|
|
@ -724,7 +724,7 @@ end
|
|||
|
||||
module AmlOfficerSetup = struct
|
||||
type t = {
|
||||
officer_pub: EddsaPublicKey.t;
|
||||
officer_pub: Eddsa.pub;
|
||||
master_sig: MasterAmlOfficerStatus.t;
|
||||
officer_name: string;
|
||||
is_active: bool;
|
||||
|
|
@ -751,7 +751,7 @@ module AmlOfficerSetup = struct
|
|||
let master_sig v = v.master_sig in
|
||||
let change_date v = v.change_date in
|
||||
map ~kind:"AmlOfficerSetup" make
|
||||
|> mem "officer_pub" EddsaPublicKey.jsont ~enc:officer_pub
|
||||
|> mem "officer_pub" Eddsa.pub_jsont ~enc:officer_pub
|
||||
|> mem "officer_name" Jsont.string ~enc:officer_name
|
||||
|> mem "is_active" Jsont.bool ~enc:is_active
|
||||
|> mem "read_only" Jsont.bool ~enc:read_only
|
||||
|
|
@ -763,7 +763,7 @@ end
|
|||
module ExchangePartnerSetupRequest = struct
|
||||
type t = {
|
||||
partner_base_url: string;
|
||||
partner_pub: EddsaPublicKey.t;
|
||||
partner_pub: Eddsa.pub;
|
||||
wad_frequency: TimeRelative.t;
|
||||
master_sig: PartnerConfiguration.t;
|
||||
start_date: Timestamp.t;
|
||||
|
|
@ -793,7 +793,7 @@ module ExchangePartnerSetupRequest = struct
|
|||
let wad_fee v = v.wad_fee in
|
||||
map ~kind:"ExchangePartnerSetupRequest" make
|
||||
|> mem "partner_base_url" Jsont.string ~enc:partner_base_url
|
||||
|> mem "partner_pub" EddsaPublicKey.jsont ~enc:partner_pub
|
||||
|> mem "partner_pub" Eddsa.pub_jsont ~enc:partner_pub
|
||||
|> mem "wad_frequency" TimeRelative.jsont ~enc:wad_frequency
|
||||
|> mem "master_sig" PartnerConfiguration.jsont ~enc:master_sig
|
||||
|> mem "start_date" Timestamp.jsont ~enc:start_date
|
||||
|
|
@ -807,7 +807,7 @@ end
|
|||
module ExchangePartnerListEntry = struct
|
||||
type t = {
|
||||
partner_base_url: string;
|
||||
partner_master_pub: EddsaPublicKey.t;
|
||||
partner_master_pub: Eddsa.pub;
|
||||
wad_fee: Amount.t;
|
||||
wad_frequency: TimeRelative.t;
|
||||
start_date: Timestamp.t;
|
||||
|
|
@ -837,7 +837,7 @@ module ExchangePartnerListEntry = struct
|
|||
let master_sig v = v.master_sig in
|
||||
map ~kind:"ExchangePartnerListEntry" make
|
||||
|> mem "partner_base_url" Jsont.string ~enc:partner_base_url
|
||||
|> mem "partner_master_pub" EddsaPublicKey.jsont ~enc:partner_master_pub
|
||||
|> mem "partner_master_pub" Eddsa.pub_jsont ~enc:partner_master_pub
|
||||
|> mem "wad_fee" Amount.jsont ~enc:wad_fee
|
||||
|> mem "wad_frequency" TimeRelative.jsont ~enc:wad_frequency
|
||||
|> mem "start_date" Timestamp.jsont ~enc:start_date
|
||||
|
|
@ -891,7 +891,7 @@ end
|
|||
|
||||
module AuditorKeys = struct
|
||||
type t = {
|
||||
auditor_pub: EddsaPublicKey.t;
|
||||
auditor_pub: Eddsa.pub;
|
||||
auditor_url: string;
|
||||
auditor_name: string;
|
||||
denomination_keys: AuditorDenominationKey.t list;
|
||||
|
|
@ -906,7 +906,7 @@ module AuditorKeys = struct
|
|||
let auditor_name v = v.auditor_name in
|
||||
let denomination_keys v = v.denomination_keys in
|
||||
map ~kind:"AuditorKeys" make
|
||||
|> mem "auditor_pub" EddsaPublicKey.jsont ~enc:auditor_pub
|
||||
|> mem "auditor_pub" Eddsa.pub_jsont ~enc:auditor_pub
|
||||
|> mem "auditor_url" Jsont.string ~enc:auditor_url
|
||||
|> mem "auditor_name" Jsont.string ~enc:auditor_name
|
||||
|> mem "denomination_keys"
|
||||
|
|
@ -917,7 +917,7 @@ end
|
|||
|
||||
module SignKey = struct
|
||||
type t = {
|
||||
key: EddsaPublicKey.t;
|
||||
key: Eddsa.pub;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire: Timestamp.t;
|
||||
stamp_end: Timestamp.t;
|
||||
|
|
@ -943,7 +943,7 @@ module SignKey = struct
|
|||
let stamp_end v = v.stamp_end in
|
||||
let master_sig v = v.master_sig in
|
||||
map ~kind:"SignKey" make
|
||||
|> mem "key" EddsaPublicKey.jsont ~enc:key
|
||||
|> mem "key" Eddsa.pub_jsont ~enc:key
|
||||
|> mem "stamp_start" Timestamp.jsont ~enc:stamp_start
|
||||
|> mem "stamp_expire" Timestamp.jsont ~enc:stamp_expire
|
||||
|> mem "stamp_end" Timestamp.jsont ~enc:stamp_end
|
||||
|
|
@ -965,7 +965,7 @@ end
|
|||
module RsaDenom = struct
|
||||
(* correspond to: ({ rsa_pub: RsaPublicKey;} & DenomCommon) *)
|
||||
type t = {
|
||||
rsa_pub: RsaPublicKey.t;
|
||||
rsa_pub: Rsa.pub;
|
||||
master_sig: DenominationKeyValidity.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire_withdraw: Timestamp.t;
|
||||
|
|
@ -995,7 +995,7 @@ module RsaDenom = struct
|
|||
let stamp_expire_legal v = v.stamp_expire_legal in
|
||||
let lost v = v.lost in
|
||||
map ~kind:"RsaDenom" make
|
||||
|> mem "rsa_pub" RsaPublicKey.jsont ~enc:rsa_pub
|
||||
|> mem "rsa_pub" Rsa.pub_jsont ~enc:rsa_pub
|
||||
|> mem "master_sig" DenominationKeyValidity.jsont ~enc:master_sig
|
||||
|> mem "stamp_start" Timestamp.jsont ~enc:stamp_start
|
||||
|> mem "stamp_expire_withdraw" Timestamp.jsont ~enc:stamp_expire_withdraw
|
||||
|
|
@ -1283,14 +1283,14 @@ module ExchangeKeysResponse = struct
|
|||
wads: ExchangePartnerListEntry.t list;
|
||||
kyc_enabled: bool;
|
||||
disable_direct_deposit: bool;
|
||||
master_public_key: EddsaPublicKey.t;
|
||||
master_public_key: Eddsa.pub;
|
||||
reserve_closing_delay: TimeRelative.t;
|
||||
wallet_balance_limit_without_kyc: Amount.t list option;
|
||||
hard_limits: AccountLimit.t list;
|
||||
zero_limits: ZeroLimitedOperation.t list;
|
||||
denominations: DenomGroup.t list;
|
||||
exchange_sig: ExchangeKeySet.t;
|
||||
exchange_pub: EddsaPublicKey.t;
|
||||
exchange_pub: Eddsa.pub;
|
||||
recoup: RecoupDenoms.t list;
|
||||
global_fees: GlobalFees.t list;
|
||||
list_issue_date: Timestamp.t;
|
||||
|
|
@ -1300,7 +1300,7 @@ module ExchangeKeysResponse = struct
|
|||
(* Signature by the exchange master key of the SHA-256 hash of the
|
||||
normalized JSON-object of field extensions, if it was set.
|
||||
The signature has purpose TALER_SIGNATURE_MASTER_EXTENSIONS. *)
|
||||
extensions_sig: EddsaSignature.t option;
|
||||
extensions_sig: Eddsa.sig_ option;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
|
|
@ -1403,7 +1403,7 @@ module ExchangeKeysResponse = struct
|
|||
|> mem "wads" (Jsont.list ExchangePartnerListEntry.jsont) ~enc:wads
|
||||
|> mem "kyc_enabled" Jsont.bool ~enc:kyc_enabled
|
||||
|> mem "disable_direct_deposit" Jsont.bool ~enc:disable_direct_deposit
|
||||
|> mem "master_public_key" EddsaPublicKey.jsont ~enc:master_public_key
|
||||
|> mem "master_public_key" Eddsa.pub_jsont ~enc:master_public_key
|
||||
|> mem "reserve_closing_delay" TimeRelative.jsont ~enc:reserve_closing_delay
|
||||
|> opt_mem "wallet_balance_limit_without_kyc" (Jsont.list Amount.jsont)
|
||||
~enc:wallet_balance_limit_without_kyc
|
||||
|
|
@ -1413,7 +1413,7 @@ module ExchangeKeysResponse = struct
|
|||
~enc:zero_limits
|
||||
|> mem "denominations" (Jsont.list DenomGroup.jsont) ~enc:denominations
|
||||
|> mem "exchange_sig" ExchangeKeySet.jsont ~enc:exchange_sig
|
||||
|> mem "exchange_pub" EddsaPublicKey.jsont ~enc:exchange_pub
|
||||
|> mem "exchange_pub" Eddsa.pub_jsont ~enc:exchange_pub
|
||||
|> mem "recoup" (Jsont.list RecoupDenoms.jsont) ~enc:recoup
|
||||
|> mem "global_fees" (Jsont.list GlobalFees.jsont) ~enc:global_fees
|
||||
|> mem "list_issue_date" Timestamp.jsont ~enc:list_issue_date
|
||||
|
|
@ -1422,6 +1422,6 @@ module ExchangeKeysResponse = struct
|
|||
|> opt_mem "extensions"
|
||||
(Jsont.Object.as_string_map ExtensionManifest.jsont)
|
||||
~enc:extensions
|
||||
|> opt_mem "extensions_sig" EddsaSignature.jsont ~enc:extensions_sig
|
||||
|> opt_mem "extensions_sig" Eddsa.sig_jsont ~enc:extensions_sig
|
||||
|> finish
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue