| 117 | } |
| 118 | |
| 119 | int main(int argc, char *argv[]) |
| 120 | { |
| 121 | struct privkey privkey; |
| 122 | struct secret base_secret, per_commitment_secret; |
| 123 | struct pubkey base_point, per_commitment_point, pubkey, pubkey2; |
| 124 | |
| 125 | common_setup(argv[0]); |
| 126 | |
| 127 | base_secret = secret_from_hex("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"); |
| 128 | per_commitment_secret = secret_from_hex("0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"); |
| 129 | |
| 130 | printf("base_secret: 0x%s\n", |
| 131 | tal_hexstr(tmpctx, &base_secret, sizeof(base_secret))); |
| 132 | printf("per_commitment_secret: 0x%s\n", |
| 133 | tal_hexstr(tmpctx, &per_commitment_secret, |
| 134 | sizeof(per_commitment_secret))); |
| 135 | if (!secp256k1_ec_pubkey_create(secp256k1_ctx, |
| 136 | &per_commitment_point.pubkey, |
| 137 | per_commitment_secret.data)) |
| 138 | abort(); |
| 139 | if (!secp256k1_ec_pubkey_create(secp256k1_ctx, |
| 140 | &base_point.pubkey, |
| 141 | base_secret.data)) |
| 142 | abort(); |
| 143 | printf("base_point: 0x%s\n", |
| 144 | fmt_pubkey(tmpctx, &base_point)); |
| 145 | printf("per_commitment_point: 0x%s\n", |
| 146 | fmt_pubkey(tmpctx, &per_commitment_point)); |
| 147 | |
| 148 | /* FIXME: Annotate internal steps. */ |
| 149 | if (!derive_simple_key(&base_point, &per_commitment_point, &pubkey)) |
| 150 | abort(); |
| 151 | printf("localkey: 0x%s\n", |
| 152 | fmt_pubkey(tmpctx, &pubkey)); |
| 153 | if (!derive_simple_privkey(&base_secret, &base_point, |
| 154 | &per_commitment_point, &privkey)) |
| 155 | abort(); |
| 156 | printf("localprivkey: 0x%s\n", |
| 157 | tal_hexstr(tmpctx, &privkey, sizeof(privkey))); |
| 158 | pubkey_from_privkey(&privkey, &pubkey2); |
| 159 | assert(pubkey_eq(&pubkey, &pubkey2)); |
| 160 | |
| 161 | /* FIXME: Annotate internal steps. */ |
| 162 | if (!derive_revocation_key(&base_point, &per_commitment_point, &pubkey)) |
| 163 | abort(); |
| 164 | printf("revocationkey: 0x%s\n", |
| 165 | fmt_pubkey(tmpctx, &pubkey)); |
| 166 | if (!derive_revocation_privkey(&base_secret, &per_commitment_secret, |
| 167 | &base_point, &per_commitment_point, |
| 168 | &privkey)) |
| 169 | abort(); |
| 170 | printf("revocationprivkey: 0x%s\n", |
| 171 | tal_hexstr(tmpctx, &privkey, sizeof(privkey))); |
| 172 | pubkey_from_privkey(&privkey, &pubkey2); |
| 173 | assert(pubkey_eq(&pubkey, &pubkey2)); |
| 174 | |
| 175 | common_shutdown(); |
| 176 | } |
nothing calls this directly
no test coverage detected