Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting signature parameters r, s, v #2047

Closed
deanvaessen opened this issue Nov 14, 2018 · 1 comment
Closed

Extracting signature parameters r, s, v #2047

deanvaessen opened this issue Nov 14, 2018 · 1 comment
Labels
Enhancement Includes improvements or optimizations Feature Request

Comments

@deanvaessen
Copy link

Hi,

I needed a function to generate the r, s, v parameters of the signature of a message that I signed with web3, and was surprised that I couldn't find such a function available in web3 (unless I missed something of course). Does it fit within the scope of the project to include this? I can make a pull request if so, this is my current implementation:

    getSignatureParameters( signature ) {
        const r = signature.slice( 0, 66 );
        const s = `0x${signature.slice( 66, 130 )}`;
        let v = `0x${signature.slice( 130, 132 )}`;
        v = this.web3.utils.toDecimal( v );

        if ( ![ 27, 28 ].includes( v ) ) v += 27;

        return {
            r,
            s,
            v
        };
    };
@nivida nivida added Enhancement Includes improvements or optimizations Feature Request labels Nov 28, 2018
@nivida nivida added this to the 1.0 milestone Nov 30, 2018
@nivida nivida closed this as completed Jan 21, 2019
@ryanc414
Copy link

ryanc414 commented Jun 2, 2023

Was this function removed? I can't find it in the docs for the v1.10.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Includes improvements or optimizations Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants