Add ECVRF (RFC 9381) token support with FullKeyHash identifier#27
Merged
Add ECVRF (RFC 9381) token support with FullKeyHash identifier#27
Conversation
Implement ECVRF-RISTRETTO255-SHA512 via the vrf-r255 crate, enabling tokens where anyone with the public key can verify, without possessing the secret key. This turns symmetric verification into public verification. Key changes: - Algorithm::EcVrf (4) with 64-byte VRF output as signature - KeyIdentifier::FullKeyHash: 32-byte SHA-256 for full collision resistance - New `proof` field (80 bytes) in SignedToken wire format (field 3) - VRF signing, verification, and key generation - CLI support: generate-key/sign/verify/inspect with --algorithm ecvrf - 20 new tests (126 total), all passing Research notes in notes/research-symmetric-key-proofs.md comparing SNARKs, VRFs, Poseidon, and other approaches. https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM
- Run cargo fmt to fix line-wrapping in serialize.rs, sign.rs, verify.rs - Replace JSON indexing with safe as_object_mut().insert() in main.rs to satisfy clippy::indexing_slicing lint https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM
Add ECVRF (RFC 9381) to supported algorithms list, CLI examples, wire format schema, token sizes table, and security considerations. https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM
Replace `panic!()` with `assert!(matches!(...))` in the test_ecvrf_uses_full_key_hash test to satisfy the clippy::panic lint which CI promotes to an error via -D warnings. https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for ECVRF (Elliptic Curve Verifiable Random Function) tokens as a new algorithm option, implementing RFC 9381 (ECVRF-RISTRETTO255-SHA512). ECVRF enables a "public verification" model where verifiers only need a key hash rather than the full key material, while the token issuer proves knowledge of the corresponding secret key through a cryptographic proof.
Key Changes
Algorithm::EcVrf = 4to support ECVRF token signing and verificationKeyIdType::FullKeyHash = 3for full 32-byte SHA-256 hashes of key material, enabling collision-resistant key identification without embedding full public keysprooffield toSignedToken(80 bytes for ECVRF, empty for other algorithms)signaturefield and the VRF proof (80 bytes) in theprooffieldsrc/sign.rs):generate_ecvrf_key(): Generates 32-byte secret/public key pairssign_ecvrf(): Creates ECVRF tokens with deterministic VRF proofscompute_full_key_hash(): Computes full 32-byte SHA-256 hashes for key identificationsrc/verify.rs):verify_ecvrf(): Verifies ECVRF tokens by validating the VRF proof against the payloadFullKeyHashidentifiers (only valid for ECVRF)KeyHashidentifierssrc/serialize.rs):prooffield (field 3 in SignedToken)FullKeyHashkey identifier type in payload serializationsrc/types.rs):EcVrfalgorithm variant with correct signature length (64 bytes)FullKeyHashkey identifier variantsrc/keys.rs):src/main.rs):CLAUDE.md):notes/research-symmetric-key-proofs.md):Implementation Details
vrf-r255crate (str4d/Zcash), which implements RFC 9381 with RISTRETTO255-SHA512FullKeyHashidentifiers; other algorithms reject this typeprooffieldshttps://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM