Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ripemd_160builtin #6378

Merged
merged 20 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ allow-newer:
, inline-r:containers
, inline-r:primitive


-- -------------------------------------------------------------------------------------------------
-- Following currently required for building with ghc-9.10.

constraints:
-- The API has changed for version 2.2, ledger depends on the old version and ledger will not
-- be updated until after the Conway release.
, cardano-crypto-class ^>= 2.1

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2132
2135
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ExBudget {exBudgetCPU = ExCPU 601476171, exBudgetMemory = ExMemory 2971818}
ExBudget {exBudgetCPU = ExCPU 601524171, exBudgetMemory = ExMemory 2972118}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
ExBudget {exBudgetCPU = ExCPU 91525157, exBudgetMemory = ExMemory 413605}
ExBudget {exBudgetCPU = ExCPU 91573157, exBudgetMemory = ExMemory 413905}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions nix/project.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# editorconfig-checker-disable-file
# editorconfig-checker-disable-file

{ repoRoot, inputs, pkgs, system, lib }:

Expand All @@ -8,7 +8,7 @@ let
{
name = "plutus";

# We need the mkDefault here since compiler-nix-name will be overridden
# We need the mkDefault here since compiler-nix-name will be overridden
# in the flake variants.
compiler-nix-name = lib.mkDefault "ghc96";

Expand Down Expand Up @@ -59,7 +59,7 @@ let

modules = [

# Cross Compiling
# Cross Compiling
(lib.mkIf isCrossCompiling {
packages = {
# Things that need plutus-tx-plugin
Expand All @@ -79,7 +79,7 @@ let
reinstallableLibGhc = false;
})

# Common
# Common
{
packages = {
# In this case we can just propagate the native dependencies for the build of
Expand Down
2 changes: 1 addition & 1 deletion plutus-benchmark/plutus-benchmark.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ library marlowe-internal
build-depends:
, base
, bytestring
, cardano-crypto-class >=2.0.0.1 && <2.2
, cardano-crypto-class >=2.1.5 && <2.3
, directory
, filepath
, mtl
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Test vector (0-bit input) for Ripemd_160.
-- Output obtained using the online tool https://emn178.github.io/online-tools/ripemd_160.html
(program 1.0.0
[
[
(builtin equalsByteString)
[
(builtin ripemd_160)
(con bytestring #)
]
]
(con bytestring #9c1185a5c5e9fc54612808977ee8f548b2258d31)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
({cpu: 2130451
| mem: 804})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Test vector (0-bit input) for Ripemd_160.
-- Output obtained using the online tool https://emn178.github.io/online-tools/ripemd_160.html
(program 1.0.0
[
[
(builtin equalsByteString)
[
(builtin ripemd_160)
(con bytestring #2e7ea84da4bc4d7cfb463e3f2c8647057afff3fbececa1d200)
]
]
(con bytestring #f18921115370b049e99dfdd49fc92b371dd7c7e9)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
({cpu: 2204011
| mem: 804})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(program 1.0.0 (con bool True))
3 changes: 3 additions & 0 deletions plutus-core/changelog.d/20240806_115314_kenneth.mackenzie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- Builtin function `ripemd_160` implementing RIPEMD-160 hashing.
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,5 @@ makeBenchmarks gen = [ benchVerifyEd25519Signature
, benchVerifyEcdsaSecp256k1Signature
, benchVerifySchnorrSecp256k1Signature
]
<> (benchByteStringOneArgOp <$> [Sha2_256, Sha3_256, Blake2b_224, Blake2b_256, Keccak_256])
<> (benchByteStringOneArgOp <$> [Sha2_256, Sha3_256, Blake2b_224, Blake2b_256, Keccak_256, Ripemd_160])
<> blsBenchmarks gen
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ builtinMemoryModels = BuiltinCostModelBase
, paramRotateByteString = Id $ ModelTwoArgumentsLinearInX identityFunction
, paramCountSetBits = Id $ ModelOneArgumentConstantCost 1
, paramFindFirstSetBit = Id $ ModelOneArgumentConstantCost 1
, paramRipemd_160 = Id $ hashMemModel Hash.ripemd_160
}
where identityFunction = OneVariableLinearFunction 0 1

Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ builtinCostModelNames = BuiltinCostModelBase
, paramRotateByteString = "rotateByteStringModel"
, paramCountSetBits = "countSetBitsModel"
, paramFindFirstSetBit = "findFirstSetBitModel"
, paramRipemd_160 = "ripemd_160Model"

}


Expand Down Expand Up @@ -260,6 +262,8 @@ createBuiltinCostModel bmfile rfile = do
paramRotateByteString <- getParams readCF2 paramRotateByteString
paramCountSetBits <- getParams readCF1 paramCountSetBits
paramFindFirstSetBit <- getParams readCF1 paramFindFirstSetBit
-- And another hash function
paramRipemd_160 <- getParams readCF1 paramRipemd_160

pure $ BuiltinCostModelBase {..}

Expand Down
51 changes: 51 additions & 0 deletions plutus-core/cost-model/data/benching-conway.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11433,3 +11433,54 @@ Nop3o/1/1/1,9.681605179728e-7,9.678482768634729e-7,9.68507964034034e-7,1.5097728
Nop4o/1/1/1/1,1.06931526883948e-6,1.069022694427051e-6,1.0696382508038666e-6,1.4394723113881347e-9,1.2607649026895387e-9,1.6935844242798764e-9
Nop5o/1/1/1/1/1,1.204797533387616e-6,1.2045006785441098e-6,1.2051050348542126e-6,1.4396484354218353e-9,1.2271158795291387e-9,1.70998698648575e-9
Nop6o/1/1/1/1/1/1,1.3311962475075014e-6,1.3307031569084609e-6,1.3316929325432997e-6,2.2438474798697615e-9,1.9046722710705117e-9,2.7396972459837584e-9
# Started at 2024-08-05 07:26:21.979988937 UTC
Ripemd_160/1,1.5132350845747514e-6,1.5118411187857098e-6,1.515017089955688e-6,5.298057851124566e-9,4.2266649721786944e-9,6.609805647162176e-9
Ripemd_160/200,6.841009208399598e-6,6.8382065986383185e-6,6.844534041120339e-6,1.0536752833618596e-8,9.41602138266087e-9,1.2106025604356829e-8
Ripemd_160/400,1.1793233767606008e-5,1.1791162825326592e-5,1.1794988440295106e-5,6.711132919407076e-9,5.560673668311969e-9,8.410945234272372e-9
Ripemd_160/600,1.6744515432185002e-5,1.6742944270117827e-5,1.6745976227894485e-5,5.325818361271396e-9,4.395180081910924e-9,6.514601236994164e-9
Ripemd_160/800,2.170171248145459e-5,2.1699538731259683e-5,2.1703738256762653e-5,7.064104257501118e-9,5.848051539391738e-9,8.635980636105445e-9
Ripemd_160/1000,2.6640371485406597e-5,2.6638335727696123e-5,2.6644054614174627e-5,8.796851948891501e-9,5.599264173361815e-9,1.6382546182479345e-8
Ripemd_160/1200,3.158436701720805e-5,3.158244376761593e-5,3.158661920828091e-5,7.124103539115529e-9,5.986682473269068e-9,8.801518145161499e-9
Ripemd_160/1400,3.660986994485495e-5,3.6606861214486154e-5,3.6612374115077236e-5,8.857495956415449e-9,7.112622381672956e-9,1.1225669419732363e-8
Ripemd_160/1600,4.1467060244872236e-5,4.146459324902047e-5,4.146921312043702e-5,7.91802006904137e-9,6.466482791501854e-9,1.0480012509572214e-8
Ripemd_160/1800,4.641764438345083e-5,4.641516712506078e-5,4.641994228050728e-5,7.694796965772236e-9,6.428893698050284e-9,9.424153550540112e-9
Ripemd_160/2000,5.1360415563825054e-5,5.135755640301104e-5,5.136335663836417e-5,9.929553741287015e-9,8.412578595662977e-9,1.2790500059239878e-8
Ripemd_160/2200,5.6792878218852507e-5,5.677996136294955e-5,5.680271989061711e-5,3.641234782563769e-8,2.684231987254383e-8,5.321385315289667e-8
Ripemd_160/2400,6.175775110108907e-5,6.174736760432796e-5,6.176906345058063e-5,3.6600307383209986e-8,3.0914094527228907e-8,4.556279872990617e-8
Ripemd_160/2600,6.671146084040607e-5,6.66966721370686e-5,6.672587963619058e-5,4.8852605057789846e-8,4.170311548342996e-8,5.8119505974442774e-8
Ripemd_160/2800,7.177317520556808e-5,7.175658953463667e-5,7.178884504446553e-5,5.2924827853276176e-8,4.292991629888966e-8,6.95040560050818e-8
Ripemd_160/3000,7.666028164541757e-5,7.664689973710159e-5,7.667464764262507e-5,4.732865658294394e-8,3.8730033215174814e-8,6.132213198384772e-8
Ripemd_160/3200,8.159078856745704e-5,8.157807793548139e-5,8.160512597640112e-5,4.546752960695832e-8,3.726075989110787e-8,5.677359357715035e-8
Ripemd_160/3400,8.656040909220607e-5,8.654726438838939e-5,8.657349591723488e-5,4.345688283634391e-8,3.82654912581222e-8,5.2513567203941314e-8
Ripemd_160/3600,9.150882492727946e-5,9.149727387945303e-5,9.152170588006632e-5,4.092846580642266e-8,3.270285913300621e-8,5.206177316806231e-8
Ripemd_160/3800,9.647057145703121e-5,9.645878839758356e-5,9.648560202549996e-5,4.5675335821762925e-8,3.2847735138391845e-8,6.57316659838146e-8
Ripemd_160/4000,1.0144495106274466e-4,1.0143314046481972e-4,1.0147114788607725e-4,5.7790780826158674e-8,3.242205333612295e-8,1.0706867104875544e-7
Ripemd_160/4200,1.064136611598584e-4,1.0640160961658361e-4,1.064315578120235e-4,5.007170357131213e-8,3.564448239690182e-8,7.132065962130506e-8
Ripemd_160/4400,1.1139734745936589e-4,1.1138634766662453e-4,1.1141351800190054e-4,4.4325600520124486e-8,3.181199659468801e-8,6.722031492388221e-8
Ripemd_160/4600,1.1637189495904111e-4,1.163573588753104e-4,1.164118838815439e-4,7.624402437506816e-8,3.367802681906268e-8,1.475066489219422e-7
Ripemd_160/4800,1.2133201271664437e-4,1.2132160447597562e-4,1.2135376974738075e-4,4.708091905055114e-8,3.1684408269019496e-8,6.79024490060088e-8
Ripemd_160/5000,1.2628794861794629e-4,1.2627948018504497e-4,1.262973365041196e-4,2.8145757422848556e-8,2.2293083464738424e-8,3.596781157390958e-8
Ripemd_160/5200,1.3135832359039763e-4,1.313492573862742e-4,1.3137307911645395e-4,3.8634463692768977e-8,2.5193999153752736e-8,5.5512274225563884e-8
Ripemd_160/5400,1.3624821205221758e-4,1.3624110927221988e-4,1.3625701130785448e-4,2.744502441916473e-8,2.2382474534706863e-8,3.484318653253273e-8
Ripemd_160/5600,1.4043963116630386e-4,1.4019304051856807e-4,1.4067633903983552e-4,8.68105676121551e-7,8.497480819994088e-7,8.97572211794186e-7
Ripemd_160/5800,1.4441907543861633e-4,1.4440895252339282e-4,1.4443259345237953e-4,4.137467112684667e-8,3.135791523160096e-8,6.488155748902933e-8
Ripemd_160/6000,1.4931175476918358e-4,1.4930249679683108e-4,1.4932147305107398e-4,3.113758280806605e-8,2.4786355485355863e-8,4.523617056134077e-8
Ripemd_160/6200,1.5426711791295507e-4,1.5425675847032154e-4,1.542758904261773e-4,3.204928223317973e-8,2.524273181564994e-8,4.1261912618542614e-8
Ripemd_160/6400,1.591745415092679e-4,1.5916038205778568e-4,1.5918864502737298e-4,4.6549929814377885e-8,3.623316264992542e-8,6.647925951723197e-8
Ripemd_160/6600,1.6413228089625961e-4,1.6412089608236884e-4,1.6414548727421976e-4,4.255418758821198e-8,3.274991127568543e-8,6.3294558218372e-8
Ripemd_160/6800,1.6903955492127807e-4,1.6902857794856278e-4,1.6905027051278726e-4,3.4520630480382874e-8,2.7360678555366422e-8,4.2969562401966e-8
Ripemd_160/7000,1.7394216498352322e-4,1.7393202377369407e-4,1.7395442171024245e-4,3.7399736098273814e-8,2.9533324905131478e-8,4.906642949625498e-8
Ripemd_160/7200,1.7888642589463042e-4,1.7887301579945776e-4,1.7890533912685115e-4,5.446896818722027e-8,3.386600637389619e-8,1.0529356304837259e-7
Ripemd_160/7400,1.837768736913733e-4,1.837658524462315e-4,1.8378782720165416e-4,3.9060585252019643e-8,3.165720780181308e-8,5.1459036500260626e-8
Ripemd_160/7600,1.8866245188147303e-4,1.8864940756666953e-4,1.886743110882819e-4,4.1915406874910805e-8,3.492144662022963e-8,5.051738012732979e-8
Ripemd_160/7800,1.9356096004070217e-4,1.935518930307216e-4,1.9357110957366464e-4,3.4962728890651325e-8,2.9377533807021126e-8,4.403705039654489e-8
Ripemd_160/8000,1.9844222079078313e-4,1.9843136531631198e-4,1.98454934789172e-4,4.1377908865412866e-8,3.128095169003802e-8,5.818472906493245e-8
Ripemd_160/8200,2.0335917362245852e-4,2.033472561504486e-4,2.0337376829130473e-4,4.474839674470891e-8,3.6077557481227914e-8,5.8583661743984115e-8
Ripemd_160/8400,2.0829014393556597e-4,2.0827679370720732e-4,2.0830553996913274e-4,4.835772690484657e-8,3.8602879988443036e-8,6.515905065686177e-8
Ripemd_160/8600,2.1321405893878276e-4,2.1320331378667917e-4,2.1322528559354024e-4,3.7491038403944355e-8,3.019404853041815e-8,4.896143243508293e-8
Ripemd_160/8800,2.1815689550433952e-4,2.181438710869816e-4,2.1816957479094262e-4,4.21799867069179e-8,3.63267790000029e-8,5.0783232385378544e-8
Ripemd_160/9000,2.2306545920172937e-4,2.2305447964209162e-4,2.230802459513365e-4,4.4901809979463514e-8,3.5915547047704115e-8,5.556556882719567e-8
Ripemd_160/9200,2.2798102588521204e-4,2.2796728294662707e-4,2.2799493612073009e-4,4.4355425155114936e-8,3.674454466895004e-8,5.304381785564644e-8
Ripemd_160/9400,2.3288831755318549e-4,2.3287308930972463e-4,2.3290453030529445e-4,5.2322835877503795e-8,4.290246126179285e-8,6.604178165621836e-8
Ripemd_160/9600,2.378052184625935e-4,2.3779168592172589e-4,2.3781913169050722e-4,5.0639404403681375e-8,4.0874644361786214e-8,6.674849010446902e-8
Ripemd_160/9800,2.4272532226507086e-4,2.4270938576497592e-4,2.4274161344337142e-4,5.41171443818676e-8,4.5486062671210296e-8,6.537052464058937e-8
13 changes: 13 additions & 0 deletions plutus-core/cost-model/data/builtinCostModelA.json
Original file line number Diff line number Diff line change
Expand Up @@ -1100,5 +1100,18 @@
"arguments": 1,
"type": "constant_cost"
}
},
"ripemd_160": {
"cpu": {
"arguments": {
"intercept": 1964219,
"slope": 24520
},
"type": "linear_in_x"
},
"memory": {
"arguments": 3,
"type": "constant_cost"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERY IMPORTANT!

This has 2 entries for RIPEMD (with different values actually), which is dangerous considering it is JSON: based on the specific implementation, a json library silently picks the first occurrence or the last occurence. Aeson I think picks the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I hope that's fixed now. I added the new costing function but forgot to delete the preliminary one (which was a duplicate of the one for keccak_256). The old one was also in the wrong place, which might not have been so good.

}
}
13 changes: 13 additions & 0 deletions plutus-core/cost-model/data/builtinCostModelB.json
Original file line number Diff line number Diff line change
Expand Up @@ -1100,5 +1100,18 @@
"arguments": 1,
"type": "constant_cost"
}
},
"ripemd_160": {
"cpu": {
"arguments": {
"intercept": 1964219,
"slope": 24520
},
"type": "linear_in_x"
},
"memory": {
"arguments": 3,
"type": "constant_cost"
}
}
}
13 changes: 13 additions & 0 deletions plutus-core/cost-model/data/builtinCostModelC.json
Original file line number Diff line number Diff line change
Expand Up @@ -1118,5 +1118,18 @@
"arguments": 1,
"type": "constant_cost"
}
},
"ripemd_160": {
"cpu": {
"arguments": {
"intercept": 1964219,
"slope": 24520
},
"type": "linear_in_x"
},
"memory": {
"arguments": 3,
"type": "constant_cost"
}
}
}
3 changes: 3 additions & 0 deletions plutus-core/cost-model/data/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ arity <- function(name) {
"Bls12_381_finalVerify" = 2,
"Keccak_256" = 1,
"Blake2b_224" = 1,
"Ripemd_160" = 1,
"IntegerToByteString" = 3,
"ByteStringToInteger" = 2,
"AndByteString" = 3,
Expand Down Expand Up @@ -569,6 +570,7 @@ modelFun <- function(path) {
blake2b_224Model <- linearInX ("Blake2b_224")
blake2b_256Model <- linearInX ("Blake2b_256")
keccak_256Model <- linearInX ("Keccak_256")
ripemd_160Model <- linearInX ("Ripemd_160")

###### Signature verification #####

Expand Down Expand Up @@ -802,6 +804,7 @@ modelFun <- function(path) {
blake2b_224Model = blake2b_224Model,
blake2b_256Model = blake2b_256Model,
keccak_256Model = keccak_256Model,
ripemd_160Model = ripemd_160Model,
verifyEd25519SignatureModel = verifyEd25519SignatureModel,
verifyEcdsaSecp256k1SignatureModel = verifyEcdsaSecp256k1SignatureModel,
verifySchnorrSecp256k1SignatureModel = verifySchnorrSecp256k1SignatureModel,
Expand Down
3 changes: 2 additions & 1 deletion plutus-core/cost-model/test/TestCostModels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ main =
, $(genTest 2 "bls12_381_mulMlResult") Everywhere
, $(genTest 2 "bls12_381_finalVerify") Everywhere

-- Keccak_256, Blake2b_224
-- Keccak_256, Blake2b_224, Ripemd_160
, $(genTest 1 "keccak_256")
, $(genTest 1 "blake2b_224")
, $(genTest 1 "ripemd_160")

-- Bitwise operations
, $(genTest 3 "integerToByteString")
Expand Down
3 changes: 2 additions & 1 deletion plutus-core/plutus-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ library
, bytestring
, bytestring-strict-builder
, cardano-crypto
, cardano-crypto-class ^>=2.1
, cardano-crypto-class ^>=2.1.5
, cassava
, cborg
, composition-prelude >=1.1.0.1
Expand Down Expand Up @@ -440,6 +440,7 @@ test-suite untyped-plutus-core-test

build-depends:
, base >=4.9 && <5
, base16-bytestring
, bytestring
, cardano-crypto-class
, dlist
Expand Down
6 changes: 6 additions & 0 deletions plutus-core/plutus-core/src/PlutusCore/Crypto/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ module PlutusCore.Crypto.Hash
, blake2b_224
, blake2b_256
, keccak_256
, ripemd_160
) where

import Cardano.Crypto.Hash.Blake2b
import Cardano.Crypto.Hash.Class
import Cardano.Crypto.Hash.Keccak256
import Cardano.Crypto.Hash.RIPEMD160
import Cardano.Crypto.Hash.SHA256
import Cardano.Crypto.Hash.SHA3_256
import Data.ByteString qualified as BS
Expand All @@ -35,3 +37,7 @@ blake2b_256 = digest (Proxy @Blake2b_256)
-- | Hash a `ByteString` using the Keccak-256 hash function.
keccak_256 :: BS.ByteString -> BS.ByteString
keccak_256 = digest (Proxy @Keccak256)

-- | Hash a `ByteString` using the RIPEMD-160 hash function.
ripemd_160 :: BS.ByteString -> BS.ByteString
ripemd_160 = digest (Proxy @RIPEMD160)
13 changes: 12 additions & 1 deletion plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ data DefaultFun
| RotateByteString
| CountSetBits
| FindFirstSetBit
-- Ripemd_160
| Ripemd_160
deriving stock (Show, Eq, Ord, Enum, Bounded, Generic, Ix)
deriving anyclass (NFData, Hashable, PrettyBy PrettyConfigPlc)

Expand Down Expand Up @@ -1982,6 +1984,14 @@ instance uni ~ DefaultUni => ToBuiltinMeaning uni DefaultFun where
findFirstSetBitDenotation
(runCostingFunOneArgument . paramFindFirstSetBit)

toBuiltinMeaning _semvar Ripemd_160 =
let ripemd_160Denotation :: BS.ByteString -> BS.ByteString
ripemd_160Denotation = Hash.ripemd_160
{-# INLINE ripemd_160Denotation #-}
in makeBuiltinMeaning
ripemd_160Denotation
(runCostingFunOneArgument . paramRipemd_160)

-- See Note [Inlining meanings of builtins].
{-# INLINE toBuiltinMeaning #-}

Expand Down Expand Up @@ -2108,7 +2118,6 @@ instance Flat DefaultFun where

IntegerToByteString -> 73
ByteStringToInteger -> 74

AndByteString -> 75
OrByteString -> 76
XorByteString -> 77
Expand All @@ -2121,6 +2130,7 @@ instance Flat DefaultFun where
RotateByteString -> 83
CountSetBits -> 84
FindFirstSetBit -> 85
Ripemd_160 -> 86

decode = go =<< decodeBuiltin
where go 0 = pure AddInteger
Expand Down Expand Up @@ -2209,6 +2219,7 @@ instance Flat DefaultFun where
go 83 = pure RotateByteString
go 84 = pure CountSetBits
go 85 = pure FindFirstSetBit
go 86 = pure Ripemd_160
go t = fail $ "Failed to decode builtin tag, got: " ++ show t

size _ n = n + builtinTagWidth
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ data BuiltinCostModelBase f =
, paramRotateByteString :: f ModelTwoArguments
, paramCountSetBits :: f ModelOneArgument
, paramFindFirstSetBit :: f ModelOneArgument
-- Ripemd_160
, paramRipemd_160 :: f ModelOneArgument
}
deriving stock (Generic)
deriving anyclass (FunctorB, TraversableB, ConstraintsB)
Expand Down
Loading