From bd39c0672771ea542ff7f69a4b69d09755c5a44e Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 13:59:03 +1000 Subject: [PATCH 1/8] Updates for crypton/memory/ram changes The package `crypton < 1.1` depends on `memory` and `>= 1.1` depends on `ram`. By dropping the dependency on `memory` and adding the dependency on `ram` we are effectively changing to `crypton >= 1.1`. --- cardano-api/cardano-api.cabal | 2 +- cardano-rpc/cardano-rpc.cabal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index e1ea28870c..5e3aa07906 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -168,7 +168,6 @@ library formatting, fs-api ^>=0.4, iproute, - memory, mempack, microlens <0.6, mono-traversable, @@ -186,6 +185,7 @@ library prettyprinter, prettyprinter-ansi-terminal, prettyprinter-configurable ^>=1.36, + ram, random, resource-registry ^>=0.3, safe-exceptions, diff --git a/cardano-rpc/cardano-rpc.cabal b/cardano-rpc/cardano-rpc.cabal index d680094624..f7b45e5c56 100644 --- a/cardano-rpc/cardano-rpc.cabal +++ b/cardano-rpc/cardano-rpc.cabal @@ -118,11 +118,11 @@ library generic-data, grapesy, grpc-spec, - memory, mempack, microlens, proto-lens >=0.7.1.7, proto-lens-protobuf-types, + ram, random, rio, text, @@ -184,10 +184,10 @@ test-suite cardano-rpc-test hedgehog, hedgehog-extras, hedgehog-quickcheck, - memory, mtl, ouroboros-consensus:cardano, proto-lens, + ram, rio, scientific, tasty, From 16e57a6ff50be3c07b47800ca2ce0bad1306aadd Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 15:03:03 +1000 Subject: [PATCH 2/8] Use SRPs to pull in dependencies that use crypton >= 1.1 --- cabal.project | 99 +++++++++++++++++++++++++++++++++-- cardano-api/cardano-api.cabal | 10 ++-- 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/cabal.project b/cabal.project index de118ade25..019d06a46a 100644 --- a/cabal.project +++ b/cabal.project @@ -48,11 +48,6 @@ jobs: $ncpus semaphore: True -constraints: - -- haskell.nix patch does not work for 1.6.8 - , any.crypton-x509-system < 1.6.8 - - -- WASM compilation specific if arch(wasm32) @@ -166,3 +161,97 @@ if impl(ghc >=9.14) , time-locale-compat:time , with-utf8:base -- cabal-allow-newer end + +-- TEMPORARY: switching to crypton >= 1.1 (which depends on `ram` instead of +-- `memory`) needs cardano-crypto-class-2.6.0.0 (the first version depending +-- on crypton ^>=1.1 and `ram`), but the released ouroboros-consensus-3.0.1.0 +-- pins `cardano-crypto-class ^>=2.3`, which excludes it. The blocks below +-- replicate the (draft, do-not-merge) upstream fix in +-- https://github.com/IntersectMBO/ouroboros-consensus/pull/2213, which widens +-- ouroboros-consensus's bound to also allow cardano-crypto-class-2.6.0.0 and +-- pulls in the handful of other packages that need to move in lockstep with +-- it. Remove all of this once these land upstream and a release picks them up. +allow-newer: + cardano-ledger-mary:cardano-crypto-class, + cardano-ledger-shelley:cardano-crypto-class, + cardano-ledger-binary:cardano-crypto-class, + cardano-ledger-core:cardano-crypto-class, + cardano-protocol:cardano-crypto-class, + cardano-protocol-tpraos:cardano-crypto-class, + kes-agent:cardano-crypto-class, + kes-agent-crypto:cardano-crypto-class, + +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-consensus + tag: 4da82e0afed5dabbe930d5f5cad5de687428e07b + +-- TEMPORARY: pulls in cardano-base PR #694 (erikd/contra-tracer, not yet +-- merged) https://github.com/IntersectMBO/cardano-base/pull/694, which widens +-- cardano-crypto-class:testlib's contra-tracer bound so it builds against the +-- same contra-tracer version as everything else here. Needed by the +-- ouroboros-consensus pin above. Remove once this PR (or an equivalent fix) +-- is released. +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-base + tag: ad3afec8113872652ec8edf19ae1280552ce2a20 + subdir: cardano-crypto-class + +-- TEMPORARY: pulls in kes-agent PR #105 (erikd/contra-tracer, not yet merged) +-- https://github.com/input-output-hk/kes-agent/pull/105, which widens the +-- same contra-tracer bound for kes-agent/kes-agent-crypto, on top of the +-- FixedSizeCodec migration cardano-crypto-class-2.6.0.0 needs. Needed by the +-- ouroboros-consensus pin above. Remove once this PR (or an equivalent fix) +-- is released. +source-repository-package + type: git + location: https://github.com/input-output-hk/kes-agent + tag: 0e9a16c61ecc6b5cc747ae0ebdb718a02eae8ddc + subdir: + kes-agent + kes-agent-crypto + +-- TEMPORARY: pulls in cardano-ledger PR #5999 (erikd/ram, not yet merged) +-- https://github.com/IntersectMBO/cardano-ledger/pull/5999, which switches +-- cardano-crypto-wrapper from `memory` to `ram` so it builds against crypton +-- >=1.1. Needed by the ouroboros-consensus pin above. Remove once this PR (or +-- an equivalent fix) is released. +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-ledger + tag: 6def84b5ae0033053feda72f32b1dac41c812e0e + subdir: eras/byron/crypto + +-- TEMPORARY: cardano-addresses-4.0.2 (the latest released on CHaP) still pins +-- `crypton >=0.32 && <1.1` and depends on the standalone `cardano-crypto` +-- package (capped at <1.4.0, i.e. before its own `memory`->`ram` switch). +-- master (unreleased, 4.0.7) has already moved to `crypton >=1.1 && <1.2` / +-- `ram` and dropped the `cardano-crypto` dependency entirely. Remove once a +-- release picks this up. +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-addresses + tag: 63c2497f965e96610c6e3df1127dbd0b9481228f + +-- TEMPORARY: grapesy-1.1.1 (the latest released on Hackage) pins +-- `tls >=1.7 && <2.2`, which excludes tls-2.4.3 (needed for crypton >=1.1, +-- since older tls versions pull in crypton-x509-validation <1.7, which caps +-- crypton <1.1). well-typed/grapesy's master widens that to +-- `tls >=1.7 && <2.5`, still version 1.1.1 (unreleased bump). Remove once a +-- release picks this up. +source-repository-package + type: git + location: https://github.com/well-typed/grapesy + tag: bd6af64f69ff89e3a8fc02e2c81262e648f4715d + subdir: + grapesy + grpc-spec + +-- TEMPORARY: this pin (working around a haskell.nix patch that doesn't apply +-- to crypton-x509-system-1.6.8) forces an old crypton-x509-system, which +-- conflicts with the crypton >=1.1 migration above (that needs +-- crypton-x509-system-1.9.0). Dropped for now; revisit once the crypton +-- migration lands and re-check whether the haskell.nix issue still applies. +-- constraints: +-- , any.crypton-x509-system < 1.6.8 diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 5e3aa07906..b7e1e99b74 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -135,8 +135,8 @@ library cardano-base ^>=0.1, cardano-binary, cardano-crypto, - cardano-crypto-class ^>=2.5, - cardano-crypto-wrapper ^>=1.7, + cardano-crypto-class ^>=2.5 || ^>=2.6, + cardano-crypto-wrapper ^>=1.7 || ^>=1.8, cardano-data >=1.0, cardano-diffusion:{api, cardano-diffusion} ^>=1.1, cardano-ledger-allegra >=1.7, @@ -329,8 +329,8 @@ library gen bytestring, cardano-api, cardano-binary >=1.6 && <1.10, - cardano-crypto-class ^>=2.5, - cardano-crypto-wrapper:testlib ^>=1.7, + cardano-crypto-class ^>=2.5 || ^>=2.6, + cardano-crypto-wrapper:testlib ^>=1.7 || ^>=1.8, cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib}, cardano-ledger-byron:testlib, cardano-ledger-conway:testlib, @@ -373,7 +373,7 @@ test-suite cardano-api-test cardano-api:gen, cardano-binary, cardano-crypto, - cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.5, + cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.5 || ^>=2.6, cardano-crypto-wrapper:testlib, cardano-ledger-alonzo, cardano-ledger-api ^>=1.14, From 2a4bf959dd4ff3ee614297b99e44fecc7d0aacfe Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 15:18:11 +1000 Subject: [PATCH 3/8] Update all DSIGN operations to FixedSizeCodec ops This change required due to dependence on cardano-crypto-class which in turn was required to support crypton >= 1.1. --- cardano-api/cardano-api.cabal | 15 +++++++++++ .../src/Cardano/Api/Crypto/Ed25519Bip32.hs | 25 +++++++++++-------- cardano-rpc/cardano-rpc.cabal | 4 +-- .../Rpc/Server/Internal/UtxoRpc/Type/Byron.hs | 4 +-- .../Rpc/Server/Internal/UtxoRpc/Type/Tx.hs | 16 ++++++------ 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index b7e1e99b74..59d9adbc75 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -132,10 +132,16 @@ library bytestring, bytestring-trie, cardano-addresses ^>=4.0.0, +<<<<<<< HEAD cardano-base ^>=0.1, cardano-binary, cardano-crypto, cardano-crypto-class ^>=2.5 || ^>=2.6, +======= + cardano-binary >=1.9.1, + cardano-crypto, + cardano-crypto-class ^>=2.6, +>>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper ^>=1.7 || ^>=1.8, cardano-data >=1.0, cardano-diffusion:{api, cardano-diffusion} ^>=1.1, @@ -328,8 +334,13 @@ library gen base16-bytestring, bytestring, cardano-api, +<<<<<<< HEAD cardano-binary >=1.6 && <1.10, cardano-crypto-class ^>=2.5 || ^>=2.6, +======= + cardano-binary >=1.9.1 && <1.10, + cardano-crypto-class ^>=2.6, +>>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper:testlib ^>=1.7 || ^>=1.8, cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib}, cardano-ledger-byron:testlib, @@ -373,7 +384,11 @@ test-suite cardano-api-test cardano-api:gen, cardano-binary, cardano-crypto, +<<<<<<< HEAD cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.5 || ^>=2.6, +======= + cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.6, +>>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper:testlib, cardano-ledger-alonzo, cardano-ledger-api ^>=1.14, diff --git a/cardano-api/src/Cardano/Api/Crypto/Ed25519Bip32.hs b/cardano-api/src/Cardano/Api/Crypto/Ed25519Bip32.hs index 4cf0685b01..fc0a8c7d03 100644 --- a/cardano-api/src/Cardano/Api/Crypto/Ed25519Bip32.hs +++ b/cardano-api/src/Cardano/Api/Crypto/Ed25519Bip32.hs @@ -40,15 +40,6 @@ data Ed25519Bip32DSIGN instance DSIGNAlgorithm Ed25519Bip32DSIGN where type SeedSizeDSIGN Ed25519Bip32DSIGN = 32 - -- \| BIP32-Ed25519 extended verification key size is 64 octets. - type VerKeySizeDSIGN Ed25519Bip32DSIGN = 64 - - -- \| BIP32-Ed25519 extended signing key size is 96 octets. - type SignKeySizeDSIGN Ed25519Bip32DSIGN = 96 - - -- \| BIP32-Ed25519 extended signature size is 64 octets. - type SigSizeDSIGN Ed25519Bip32DSIGN = 64 - -- -- Key and signature types -- @@ -102,21 +93,33 @@ instance DSIGNAlgorithm Ed25519Bip32DSIGN where (mempty :: ScrubbedBytes) (mempty :: ScrubbedBytes) +-- +-- raw serialise/deserialise, in fixed-size raw format +-- + instance FixedSizeCodec (VerKeyDSIGN Ed25519Bip32DSIGN) where + -- \| BIP32-Ed25519 extended verification key size is 64 octets. type FixedSize (VerKeyDSIGN Ed25519Bip32DSIGN) = 64 + rawEncodeFixedSized (VerKeyEd25519Bip32DSIGN vk) = CC.unXPub vk rawDecodeFixedSized bs = either fail (pure . VerKeyEd25519Bip32DSIGN) (CC.xpub bs) instance FixedSizeCodec (SignKeyDSIGN Ed25519Bip32DSIGN) where + -- \| BIP32-Ed25519 extended signing key size is 96 octets. type FixedSize (SignKeyDSIGN Ed25519Bip32DSIGN) = 96 + rawEncodeFixedSized (SignKeyEd25519Bip32DSIGN sk) = xPrvToBytes sk rawDecodeFixedSized bs = - maybe (fail "invalid Ed25519Bip32DSIGN signing key") (pure . SignKeyEd25519Bip32DSIGN) $ - xPrvFromBytes bs + maybe + (fail "Ed25519Bip32DSIGN: invalid SignKeyDSIGN") + (pure . SignKeyEd25519Bip32DSIGN) + (xPrvFromBytes bs) instance FixedSizeCodec (SigDSIGN Ed25519Bip32DSIGN) where + -- \| BIP32-Ed25519 extended signature size is 64 octets. type FixedSize (SigDSIGN Ed25519Bip32DSIGN) = 64 + rawEncodeFixedSized = BA.convert rawDecodeFixedSized bs = either fail (pure . SigEd25519Bip32DSIGN) (CC.xsignature bs) diff --git a/cardano-rpc/cardano-rpc.cabal b/cardano-rpc/cardano-rpc.cabal index f7b45e5c56..586e462b49 100644 --- a/cardano-rpc/cardano-rpc.cabal +++ b/cardano-rpc/cardano-rpc.cabal @@ -95,9 +95,9 @@ library base16-bytestring, bytestring, cardano-api >=11.2, - cardano-binary, + cardano-binary >=1.9.1, cardano-crypto, - cardano-crypto-class, + cardano-crypto-class ^>=2.6, cardano-crypto-wrapper, cardano-ledger-allegra, cardano-ledger-alonzo, diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Byron.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Byron.hs index d210b94bd4..3db2468e5a 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Byron.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Byron.hs @@ -15,7 +15,7 @@ import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc import Cardano.Rpc.Server.Internal.Orphans () -import Cardano.Binary.FixedSizeCodec (rawEncodeFixedSized) +import Cardano.Binary.FixedSizeCodec qualified as DSIGN import Cardano.Chain.Block qualified as Byron (ABlockOrBoundary (..), blockTxPayload) import Cardano.Chain.Common (lovelaceToInteger) import Cardano.Chain.UTxO @@ -99,7 +99,7 @@ byronTxToUtxoRpcTx txAux = do bootstrapWitnesses :: [Proto UtxoRpc.BootstrapWitness] bootstrapWitnesses = [ defMessage - & U5c.vkey .~ rawEncodeFixedSized vkey + & U5c.vkey .~ DSIGN.rawEncodeFixedSized vkey & U5c.signature .~ WC.unXSignature xSignature & U5c.chainCode .~ SBS.fromShort (byteArrayToShortByteString (L.unChainCode chainCode)) | VKWitness verificationKey (Byron.Signature xSignature) <- witnesses diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs index 04c70d3cf5..5c0192ebdb 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs @@ -40,7 +40,7 @@ import Cardano.Rpc.Server.Internal.UtxoRpc.Type.TxOutput , txOutToUtxoRpcTxOutput ) -import Cardano.Binary.FixedSizeCodec (rawEncodeFixedSized) +import Cardano.Binary.FixedSizeCodec qualified as DSIGN import Cardano.Crypto.DSIGN.Class qualified as DSIGN import Cardano.Ledger.Api qualified as L import Cardano.Ledger.BaseTypes qualified as L @@ -128,20 +128,18 @@ txToUtxoRpcTx ledgerTx = anyEraTxConstraints sbe $ do vkeyWitnesses = toList (wits ^. L.addrTxWitsL) <&> \(L.WitVKey (L.VKey vkey) (DSIGN.SignedDSIGN signature)) -> defMessage - & U5c.vkey .~ rawEncodeFixedSized vkey - & U5c.signature .~ rawEncodeFixedSized signature + & U5c.vkey .~ DSIGN.rawEncodeFixedSized vkey + & U5c.signature .~ DSIGN.rawEncodeFixedSized signature bootstrapWitnesses :: [Proto UtxoRpc.BootstrapWitness] bootstrapWitnesses = toList (wits ^. L.bootAddrTxWitsL) <&> \bootstrapWitness -> do let L.VKey bootstrapKey = L.bwKey bootstrapWitness DSIGN.SignedDSIGN bootstrapSignature = L.bwSignature bootstrapWitness defMessage - & U5c.vkey .~ rawEncodeFixedSized bootstrapKey - & U5c.signature .~ rawEncodeFixedSized bootstrapSignature - & U5c.chainCode - .~ SBS.fromShort (byteArrayToShortByteString (L.unChainCode (L.bwChainCode bootstrapWitness))) - & U5c.attributes - .~ SBS.fromShort (byteArrayToShortByteString (L.bwAttributes bootstrapWitness)) + & U5c.vkey .~ DSIGN.rawEncodeFixedSized bootstrapKey + & U5c.signature .~ DSIGN.rawEncodeFixedSized bootstrapSignature + & U5c.chainCode .~ L.unChainCode (L.bwChainCode bootstrapWitness) + & U5c.attributes .~ L.bwAttributes bootstrapWitness scriptWitnesses :: [Proto UtxoRpc.Script] scriptWitnesses = M.elems (wits ^. L.scriptTxWitsL) <&> ledgerScriptToUtxoRpcScript sbe From f143fc7b53ed3091d548bc2c72762415ce373dae Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 16:06:50 +1000 Subject: [PATCH 4/8] Fix cardano-api for the validation package's 1.1 -> 1.2 breaking rewrite validation had no version bound in cardano-api.cabal. Its 1.2.2 release (uploaded between the two Hackage index-states this crypton migration spans) is a complete rewrite to a lens/profunctor-optics based API, which dropped Valid.toEither/Valid.liftError used by Cardano.Api.Tx.Internal.Sign.decodeShelleyBasedWitness. Capping validation to <1.2 to keep that old API is not an option: the ouroboros-consensus changes pulled in by the cabal.project SRP had already migrated Ouroboros.Consensus.Shelley.Ledger.Mempool to the new validation >=1.2 API (view Data.Validation.either) themselves, and validation is a single globally-resolved package across the whole build plan, so pinning it down for cardano-api's sake breaks ouroboros-consensus-cardano instead. Rewrite decodeShelleyBasedWitness to use only the primitives that are stable across both API generations (the Valid.Failure/Valid.Success constructors and the Semigroup/Monoid instances), and pin validation ^>=1.2 to reflect what the build already requires transitively. --- cardano-api/cardano-api.cabal | 18 +---------- .../src/Cardano/Api/Tx/Internal/Sign.hs | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 59d9adbc75..0e56fa226f 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -132,16 +132,9 @@ library bytestring, bytestring-trie, cardano-addresses ^>=4.0.0, -<<<<<<< HEAD - cardano-base ^>=0.1, - cardano-binary, - cardano-crypto, - cardano-crypto-class ^>=2.5 || ^>=2.6, -======= cardano-binary >=1.9.1, cardano-crypto, cardano-crypto-class ^>=2.6, ->>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper ^>=1.7 || ^>=1.8, cardano-data >=1.0, cardano-diffusion:{api, cardano-diffusion} ^>=1.1, @@ -207,7 +200,7 @@ library transformers, transformers-except ^>=0.1.3, typed-protocols ^>=1.2, - validation, + validation ^>=1.2, vector, yaml, @@ -334,13 +327,8 @@ library gen base16-bytestring, bytestring, cardano-api, -<<<<<<< HEAD cardano-binary >=1.6 && <1.10, cardano-crypto-class ^>=2.5 || ^>=2.6, -======= - cardano-binary >=1.9.1 && <1.10, - cardano-crypto-class ^>=2.6, ->>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper:testlib ^>=1.7 || ^>=1.8, cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib}, cardano-ledger-byron:testlib, @@ -384,11 +372,7 @@ test-suite cardano-api-test cardano-api:gen, cardano-binary, cardano-crypto, -<<<<<<< HEAD cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.5 || ^>=2.6, -======= - cardano-crypto-class:{cardano-crypto-class, testlib} ^>=2.6, ->>>>>>> e9b8beea3 (Update all DSIGN operations to FixedSizeCodec ops) cardano-crypto-wrapper:testlib, cardano-ledger-alonzo, cardano-ledger-api ^>=1.14, diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs index 2ac9770d75..791fd22adc 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs @@ -782,20 +782,24 @@ decodeShelleyBasedWitness -> ByteString -> Either CBOR.DecoderError (KeyWitness era) decodeShelleyBasedWitness sbe bs = - let e = - Valid.foldValidation Left Right $ - mconcat $ - map - (either (Valid.Failure . (: [])) Valid.Success) - [ bootstrapWitnessDecoder bs - , shelleyKeyWitnessDecoder bs - , legacyKeyWitnessDecoder bs - ] - in case e of - Left errs -> - let allErrs = Text.unlines $ map renderBuildable errs - in Left $ CBOR.DecoderErrorCustom "Failed to deserialise key witness" allErrs - Right res -> return res + -- NB: built directly from 'Valid.Failure'/'Valid.Success' (rather than via + -- 'Valid.liftError'/'Valid.toEither') since those convenience functions were + -- removed from the "validation" package's newer, lens-based API; the + -- constructors and the 'Semigroup'/'Monoid' instances used here are stable + -- across both APIs. + case + mconcat $ + map + (either (Valid.Failure . return) Valid.Success) + [ bootstrapWitnessDecoder bs + , shelleyKeyWitnessDecoder bs + , legacyKeyWitnessDecoder bs + ] + of + Valid.Failure errs -> + let allErrs = Text.unlines $ map renderBuildable errs + in Left $ CBOR.DecoderErrorCustom "Failed to deserialise key witness" allErrs + Valid.Success res -> return res where shelleyKeyWitnessDecoder b = ShelleyKeyWitness sbe From d3ddb33953cbf7db26579ef28062967abafa31e6 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 16:08:23 +1000 Subject: [PATCH 5/8] Adapt to cardano-crypto-class-2.5.0.0's BLS12381SignContext/testlib changes cardano-crypto-class-2.5.0.0 removed BLS12381SignContext's constructors from export in favour of the pre-built minSigPoPDST/minVerKeyPoPDST values, which broke Leios.hs's provisional reconstruction of that context (already flagged there with a TODO anticipating this exact change). Use Crypto.minSigPoPDST directly now that it's available. The same version bump renamed cardano-crypto-class:testlib's prop_cbor_with -> prop_cbor_fixed_sized, prop_cbor_direct_vs_class -> prop_cbor_fixed_sized_vs_class, and added _fixed_sized variants of prop_raw_serialise/prop_size_serialise built on FixedSizeCodec directly. Switch Test.Cardano.Api.Crypto to the new names/variants, following on from "Update all DSIGN operations to FixedSizeCodec ops". --- cardano-api/src/Cardano/Api/Key/Internal/Leios.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs b/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs index dd7cc93f48..94ff2377a1 100644 --- a/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs +++ b/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs @@ -191,6 +191,17 @@ blsPossessionProof hexBs = Left e -> error $ "blsPossessionProof: " ++ show e Right p -> p +-- | Signing context including the Domain Separation Tag (DST) for the proofs-of-possession of +-- BLS keys using the minimal-signature-size BLS12-381 variant. +-- +-- A Domain Separation Tag is a unique tag (like a magic number) that we add to ensure that +-- the signature is used only in the context that it was intended for. +-- This is because BLS keys and signatures can be used for multiple purposes, and +-- we don't want a proof of possession for one purpose to be interpreted as something different +-- in a different context. +minSigPoPContext :: Crypto.BLS12381SignContext +minSigPoPContext = Crypto.minSigPoPDST + -- | Create a proof of possession for a BLS signing key. -- -- This proof demonstrates that the holder of a BLS verification key knows the corresponding From 5a137932b7fd6ee29294f3140715b94e8c16ef03 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 16:08:34 +1000 Subject: [PATCH 6/8] Bridge cardano-addresses' vendored XPrv to cardano-crypto's in Mnemonic.hs cardano-addresses' master (pulled in by the cabal.project SRP, needed for its own crypton >=1.1/ram migration) vendored its own copy of Cardano.Crypto.Wallet to drop the cardano-crypto/memory dependency, rather than re-exporting cardano-crypto's module as before. Its XPrv is now a distinct type from the Crypto.HD.XPrv ("Cardano.Crypto.Wallet", from the standalone cardano-crypto package) that SigningKey constructors expect. Bridge the two via the same 96-byte compact raw format both sides already implement (Cardano.Address.Derivation.xprvToBytes round-tripped through Cardano.Api.Crypto.Ed25519Bip32.xPrvFromBytes) rather than changing what type SigningKey wraps, so the on-disk/wire key format is unaffected. --- .../src/Cardano/Api/Key/Internal/Mnemonic.hs | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Key/Internal/Mnemonic.hs b/cardano-api/src/Cardano/Api/Key/Internal/Mnemonic.hs index acab90c299..da37d444b6 100644 --- a/cardano-api/src/Cardano/Api/Key/Internal/Mnemonic.hs +++ b/cardano-api/src/Cardano/Api/Key/Internal/Mnemonic.hs @@ -15,6 +15,7 @@ module Cardano.Api.Key.Internal.Mnemonic ) where +import Cardano.Api.Crypto.Ed25519Bip32 (xPrvFromBytes) import Cardano.Api.Error (Error (..)) import Cardano.Api.Key.Internal ( AsType @@ -35,6 +36,7 @@ import Cardano.Address.Derivation , XPrv , genMasterKeyFromMnemonic , indexFromWord32 + , xprvToBytes ) import Cardano.Address.Style.Shelley ( Role (..) @@ -44,6 +46,7 @@ import Cardano.Address.Style.Shelley , deriveDRepPrivateKey ) import Cardano.Crypto.Encoding.BIP39 (Dictionary (dictionaryIndexToWord)) +import Cardano.Crypto.Wallet qualified as Crypto.HD import Cardano.Mnemonic ( MkSomeMnemonic (mkSomeMnemonic) , MkSomeMnemonicError (..) @@ -59,6 +62,7 @@ import Data.ByteString qualified as BS import Data.Either.Combinators (mapLeft, maybeToRight) import Data.Either.Extra (maybeToEither) import Data.Foldable (toList) +import Data.Maybe (fromMaybe) import Data.Text (Text) import Data.Text qualified as Text import Data.Text.Encoding (decodeUtf8, encodeUtf8) @@ -146,6 +150,23 @@ class IndexedSigningKeyFromRootKey keyrole where -> Either Word32 (SigningKey keyrole) -- ^ The derived extended signing key or the 'indexType' if it is invalid. +-- | cardano-addresses' own 'XPrv' (from key derivation) and the 'Crypto.HD.XPrv' +-- ("Cardano.Crypto.Wallet", from the standalone @cardano-crypto@ package) that +-- 'SigningKey' constructors expect used to be the same type: cardano-addresses +-- re-exported cardano-crypto's. Since cardano-addresses vendored its own copy of +-- "Cardano.Crypto.Wallet" (to drop the @cardano-crypto@/@memory@ dependency in +-- favour of @crypton@/@ram@), the two are now distinct types, so bridge between +-- them via the same 96-byte compact raw format both sides already use (compare +-- 'Cardano.Address.Derivation.xprvToBytes' with +-- 'Cardano.Api.Crypto.Ed25519Bip32.xPrvToBytes'/'xPrvFromBytes'). Both are +-- implementations of the same BIP32-Ed25519 extended-key format, so this +-- round-trip is lossless. +toCryptoXPrv :: XPrv -> Crypto.HD.XPrv +toCryptoXPrv = + fromMaybe (error "toCryptoXPrv: impossible: cardano-addresses' XPrv is always 96 bytes") + . xPrvFromBytes + . xprvToBytes + instance IndexedSigningKeyFromRootKey PaymentExtendedKey where deriveSigningKeyFromAccountWithPaymentKeyIndex :: AsType PaymentExtendedKey @@ -154,7 +175,11 @@ instance IndexedSigningKeyFromRootKey PaymentExtendedKey where -> Either Word32 (SigningKey PaymentExtendedKey) deriveSigningKeyFromAccountWithPaymentKeyIndex _ accK idx = do payKeyIx <- maybeToEither idx $ indexFromWord32 @(Index 'Soft 'PaymentK) idx - return $ PaymentExtendedSigningKey $ getKey $ deriveAddressPrivateKey accK UTxOExternal payKeyIx + return $ + PaymentExtendedSigningKey $ + toCryptoXPrv $ + getKey $ + deriveAddressPrivateKey accK UTxOExternal payKeyIx instance IndexedSigningKeyFromRootKey StakeExtendedKey where deriveSigningKeyFromAccountWithPaymentKeyIndex @@ -164,7 +189,11 @@ instance IndexedSigningKeyFromRootKey StakeExtendedKey where -> Either Word32 (SigningKey StakeExtendedKey) deriveSigningKeyFromAccountWithPaymentKeyIndex _ accK idx = do payKeyIx <- maybeToEither idx $ indexFromWord32 @(Index 'Soft 'PaymentK) idx - return $ StakeExtendedSigningKey $ getKey $ deriveAddressPrivateKey accK Stake payKeyIx + return $ + StakeExtendedSigningKey $ + toCryptoXPrv $ + getKey $ + deriveAddressPrivateKey accK Stake payKeyIx instance SigningKeyFromRootKey DRepExtendedKey where deriveSigningKeyFromAccount @@ -172,7 +201,7 @@ instance SigningKeyFromRootKey DRepExtendedKey where -> Shelley 'AccountK XPrv -> SigningKey DRepExtendedKey deriveSigningKeyFromAccount _ accK = - DRepExtendedSigningKey $ getKey $ deriveDRepPrivateKey accK + DRepExtendedSigningKey $ toCryptoXPrv $ getKey $ deriveDRepPrivateKey accK instance SigningKeyFromRootKey CommitteeColdExtendedKey where deriveSigningKeyFromAccount @@ -180,7 +209,7 @@ instance SigningKeyFromRootKey CommitteeColdExtendedKey where -> Shelley 'AccountK XPrv -> SigningKey CommitteeColdExtendedKey deriveSigningKeyFromAccount _ accK = - CommitteeColdExtendedSigningKey $ getKey $ deriveCCColdPrivateKey accK + CommitteeColdExtendedSigningKey $ toCryptoXPrv $ getKey $ deriveCCColdPrivateKey accK instance SigningKeyFromRootKey CommitteeHotExtendedKey where deriveSigningKeyFromAccount @@ -188,7 +217,7 @@ instance SigningKeyFromRootKey CommitteeHotExtendedKey where -> Shelley 'AccountK XPrv -> SigningKey CommitteeHotExtendedKey deriveSigningKeyFromAccount _ accK = - CommitteeHotExtendedSigningKey $ getKey $ deriveCCHotPrivateKey accK + CommitteeHotExtendedSigningKey $ toCryptoXPrv $ getKey $ deriveCCHotPrivateKey accK -- | Generate a signing key from a mnemonic sentence given a function that -- derives a key from an account extended key. From 03ba67471b081ee3c0adc32e8ab334cde1d37e63 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 20 Aug 2026 15:19:56 +1000 Subject: [PATCH 7/8] Update cardano-ledger SRP --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 019d06a46a..6fc2f368ac 100644 --- a/cabal.project +++ b/cabal.project @@ -220,7 +220,7 @@ source-repository-package source-repository-package type: git location: https://github.com/IntersectMBO/cardano-ledger - tag: 6def84b5ae0033053feda72f32b1dac41c812e0e + tag: 407b27ad62459cccf346145f97f63a259ae7ec75 subdir: eras/byron/crypto -- TEMPORARY: cardano-addresses-4.0.2 (the latest released on CHaP) still pins From 7f8770a3125edb128f2ced77dbc541cba3ded00e Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 20 Aug 2026 21:15:35 +1000 Subject: [PATCH 8/8] wip --- cabal.project | 6 +++--- cardano-api/cardano-api.cabal | 1 + cardano-api/src/Cardano/Api/Key/Internal/Leios.hs | 2 +- .../src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cabal.project b/cabal.project index 6fc2f368ac..efcbe4629b 100644 --- a/cabal.project +++ b/cabal.project @@ -164,8 +164,8 @@ if impl(ghc >=9.14) -- TEMPORARY: switching to crypton >= 1.1 (which depends on `ram` instead of -- `memory`) needs cardano-crypto-class-2.6.0.0 (the first version depending --- on crypton ^>=1.1 and `ram`), but the released ouroboros-consensus-3.0.1.0 --- pins `cardano-crypto-class ^>=2.3`, which excludes it. The blocks below +-- on crypton ^>=1.1 and `ram`), but the released ouroboros-consensus-4.1.0.0 +-- pins `cardano-crypto-class ^>=2.5`, which excludes it. The blocks below -- replicate the (draft, do-not-merge) upstream fix in -- https://github.com/IntersectMBO/ouroboros-consensus/pull/2213, which widens -- ouroboros-consensus's bound to also allow cardano-crypto-class-2.6.0.0 and @@ -184,7 +184,7 @@ allow-newer: source-repository-package type: git location: https://github.com/IntersectMBO/ouroboros-consensus - tag: 4da82e0afed5dabbe930d5f5cad5de687428e07b + tag: 206dffef96e76e42e15a1fb9fd6796394aef3409 -- TEMPORARY: pulls in cardano-base PR #694 (erikd/contra-tracer, not yet -- merged) https://github.com/IntersectMBO/cardano-base/pull/694, which widens diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 0e56fa226f..7bd4c54e0f 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -132,6 +132,7 @@ library bytestring, bytestring-trie, cardano-addresses ^>=4.0.0, + cardano-base ^>=0.1, cardano-binary >=1.9.1, cardano-crypto, cardano-crypto-class ^>=2.6, diff --git a/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs b/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs index 94ff2377a1..443ff7d8bd 100644 --- a/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs +++ b/cardano-api/src/Cardano/Api/Key/Internal/Leios.hs @@ -210,7 +210,7 @@ minSigPoPContext = Crypto.minSigPoPDST -- honest participants' keys during aggregation (a rogue key attack). createBlsPossessionProof :: SigningKey BlsKey -> BlsPossessionProof createBlsPossessionProof (BlsSigningKey sk) = - BlsPossessionProof (Crypto.createPossessionProofDSIGN Crypto.minSigPoPDST sk) + BlsPossessionProof (Crypto.createPossessionProofDSIGN minSigPoPContext sk) instance HasTypeProxy BlsPossessionProof where data AsType BlsPossessionProof = AsBlsPossessionProof diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs index 5c0192ebdb..1aac3ef8c9 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs @@ -138,8 +138,8 @@ txToUtxoRpcTx ledgerTx = anyEraTxConstraints sbe $ do defMessage & U5c.vkey .~ DSIGN.rawEncodeFixedSized bootstrapKey & U5c.signature .~ DSIGN.rawEncodeFixedSized bootstrapSignature - & U5c.chainCode .~ L.unChainCode (L.bwChainCode bootstrapWitness) - & U5c.attributes .~ L.bwAttributes bootstrapWitness + & U5c.chainCode .~ SBS.fromShort (byteArrayToShortByteString (L.unChainCode (L.bwChainCode bootstrapWitness))) + & U5c.attributes .~ SBS.fromShort (byteArrayToShortByteString (L.bwAttributes bootstrapWitness)) scriptWitnesses :: [Proto UtxoRpc.Script] scriptWitnesses = M.elems (wits ^. L.scriptTxWitsL) <&> ledgerScriptToUtxoRpcScript sbe