~ This is used when the remote peer claims to have knowledge of future * commitment states (option_data_loss_protect in the spec) which means we've * been restored from backup or something, and may have already revealed * secrets. We carefully check that this is true, here. */
| 787 | * been restored from backup or something, and may have already revealed |
| 788 | * secrets. We carefully check that this is true, here. */ |
| 789 | static u8 *handle_check_future_secret(struct hsmd_client *c, const u8 *msg_in) |
| 790 | { |
| 791 | struct secret channel_seed; |
| 792 | struct sha256 shaseed; |
| 793 | u64 n; |
| 794 | struct secret secret, suggested; |
| 795 | |
| 796 | if (!fromwire_hsmd_check_future_secret(msg_in, &n, &suggested)) |
| 797 | return hsmd_status_malformed_request(c, msg_in); |
| 798 | |
| 799 | get_channel_seed(&c->id, c->dbid, &channel_seed); |
| 800 | if (!derive_shaseed(&channel_seed, &shaseed)) |
| 801 | return hsmd_status_bad_request_fmt(c, msg_in, |
| 802 | "bad derive_shaseed"); |
| 803 | |
| 804 | if (!per_commit_secret(&shaseed, &secret, n)) |
| 805 | return hsmd_status_bad_request_fmt( |
| 806 | c, msg_in, "bad commit secret #%" PRIu64, n); |
| 807 | |
| 808 | /*~ Note the special secret_eq_consttime: we generate foo_eq for many |
| 809 | * types using ccan/structeq, but not 'struct secret' because any |
| 810 | * comparison risks leaking information about the secret if it is |
| 811 | * timing dependent. */ |
| 812 | return towire_hsmd_check_future_secret_reply( |
| 813 | NULL, secret_eq_consttime(&secret, &suggested)); |
| 814 | } |
| 815 | |
| 816 | static u8 *handle_get_output_scriptpubkey(struct hsmd_client *c, |
| 817 | const u8 *msg_in) |
no test coverage detected