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

how to replicate the sing behaviour #7

Open
Assassyn opened this issue Nov 19, 2021 · 0 comments
Open

how to replicate the sing behaviour #7

Assassyn opened this issue Nov 19, 2021 · 0 comments

Comments

@Assassyn
Copy link

I am trying to replicate some javascript code to sign into the dApp. The JS code looks like that:

// Check if this is a master password, if so try to generate the private key
if (key && !steem.auth.isWif(key))
     key = steem.auth.getPrivateKeys(username, key, ['posting']).posting;

// Check that the key is a valid private key.
try { steem.auth.wifToPublic(key); }
catch (err) { return { success: false, error: `Invalid password or private posting key for account @${username}` }; }

// Sign the login request using the provided private key
params.ts = Date.now();
params.sig = eosjs_ecc.sign(username + params.ts, key);

the code I am using looks like that:

let sign (message: string) postingKey =
    let secKey = CBase58.DecodePrivateWif postingKey
    let digest = message |>Encoding.Default.GetBytes |> Sha256Manager.GetHash    
    Secp256K1Manager.SignCompressedCompact(digest, secKey) |> Hex.ToString

let private uri name key = 
    let ts = int64(DateTime.UtcNow.Subtract(unixStart).TotalMilliseconds)
    let signature = sign name key 
    let parameters = 
        $"name={name}&ts={ts}&sig={signature}"

I have tried to use SingCompact instead of SignCompressedCompact, as well as Hex to convert string to byte[], as well as trying to return value with Base58 instead of Hext.ToString but I am not able to generate a similar output as JS code.
I am not sure what I am doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant