diff --git a/cabal.project b/cabal.project index 6daa1c2e1e6..1bd4472e069 100644 --- a/cabal.project +++ b/cabal.project @@ -84,7 +84,6 @@ allow-newer: , inline-r:containers , inline-r:primitive - -- ------------------------------------------------------------------------------------------------- -- Following currently required for building with ghc-9.10. @@ -92,4 +91,3 @@ 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 - diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.cbor.size.golden b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.cbor.size.golden index 3827a8bde10..b9dc6e97900 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.cbor.size.golden +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.cbor.size.golden @@ -1 +1 @@ -2132 \ No newline at end of file +2135 \ No newline at end of file diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.large.budget.golden b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.large.budget.golden index 599c961fc12..8fadf8bc196 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.large.budget.golden +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.large.budget.golden @@ -1 +1 @@ -ExBudget {exBudgetCPU = ExCPU 601476171, exBudgetMemory = ExMemory 2971818} \ No newline at end of file +ExBudget {exBudgetCPU = ExCPU 601524171, exBudgetMemory = ExMemory 2972118} \ No newline at end of file diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.small.budget.golden b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.small.budget.golden index b4f2588f1b2..e5a1b195d58 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.small.budget.golden +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.small.budget.golden @@ -1 +1 @@ -ExBudget {exBudgetCPU = ExCPU 91525157, exBudgetMemory = ExMemory 413605} \ No newline at end of file +ExBudget {exBudgetCPU = ExCPU 91573157, exBudgetMemory = ExMemory 413905} \ No newline at end of file diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.uplc.golden b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.uplc.golden index 74be06e7ece..34374b790ee 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.uplc.golden +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/sorted.uplc.golden @@ -40,850 +40,851 @@ program (\cse -> (\cse -> (\cse -> - (\fun - ds -> - force - (case - ((\cse -> - (\x -> - force - (force + (\cse -> + (\fun + ds -> + force + (case + ((\cse -> + (\x -> + force (force - ifThenElse - (equalsInteger - 0 - x) - (delay + (force + ifThenElse + (equalsInteger + 0 + x) (delay - (constr 0 - [ (go - (unMapData - (force - headList + (delay + (constr 0 + [ (go + (unMapData (force - tailList + headList (force + tailList (force - sndPair) - cse))))) ]))) - (delay + (force + sndPair) + cse))))) ]))) (delay - (force + (delay (force (force - ifThenElse - (equalsInteger - 2 - x) - (delay + (force + ifThenElse + (equalsInteger + 2 + x) (delay - (constr 1 - [ ]))) - (delay + (delay + (constr 1 + [ ]))) (delay - error)))))))))) - (force + (delay + error)))))))))) (force - fstPair) - cse)) - (unConstrData - (force - headList + (force + fstPair) + cse)) + (unConstrData (force - tailList + headList (force tailList (force + tailList (force - sndPair) - (unConstrData - ((\cse -> - force - (force + (force + sndPair) + (unConstrData + ((\cse -> + force (force - ifThenElse - (equalsInteger - 5 - (force + (force + ifThenElse + (equalsInteger + 5 (force - fstPair) - cse)) - (delay + (force + fstPair) + cse)) (delay - (force - headList + (delay (force - tailList + headList (force + tailList (force - sndPair) - cse))))) - (delay + (force + sndPair) + cse))))) (delay - error))))) - (unConstrData - (force - headList + (delay + error))))) + (unConstrData (force - tailList + headList (force tailList (force + tailList (force - sndPair) - (unConstrData - ds)))))))))))))) - [ (\cparams -> - delay - (force - (case - (fun - cparams) - [ (delay - ()) - , (delay - error) ]))) - , (delay - ()) ])) - (runRules - (constr 1 - [ (constr 0 - [ 0 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 30 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 1000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 1 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 100000 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 10000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 2 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 24576 - , (constr 0 - [ ]) ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 122880 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 3 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 32768 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 4 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 5000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 5 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 1000000 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 5000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 6 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 250000000 - , cse ]) ]) - , cse ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 7 - , (constr 1 - [ (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 8 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 250 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 2000 - , (constr 0 - [ ]) ]) ]) - , cse ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 9 - , (constr 3 - [ (constr 1 - [ cse - , cse ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 10 - , (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ (cse - 1000) - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ (cse - 200) - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 11 - , (constr 3 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ (cse - 10) - , cse ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 16 - , (constr 1 - [ (constr 1 - [ cse - , cse ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 17 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 3000 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 6500 - , (constr 0 - [ ]) ]) ]) - , cse ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 18 - , (constr 0 - [ ]) ]) - , (constr 1 - [ (constr 0 - [ 19 - , (constr 2 - [ (constr 1 - [ (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ (cse - 25) - , (constr 0 - [ ]) ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ (cse - 5) - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ (cse - 20000) - , (constr 0 - [ ]) ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ (cse - 5000) - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 20 - , (constr 2 - [ (constr 1 - [ (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 40000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 15000000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 21 - , (constr 2 - [ (constr 1 - [ (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 120000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 40000000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 22 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 12288 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 23 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 100 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 200 - , (constr 0 - [ ]) ]) ]) - , cse ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 24 - , (constr 1 - [ (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 25 - , (constr 2 - [ (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ cse - , cse ]) ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 26 - , (constr 2 - [ (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ cse - , (constr 1 - [ (unsafeRatio - 13 - 20) - , (constr 0 - [ ]) ]) ]) ]) - , cse ]) ]) - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 1 - [ (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ cse - , cse ]) ]) - , cse ]) ]) - , cse ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 27 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 0 - , (constr 1 - [ 3 - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 10 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 28 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 0 - , (constr 1 - [ 18 - , (constr 0 - [ ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 293 - , (constr 0 - [ ]) ]) ]) - , cse ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 29 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 15 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 30 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 10000000000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 31 - , (constr 1 - [ (constr 1 - [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 100000000000 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 32 - , (constr 1 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 13 - , cse ]) ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 37 - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 1 - [ (constr 0 - [ 33 - , (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , cse ]) - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ (unsafeRatio - 1000 - 1) - , (constr 0 - [ ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]))) + (force + sndPair) + (unConstrData + ds)))))))))))))) + [ (\cparams -> + delay + (force + (case + (fun + cparams) + [ (delay + ()) + , (delay + error) ]))) + , (delay + ()) ])) + (runRules + (constr 1 + [ (constr 0 + [ 0 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 30 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 1000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 1 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 100000 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 10000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 2 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 24576 + , (constr 0 + [ ]) ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 122880 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 3 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 32768 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 4 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 5000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 5 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 1000000 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 5000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 6 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 250000000 + , cse ]) ]) + , cse ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 7 + , (constr 1 + [ (constr 1 + [ cse + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 8 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 250 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 2000 + , (constr 0 + [ ]) ]) ]) + , cse ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 9 + , (constr 3 + [ (constr 1 + [ cse + , cse ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 10 + , (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ (cse + 1000) + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ (cse + 200) + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 11 + , (constr 3 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ (cse + 10) + , cse ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 16 + , (constr 1 + [ (constr 1 + [ cse + , cse ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 17 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 3000 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 6500 + , (constr 0 + [ ]) ]) ]) + , cse ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 18 + , (constr 0 + [ ]) ]) + , (constr 1 + [ (constr 0 + [ 19 + , (constr 2 + [ (constr 1 + [ (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ (cse + 25) + , (constr 0 + [ ]) ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ (cse + 5) + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ (cse + 20000) + , (constr 0 + [ ]) ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ (cse + 5000) + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 20 + , (constr 2 + [ (constr 1 + [ (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 40000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 15000000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 21 + , (constr 2 + [ (constr 1 + [ (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 120000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 40000000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 22 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 12288 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 23 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 100 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 200 + , (constr 0 + [ ]) ]) ]) + , cse ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 24 + , (constr 1 + [ (constr 1 + [ cse + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 25 + , (constr 2 + [ (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ cse + , cse ]) ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 26 + , (constr 2 + [ (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ cse + , (constr 1 + [ (unsafeRatio + 13 + 20) + , (constr 0 + [ ]) ]) ]) ]) + , cse ]) ]) + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 1 + [ (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ cse + , cse ]) ]) + , cse ]) ]) + , cse ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 27 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 0 + , (constr 1 + [ 3 + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 10 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 28 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 0 + , (constr 1 + [ 18 + , (constr 0 + [ ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 293 + , (constr 0 + [ ]) ]) ]) + , cse ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 29 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 15 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 30 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 10000000000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 31 + , (constr 1 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 100000000000 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 32 + , (constr 1 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 13 + , cse ]) ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ 37 + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 1 + [ (constr 0 + [ 33 + , (constr 3 + [ (constr 1 + [ (constr 0 + [ (constr 1 + [ ]) + , cse ]) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ (unsafeRatio + 1000 + 1) + , (constr 0 + [ ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]) ]))) + (constr 3 + [ (constr 1 + [ cse + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ cse + , cse ]) ]) + , (constr 0 + [ ]) ]) ]) ])) (constr 3 [ (constr 1 [ cse - , cse ]) ])) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 0 + [ ]) ]) ]) ]) + , (constr 0 + [ ]) ]) ]) ])) (constr 3 [ (constr 1 [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ]) - , (constr 0 - [ ]) ]) ]) ])) - (constr 3 - [ (constr 1 - [ cse - , (constr 1 + , cse ]) ])) + (constr 1 + [ (constr 3 + [ (constr 1 [ (constr 0 - [ (constr 0 + [ (constr 1 [ ]) , (constr 1 [ cse - , cse ]) ]) - , (constr 0 - [ ]) ]) ]) ])) + , (constr 0 + [ ]) ]) ]) + , cse ]) ]) + , (constr 0 + [ ]) ])) (constr 1 - [ (constr 3 - [ (constr 1 - [ (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) - , cse ]) ]) + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ cse + , (constr 1 + [ cse + , (constr 0 + [ ]) ]) ]) ]) , (constr 0 [ ]) ])) - (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) + (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ cse , (constr 1 [ cse - , (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ]) - , (constr 0 - [ ]) ])) + , (constr 0 + [ ]) ]) ]) ])) (constr 0 [ (constr 1 [ ]) , (constr 1 [ cse - , (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ])) - (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ (cse - 10) - , cse ]) ])) - (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , cse ]) - , (constr 0 - [ ]) ])) - (constr 0 - [ (constr 1 - [ ]) - , (constr 1 - [ 0 - , (constr 1 - [ 1000000 - , (constr 0 - [ ]) ]) ]) ])) + , cse ]) ])) + (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , cse ]) + , (constr 0 + [ ]) ])) + (constr 0 + [ (constr 1 + [ ]) + , (constr 1 + [ 0 + , (constr 1 + [ 1000000 + , (constr 0 + [ ]) ]) ]) ])) + (constr 1 + [ (constr 0 + [ (constr 2 + [ ]) + , cse ]) + , (constr 0 + [ ]) ])) (constr 1 [ (constr 0 - [ (constr 2 + [ (constr 0 [ ]) - , cse ]) + , (constr 1 + [ 500000000 + , (constr 0 + [ ]) ]) ]) , (constr 0 [ ]) ])) (constr 1 - [ (cse - 4) + [ cse , (constr 0 [ ]) ])) (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ 500000000 - , (constr 0 - [ ]) ]) ]) + [ cse , (constr 0 [ ]) ])) (constr 1 - [ cse + [ (cse + 1) , (constr 0 [ ]) ])) - (constr 1 - [ cse - , (constr 0 - [ ]) ])) + (constr 0 + [ (constr 1 + [ ]) + , cse ])) (cse - 100)) + 5)) (cse - 10)) + 2)) (cse - 1)) + 10)) (constr 0 [ (constr 1 [ ]) - , cse ])) - (constr 0 - [ (constr 1 - []) - , (constr 1 - [ 1 - , (constr 0 - [ ]) ]) ])) - (cse 2)) + , (constr 1 + [ 1 + , (constr 0 + [ ]) ]) ])) + (cse 100)) + (cse 4)) (cse 1)) - (cse 5)) - (unsafeRatio 0)) - (unsafeRatio 3)) + (cse 10)) + (unsafeRatio 1)) + (unsafeRatio 4)) (unsafeRatio 9)) - (unsafeRatio 1)) - (unsafeRatio 51)) - (constr 1 [0, (constr 0 [])])) - (unsafeRatio 4)) + (unsafeRatio 51)) + (constr 1 [0, (constr 0 [])])) + (unsafeRatio 3)) + (unsafeRatio 0)) (fix1 (\go l -> force (force chooseList) diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/unsorted.uplc.golden b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/unsorted.uplc.golden index 8d58ae70df1..800de534665 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/unsorted.uplc.golden +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests/unsorted.uplc.golden @@ -801,15 +801,7 @@ program (constr 3 [ (constr 1 [ cse - , (constr 1 - [ (constr 0 - [ (constr 0 - [ ]) - , (constr 1 - [ cse - , cse ]) ]) - , (constr 0 - [ ]) ]) ]) ])) + , cse ]) ])) (constr 3 [ (constr 1 [ cse @@ -828,7 +820,15 @@ program (constr 3 [ (constr 1 [ cse - , cse ]) ])) + , (constr 1 + [ (constr 0 + [ (constr 0 + [ ]) + , (constr 1 + [ cse + , cse ]) ]) + , (constr 0 + [ ]) ]) ]) ])) (constr 1 [ (constr 3 [ (constr 1 @@ -849,8 +849,7 @@ program , (constr 1 [ cse , (constr 1 - [ (cse - 10) + [ cse , (constr 0 [ ]) ]) ]) ]) , (constr 0 @@ -859,18 +858,18 @@ program [ (constr 1 [ ]) , (constr 1 - [ (cse - 10) - , cse ]) ])) + [ cse + , (constr 1 + [ cse + , (constr 0 + [ ]) ]) ]) ])) (constr 0 [ (constr 1 [ ]) , (constr 1 - [ cse - , (constr 1 - [ cse - , (constr 0 - [ ]) ]) ]) ])) + [ (cse + 10) + , cse ]) ])) (constr 1 [ (constr 0 [ (constr 0 @@ -905,7 +904,8 @@ program , (constr 0 [ ]) ])) (constr 1 - [ cse + [ (cse + 1) , (constr 0 [ ]) ])) (constr 1 @@ -917,14 +917,14 @@ program , (constr 0 [ ]) ])) (cse - 1)) + 100)) (constr 0 [ (constr 1 [ ]) , cse ])) (cse - 100)) - (cse 2)) + 10)) + (cse 5)) (constr 0 [ (constr 1 []) @@ -932,16 +932,16 @@ program [ 1 , (constr 0 [ ]) ]) ])) - (cse 4)) - (cse 5)) + (cse 2)) + (cse 4)) (cse 1)) - (unsafeRatio 9)) - (unsafeRatio 0)) - (unsafeRatio 3)) - (unsafeRatio 4)) + (unsafeRatio 4)) + (unsafeRatio 3)) + (unsafeRatio 9)) + (unsafeRatio 1)) (constr 1 [0, (constr 0 [])])) (unsafeRatio 51)) - (unsafeRatio 1)) + (unsafeRatio 0)) (fix1 (\go l -> force (force chooseList) diff --git a/nix/project.nix b/nix/project.nix index 847fac8039d..9d72b599529 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -1,4 +1,4 @@ -# editorconfig-checker-disable-file +# editorconfig-checker-disable-file { repoRoot, inputs, pkgs, system, lib }: @@ -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"; @@ -59,7 +59,7 @@ let modules = [ - # Cross Compiling + # Cross Compiling (lib.mkIf isCrossCompiling { packages = { # Things that need plutus-tx-plugin @@ -79,7 +79,7 @@ let reinstallableLibGhc = false; }) - # Common + # Common { packages = { # In this case we can just propagate the native dependencies for the build of diff --git a/plutus-benchmark/plutus-benchmark.cabal b/plutus-benchmark/plutus-benchmark.cabal index 7b5a50b507f..5ca9de02a6c 100644 --- a/plutus-benchmark/plutus-benchmark.cabal +++ b/plutus-benchmark/plutus-benchmark.cabal @@ -474,7 +474,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 diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc new file mode 100644 index 00000000000..35088a1c4d8 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc @@ -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) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.budget.expected new file mode 100644 index 00000000000..2918618267c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 2130451 +| mem: 804}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-empty/ripemd_160-empty.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc new file mode 100644 index 00000000000..61017a9a98c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc @@ -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) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.budget.expected new file mode 100644 index 00000000000..25ed34590a8 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 2204011 +| mem: 804}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/ripemd_160/ripemd_160-length-200/ripemd_160-length-200.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-core/changelog.d/20240806_115314_kenneth.mackenzie.md b/plutus-core/changelog.d/20240806_115314_kenneth.mackenzie.md new file mode 100644 index 00000000000..2d6ecca1558 --- /dev/null +++ b/plutus-core/changelog.d/20240806_115314_kenneth.mackenzie.md @@ -0,0 +1,3 @@ +### Added + +- Builtin function `ripemd_160` implementing RIPEMD-160 hashing. diff --git a/plutus-core/cost-model/budgeting-bench/Benchmarks/Crypto.hs b/plutus-core/cost-model/budgeting-bench/Benchmarks/Crypto.hs index 031f5ed67d8..575e7322e89 100644 --- a/plutus-core/cost-model/budgeting-bench/Benchmarks/Crypto.hs +++ b/plutus-core/cost-model/budgeting-bench/Benchmarks/Crypto.hs @@ -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 diff --git a/plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs b/plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs index 74d222ac932..a53bcd1eefc 100644 --- a/plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs +++ b/plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs @@ -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 diff --git a/plutus-core/cost-model/create-cost-model/CreateBuiltinCostModel.hs b/plutus-core/cost-model/create-cost-model/CreateBuiltinCostModel.hs index 222d5f234f0..ca520bd5a8b 100644 --- a/plutus-core/cost-model/create-cost-model/CreateBuiltinCostModel.hs +++ b/plutus-core/cost-model/create-cost-model/CreateBuiltinCostModel.hs @@ -123,6 +123,8 @@ builtinCostModelNames = BuiltinCostModelBase , paramRotateByteString = "rotateByteStringModel" , paramCountSetBits = "countSetBitsModel" , paramFindFirstSetBit = "findFirstSetBitModel" + , paramRipemd_160 = "ripemd_160Model" + } @@ -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 {..} diff --git a/plutus-core/cost-model/data/benching-conway.csv b/plutus-core/cost-model/data/benching-conway.csv index c5aa9e70a14..b6e4fb1eb76 100644 --- a/plutus-core/cost-model/data/benching-conway.csv +++ b/plutus-core/cost-model/data/benching-conway.csv @@ -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 diff --git a/plutus-core/cost-model/data/builtinCostModelA.json b/plutus-core/cost-model/data/builtinCostModelA.json index 39d8d789187..211942e8850 100644 --- a/plutus-core/cost-model/data/builtinCostModelA.json +++ b/plutus-core/cost-model/data/builtinCostModelA.json @@ -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" + } } } diff --git a/plutus-core/cost-model/data/builtinCostModelB.json b/plutus-core/cost-model/data/builtinCostModelB.json index cdccb790321..2a5f6f32da2 100644 --- a/plutus-core/cost-model/data/builtinCostModelB.json +++ b/plutus-core/cost-model/data/builtinCostModelB.json @@ -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" + } } } diff --git a/plutus-core/cost-model/data/builtinCostModelC.json b/plutus-core/cost-model/data/builtinCostModelC.json index 25e7ba80221..0de45a43f58 100644 --- a/plutus-core/cost-model/data/builtinCostModelC.json +++ b/plutus-core/cost-model/data/builtinCostModelC.json @@ -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" + } } } diff --git a/plutus-core/cost-model/data/models.R b/plutus-core/cost-model/data/models.R index 00cd2c4e080..93202a18e09 100644 --- a/plutus-core/cost-model/data/models.R +++ b/plutus-core/cost-model/data/models.R @@ -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, @@ -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 ##### @@ -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, diff --git a/plutus-core/cost-model/test/TestCostModels.hs b/plutus-core/cost-model/test/TestCostModels.hs index 180d7bb42ef..1ba99fdf94a 100644 --- a/plutus-core/cost-model/test/TestCostModels.hs +++ b/plutus-core/cost-model/test/TestCostModels.hs @@ -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") diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index 6ff98d5876b..3ab89319a55 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -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 @@ -440,6 +440,7 @@ test-suite untyped-plutus-core-test build-depends: , base >=4.9 && <5 + , base16-bytestring , bytestring , cardano-crypto-class , dlist diff --git a/plutus-core/plutus-core/src/PlutusCore/Crypto/Hash.hs b/plutus-core/plutus-core/src/PlutusCore/Crypto/Hash.hs index c956927be49..9d311f60e58 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Crypto/Hash.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Crypto/Hash.hs @@ -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 @@ -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) diff --git a/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs b/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs index 10cf657e2d7..2d986657520 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs @@ -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) @@ -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 #-} @@ -2108,7 +2118,6 @@ instance Flat DefaultFun where IntegerToByteString -> 73 ByteStringToInteger -> 74 - AndByteString -> 75 OrByteString -> 76 XorByteString -> 77 @@ -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 @@ -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 diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs index 86b2a4565d7..42311f0cd62 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs @@ -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) diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs index 967aa919969..0e0ed24ead2 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs @@ -341,6 +341,8 @@ unitCostBuiltinCostModel = BuiltinCostModelBase , paramRotateByteString = unitCostTwoArguments , paramCountSetBits = unitCostOneArgument , paramFindFirstSetBit = unitCostOneArgument + -- Ripemd_160 + , paramRipemd_160 = unitCostOneArgument } unitCekParameters :: Typeable ann => MachineParameters CekMachineCosts DefaultFun (CekValue DefaultUni DefaultFun ann) diff --git a/plutus-core/plutus-core/test/CostModelInterface/defaultCostModelParams.json b/plutus-core/plutus-core/test/CostModelInterface/defaultCostModelParams.json index ac8d35742ce..7b91b1512a8 100644 --- a/plutus-core/plutus-core/test/CostModelInterface/defaultCostModelParams.json +++ b/plutus-core/plutus-core/test/CostModelInterface/defaultCostModelParams.json @@ -144,6 +144,9 @@ "keccak_256-cpu-arguments-intercept": 2261318, "keccak_256-cpu-arguments-slope": 64571, "keccak_256-memory-arguments": 4, + "ripemd_160-cpu-arguments-intercept": 1964219, + "ripemd_160-cpu-arguments-slope": 24520, + "ripemd_160-memory-arguments": 3, "lengthOfByteString-cpu-arguments": 1000, "lengthOfByteString-memory-arguments": 10, "lessThanByteString-cpu-arguments-intercept": 197145, diff --git a/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs b/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs index 0424128e68f..dbb70ed0541 100644 --- a/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs +++ b/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs @@ -79,6 +79,7 @@ isCommutative = \case Blake2b_224 -> False Blake2b_256 -> False Keccak_256 -> False + Ripemd_160 -> False VerifyEd25519Signature -> False VerifyEcdsaSecp256k1Signature -> False VerifySchnorrSecp256k1Signature -> False diff --git a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Denotation.hs b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Denotation.hs index bc3e5b75d76..cc4097ecb51 100644 --- a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Denotation.hs +++ b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Denotation.hs @@ -143,5 +143,6 @@ typedBuiltins . insertBuiltin Blake2b_224 . insertBuiltin Blake2b_256 . insertBuiltin Keccak_256 + . insertBuiltin Ripemd_160 . insertBuiltin EqualsByteString $ DenotationContext mempty diff --git a/plutus-core/testlib/PlutusCore/Generators/NEAT/Term.hs b/plutus-core/testlib/PlutusCore/Generators/NEAT/Term.hs index 96601ef819d..ad695aed8de 100644 --- a/plutus-core/testlib/PlutusCore/Generators/NEAT/Term.hs +++ b/plutus-core/testlib/PlutusCore/Generators/NEAT/Term.hs @@ -401,7 +401,7 @@ defaultFunTypes = Map.fromList [(TyFunG (TyBuiltinG TyIntegerG) (TyFunG (TyBuilt ,(TyFunG (TyBuiltinG TyByteStringG) (TyFunG (TyBuiltinG TyIntegerG) (TyBuiltinG TyIntegerG)) ,[IndexByteString]) ,(TyFunG (TyBuiltinG TyByteStringG) (TyBuiltinG TyByteStringG) - ,[Sha2_256,Sha3_256,Blake2b_224,Blake2b_256,Keccak_256]) + ,[Sha2_256,Sha3_256,Blake2b_224,Blake2b_256,Keccak_256,Ripemd_160]) ,(TyFunG (TyBuiltinG TyByteStringG) (TyFunG (TyBuiltinG TyByteStringG) (TyFunG (TyBuiltinG TyByteStringG) (TyBuiltinG TyBoolG))) ,[VerifyEd25519Signature]) ,(TyFunG (TyBuiltinG TyByteStringG) (TyFunG (TyBuiltinG TyByteStringG) (TyBuiltinG TyBoolG)) diff --git a/plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs index 57029c669aa..dbe2fe816ec 100644 --- a/plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs @@ -55,11 +55,14 @@ import UntypedPlutusCore.Evaluation.Machine.Cek import Control.Exception import Data.Bifunctor (bimap) import Data.ByteString (ByteString, pack) +import Data.ByteString.Base16 qualified as Base16 import Data.DList qualified as DList import Data.List (find) import Data.Proxy import Data.String (IsString (fromString)) import Data.Text (Text) +import Data.Text qualified as Text +import Data.Text.Encoding qualified as Text import Hedgehog hiding (Opaque, Size, Var) import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range @@ -774,6 +777,14 @@ test_Crypto = testNestedM "Crypto" $ do -- hex output: 47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad evals @ByteString "G\ETB2\133\168\215\&4\RS^\151/\198w(c\132\248\STX\248\239B\165\236_\ETX\187\250%L\176\US\173" Keccak_256 [] [cons @ByteString "hello world"] + -- independently verified by the calculator at https://emn178.github.io/online-tools/ripemd_160.html + let + hashHex = "98c615784ccb5fe5936fbc0cbe9dfdb408d92f0f" + ripemd_160Hash = case Base16.decode $ Text.encodeUtf8 hashHex of + Right res -> res + Left _ -> error $ "Unexpected error during hex decoding: " <> Text.unpack hashHex + evals @ByteString ripemd_160Hash + Ripemd_160 [] [cons @ByteString "hello world"] -- Tests for blake2b_224: output obtained using the b2sum program from https://github.com/BLAKE2/BLAKE2 evals (pack [ 0x83, 0x6c, 0xc6, 0x89, 0x31, 0xc2, 0xe4, 0xe3, 0xe8, 0x38, 0x60, 0x2e, 0xca, 0x19 , 0x02, 0x59, 0x1d, 0x21, 0x68, 0x37, 0xba, 0xfd, 0xdf, 0xe6, 0xf0, 0xc8, 0xcb, 0x07 ]) @@ -853,11 +864,12 @@ test_HashSize hashFun expectedNumBits = test_HashSizes :: TestTree test_HashSizes = testGroup "Hash sizes" - [ test_HashSize Sha2_256 256 - , test_HashSize Sha3_256 256 - , test_HashSize Blake2b_256 256 - , test_HashSize Keccak_256 256 - , test_HashSize Blake2b_224 224 + [ test_HashSize Sha2_256 256 + , test_HashSize Sha3_256 256 + , test_HashSize Blake2b_256 256 + , test_HashSize Keccak_256 256 + , test_HashSize Blake2b_224 224 + , test_HashSize Ripemd_160 160 ] -- Test all remaining builtins of the default universe diff --git a/plutus-ledger-api/changelog.d/20240806_115735_kenneth.mackenzie_ripemd_160.md b/plutus-ledger-api/changelog.d/20240806_115735_kenneth.mackenzie_ripemd_160.md new file mode 100644 index 00000000000..2d6ecca1558 --- /dev/null +++ b/plutus-ledger-api/changelog.d/20240806_115735_kenneth.mackenzie_ripemd_160.md @@ -0,0 +1,3 @@ +### Added + +- Builtin function `ripemd_160` implementing RIPEMD-160 hashing. diff --git a/plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs b/plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs index 6e2adc4619f..9358e6d8996 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs @@ -123,7 +123,8 @@ builtinsIntroducedIn = Map.fromList [ ((PlutusV3, futurePV), Set.fromList [ AndByteString, OrByteString, XorByteString, ComplementByteString, ReadBit, WriteBits, ReplicateByte, - ShiftByteString, RotateByteString, CountSetBits, FindFirstSetBit + ShiftByteString, RotateByteString, CountSetBits, FindFirstSetBit, + Ripemd_160 ]) ] diff --git a/plutus-ledger-api/test/Spec.hs b/plutus-ledger-api/test/Spec.hs index 55cf4337e90..ec9cf5dce1c 100644 --- a/plutus-ledger-api/test/Spec.hs +++ b/plutus-ledger-api/test/Spec.hs @@ -114,26 +114,35 @@ saltedFunction = tests :: TestTree -tests = testGroup "plutus-ledger-api"[ - testGroup "basic evaluation tests" [ - alwaysTrue - , alwaysFalse - , saltedFunction - , unavailableBuiltins - , availableBuiltins - , integerToByteStringExceedsBudget +tests = testGroup "plutus-ledger-api" + [ testGroup "basic evaluation tests" + [ + alwaysTrue + , alwaysFalse + , saltedFunction + , unavailableBuiltins + , availableBuiltins + , integerToByteStringExceedsBudget ] - , Spec.Interval.tests - , Spec.Eval.tests - , Spec.Data.Eval.tests - , Spec.Versions.tests - , Spec.Data.Versions.tests - , Spec.CostModelParams.tests - , Spec.Data.CostModelParams.tests - , Spec.CBOR.DeserialiseFailureInfo.tests - , Spec.ScriptDecodeError.tests - , Spec.ContextDecoding.tests - , Spec.Data.ContextDecoding.tests - , Value.test_Value - , Data.Value.test_Value + , testGroup "Common" + [ Spec.Interval.tests + , Spec.CBOR.DeserialiseFailureInfo.tests + , Spec.ScriptDecodeError.tests + ] + , testGroup "Context-dependent tests" + [ testGroup "Original" + [ Spec.Eval.tests + , Spec.Versions.tests + , Spec.CostModelParams.tests + , Spec.ContextDecoding.tests + , Value.test_Value + ] + , testGroup "Data" + [ Spec.Data.Eval.tests + , Spec.Data.Versions.tests + , Spec.Data.CostModelParams.tests + , Spec.Data.ContextDecoding.tests + , Data.Value.test_Value + ] + ] ] diff --git a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/Data/EvaluationContext.hs b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/Data/EvaluationContext.hs index c21586ab5d6..dc5c814ba6b 100644 --- a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/Data/EvaluationContext.hs +++ b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/Data/EvaluationContext.hs @@ -82,6 +82,7 @@ clearBuiltinCostModel r = r , paramRotateByteString = mempty , paramCountSetBits = mempty , paramFindFirstSetBit = mempty + , paramRipemd_160 = mempty } @@ -102,4 +103,5 @@ clearBuiltinCostModel' r = r , paramRotateByteString = mempty , paramCountSetBits = mempty , paramFindFirstSetBit = mempty + , paramRipemd_160 = mempty } diff --git a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/EvaluationContext.hs b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/EvaluationContext.hs index e6cc220c7a8..91de05a908a 100644 --- a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/EvaluationContext.hs +++ b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/EvaluationContext.hs @@ -83,6 +83,7 @@ clearBuiltinCostModel r = r , paramRotateByteString = mempty , paramCountSetBits = mempty , paramFindFirstSetBit = mempty + , paramRipemd_160 = mempty } @@ -103,4 +104,5 @@ clearBuiltinCostModel' r = r , paramRotateByteString = mempty , paramCountSetBits = mempty , paramFindFirstSetBit = mempty + , paramRipemd_160 = mempty } diff --git a/plutus-metatheory/src/Algorithmic/CEK.lagda.md b/plutus-metatheory/src/Algorithmic/CEK.lagda.md index 98744f0a5b4..4765db402b0 100644 --- a/plutus-metatheory/src/Algorithmic/CEK.lagda.md +++ b/plutus-metatheory/src/Algorithmic/CEK.lagda.md @@ -222,6 +222,7 @@ BUILTIN sha3-256 (base $ V-con b) = inj₂ (V-con (SHA3-256 b)) BUILTIN blake2b-224 (base $ V-con b) = inj₂ (V-con (BLAKE2B-224 b)) BUILTIN blake2b-256 (base $ V-con b) = inj₂ (V-con (BLAKE2B-256 b)) BUILTIN keccak-256 (base $ V-con b) = inj₂ (V-con (KECCAK-256 b)) +BUILTIN ripemd-160 (base $ V-con b) = inj₂ (V-con (RIPEMD-160 b)) BUILTIN verifyEd25519Signature (base $ V-con k $ V-con d $ V-con c) with (verifyEd25519Sig k d c) ... | just b = inj₂ (V-con b) ... | nothing = inj₁ (con (ne (^ (atomic aBool)))) diff --git a/plutus-metatheory/src/Builtin.lagda.md b/plutus-metatheory/src/Builtin.lagda.md index 9fadaee40af..700a021ee32 100644 --- a/plutus-metatheory/src/Builtin.lagda.md +++ b/plutus-metatheory/src/Builtin.lagda.md @@ -143,6 +143,8 @@ data Builtin : Set where rotateByteString : Builtin countSetBits : Builtin findFirstSetBit : Builtin + -- Ripemd-160 + ripemd-160 : Builtin ``` ## Signatures @@ -259,6 +261,7 @@ sig n⋆ n♯ (t₃ ∷ t₂ ∷ t₁) tᵣ signature blake2b-224 = ∙ [ bytestring ↑ ]⟶ bytestring ↑ signature blake2b-256 = ∙ [ bytestring ↑ ]⟶ bytestring ↑ signature keccak-256 = ∙ [ bytestring ↑ ]⟶ bytestring ↑ + signature ripemd-160 = ∙ [ bytestring ↑ ]⟶ bytestring ↑ signature verifyEd25519Signature = ∙ [ bytestring ↑ , bytestring ↑ , bytestring ↑ ]⟶ bool ↑ signature verifyEcdsaSecp256k1Signature = ∙ [ bytestring ↑ , bytestring ↑ , bytestring ↑ ]⟶ bool ↑ signature verifySchnorrSecp256k1Signature = ∙ [ bytestring ↑ , bytestring ↑ , bytestring ↑ ]⟶ bool ↑ @@ -423,6 +426,7 @@ Each Agda built-in name must be mapped to a Haskell name. | RotateByteString | CountSetBits | FindFirstSetBit + | Ripemd_160 ) #-} ``` @@ -489,6 +493,7 @@ postulate rotateBYTESTRING : ByteString -> Int -> ByteString countSetBITS : ByteString -> Int findFirstSetBIT : ByteString -> Int + RIPEMD-160 : ByteString → ByteString ``` ### What builtin operations should be compiled to if we compile to Haskell @@ -611,6 +616,8 @@ postulate {-# COMPILE GHC countSetBITS = \s -> fromIntegral $ Bitwise.countSetBits s #-} {-# COMPILE GHC findFirstSetBIT = \s -> fromIntegral $ Bitwise.findFirstSetBit s #-} +{-# COMPILE GHC RIPEMD-160 = Hash.ripemd_160 #-} + -- no binding needed for appendStr -- no binding needed for traceStr ``` diff --git a/plutus-metatheory/src/Untyped/CEK.lagda.md b/plutus-metatheory/src/Untyped/CEK.lagda.md index 7257c64d936..0065fa9c032 100644 --- a/plutus-metatheory/src/Untyped/CEK.lagda.md +++ b/plutus-metatheory/src/Untyped/CEK.lagda.md @@ -560,6 +560,10 @@ BUILTIN findFirstSetBit = λ { (app base (V-con bytestring s)) -> inj₂ (V-con integer (findFirstSetBIT s)) ; _ -> inj₁ userError } +BUILTIN ripemd-160 = λ + { (app base (V-con bytestring b)) -> inj₂ (V-con bytestring (RIPEMD-160 b)) + ; _ -> inj₁ userError + } -- Take an apparently more general index and show that it is a fully applied builtin. mkFullyAppliedBuiltin : ∀ { b } diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs index e58d77de70a..55c580342d7 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs @@ -172,6 +172,7 @@ builtinNames = [ , 'Builtins.blake2b_224 , 'Builtins.blake2b_256 , 'Builtins.keccak_256 + , 'Builtins.ripemd_160 , 'Builtins.equalsByteString , 'Builtins.lessThanByteString , 'Builtins.lessThanEqualsByteString @@ -363,6 +364,7 @@ defineBuiltinTerms = do PLC.Blake2b_224 -> defineBuiltinInl 'Builtins.blake2b_224 PLC.Blake2b_256 -> defineBuiltinInl 'Builtins.blake2b_256 PLC.Keccak_256 -> defineBuiltinInl 'Builtins.keccak_256 + PLC.Ripemd_160 -> defineBuiltinInl 'Builtins.ripemd_160 PLC.EqualsByteString -> defineBuiltinInl 'Builtins.equalsByteString PLC.LessThanByteString -> defineBuiltinInl 'Builtins.lessThanByteString PLC.LessThanEqualsByteString -> defineBuiltinInl 'Builtins.lessThanEqualsByteString diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden index b714fb429ee..5bcee06806b 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-129" + "entering addInteger-130" (\(thunk : unit) -> - trace {integer} "exiting addInteger-129" (addInteger x y)) + trace {integer} "exiting addInteger-130" (addInteger x y)) () ~addInt : integer -> integer -> integer = \(x : integer) -> @@ -24,9 +24,9 @@ program in trace {unit -> integer -> integer} - "entering addInt-126" + "entering addInt-127" (\(thunk : unit) -> - trace {integer -> integer} "exiting addInt-126" (addInteger x)) + trace {integer -> integer} "exiting addInt-127" (addInteger x)) () in addInt) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden index 9bd01c9535d..ad9a3684df7 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden @@ -1 +1 @@ -[entering addInt-126, exiting addInt-126] \ No newline at end of file +[entering addInt-127, exiting addInt-127] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden index 14e3e61691c..84d1bfa97c9 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden @@ -1,6 +1,6 @@ -[ entering runIdentity-129 -, exiting runIdentity-129 -, entering newtypeFunction-137 -, exiting newtypeFunction-137 -, entering `$fFoldableIdentity`-131 -, exiting `$fFoldableIdentity`-131 ] \ No newline at end of file +[ entering runIdentity-130 +, exiting runIdentity-130 +, entering newtypeFunction-138 +, exiting newtypeFunction-138 +, entering `$fFoldableIdentity`-132 +, exiting `$fFoldableIdentity`-132 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden index b0bc86d7306..8247a445426 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden @@ -1 +1 @@ -[entering obscuredFunction-127, exiting obscuredFunction-127] \ No newline at end of file +[entering obscuredFunction-128, exiting obscuredFunction-128] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden index 0d688af7c21..4a02cd564b2 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden @@ -1,36 +1,36 @@ -[ entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 ] \ No newline at end of file +[ entering fact-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-151 +, exiting subtractInteger-151 +, entering fact-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-151 +, exiting subtractInteger-151 +, entering fact-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-151 +, exiting subtractInteger-151 +, entering fact-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-151 +, exiting subtractInteger-151 +, entering fact-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fact-127 +, entering multiplyInteger-145 +, exiting multiplyInteger-145 +, exiting fact-127 +, entering multiplyInteger-145 +, exiting multiplyInteger-145 +, exiting fact-127 +, entering multiplyInteger-145 +, exiting multiplyInteger-145 +, exiting fact-127 +, entering multiplyInteger-145 +, exiting multiplyInteger-145 +, exiting fact-127 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden index 6df2672558c..11540b3f80f 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-148" + "entering addInteger-149" (\(thunk : unit) -> - trace {integer} "exiting addInteger-148" (addInteger x y)) + trace {integer} "exiting addInteger-149" (addInteger x y)) () data Bool | Bool_match where True : Bool @@ -33,11 +33,11 @@ program in trace {unit -> Bool} - "entering equalsInteger-133" + "entering equalsInteger-134" (\(thunk : unit) -> trace {Bool} - "exiting equalsInteger-133" + "exiting equalsInteger-134" (let !b : bool = equalsInteger x y in @@ -55,11 +55,11 @@ program in trace {unit -> integer} - "entering subtractInteger-154" + "entering subtractInteger-155" (\(thunk : unit) -> trace {integer} - "exiting subtractInteger-154" + "exiting subtractInteger-155" (subtractInteger x y)) () in @@ -71,11 +71,11 @@ program in trace {unit -> integer} - "entering fib-126" + "entering fib-127" (\(thunk : unit) -> trace {integer} - "exiting fib-126" + "exiting fib-127" (Bool_match (equalsInteger n 0) {all dead. integer} diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden index dd4c4ebeacf..ac47dd17b24 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden @@ -1,74 +1,74 @@ -[ entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 ] \ No newline at end of file +[ entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fib-127 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fib-127 +, entering addInteger-149 +, exiting addInteger-149 +, exiting fib-127 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fib-127 +, entering addInteger-149 +, exiting addInteger-149 +, exiting fib-127 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fib-127 +, entering subtractInteger-155 +, exiting subtractInteger-155 +, entering fib-127 +, entering equalsInteger-134 +, exiting equalsInteger-134 +, exiting fib-127 +, entering addInteger-149 +, exiting addInteger-149 +, exiting fib-127 +, entering addInteger-149 +, exiting addInteger-149 +, exiting fib-127 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden index b44a413ba8b..f676a169934 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden @@ -1 +1 @@ -[entering id-127, exiting id-127, entering id-127, exiting id-127] \ No newline at end of file +[entering id-128, exiting id-128, entering id-128, exiting id-128] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden index 7bb5394e1a3..6ee433ec390 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden @@ -6,8 +6,8 @@ program \(x : a) -> trace {unit -> a} - "entering id-127" - (\(thunk : unit) -> trace {a} "exiting id-127" x) + "entering id-128" + (\(thunk : unit) -> trace {a} "exiting id-128" x) () in id {integer} (id {integer} 1)) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden index 55db6efde8c..0904615ba42 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden @@ -1,10 +1,10 @@ -[ entering f-138 -, entering addInteger-132 -, exiting addInteger-132 -, exiting f-138 -, entering f-138 -, entering addInteger-132 -, exiting addInteger-132 -, exiting f-138 -, entering addInteger-132 -, exiting addInteger-132 ] \ No newline at end of file +[ entering f-139 +, entering addInteger-133 +, exiting addInteger-133 +, exiting f-139 +, entering f-139 +, entering addInteger-133 +, exiting addInteger-133 +, exiting f-139 +, entering addInteger-133 +, exiting addInteger-133 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden index dcf5f62de33..748c44a94ce 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden @@ -1,12 +1,12 @@ -[ entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering addInteger-134 -, exiting addInteger-134 -, entering multiplyInteger-142 -, exiting multiplyInteger-142 ] \ No newline at end of file +[ entering f-141 +, entering addInteger-135 +, exiting addInteger-135 +, exiting f-141 +, entering f-141 +, entering addInteger-135 +, exiting addInteger-135 +, exiting f-141 +, entering addInteger-135 +, exiting addInteger-135 +, entering multiplyInteger-143 +, exiting multiplyInteger-143 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden index 29dd653b9b7..7c287045bb2 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden @@ -1,28 +1,28 @@ -[ entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 ] \ No newline at end of file +[ entering f-129 +, entering equalsInteger-136 +, exiting equalsInteger-136 +, entering subtractInteger-153 +, exiting subtractInteger-153 +, entering f-129 +, entering equalsInteger-136 +, exiting equalsInteger-136 +, entering subtractInteger-153 +, exiting subtractInteger-153 +, entering f-129 +, entering equalsInteger-136 +, exiting equalsInteger-136 +, entering subtractInteger-153 +, exiting subtractInteger-153 +, entering f-129 +, entering equalsInteger-136 +, exiting equalsInteger-136 +, exiting f-129 +, entering addInteger-147 +, exiting addInteger-147 +, exiting f-129 +, entering addInteger-147 +, exiting addInteger-147 +, exiting f-129 +, entering addInteger-147 +, exiting addInteger-147 +, exiting f-129 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden index 95ccf2e19ca..84c6df802db 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden @@ -1 +1 @@ -[entering swap-133, exiting swap-133] \ No newline at end of file +[entering swap-134, exiting swap-134] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden index fe995dbadbe..608ce6329ed 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden @@ -1,12 +1,12 @@ -[ entering useTypeclass-135 -, entering methodA-149 -, exiting methodA-149 -, entering addInteger-142 -, exiting addInteger-142 -, entering methodB-160 -, exiting methodB-160 -, entering subtractInteger-172 -, exiting subtractInteger-172 -, entering addInteger-142 -, exiting addInteger-142 -, exiting useTypeclass-135 ] \ No newline at end of file +[ entering useTypeclass-136 +, entering methodA-150 +, exiting methodA-150 +, entering addInteger-143 +, exiting addInteger-143 +, entering methodB-161 +, exiting methodB-161 +, entering subtractInteger-173 +, exiting subtractInteger-173 +, entering addInteger-143 +, exiting addInteger-143 +, exiting useTypeclass-136 ] \ No newline at end of file diff --git a/plutus-tx/changelog.d/20240806_115427_kenneth.mackenzie.md b/plutus-tx/changelog.d/20240806_115427_kenneth.mackenzie.md new file mode 100644 index 00000000000..2d6ecca1558 --- /dev/null +++ b/plutus-tx/changelog.d/20240806_115427_kenneth.mackenzie.md @@ -0,0 +1,3 @@ +### Added + +- Builtin function `ripemd_160` implementing RIPEMD-160 hashing. diff --git a/plutus-tx/src/PlutusTx/Builtins.hs b/plutus-tx/src/PlutusTx/Builtins.hs index 9ff0e4d4232..2c66e6ac03c 100644 --- a/plutus-tx/src/PlutusTx/Builtins.hs +++ b/plutus-tx/src/PlutusTx/Builtins.hs @@ -20,6 +20,7 @@ module PlutusTx.Builtins ( , blake2b_224 , blake2b_256 , keccak_256 + , ripemd_160 , verifyEd25519Signature , verifyEcdsaSecp256k1Signature , verifySchnorrSecp256k1Signature @@ -198,6 +199,11 @@ blake2b_256 = BI.blake2b_256 keccak_256 :: BuiltinByteString -> BuiltinByteString keccak_256 = BI.keccak_256 +{-# INLINABLE ripemd_160 #-} +-- | The RIPEMD-160 hash of a 'ByteString' +ripemd_160 :: BuiltinByteString -> BuiltinByteString +ripemd_160 = BI.ripemd_160 + {-# INLINABLE verifyEd25519Signature #-} -- | Ed25519 signature verification. Verify that the signature is a signature of -- the message by the public key. This will fail if key or the signature are not diff --git a/plutus-tx/src/PlutusTx/Builtins/Internal.hs b/plutus-tx/src/PlutusTx/Builtins/Internal.hs index 520b3d09c04..527a7f0a26e 100644 --- a/plutus-tx/src/PlutusTx/Builtins/Internal.hs +++ b/plutus-tx/src/PlutusTx/Builtins/Internal.hs @@ -254,6 +254,10 @@ blake2b_256 (BuiltinByteString b) = BuiltinByteString $ Hash.blake2b_256 b keccak_256 :: BuiltinByteString -> BuiltinByteString keccak_256 (BuiltinByteString b) = BuiltinByteString $ Hash.keccak_256 b +{-# NOINLINE ripemd_160 #-} +ripemd_160 :: BuiltinByteString -> BuiltinByteString +ripemd_160 (BuiltinByteString b) = BuiltinByteString $ Hash.ripemd_160 b + {-# NOINLINE verifyEd25519Signature #-} verifyEd25519Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> BuiltinBool verifyEd25519Signature (BuiltinByteString vk) (BuiltinByteString msg) (BuiltinByteString sig) = diff --git a/plutus-tx/src/PlutusTx/Prelude.hs b/plutus-tx/src/PlutusTx/Prelude.hs index ab1789c214a..448dbfa2e62 100644 --- a/plutus-tx/src/PlutusTx/Prelude.hs +++ b/plutus-tx/src/PlutusTx/Prelude.hs @@ -83,6 +83,7 @@ module PlutusTx.Prelude ( blake2b_224, blake2b_256, keccak_256, + ripemd_160, verifyEd25519Signature, verifyEcdsaSecp256k1Signature, verifySchnorrSecp256k1Signature, @@ -148,8 +149,8 @@ import PlutusTx.Builtins (BuiltinBLS12_381_G1_Element, BuiltinBLS12_381_G2_Eleme emptyByteString, emptyString, encodeUtf8, equalsByteString, equalsString, error, fromBuiltin, fromOpaque, greaterThanByteString, indexByteString, integerToByteString, keccak_256, lengthOfByteString, lessThanByteString, - sha2_256, sha3_256, sliceByteString, toBuiltin, toOpaque, trace, - verifyEcdsaSecp256k1Signature, verifyEd25519Signature, + ripemd_160, sha2_256, sha3_256, sliceByteString, toBuiltin, toOpaque, + trace, verifyEcdsaSecp256k1Signature, verifyEd25519Signature, verifySchnorrSecp256k1Signature) import PlutusTx.Builtins qualified as Builtins