IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.57k stars 479 forks source link

RIPEMD-160 builtin #6155

Open kwxm opened 4 months ago

kwxm commented 4 months ago

It's been proposed that the RIPEMD-160 hash function should be added to Plutus Core, and a CIP is currently being prepared.

To do this we'll need to

We already have a number of hash functions in Plutus Core and this will be very similar, so it shouldn't be too difficult to add it

paluh commented 4 months ago

Thanks a lot for putting this together @kwxm! Let me add some context to your points:

  • [x] Identify a library function that provides the required functionality. This should be audited for safety and a Haskell interface should be provided in cardano-base.

The binding which was just added to cardano-base is based on cryptonite implementation and I believe that library was already approved as source of cryptographic primitives. Am I right @perturbing? This new minor release was also published on CHaP so I was able to just bump the CHaP version in cabal.project and flake.lock to use it.

  • [x] Add a new builtin to Plutus Core based on the library function.

This addition was done in few places: primitive binding, builtin definition, fake cost model params, test case

  • [ ] Cost the new function.

This is still missing :-(

  • [x] Add a corresponding function to PlutusTx

Implemented here

  • [x] Add some tests, including some standard test vectors. We'll want some tests in plutus-conformance, and perhaps they should all go there.

Implemented in #d7470ca8cc4e664c7e21ec79de1c0a961ad1c6b7

  • [ ] Add e2e tests

Could you please point me to some examples which I can follow. I'm testing this new builtin in the context of Bitcoin pubkeyhash<->pubkey hash verification so I'm happy to turn this into a test case.

  • [x] Add the new function to plutus-metatheory

I think this is done here: https://github.com/IntersectMBO/plutus/pull/6147/files#diff-0edb07d418229734a515c575977b4866dccdfee4aadeeee116b4dda09999639dR225

  • [ ] Add the new function to the Plutus Core specification.

Happy to do this by following keccak_256 and blake2b entries. Could you please point me to a repo/file(s) where it should be added?

paluh commented 3 months ago

Please note that I rebased and reopened the PR from my fork (due to permission problems). The links from the previous post should still work and are relevant but some of them don't point to my latest rebased version of the PR: https://github.com/IntersectMBO/plutus/pull/6252