per-peer seed is a 'struct secret' not a 'struct privkey'.

They're both 32 bytes, but it's not a privkey at all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-07-09 20:47:58 +09:30 committed by Christian Decker
parent 019ba86b91
commit 6c98457ef2
16 changed files with 22 additions and 22 deletions

View File

@ -2398,7 +2398,7 @@ static void init_shared_secrets(struct channel *channel,
/* We do this synchronously. */
static void init_channel(struct peer *peer)
{
struct privkey seed;
struct secret seed;
struct basepoints points[NUM_SIDES];
u64 funding_satoshi;
u16 funding_txout;

View File

@ -26,7 +26,7 @@ channel_init,,funder,enum side
channel_init,,fee_base,u32
channel_init,,fee_proportional,u32
channel_init,,local_msatoshi,u64
channel_init,,seed,struct privkey
channel_init,,seed,struct secret
channel_init,,local_node_id,struct pubkey
channel_init,,remote_node_id,struct pubkey
channel_init,,commit_msec,u32

1 #include <common/cryptomsg.h>
26 channel_init,,fee_proportional,u32
27 channel_init,,local_msatoshi,u64
28 channel_init,,seed,struct privkey channel_init,,seed,struct secret
29 channel_init,,local_node_id,struct pubkey
30 channel_init,,remote_node_id,struct pubkey
31 channel_init,,commit_msec,u32
32 channel_init,,cltv_delta,u16

View File

@ -424,7 +424,7 @@ int main(int argc, char *argv[])
struct crypto_state cs;
const tal_t *ctx = tal(NULL, char);
u8 *msg;
struct privkey seed;
struct secret seed;
struct pubkey funding_pubkey[NUM_SIDES];
struct bitcoin_txid funding_txid;
u16 funding_txout;

View File

@ -3,7 +3,7 @@
# Begin! (passes peer fd, gossipd-client fd)
closing_init,2001
closing_init,,crypto_state,struct crypto_state
closing_init,,seed,struct privkey
closing_init,,seed,struct secret
closing_init,,funding_txid,struct bitcoin_txid
closing_init,,funding_txout,u16
closing_init,,funding_satoshi,u64

1 #include <common/cryptomsg.h>
3 # Begin! (passes peer fd, gossipd-client fd)
4 closing_init,2001
5 closing_init,,crypto_state,struct crypto_state
6 closing_init,,seed,struct privkey closing_init,,seed,struct secret
7 closing_init,,funding_txid,struct bitcoin_txid
8 closing_init,,funding_txout,u16
9 closing_init,,funding_satoshi,u64

View File

@ -3,7 +3,7 @@
#include <common/derive_basepoints.h>
#include <common/utils.h>
bool derive_basepoints(const struct privkey *seed,
bool derive_basepoints(const struct secret *seed,
struct pubkey *funding_pubkey,
struct basepoints *basepoints,
struct secrets *secrets,

View File

@ -32,7 +32,7 @@ struct secrets {
* @secrets: (out) basepoints for channel (if non-NULL)
* @shaseed: (out) seed for shachain (if non-NULL)
*/
bool derive_basepoints(const struct privkey *seed,
bool derive_basepoints(const struct secret *seed,
struct pubkey *funding_pubkey,
struct basepoints *basepoints,
struct secrets *secrets,

View File

@ -545,7 +545,7 @@ static void pass_client_hsmfd(struct daemon_conn *master, const u8 *msg)
}
static void derive_peer_seed(struct privkey *peer_seed, struct privkey *peer_seed_base,
static void derive_peer_seed(struct secret *peer_seed, struct secret *peer_seed_base,
const struct pubkey *peer_id, const u64 channel_id)
{
u8 input[PUBKEY_DER_LEN + sizeof(channel_id)];
@ -562,10 +562,10 @@ static void derive_peer_seed(struct privkey *peer_seed, struct privkey *peer_see
static void hsm_unilateral_close_privkey(struct privkey *dst,
struct unilateral_close_info *info)
{
struct privkey peer_seed, peer_seed_base;
struct secret peer_seed, peer_seed_base;
struct basepoints basepoints;
struct secrets secrets;
hsm_peer_secret_base(&peer_seed_base.secret);
hsm_peer_secret_base(&peer_seed_base);
derive_peer_seed(&peer_seed, &peer_seed_base, &info->peer_id, info->channel_id);
derive_basepoints(&peer_seed, NULL, &basepoints, &secrets, NULL);

View File

@ -114,7 +114,7 @@ void delete_channel(struct channel *channel)
* reconnection. We use the DB channel ID to guarantee unique secrets
* per channel.
*/
void derive_channel_seed(struct lightningd *ld, struct privkey *seed,
void derive_channel_seed(struct lightningd *ld, struct secret *seed,
const struct pubkey *peer_id,
const u64 dbid)
{

View File

@ -79,7 +79,7 @@ struct channel {
struct channel_info channel_info;
/* Secret seed (FIXME: Move to hsm!) */
struct privkey seed;
struct secret seed;
/* Their scriptpubkey if they sent shutdown. */
u8 *remote_shutdown_scriptpubkey;
@ -203,7 +203,7 @@ static inline bool channel_active(const struct channel *channel)
&& !channel_on_chain(channel);
}
void derive_channel_seed(struct lightningd *ld, struct privkey *seed,
void derive_channel_seed(struct lightningd *ld, struct secret *seed,
const struct pubkey *peer_id,
const u64 dbid);

View File

@ -46,7 +46,7 @@ struct uncommitted_channel {
struct funding_channel *fc;
/* Secret seed (FIXME: Move to hsm!) */
struct privkey seed;
struct secret seed;
/* Blockheight at creation, scans for funding confirmations
* will start here */

View File

@ -2135,7 +2135,7 @@ int main(int argc, char *argv[])
const tal_t *ctx = tal(NULL, char);
u8 *msg;
struct privkey seed;
struct secret seed;
struct pubkey remote_payment_basepoint, remote_htlc_basepoint,
remote_per_commit_point, old_remote_per_commit_point,
remote_revocation_basepoint, remote_delayed_payment_basepoint;

View File

@ -1,7 +1,7 @@
#include <common/htlc_wire.h>
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
onchain_init,5001
onchain_init,,seed,struct privkey
onchain_init,,seed,struct secret
onchain_init,,shachain,struct shachain
onchain_init,,funding_amount_satoshi,u64
# Remote per commit point for committed tx.

1 #include <common/htlc_wire.h>
2 # Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
3 onchain_init,5001
4 onchain_init,,seed,struct privkey onchain_init,,seed,struct secret
5 onchain_init,,shachain,struct shachain
6 onchain_init,,funding_amount_satoshi,u64
7 # Remote per commit point for committed tx.

View File

@ -19,7 +19,7 @@ u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint UNNEEDE
void daemon_shutdown(void)
{ fprintf(stderr, "daemon_shutdown called!\n"); abort(); }
/* Generated stub for derive_basepoints */
bool derive_basepoints(const struct privkey *seed UNNEEDED,
bool derive_basepoints(const struct secret *seed UNNEEDED,
struct pubkey *funding_pubkey UNNEEDED,
struct basepoints *basepoints UNNEEDED,
struct secrets *secrets UNNEEDED,
@ -55,7 +55,7 @@ bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UN
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
/* Generated stub for fromwire_onchain_init */
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct privkey *seed UNNEEDED, struct shachain *shachain UNNEEDED, u64 *funding_amount_satoshi UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *feerate_per_kw UNNEEDED, u64 *local_dust_limit_satoshi UNNEEDED, struct pubkey *remote_revocation_basepoint UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *funder UNNEEDED, struct pubkey *remote_payment_basepoint UNNEEDED, struct pubkey *remote_htlc_basepoint UNNEEDED, struct pubkey *remote_delayed_payment_basepoint UNNEEDED, struct bitcoin_tx **tx UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED)
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct secret *seed UNNEEDED, struct shachain *shachain UNNEEDED, u64 *funding_amount_satoshi UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *feerate_per_kw UNNEEDED, u64 *local_dust_limit_satoshi UNNEEDED, struct pubkey *remote_revocation_basepoint UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *funder UNNEEDED, struct pubkey *remote_payment_basepoint UNNEEDED, struct pubkey *remote_htlc_basepoint UNNEEDED, struct pubkey *remote_delayed_payment_basepoint UNNEEDED, struct bitcoin_tx **tx UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED)
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
/* Generated stub for fromwire_onchain_known_preimage */
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED)

View File

@ -813,7 +813,7 @@ int main(int argc, char *argv[])
u8 *msg, *peer_msg;
struct state *state = tal(NULL, struct state);
struct privkey seed;
struct secret seed;
struct basepoints our_points;
struct pubkey our_funding_pubkey;
u32 minimum_depth;
@ -849,14 +849,14 @@ int main(int argc, char *argv[])
&state->shaseed))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Secret derivation failed, secret = %s",
type_to_string(tmpctx, struct privkey, &seed));
type_to_string(tmpctx, struct secret, &seed));
if (!per_commit_point(&state->shaseed, &state->next_per_commit[LOCAL],
0))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"First per_commitment_point derivation failed,"
" secret = %s",
type_to_string(tmpctx, struct privkey, &seed));
type_to_string(tmpctx, struct secret, &seed));
status_trace("First per_commit_point = %s",
type_to_string(tmpctx, struct pubkey,

View File

@ -10,7 +10,7 @@ opening_init,,max_to_self_delay,u32
opening_init,,min_effective_htlc_capacity_msat,u64
opening_init,,crypto_state,struct crypto_state
# Seed to generate all the keys from
opening_init,,seed,struct privkey
opening_init,,seed,struct secret
#include <common/bip32.h>
#include <common/htlc_wire.h>

1 #include <common/cryptomsg.h>
10 opening_init,,min_effective_htlc_capacity_msat,u64
11 opening_init,,crypto_state,struct crypto_state
12 # Seed to generate all the keys from
13 opening_init,,seed,struct privkey opening_init,,seed,struct secret
14 #include <common/bip32.h>
15 #include <common/htlc_wire.h>
16 # This means we offer the open.

View File

@ -60,7 +60,7 @@ void command_still_pending(struct command *cmd UNNEEDED)
void command_success(struct command *cmd UNNEEDED, struct json_result *response UNNEEDED)
{ fprintf(stderr, "command_success called!\n"); abort(); }
/* Generated stub for derive_basepoints */
bool derive_basepoints(const struct privkey *seed UNNEEDED,
bool derive_basepoints(const struct secret *seed UNNEEDED,
struct pubkey *funding_pubkey UNNEEDED,
struct basepoints *basepoints UNNEEDED,
struct secrets *secrets UNNEEDED,