Skip to content

Commit af924ad

Browse files
serejkerphairRyun1iquerejeta
authored
CIP-0101 | Integration of keccak256 into Plutus (cardano-foundation#524)
* CIP: Integration of `keccak256` into Plutus. * single ? in CIP number for standard form Co-authored-by: Ryan Williams <[email protected]> * fix: update formatting of headers. * fix: add a reference to CIP-49. * fix: remove "Path to Proposed". * fix: elaborate on the Specification. * full title for Motivation * full title for Rationale * adding Copyright section in standard form * fix: drop "Backward Compatibility" section. * fix: drop "References" section. * fix: add "Path to Active" subsections. * fix: spelling of Mainnet. * fix: add Michael Peyton Jones as an implementor. * fix: add a real integration use case. * fix: update the costing comment. Co-authored-by: Iñigo Querejeta Azurmendi <[email protected]> * obligatory language for acceptance as per cip35 Co-authored-by: Iñigo Querejeta Azurmendi <[email protected]> * satisfying all cip35 criteria except guaranteed termination Co-authored-by: Iñigo Querejeta Azurmendi <[email protected]> * fix: CR suggestion on the costing functions. * assign CIP number 101 * fix: rename folder to CIP-0101 --------- Co-authored-by: Robert Phair <[email protected]> Co-authored-by: Ryan Williams <[email protected]> Co-authored-by: Iñigo Querejeta Azurmendi <[email protected]>
1 parent 5f926f2 commit af924ad

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

CIP-0101/README.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
CIP: 101
3+
Title: Integration of `keccak256` into Plutus
4+
Status: Proposed
5+
Category: Plutus
6+
Authors:
7+
- Sergei Patrikeev <[email protected]>
8+
- Iñigo Querejeta-Azurmendi <[email protected]>
9+
Implementors:
10+
- Michael Peyton Jones <[email protected]>
11+
Discussions:
12+
- https://github.com/cardano-foundation/CIPs/pull/524
13+
Created: 2023-06-13
14+
License: Apache-2.0
15+
---
16+
17+
## Abstract
18+
This CIP proposes an extension of the current Plutus functions to provide support for the [`keccak256`](https://keccak.team/files/Keccak-submission-3.pdf) hashing algorithm,
19+
primarily to ensure compatibility with Ethereum's cryptographic infrastructure.
20+
21+
## Motivation: why is this CIP necessary?
22+
23+
The [integration](https://github.com/cardano-foundation/CIPs/blob/master/CIP-0049/README.md) of the ECDSA and Schnorr signatures over the secp256k1 curve into Plutus was a significant
24+
step towards interoperability with Ethereum and Bitcoin ecosystems. However, full compatibility is still impossible
25+
due to the absence of the `keccak256` hashing algorithm in Plutus interpreter,
26+
which is a fundamental component of Ethereum's cryptographic framework:
27+
- data signing standard [EIP-712](https://eips.ethereum.org/EIPS/eip-712),
28+
- `keccak256` is the hashing algorithm underlying Ethereum's ECDSA signatures.
29+
- EVM heavily [depends](https://ethereum.github.io/yellowpaper/paper.pdf) on `keccak256` for internal state management
30+
31+
Adding `keccak256` to Plutus would enhance the potential for cross-chain solutions between Cardano and EVM-based blockchains.
32+
33+
A compelling integration that would greatly benefit from `keccak256` support on the Cardano blockchain is [Hyperlane](https://hyperlane.xyz/).
34+
Hyperlane is a permissionless interoperability layer that facilitates communication of arbitrary data between smart contracts across multiple blockchains. Hyperlane's [interchain security modules](https://docs.hyperlane.xyz/docs/protocol/sovereign-consensus)
35+
rely on the verification of specific cryptographic proofs from one chain to another. These proofs utilize the `keccak256` hash to calculate consistent cross-chain message IDs.
36+
The multi-signature module verifies that a majority of off-chain validators have signed an ECDSA signature over a `keccak256` digest, a common practice in EVM.
37+
38+
While Hyperlane [can support](https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/2399) different cryptographic primitives for non-EVM chains, doing so could compromise censorship resistance, resulting in only limited support for Cardano in Hyperlane. By implementing this CIP, Cardano could fully integrate with Hyperlane's security modules, enabling Cardano smart contracts to communicate with any blockchain supported by Hyperlane.
39+
40+
## Specification
41+
This proposal aims to introduce a new built-in hash function `keccak_256`.
42+
43+
This function will be developed following the [`keccak256`](https://keccak.team/files/Keccak-submission-3.pdf) specification
44+
and will utilize the [cryptonite](https://github.com/haskell-crypto/cryptonite/blob/master/Crypto/Hash/Keccak.hs) implementation.
45+
Since `cryptonite` is already a part of the [`cardano-base`](https://github.com/input-output-hk/cardano-base/blob/master/cardano-crypto-class/src/Cardano/Crypto/Hash/Keccak256.hs),
46+
this simplifies its integration into Plutus. The cost of the `keccak_256` operation will scale linearly with the length of the message.
47+
48+
More specifically, Plutus will gain the following primitive operation:
49+
50+
* `keccak_256` :: ByteString -> ByteString
51+
52+
The input to this function can be a `ByteString` of arbitrary size, and the output will be a `ByteString` of 32 bytes.
53+
Note that this function aligns with the format of existing hash functions in Plutus, such as [blake2b_256](https://github.com/input-output-hk/plutus/blob/75267027f157f1312964e7126280920d1245c52d/plutus-core/plutus-core/src/Data/ByteString/Hash.hs#L25)
54+
55+
## Rationale: how does this CIP achieve its goals?
56+
While the `keccak256` function might be implemented in on-chain scripts, doing so would be computationally unfeasible.
57+
58+
The library, cryptonite, is not implemented by and under control of the Plutus team. However,
59+
* It is a library already used in the Cardano stack to expose SHA3, and can be considered as a trustworthy implementation.
60+
* The function does not throw any exceptions as hash functions are defined to work with any ByteString input. It does not expect a particular particular structure.
61+
* It's behaviour is predictable. As mentioned above, 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) have.
62+
## Path to Active
63+
This CIP may transition to active status once the Plutus version containing the `keccak_256` function is introduced
64+
in a node release and becomes available on Mainnet.
65+
66+
### Acceptance Criteria
67+
* A Plutus binding is created for the `keccak256` function and included in a new version of Plutus.
68+
* Integration tests, similar to those of the existing Plutus hash functions, are added to the testing infrastructure.
69+
* The function is benchmarked to assess its cost. As for other hash functions available in Plutus (blake2b and sha256), we expect the cost of keccak to be linear with respect to the size of the message. The Plutus team determines the exact costing functions empirically.
70+
* The ledger is updated to include new protocol parameters to control costing of the new builtins.
71+
72+
### Implementation Plan
73+
The Plutus team will develop the binding, integration tests, and benchmarks. The E2E tests will be designed and implemented
74+
collaboratively by the testing team, the Plutus team, and community members planning to use this primitive.
75+
76+
## Copyright
77+
This CIP is licensed under [Apache-2.0][https://www.apache.org/licenses/LICENSE-2.0].

0 commit comments

Comments
 (0)