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);
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.