IPUP is a pack of multiple custom syscalls which allow extending your contract's on-chain functionality beyond the native level. It currently includes 5 custom syscalls including hashing algorithms such as blake2 and crc64, password encryption algorithms such as pbkdf2 and argon2, along with non-verifiable prng.
How it works
I created multiple custom syscalls and linked it to a custom kernel. These syscalls allow users to add functionality to the smart contracts which wouldn't have been possible with native solidity contracts.
Checkout IPUP for more information.
Currently there are following syscalls -
- Blake2 Hashing - Blake2 is a cryptographic hash function which provides high performance, versatility and security to the users. It is not natively supported in solidity, however it's highly needed in cryptographic operations.
- CRC - CRC (Cyclic Redundancy Check) is an error-detecting code used in digital networks and storage devices to detect accidental changes to raw data. It operates by generating a fixed-size checksum (typically 16, 32, or 64 bits) based on the data being checked, which is then appended to the data or transmitted alongside it.
- Pbkdf2 - PBKDF2 (Password-Based Key Derivation Function 2) is a key derivation function that is used to securely derive cryptographic keys from passwords or passphrases. It's a widely-used algorithm for deriving cryptographic keys from passwords, and it's designed to be resistant to brute-force attacks.
- Argon2 - Argon2 is a key derivation function that was selected as the winner of the Password Hashing Competition (PHC) in 2015. It's designed to securely hash passwords and other sensitive information while also being resistant to various types of attacks, including brute-force, dictionary, and side-channel attacks. Argon2 is considered to be one of the most secure and efficient password hashing algorithms available today, and it's being widely adopted in various applications and security protocols.
- Non Verifiable Randomness - The custom syscall for Non-verifiable PRNG is created using Box-Muller method(shown in the image below). It uses rand crate from rust.
How to use
- Clone the IPUP Repo
- Deploy the subnet using IPC Docs (make sure you don't end up cloning the IPC repo).
- Use IPUP Readme to invoke the actor.
Problems that I faced
Setting up the subnet - It took me around 6-7 days to get comfortable with the workflow. I was trying to run it on WSL but I kept running into errors, so I installed Ubuntu on my machine and finally got everything working.
Errors while invoking actor - Smoke Tests worked pretty well but there was always an error whenever I tried invoking actor from solidity. These errors ate up a week of mine, and I finally figured out it was due to a single line, View in repo
rt.validate_immediate_caller_is(std::iter::once(&SYSTEM_ACTOR_ADDR))?;
I just changed it to -
rt.validate_immediate_caller_accept_any()?;
- Custom syscalls only support input datatypes like u64, i64 - To create hashing algorithms, it's a necessity to take string as an input, but it seems like custom kernel support only a few input types, so I had to use workarounds to convert string into u64 before passing to params.
What's next for IPUP
I planned to add a few more syscalls such as -
- JSON String Schema Validation.
- A syscall to make On-chain api calls.
But, both of them require long string based inputs. So, I'll be adding these once I figure out a way to input strings.
I'll be accepting open-source contributions to this project after the hackathon, it'll be great to have various syscalls in a single place.