Blinds node_id and calculates next blinding factor. */
| 14 | |
| 15 | /* Blinds node_id and calculates next blinding factor. */ |
| 16 | static bool blind_node(const struct privkey *blinding, |
| 17 | const struct secret *ss, |
| 18 | const struct pubkey *node, |
| 19 | struct pubkey *node_alias, |
| 20 | struct privkey *next_blinding) |
| 21 | { |
| 22 | struct secret node_id_blinding; |
| 23 | struct pubkey blinding_pubkey; |
| 24 | struct sha256 h; |
| 25 | |
| 26 | /* |
| 27 | * Blinded node_id for N(i), private key known only by N(i): |
| 28 | * B(i) = HMAC256("blinded_node_id", ss(i)) * P(i) |
| 29 | */ |
| 30 | subkey_from_hmac("blinded_node_id", ss, &node_id_blinding); |
| 31 | SUPERVERBOSE("\t\"HMAC256('blinded_node_id', ss)\": \"%s\",\n", |
| 32 | type_to_string(tmpctx, struct secret, |
| 33 | &node_id_blinding)); |
| 34 | |
| 35 | *node_alias = *node; |
| 36 | if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx, |
| 37 | &node_alias->pubkey, |
| 38 | node_id_blinding.data) != 1) |
| 39 | return false; |
| 40 | SUPERVERBOSE("\t\"blinded_node_id\": \"%s\",\n", |
| 41 | type_to_string(tmpctx, struct pubkey, node_alias)); |
| 42 | |
| 43 | /* |
| 44 | * Ephemeral private key, only known by N(r): |
| 45 | * e(i+1) = H(E(i) || ss(i)) * e(i) |
| 46 | */ |
| 47 | if (!pubkey_from_privkey(blinding, &blinding_pubkey)) |
| 48 | return false; |
| 49 | SUPERVERBOSE("\t\"E\": \"%s\",\n", |
| 50 | type_to_string(tmpctx, struct pubkey, &blinding_pubkey)); |
| 51 | |
| 52 | blinding_hash_e_and_ss(&blinding_pubkey, ss, &h); |
| 53 | SUPERVERBOSE("\t\"H(E || ss)\": \"%s\",\n", |
| 54 | type_to_string(tmpctx, struct sha256, &h)); |
| 55 | blinding_next_privkey(blinding, &h, next_blinding); |
| 56 | SUPERVERBOSE("\t\"next_e\": \"%s\",\n", |
| 57 | type_to_string(tmpctx, struct privkey, next_blinding)); |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | static u8 *enctlv_from_encmsg_raw(const tal_t *ctx, |
| 63 | const struct privkey *blinding, |
no test coverage detected