Cryptographic primitives

My team and I are developing a smart contract and need to use cryptographic primitives like bigint and hashes. We found rust packages for the purpose. However, the types are not serializable with the concordium_std trait.
Are there any way to solve this?

Hi @denada and welcome to the concordium support forum! :blush:

Yes, there is.
You need to make a wrapper type and implement Serial and Deserial on the wrapper type.
The wrapper is needed because of the orphan rules in rust, which states that you cannot implement external traits on external types.

Something along these lines:

struct BigUintWrapper(BigUint);

impl Serial for BigUintWrapper {
    fn serial<W: Write>(&self, _out: &mut W) -> Result<(), W::Err> {

impl Deserial for BigUintWrapper {
    fn deserial<R: Read>(_source: &mut R) -> ParseResult<Self> {

Let me know if you have any further issues.

Have a nice day!

Best regards,