diff options
Diffstat (limited to 'src/test_btfaddr.cpp')
| -rw-r--r-- | src/test_btfaddr.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/test_btfaddr.cpp b/src/test_btfaddr.cpp index 8de426e..9d33d63 100644 --- a/src/test_btfaddr.cpp +++ b/src/test_btfaddr.cpp | |||
| @@ -133,12 +133,23 @@ int main() | |||
| 133 | std::string d3 = btf::SignDescriptor(ctx, sk, ENC_HEX, "node-1", 5, ONION); | 133 | std::string d3 = btf::SignDescriptor(ctx, sk, ENC_HEX, "node-1", 5, ONION); |
| 134 | json j3 = json::parse(d3); | 134 | json j3 = json::parse(d3); |
| 135 | j3["onion"] = "bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde.onion:8433"; | 135 | j3["onion"] = "bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde.onion:8433"; |
| 136 | CHECK(btf::VerifyDescriptor(ctx, j3.dump(), pk, o) && o.onion.empty(), | 136 | CHECK(!btf::VerifyDescriptor(ctx, j3.dump(), pk, o), |
| 137 | "tampered onion ignored rather than trusted"); | 137 | "tampered onion rejects the descriptor"); |
| 138 | json j4 = json::parse(d3); | 138 | json j4 = json::parse(d3); |
| 139 | j4["sig3"] = std::string(128, '0'); | 139 | j4["sig3"] = std::string(128, '0'); |
| 140 | CHECK(btf::VerifyDescriptor(ctx, j4.dump(), pk, o) && o.onion.empty(), | 140 | CHECK(!btf::VerifyDescriptor(ctx, j4.dump(), pk, o), |
| 141 | "bad onion signature ignored rather than trusted"); | 141 | "bad onion signature rejects the descriptor"); |
| 142 | json j5 = json::parse(d3); | ||
| 143 | j5.erase("sig3"); | ||
| 144 | CHECK(!btf::VerifyDescriptor(ctx, j5.dump(), pk, o), | ||
| 145 | "unsigned onion rejects the descriptor"); | ||
| 146 | // Removing both fields still verifies: the result is indistinguishable | ||
| 147 | // from a peer that never had an onion endpoint. That residual strip | ||
| 148 | // needs the onion bound into the primary sig, an upstream change. | ||
| 149 | json j6 = json::parse(d3); | ||
| 150 | j6.erase("onion"); j6.erase("sig3"); | ||
| 151 | CHECK(btf::VerifyDescriptor(ctx, j6.dump(), pk, o) && o.onion.empty(), | ||
| 152 | "full strip indistinguishable from no-onion (documented residual)"); | ||
| 142 | } | 153 | } |
| 143 | 154 | ||
| 144 | printf("full_resolve_chain_from_address\n"); | 155 | printf("full_resolve_chain_from_address\n"); |