ok denom-hash
This commit is contained in:
parent
9c87aa63ea
commit
7150cc8584
14 changed files with 142 additions and 61 deletions
|
|
@ -59,6 +59,14 @@ module Arg = struct
|
|||
Fmt.pf fmt "%s" s
|
||||
in
|
||||
Arg.Conv.make ~docv:"eddsa public key argument" ~parser ~pp ()
|
||||
|
||||
let rsa_pub =
|
||||
let parser s = Crypto.RsaPublicKey.of_b32 s in
|
||||
let pp fmt key =
|
||||
let s = Crypto.RsaPublicKey.to_b32 key in
|
||||
Fmt.pf fmt "%s" s
|
||||
in
|
||||
Arg.Conv.make ~docv:"rsa public key argument" ~parser ~pp ()
|
||||
end
|
||||
|
||||
let master_key =
|
||||
|
|
@ -147,11 +155,11 @@ let revoke_denom_cmd =
|
|||
match is_rsa_pub with
|
||||
| false -> Ok v
|
||||
| true -> (
|
||||
match B32.decode v with
|
||||
match Crypto.RsaPublicKey.of_b32 v with
|
||||
| Error e -> Error e
|
||||
| Ok s ->
|
||||
let h = Hash.DenominationHash.hash s in
|
||||
let s = B32.encode (Hash.DenominationHash.to_octets h) in
|
||||
| Ok rsa_pub ->
|
||||
let h = Crypto.DenominationHash.hash_of_rsa rsa_pub in
|
||||
let s = Crypto.DenominationHash.to_b32 h in
|
||||
Ok s)
|
||||
in
|
||||
match res with
|
||||
|
|
@ -159,21 +167,15 @@ let revoke_denom_cmd =
|
|||
| Ok h_denom -> revoke_denom ~output ~master_key ~h_denom
|
||||
|
||||
(* just for tests... *)
|
||||
let test_hash64_cmd =
|
||||
let doc =
|
||||
"Compute SHA-512, print output to stdout, input and output are \
|
||||
Crockford-base32 encoded"
|
||||
in
|
||||
let s = Arg.(required & pos 0 (some string) None & info []) in
|
||||
Cmd.make (Cmd.info "hash64" ~doc)
|
||||
let test_denomination_hash_cmd =
|
||||
let doc = "compute denomination hash (of rsa)" in
|
||||
let rsa_pub = Arg.(required & pos 0 (some rsa_pub) None & info []) in
|
||||
Cmd.make (Cmd.info "denomination-hash" ~doc)
|
||||
@@
|
||||
let+ s = s in
|
||||
match B32.decode s with
|
||||
| Error e -> Error e
|
||||
| Ok s ->
|
||||
let h = Hash.DenominationHash.hash s in
|
||||
let s = B32.encode (Hash.DenominationHash.to_octets h) in
|
||||
Fmt.pr "%s@." s; Ok ()
|
||||
let+ rsa_pub = rsa_pub in
|
||||
let h = Crypto.DenominationHash.hash_of_rsa rsa_pub in
|
||||
let s = Crypto.DenominationHash.to_b32 h in
|
||||
Fmt.pr "%s@." s; Ok ()
|
||||
|
||||
let revoke_signkey_cmd =
|
||||
let doc = "Revoke signkey." in
|
||||
|
|
@ -367,7 +369,7 @@ let cli =
|
|||
disable_wire_cmd;
|
||||
drain_cmd;
|
||||
(* - *)
|
||||
test_hash64_cmd;
|
||||
test_denomination_hash_cmd;
|
||||
]
|
||||
|
||||
let main () = Cmd.eval_result cli
|
||||
|
|
|
|||
|
|
@ -30,9 +30,10 @@ module Future_keys = struct
|
|||
fee_refund= _;
|
||||
denom_secmod_sig;
|
||||
} =
|
||||
let h_denom_pub =
|
||||
DenominationHash.hash (DenominationKey.to_octets denom_pub)
|
||||
let rsa_pub =
|
||||
match denom_pub with DenominationKey.Rsa denom -> denom.rsa_pub
|
||||
in
|
||||
let h_denom_pub = DenominationHash.hash_of_rsa rsa_pub in
|
||||
let h_section_name = Hash.Cstring.H64.hash section_name in
|
||||
let anchor_time = stamp_start in
|
||||
let duration_withdraw =
|
||||
|
|
@ -96,8 +97,10 @@ module Future_keys = struct
|
|||
fee_refund;
|
||||
denom_secmod_sig= _;
|
||||
} =
|
||||
let octets = DenominationKey.to_octets denom_pub in
|
||||
let h_denom_pub = DenominationHash.hash octets in
|
||||
let rsa_pub =
|
||||
match denom_pub with DenominationKey.Rsa denom -> denom.rsa_pub
|
||||
in
|
||||
let h_denom_pub = DenominationHash.hash_of_rsa rsa_pub in
|
||||
let master_sig =
|
||||
let open Signatures.DenominationKeyValidity in
|
||||
let master = EddsaPrivateKey.(pub_of_priv master_key) in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue