Skip to content

[Update] Check that each contribution is signed by a consortium member and unchanged since signing - #344

Merged
deanwampler merged 1 commit into
The-AI-Alliance:developfrom
build4me2:build4me2/signed-contribution-manifests
Nov 25, 2026
Merged

deanwampler merged 1 commit into
The-AI-Alliance:developfrom
build4me2:build4me2/signed-contribution-manifests

Conversation

@build4me2

Copy link
Copy Markdown
Contributor

Description of the PR

Why. The contribution validator (the check that runs on each node's update before it is merged into the shared model) relies on the node to say which shared base it trained from. That statement is a plain field. Anyone can copy the right value onto any weights: a node outside the consortium, someone using a member's name, or someone changing a member's update on the way. The validator accepts all of these. This is the gap #273 describes.

What. Each node can now sign a short statement about its update: who it is, which round, which base it trained from, a fingerprint of its weights, and the quality score and token count that merge weights can depend on. Give the gate the members' public keys, and it admits an update only if a member signed it for this round and nothing changed afterwards. Each kind of failure gets its own finding in the round record. Without keys, nothing changes.

Please look closely: this touches authentication, and it adds a dependency (cryptography) to the root pyproject.toml.

flowchart LR
    N[/"Node signs manifest<br/>id · round · base · weights · score"/]:::evidence
    G{"Signed by a member?<br/>Unchanged? This round?"}:::gate
    V["Existing checks<br/>shape · dtype · NaN · limits"]:::verify
    M["Outer merge"]:::weights
    R["Rejected, with a<br/>manifest-* finding"]:::dimensions
    N --> G
    G -->|yes| V --> M
    G -.->|no| R

    classDef evidence fill:#fff2cc,stroke:#d6b656,color:#5d4b00,stroke-width:2px
    classDef gate fill:#b23a48,stroke:#8e2e39,color:#fff,stroke-width:2px
    classDef verify fill:#ede7f6,stroke:#7b1fa2,color:#4a148c,stroke-width:2px
    classDef weights fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332,stroke-width:2px
    classDef dimensions fill:#fff,stroke:#546e7a,color:#263238,stroke-width:2px
Loading

What it does not do. A signature proves who made a claim, not that the claim is true. A member that trains from the wrong base and signs the correct value is still admitted, but the false claim now carries its signature. A test pins this behaviour, and the README says so.

Related Issues

If Code Changes Are Included

Description of Code Changes

  • pyproject.toml: adds cryptography (Apache-2.0 or BSD-3-Clause) for Ed25519. The standard library cannot sign, and nothing in the repo provided it. I put it in the root project instead of giving the contrib its own pyproject.toml, which would mean a second torch install. I can move it if you prefer.
  • contrib/build4me2-contribution-validator/contribution_validator/manifest.py (new):
    • ContributionManifest: the signed fields, with a canonical encoding (compact JSON, sorted keys, and a format tag so the signature cannot be reused for another message).
    • sign_contribution() and SigningNode, for the node side.
    • verify_manifest(), which returns findings. It stops at the first of: no manifest, unknown sender, or bad signature. After that it reports every signed field that differs.
  • validator.py: ContributionValidator takes optional keyword-only member_keys and round_num. With keys, validate() checks the manifest first, and validate_state() raises, because a raw state has no manifest.
  • gate.py: ValidatingConsortiumCoordinator takes member_keys and passes it, with the current round, to each round's validator. A wrong key type fails at construction.
  • findings.py: adds manifest-missing, manifest-signer-unknown, manifest-signature-invalid and manifest-mismatch (whose details["field"] names the field).
  • README.md: a "Signed manifests" section, the four rows in the checks table, the tested guarantees, and the limitations.

Of the 548 added lines, 193 are manifest.py, 211 are its tests, and about 60 are the README.

#273 says the format and algorithm need a decision. These are the choices made here, and I'm happy to change them:

Testing Performed

  • 14 new tests in tests/test_manifest.py (one per module, as the layout guide asks). They cover: a member's signed update is accepted; unsigned, unknown sender, impersonation, an edited manifest, weights or score changed after signing, and replay in a later round are each rejected with the expected finding; a manifest that cannot be encoded, or a non-tensor value, gives a finding instead of an exception; bad configuration fails early; in the gate, an impersonator is rejected and recorded in the summary while the other member merges.

  • The example from [Code] Verify contribution manifests with signatures, not self-declared fingerprints #273 and related cases. develop has no signatures, so there each row is the same contribution with only a declared fingerprint:

    Scenario develop This PR, with a roster
    Issue example: wrong base, declares the real value accepted manifest-missing
    Outsider using a member's name accepted manifest-signature-invalid
    Outsider under its own name accepted manifest-signer-unknown
    Member's weights changed on the way accepted manifest-mismatch
    Member's round-1 update replayed in round 2 accepted manifest-mismatch
    Member signs a false base claim (known limit) accepted accepted
  • The existing 61 validator tests pass unchanged. manifest.py, validator.py and gate.py are at 100% line coverage. make contribution-validator-demo runs.

  • make before-pr completes successfully on this commit in 3 of 4 runs. The other run failed two Hypothesis tests in src/tests/tapestry/training/consortium/test_node.py that exceeded their 200 ms deadline (261 ms and 380 ms). The same file fails the same way on clean develop (2 of 5 runs), and this PR changes nothing under src/.

Example Usage

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from contribution_validator import SigningNode, ValidatingConsortiumCoordinator
from contribution_validator.testing import tiny_model, toy_corpus

model, corpus = tiny_model(), toy_corpus(0)
india_key = Ed25519PrivateKey.generate()  # held by the node; only the public key is shared
coordinator = ValidatingConsortiumCoordinator(model, member_keys={"india": india_key.public_key()})
node = SigningNode("india", "India", model, corpus, 0.9, private_key=india_key)
intruder = SigningNode("intruder", "Elsewhere", model, corpus, 0.9, private_key=Ed25519PrivateKey.generate())

coordinator.run_round([node, intruder])
coordinator.last_summary.validation_rejected_nodes  # ['intruder']
coordinator.last_summary.reports["intruder"].finding_codes  # ('manifest-signer-unknown',)

Checklist

For code changes:

  • I have tested the code changes in my local development environment.
  • I have added or modified tests for all code changes.
  • I have followed the existing code styles and conventions.
  • I have removed all API keys and other sensitive information.
  • I have updated any related documentation.
  • I have confirmed that the command make before-pr completes successfully. (See the note on timing under Testing.)

The base fingerprint a node declares is a plain field, so anyone can
attach the right digest to any weights: a node outside the consortium,
or someone changing a member's contribution on the way. Nothing ties
the declaration to the sender or to the weights it comes with.

A node can now sign a manifest naming its identity, the round, the
base it trained from, a fingerprint of the contributed tensors, and
the quality score and token count the merge weights depend on. Given a
roster of member Ed25519 public keys, the validator and the gate reject
a contribution that is unsigned, sent by a node outside the roster,
signed with the wrong key, or whose weights, score, round or base
differ from what was signed. Each case is its own finding. Without a
roster nothing changes.

A signature proves who made a claim, not that it is true, so a member
that signs a false base declaration is still admitted, though the claim
is now attributable to it. Key distribution and rotation are left to
the central node work in The-AI-Alliance#114.

Ed25519 comes from the cryptography package, added as a dependency.

Refs The-AI-Alliance#273.

Signed-off-by: Manisha Chand <chandmanisha00@gmail.com>

@deanwampler deanwampler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks.

@deanwampler
deanwampler merged commit 51b4ddf into The-AI-Alliance:develop Nov 25, 2026
8 checks passed
@deanwampler

Copy link
Copy Markdown
Member

@build4me2 , it just occurred to me that the description for the PR would be great to add to the design docs, so it's not "lost" now that this PR is closed. Could you add this content to a new file under docs/work-groups/infrastructure-operations. Use a separate PR, of course. No rush... Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants