1

I saw similar questions, but my problem is not matching any of those answered questions. I've written a function in a library that also includes in-assembly code but getting an unexpected parser error.

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.11;

library CryptoSuite {

    function splitSignature(bytes memory _sign) internal pure returns(uint8 v, bytes32 r, bytes32 s) {
        
        require(_sign.length == 65);

        //accessing virtual machine to make low level changes.
        assembly {

            //first 32 bytes
            r := mload(add(_sign, 32))
            //next 32 bytes
            s := mload(add(_sign, 64))
            //last 32 bytes
            v := byte(0, mload(add(_sign, 96))
            
        } //getting error here in remix. 

        return (v, r, s);
        
    }

    //split Signature, recieve signature for message, extract signer from that message

    function recoverSigner(bytes32 _message, bytes memory _sign) internal pure returns(address){
        //first get values

        (uint8 v, bytes32 r, bytes32 s) = splitSignature(_sign);

        return ecrecover(_message, v, r, s);

    } 

}

The error says ParserError: Expected ',' but got '}' Please anyone help me.

1 Answer 1

3

There is a missing closing bracket in the following line v := byte(0, mload(add(_sign, 96)). The line should end with ")))".

v := byte(0, mload(add(_sign, 96)))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.