Skip to content

Commit c115480

Browse files
authored
feat: node signature verification for queries (#784)
* feat: adds node signatures to query response types * moves fetchNodeKeys to canisterStatus * updating e2e tests * replaces tweetnacl with @noble/curves * more ed25519 tests and compatibility with previous stored JSON * moves public key and DER utils into agent * simplifies @dfinity/identity with agent exports * subnetStatus mapping node id to public key * lookup_path now returns tree by default * fix: canister ranges checked for root subnet fixes FOLLOW-1301 * fix: sets maxAge for delegation certificates to Infinity, bypassing check resolves FOLLOW-1302
1 parent 6e1dbfb commit c115480

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1039
-630
lines changed

canister_ids.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"counter": {
3+
"ic": "tnnnb-2yaaa-aaaab-qaiiq-cai"
4+
},
25
"docs": {
36
"ic": "erxue-5aaaa-aaaab-qaagq-cai"
47
}

docs/generated/changelog.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ <h1>Agent-JS Changelog</h1>
1212
<section>
1313
<h2>Version x.x.x</h2>
1414
<ul>
15+
<ul>
16+
<strong>feat!: node signature verification</strong
17+
><br />
18+
This feature includes additional changes in support of testing and releasing the feature:
19+
<br />
20+
<li>Mainnet e2e tests for queries and calls</li>
21+
<li>published counter canister</li>
22+
<li>
23+
New HttpAgent option - verifyQuerySignatures. Defaults to true, but allows you to opt
24+
out of verification. Useful for testing against older replica versions
25+
</li>
26+
<li>Introducing ed25519 logic to agent for validating node signatures</li>
27+
<li>Standardizing around @noble/curves instead of tweetnacl in @dfinity/identity</li>
28+
<li>
29+
new export - hashOfMap from agent, matching the naming used in the interface
30+
specification
31+
</li>
32+
<li>new unit tests</li>
33+
<li>new Verify export on ed25519 because why not</li>
34+
</ul>
35+
<li>Adds support for Uint8Arrays in Principal.from()</li>
1536
<li>
1637
chore: increases size limit for agent-js to allow for Ed25519 support for node key
1738
signature verification

e2e/node/basic/mitm.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ mitmTest(
1919
},
2020
{ timeout: 30000 },
2121
);
22+
23+
mitmTest('mitm with query verification', async () => {
24+
const counter = await createActor('tnnnb-2yaaa-aaaab-qaiiq-cai', {
25+
agent: await makeAgent({
26+
host: 'http://127.0.0.1:8888',
27+
verifyQuerySignatures: true,
28+
}),
29+
});
30+
await expect(counter.greet('counter')).rejects.toThrow(/Invalid certificate/);
31+
await expect(counter.queryGreet('counter')).rejects.toThrow(/Invalid certificate/);
32+
});

e2e/node/utils/agent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ if (Number.isNaN(port)) {
1212
export const makeAgent = async (options?: HttpAgentOptions) => {
1313
const agent = new HttpAgent({
1414
host: `http://127.0.0.1:${process.env.REPLICA_PORT ?? 4943}`,
15+
// TODO - remove this when the dfx replica supports it
16+
verifyQuerySignatures: false,
1517
...options,
1618
});
1719
try {

0 commit comments

Comments
 (0)