+ wip sign_future_keys
This commit is contained in:
parent
d7d302bafa
commit
ab82a357a9
5 changed files with 111 additions and 63 deletions
85
tools/offline_signature.ml
Normal file
85
tools/offline_signature.ml
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
let denom_signature ~master_key
|
||||
Api.FutureDenom.
|
||||
{
|
||||
section_name= _;
|
||||
value;
|
||||
stamp_start;
|
||||
stamp_expire_withdraw;
|
||||
stamp_expire_deposit;
|
||||
stamp_expire_legal;
|
||||
denom_pub;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
fee_refund= _;
|
||||
(* TODO check sigs *)
|
||||
denom_secmod_sig= _;
|
||||
} =
|
||||
let pub_octets =
|
||||
let denom_pub =
|
||||
match denom_pub with
|
||||
| Rsa v -> v
|
||||
| CS _ -> Fmt.failwith "CS key types are not supported."
|
||||
in
|
||||
let pub = denom_pub.Api.RsaDenominationKey.rsa_pub in
|
||||
Crypto.RsaPublicKey.to_octets pub
|
||||
in
|
||||
let h_denom_pub = Api.HashCode.hash pub_octets in
|
||||
let master_sig =
|
||||
let open Bin_type in
|
||||
let open Bin_signature.DenominationKeyValidityPS in
|
||||
let master = Crypto.EddsaPrivateKey.(pub_of_priv master_key) in
|
||||
let denom_hash = DenominationHash.hash pub_octets in
|
||||
{
|
||||
master;
|
||||
start= stamp_start;
|
||||
expire_withdraw= stamp_expire_withdraw;
|
||||
expire_spend= stamp_expire_deposit;
|
||||
expire_legal= stamp_expire_legal;
|
||||
value;
|
||||
fee_withdraw;
|
||||
fee_deposit;
|
||||
fee_refresh;
|
||||
denom_hash;
|
||||
}
|
||||
|> Bin.to_string bin
|
||||
|> Crypto.EddsaSignature.sign ~key:master_key
|
||||
in
|
||||
Api.DenomSignature.{ h_denom_pub; master_sig }
|
||||
|
||||
let signkey_signature ~master_key
|
||||
Api.FutureSignKey.
|
||||
{
|
||||
key;
|
||||
stamp_start;
|
||||
stamp_expire;
|
||||
stamp_end;
|
||||
(* TODO check sigs *)
|
||||
signkey_secmod_sig= _;
|
||||
} =
|
||||
let master_sig =
|
||||
let open Bin_signature.ExchangeSigningKeyValidityPS in
|
||||
{
|
||||
start= stamp_start;
|
||||
expire= stamp_expire;
|
||||
end_= stamp_end;
|
||||
signkey_pub= key;
|
||||
}
|
||||
|> Bin.to_string bin
|
||||
|> Crypto.EddsaSignature.sign ~key:master_key
|
||||
in
|
||||
Api.SignKeySignature.{ key; master_sig }
|
||||
|
||||
let master_signatures ~master_key
|
||||
Api.FutureKeysResponse.
|
||||
{
|
||||
future_denoms;
|
||||
future_signkeys;
|
||||
(* TODO check sigs *)
|
||||
master_pub= _;
|
||||
denom_secmod_public_key= _;
|
||||
signkey_secmod_public_key= _;
|
||||
} =
|
||||
let denom_sigs = List.map (denom_signature ~master_key) future_denoms in
|
||||
let signkey_sigs = List.map (signkey_signature ~master_key) future_signkeys in
|
||||
Api.MasterSignatures.{ denom_sigs; signkey_sigs }
|
||||
Loading…
Add table
Add a link
Reference in a new issue