MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_check_future_secret

Function handle_check_future_secret

hsmd/libhsmd.c:789–814  ·  view source on GitHub ↗

~ 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. */

Source from the content-addressed store, hash-verified

787 * been restored from backup or something, and may have already revealed
788 * secrets. We carefully check that this is true, here. */
789static 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
816static u8 *handle_get_output_scriptpubkey(struct hsmd_client *c,
817 const u8 *msg_in)

Callers 1

Calls 6

derive_shaseedFunction · 0.85
per_commit_secretFunction · 0.85
secret_eq_consttimeFunction · 0.85
get_channel_seedFunction · 0.70

Tested by

no test coverage detected