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 all 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}
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.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -849,8 +849,7 @@ program
, (constr 1
[ cse
, (constr 1
[ (cse
10)
[ cse
, (constr 0
[ ]) ]) ]) ])
, (constr 0
Expand All @@ -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
Expand Down Expand Up @@ -905,7 +904,8 @@ program
, (constr 0
[ ]) ]))
(constr 1
[ cse
[ (cse
1)
, (constr 0
[ ]) ]))
(constr 1
Expand All @@ -917,31 +917,31 @@ program
, (constr 0
[ ]) ]))
(cse
1))
100))
(constr 0
[ (constr 1
[ ])
, cse ]))
(cse
100))
(cse 2))
10))
(cse 5))
(constr 0
[ (constr 1
[])
, (constr 1
[ 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)
Expand Down
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 @@ -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
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
Loading