mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
dc18f3cd7b
No code changes, just catching up with the BOLT changes which rework our blinded path terminology (for the better!). Another patch will sweep the rest of our internal names, this tries only to make things compile and fix up the BOLT quotes. 1. Inside payload: current_blinding_point -> current_path_key 2. Inside update_add_htlc TLV: blinding_point -> blinded_path 3. Inside blinded_path: blinding -> first_path_key 4. Inside onion_message: blinding -> path_key. 5. Inside encrypted_data_tlv: next_blinding_override -> next_path_key_override Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
41 lines
1003 B
C
41 lines
1003 B
C
#include "config.h"
|
|
#include <bitcoin/privkey.h>
|
|
#include <bitcoin/pubkey.h>
|
|
#include <common/blinding.h>
|
|
#include <common/utils.h>
|
|
|
|
void blinding_hash_e_and_ss(const struct pubkey *e,
|
|
const struct secret *ss,
|
|
struct sha256 *sha)
|
|
{
|
|
u8 der[PUBKEY_CMPR_LEN];
|
|
struct sha256_ctx shactx;
|
|
|
|
pubkey_to_der(der, e);
|
|
sha256_init(&shactx);
|
|
sha256_update(&shactx, der, sizeof(der));
|
|
sha256_update(&shactx, ss->data, sizeof(ss->data));
|
|
sha256_done(&shactx, sha);
|
|
}
|
|
|
|
/* E(i+1) = H(E(i) || ss(i)) * E(i) */
|
|
bool blinding_next_path_key(const struct pubkey *pk,
|
|
const struct sha256 *h,
|
|
struct pubkey *next)
|
|
{
|
|
|
|
*next = *pk;
|
|
return secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx, &next->pubkey,
|
|
h->u.u8) == 1;
|
|
}
|
|
|
|
/* e(i+1) = H(E(i) || ss(i)) * e(i) */
|
|
bool blinding_next_path_privkey(const struct privkey *e,
|
|
const struct sha256 *h,
|
|
struct privkey *next)
|
|
{
|
|
*next = *e;
|
|
return secp256k1_ec_seckey_tweak_mul(secp256k1_ctx, next->secret.data,
|
|
h->u.u8) == 1;
|
|
}
|