CRYPTO NEWS

Compare different parts of two bytes[] arrays

Assume I have two bytes variables: t1 and t2, where t1<t2. I also have a bytes variable x. I want to divide t2 into two parts.

Compare the first part to see if it is equal to t1, and the second part to see if it is equal to x.

function dummy(bytes memory t1, bytes memory t2, bytes memory x) returns(bool,bool){    bytes _equal;    //first part of t2   assembly {   calldatacopy(0x0, 0, t1.length)   _equal := mload(0x0)   }    //compare first part and t1   bool equal = (keccak256(abi.encodePacked(t1)) == keccak256(abi.encodePacked(_equal));    //second part of t2   assembly {   calldatacopy(0x0, t1.length, t2.length)   _x := mload(0x0)   }    //compare second part and x   bool element = (keccak256(abi.encodePacked(x)) == keccak256(abi.encodePacked(_x));    return(equal, element); } 

The separating the part code I got from here

And the idea that I can use bytes.length I got from here, but the compiler doesnt seem to agree, as I get:

ParserError: Expected ‘)’ but got ‘.’ calldatacopy(0x0, 0,t1.length)

and

ParserError: Expected primary expression. calldatacopy(0x0, 0,t1.length)

Can anyone point out what I am doing wrong or offer an alternative way to go about it? Thanks in advance.

Compare different parts of two bytes[] arrays

Shopping cart
There are no products in the cart!
Continue shopping
0