mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
sphinx: Expose the shared secret creation function
This commit is contained in:
committed by
Rusty Russell
parent
49a3321d7e
commit
fd37c5b672
@@ -364,12 +364,12 @@ static bool blind_group_element(struct pubkey *blindedelement,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool create_shared_secret(struct secret *secret,
|
||||
bool sphinx_create_shared_secret(struct secret *privkey,
|
||||
const struct pubkey *pubkey,
|
||||
const struct secret *session_key)
|
||||
const struct secret *secret)
|
||||
{
|
||||
if (secp256k1_ecdh(secp256k1_ctx, secret->data, &pubkey->pubkey,
|
||||
session_key->data, NULL, NULL) != 1)
|
||||
if (secp256k1_ecdh(secp256k1_ctx, privkey->data, &pubkey->pubkey,
|
||||
secret->data, NULL, NULL) != 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -379,8 +379,8 @@ bool onion_shared_secret(
|
||||
const struct onionpacket *packet,
|
||||
const struct privkey *privkey)
|
||||
{
|
||||
return create_shared_secret(secret, &packet->ephemeralkey,
|
||||
&privkey->secret);
|
||||
return sphinx_create_shared_secret(secret, &packet->ephemeralkey,
|
||||
&privkey->secret);
|
||||
}
|
||||
|
||||
static void generate_key_set(const struct secret *secret,
|
||||
@@ -408,8 +408,8 @@ static struct hop_params *generate_hop_params(
|
||||
path->session_key->data) != 1)
|
||||
return NULL;
|
||||
|
||||
if (!create_shared_secret(¶ms[0].secret, &path->hops[0].pubkey,
|
||||
path->session_key))
|
||||
if (!sphinx_create_shared_secret(
|
||||
¶ms[0].secret, &path->hops[0].pubkey, path->session_key))
|
||||
return NULL;
|
||||
|
||||
compute_blinding_factor(
|
||||
@@ -491,7 +491,7 @@ static void sphinx_prefill(u8 *routinginfo, const struct sphinx_path *sp,
|
||||
|
||||
/* Now fill in the obfuscation stream, which can be regenerated by the
|
||||
* node processing this onion. */
|
||||
create_shared_secret(&shared_secret, sp->rendezvous_id, sp->session_key);
|
||||
sphinx_create_shared_secret(&shared_secret, sp->rendezvous_id, sp->session_key);
|
||||
sphinx_prefill_stream_xor(routinginfo + prefill_offset, prefill_size, &shared_secret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user