Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 5.45 KB

README.md

File metadata and controls

66 lines (49 loc) · 5.45 KB
CIP Title Status Category Authors Implementors Discussions Created License
127
ripemd-160 hashing in Plutus Core
Proposed
Plutus
Tomasz Rybarczy <[email protected]>
2024-05-22
Apache-2.0

Abstract

This CIP follows closely the (CIP-0101)1 and proposes an extension of the current Plutus functions with another hashing primitive RIPEMD-160. Primary goal is to introduce compatibility with Bitcoin's cryptographic infrastructure.

Motivation: why is this CIP necessary?

The integration of the ECDSA and Schnorr signatures over the secp256k1 curve into Plutus was a significant step towards interoperability with Ethereum and Bitcoin ecosystems. However, full compatibility is still impossible due to the absence of the RIPEMD-160 hashing algorithm in Plutus interpreter, which is a fundamental component of Bitcoin's cryptographic framework. Most of common addresses in Bitcoin are derived from double hashing procedure involving SHA-256 followed by RIPEMD-160 function:

Adding RIPEMD-160 to Plutus would enhance the potential for cross-chain solutions between Cardano and Bitcoin blockchains and complements the set of primitives which we already have in that regard. It would allow for the verification of Bitcoin addresses and transactions on-chain. This addition enables also the verification of signed messages that identify the signer by the public key hash, which has not yet been witnessed on the Bitcoin blockchain.

The RIPEMD-160 is not only relevant to Bitcoin - other chains like Cosmos or BNB also use it for address generation.

Specification

This proposal aims to introduce a new built-in hash function RIPEMD-160.

This function will be developed following the RIP-160 specification and will utilize the cryptonite

Since cardano-base already relies on cryptonite in the context of keccak-256 we would like to expose RIPEMD-160 through the same library, to facilitate its integration into Plutus.

More specifically, Plutus will gain the following primitive operation:

  • ripemd_160 :: ByteString -> ByteString

The input to this function can be a ByteString of arbitrary size, and the output will be a ByteString of 20 bytes. Note that this function aligns with the format of existing hash functions in Plutus, such as blake2b_256

Rationale: how does this CIP achieve its goals?

While the RIPEMD-160 function might be implemented in on-chain scripts, doing so would be computationally unfeasible.

The library, cryptonite, is not implemented by and under control of the Plutus team. However,

  • It is a library already used in the Plutus stack to expose KECCAK-256, and can be considered as a trustworthy implementation.
  • Its behaviour is predictable and computationally efficient. The cost of the function is linear with respect to the size of the message provided as input. This is the same behaviour that other hash functions exposed in plutus (blake, sha3, keccak-256) have.

Acceptance Criteria

  • A cardano-base binding is created for the ripemd-160 function and included in a new version of the library.
  • A Plutus binding is created for the ripemd_160 function and included in a new version of Plutus.
  • Integration tests, similar to those of the existing Plutus hash functions, are added to the testing infrastructure.
  • The function is benchmarked to assess its cost. As for other hash functions available in Plutus (blake2b, sha256 and keccak_256), we expect the cost of ripemd_160 to be linear with respect to the size of the message. The Plutus team determines the exact costing functions empirically.
  • The ledger is updated to include new protocol parameters to control costing of the new builtins.
  • This CIP may transition to active status once the Plutus version containing the ripemd_160 function is introduced in a node release and becomes available on Mainnet.

Implementation Plan

The Plutus team will develop the binding, integration tests, and benchmarks. The E2E tests will be designed and implemented collaboratively by the testing team, the Plutus team, and community members planning to use this primitive.

Copyright

This CIP is licensed under [Apache-2.0][https://www.apache.org/licenses/LICENSE-2.0].

Footnotes

  1. I did not hesitate to reuse parts of the original text of (CIP-0101)[../CIP-0101/README.md) without explicit quotations. This approach was approved by the original authors.