Repository navigation
Description
This is the foundation for the GSoC “Verifiable Certificates with Open Badges 3.0” project.
Problem Statement
The learn application needs a secure and standards-compatible mechanism to sign and verify verifiable credentials. Before integrating credential signing into application routes, database workflows, or credential issuance, we need to validate that Ed25519-based JSON Web Signatures (JWS) work correctly within the Cloudflare Python Worker runtime.
The initial implementation should establish a small, independently testable signing module and validate the underlying cryptographic operations.
Proposed Solution
Implement a standalone Ed25519 JWS signing and verification module using the Web Crypto API available in the Cloudflare Worker environment.
The implementation should include:
-
JWS signing
- Generate compact JWS tokens using the
EdDSAalgorithm. - Construct protected headers containing
alg,typ, andkid. - Serialize and Base64URL-encode the header and payload.
- Sign the
header.payloadinput using an Ed25519 private key in PKCS#8 format.
- Generate compact JWS tokens using the
-
JWS verification
- Verify signatures using an Ed25519 public key in raw format.
- Reject invalid signatures, modified payloads, malformed tokens, and unsupported algorithms.
- Return the decoded payload only when verification succeeds.
-
Signing key generation
- Add a development utility to generate Ed25519 key pairs.
- Export the private key in PKCS#8 DER format and the public key as a JWK.
- Provide the key identifier (
kid) and configuration values needed for local development and Cloudflare secrets.
-
Automated testing
- Add tests for successful signing and verification.
- Test tampered payloads and incorrect public keys.
- Ensure unsupported algorithms and malformed tokens are rejected.
- Extend the existing test environment with the necessary Web Crypto mocks.
Scope
Included:
- Standalone credential signing and verification helpers.
- Ed25519 key-generation utility.
- Unit tests and required development dependencies.
- Validation of Ed25519 operations in the Cloudflare Python Worker runtime.
Out of scope:
- Credential issuance or verification API routes.
- Database schema changes or key persistence.
- Integration with existing certificate workflows.
- Production key management and key rotation.
- Changes to existing authentication or authorization flows.
Acceptance Criteria
- Ed25519 JWS tokens can be generated using the Web Crypto API.
- Valid signatures can be successfully verified.
- Modified payloads and invalid signatures are rejected.
- Unsupported algorithms, including
none, are rejected. - Malformed tokens are handled safely.
- Key-generation utility produces the expected private-key and public-JWK formats.
- Automated tests cover successful and unsuccessful verification scenarios.
- Cryptographic operations are validated in the Cloudflare Python Worker runtime.
- No private signing keys or generated secrets are committed to the repository.
- No existing application routes or credential workflows are modified.
Expected Outcome
A minimal, independently testable Ed25519 JWS implementation that establishes the cryptographic foundation for future verifiable credential support in the learn application, while keeping application-level integration separate.
Activity