mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
gossip: Verify channel_update signatures
This commit is contained in:
parent
58196b5a32
commit
a215cb47f1
1 changed files with 17 additions and 0 deletions
|
@ -635,6 +635,19 @@ u8 *write_ip(const tal_t *ctx, const char *srcip, int port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Verify the signature of a channel_update message */
|
||||||
|
static bool check_channel_update(const struct pubkey *node_key,
|
||||||
|
const secp256k1_ecdsa_signature *node_sig,
|
||||||
|
const u8 *update)
|
||||||
|
{
|
||||||
|
/* 2 byte msg type + 64 byte signatures */
|
||||||
|
int offset = 66;
|
||||||
|
struct sha256_double hash;
|
||||||
|
sha256_double(&hash, update + offset, tal_len(update) - offset);
|
||||||
|
|
||||||
|
return check_signed_hash(&hash, node_sig, node_key);
|
||||||
|
}
|
||||||
|
|
||||||
static bool check_channel_announcement(
|
static bool check_channel_announcement(
|
||||||
const struct pubkey *node1_key, const struct pubkey *node2_key,
|
const struct pubkey *node1_key, const struct pubkey *node2_key,
|
||||||
const struct pubkey *bitcoin1_key, const struct pubkey *bitcoin2_key,
|
const struct pubkey *bitcoin1_key, const struct pubkey *bitcoin2_key,
|
||||||
|
@ -770,6 +783,10 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update, size_
|
||||||
log_debug(rstate->base_log, "Ignoring outdated update.");
|
log_debug(rstate->base_log, "Ignoring outdated update.");
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
return;
|
return;
|
||||||
|
} else if (!check_channel_update(&c->src->id, &signature, serialized)) {
|
||||||
|
log_debug(rstate->base_log, "Signature verification failed.");
|
||||||
|
tal_free(tmpctx);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME(cdecker) Check signatures
|
//FIXME(cdecker) Check signatures
|
||||||
|
|
Loading…
Add table
Reference in a new issue