The old BOLT defined what happened prior to option_static_remotekey, * which we still support for existing channels: * * If `option_static_remotekey` or `option_anchors` is negotiated, the * `remotepubkey` is simply the remote node's `payment_basepoint`, otherwise * it is calculated as above using the remote node's `payment_basepoint`. */
| 31 | * it is calculated as above using the remote node's `payment_basepoint`. |
| 32 | */ |
| 33 | bool derive_simple_key(const struct pubkey *basepoint, |
| 34 | const struct pubkey *per_commitment_point, |
| 35 | struct pubkey *key) |
| 36 | { |
| 37 | struct sha256 sha; |
| 38 | unsigned char der_keys[PUBKEY_CMPR_LEN * 2]; |
| 39 | |
| 40 | pubkey_to_der(der_keys, per_commitment_point); |
| 41 | pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, basepoint); |
| 42 | sha256(&sha, der_keys, sizeof(der_keys)); |
| 43 | #ifdef SUPERVERBOSE |
| 44 | printf("# SHA256(per_commitment_point || basepoint)\n"); |
| 45 | printf("# => SHA256(0x%s || 0x%s)\n", |
| 46 | tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), |
| 47 | tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); |
| 48 | printf("# = 0x%s\n", |
| 49 | tal_hexstr(tmpctx, &sha, sizeof(sha))); |
| 50 | #endif |
| 51 | |
| 52 | *key = *basepoint; |
| 53 | if (secp256k1_ec_pubkey_tweak_add(secp256k1_ctx, |
| 54 | &key->pubkey, sha.u.u8) != 1) |
| 55 | return false; |
| 56 | #ifdef SUPERVERBOSE |
| 57 | printf("# + basepoint (0x%s)\n", |
| 58 | fmt_pubkey(tmpctx, basepoint)); |
| 59 | printf("# = 0x%s\n", |
| 60 | fmt_pubkey(tmpctx, key)); |
| 61 | #endif |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | /* BOLT #3: |
| 66 | * |