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

Function handle_check_future_secret

hsmd/libhsmd.c:1113–1138  ·  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

1111 * been restored from backup or something, and may have already revealed
1112 * secrets. We carefully check that this is true, here. */
1113static u8 *handle_check_future_secret(struct hsmd_client *c, const u8 *msg_in)
1114{
1115 struct secret channel_seed;
1116 struct sha256 shaseed;
1117 u64 n;
1118 struct secret secret, suggested;
1119
1120 if (!fromwire_hsmd_check_future_secret(msg_in, &n, &suggested))
1121 return hsmd_status_malformed_request(c, msg_in);
1122
1123 get_channel_seed(&c->id, c->dbid, &channel_seed);
1124 if (!derive_shaseed(&channel_seed, &shaseed))
1125 return hsmd_status_bad_request_fmt(c, msg_in,
1126 "bad derive_shaseed");
1127
1128 if (!per_commit_secret(&shaseed, &secret, n))
1129 return hsmd_status_bad_request_fmt(
1130 c, msg_in, "bad commit secret #%" PRIu64, n);
1131
1132 /*~ Note the special secret_eq_consttime: we generate foo_eq for many
1133 * types using ccan/structeq, but not 'struct secret' because any
1134 * comparison risks leaking information about the secret if it is
1135 * timing dependent. */
1136 return towire_hsmd_check_future_secret_reply(
1137 NULL, secret_eq_consttime(&secret, &suggested));
1138}
1139
1140static u8 *handle_get_output_scriptpubkey(struct hsmd_client *c,
1141 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