fix secmod add/write; + wip test revoke

This commit is contained in:
swrup 2026-02-25 00:12:05 +01:00 committed by Swrup
parent 651c422cb1
commit c04fda0f1e
8 changed files with 165 additions and 45 deletions

View file

@ -128,14 +128,54 @@ let sign_cmd =
let revoke_denom_cmd =
let doc = "Revoke denomination." in
let h_denom =
let doc = "hash of denomination public key" in
let is_rsa_pub =
let doc =
"interpret input string as a RSA public key (in Crockford-base32) \
instead of a denomination hash"
in
Arg.(value & flag & info [ "rsa" ] ~doc)
in
let v =
let doc = "hash of denomination (or RSA public key if --rsa is set)" in
Arg.(required & pos 0 (some string) None & info [] ~doc)
in
Cmd.make (Cmd.info "revoke-denom" ~doc)
@@
let+ output = output and+ master_key = master_key and+ h_denom = h_denom in
revoke_denom ~output ~master_key ~h_denom
let+ output = output
and+ master_key = master_key
and+ is_rsa_pub = is_rsa_pub
and+ v = v in
let res =
match is_rsa_pub with
| false -> Ok v
| true -> (
match B32.decode 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 s)
in
match res with
| Error e -> Error e
| 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+ 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 revoke_signkey_cmd =
let doc = "Revoke signkey." in
@ -305,6 +345,7 @@ let cli =
wire_fee_cmd;
global_fees_cmd;
drain_cmd;
test_hash64_cmd;
]
let main () = Cmd.eval_result cli