Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Add Solidity Keccak256 packing support #1529

Closed
Ethan-000 opened this issue Jul 28, 2022 · 6 comments
Closed

Add Solidity Keccak256 packing support #1529

Ethan-000 opened this issue Jul 28, 2022 · 6 comments

Comments

@Ethan-000
Copy link

Hi. Is anyone working on adding Solidity Keccak256 packing support?

/// Compute the Keccak-256 hash of input bytes.
// TODO: Add Solidity Keccak256 packing support
pub fn keccak256<S>(bytes: S) -> [u8; 32]
where
    S: AsRef<[u8]>,
{
    let mut output = [0u8; 32];
    let mut hasher = Keccak::v256();
    hasher.update(bytes.as_ref());
    hasher.finalize(&mut output);
    output
}

In ethers-js, its here
https://github.com/ethers-io/ethers.js/blob/master/packages/bytes/src.ts/index.ts.

I don't know rust or the package well enough to add this myself. It could be helpful if someone can do this. Thanks!

@Ethan-000
Copy link
Author

Ethan-000 commented Jul 28, 2022

found the abi.encode and get_create2_address function sorry.

@Ethan-000
Copy link
Author

eh I think no abi pack util so I'll reopen

@Ethan-000 Ethan-000 reopened this Jul 29, 2022
@tynes
Copy link
Contributor

tynes commented Aug 4, 2022

Do you mean abi.encodePacked?

@Ethan-000
Copy link
Author

yes

@cbrzn
Copy link

cbrzn commented Feb 24, 2023

hey just wanted to share that would be awesome if this function is developed :-), if someone would like to deeply interact with safe factory contracts, they will need this (to generate salt)

@DaniPopes
Copy link
Collaborator

Actually it already is present as abi::encode_packed: https://github.com/gakonst/ethers-rs/blob/master/ethers-core/src/abi/packed.rs

It just hasn't been released yet

@gakonst we can close this, same as #1862

@gakonst gakonst closed this as completed Feb 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants