Skip to main content

Module crypto

Module crypto 

Source
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_base so they cannot disagree about which bytes a proof covers:

    Moduleproof.typeAlgorithmproofValue carries
    eddsa_jcsDataIntegrityProof (eddsa-jcs-2022)Ed25519multibase base58btc, 64 raw bytes
    ecdsa_jcsDataIntegrityProof (ecdsa-jcs-2019)ES256multibase base58btc, P1363 r‖s
    jws_envelopeJsonWebSignature2020ES256a compact DETACHED JWS

    eddsa-jcs-2022 is 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 under examples/. did_key and multibase let a verifier recover a did:key issuer’s public key on either curve with no network access at all. proof_base owns 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 — jcs canonicalization, jws_detached, and ES256 signing are 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-2019 proofValue is P1363 r‖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:key identifiers use.
proof_base
Per-proof canonicalization bases — spec §7.2.1.
signing
ECDSA ES256 signing and verification.