Expand description
Cryptographic helpers for APH envelopes.
Two layers live here:
-
Envelope signing — one module per §8.1/§8.2 combination of algorithm and carriage, all three sharing
proof_baseso they cannot disagree about which bytes a proof covers:Module proof.typeAlgorithm proofValuecarrieseddsa_jcsDataIntegrityProof(eddsa-jcs-2022)Ed25519 multibase base58btc, 64 raw bytes ecdsa_jcsDataIntegrityProof(ecdsa-jcs-2019)ES256 multibase base58btc, P1363 r‖sjws_envelopeJsonWebSignature2020ES256 a compact DETACHED JWS eddsa-jcs-2022is the protocol’s default and the suite the channel examples declare; the other two are §8.1 MUST-support and each now has a published vector underexamples/.did_keyandmultibaselet a verifier recover adid:keyissuer’s public key on either curve with no network access at all.proof_baseowns the canonicalization base each proof covers (spec §7.2.1) — the one place that decides which bytes a signature is over, so signer and verifier cannot drift apart. -
Shared primitives —
jcscanonicalization,jws_detached, and ES256signingare shared with the AP2 payment-mandate ecosystem and are vendored here so the APH crate stands alone with no external protocol dependencies.
§⛔ The signature encoding depends on the CARRIAGE, not on the algorithm
The same ES256 key produces two different wire forms in this crate, and both are correct:
- an
ecdsa-jcs-2019proofValueis P1363r‖s, per the W3C suite definition (ecdsa_jcs); - the signature inside a detached JWS is DER, and a Delegation Mandate
signature is DER, because that is the deployed AP2-interop wire
(
jws_detached,signing).
Unifying them “for consistency” would fork one of the two wires. Both sides are pinned by tests that assert they DIFFER.
Modules§
- did_key
did:key— self-describing notary identifiers.- ecdsa_
jcs ecdsa-jcs-2019— ES256 envelope signing and verification.- eddsa_
jcs eddsa-jcs-2022— envelope signing and verification.- jcs
- RFC 8785 JSON Canonicalization Scheme (JCS).
- jws_
detached - JWS Detached Signature (RFC 7515 Appendix F).
- jws_
envelope JsonWebSignature2020— the detached-JWS carriage of an envelope proof (spec §8.2).- multibase
- Multibase base58btc — the encoding APH proof values and
did:keyidentifiers use. - proof_
base - Per-proof canonicalization bases — spec §7.2.1.
- signing
- ECDSA ES256 signing and verification.