0

I want to know exactly how the final EOS transaction signature is built. I use C++ but it could be any language.
I can't find any detailed documentation about it. I'm really not sure of what I found but so far I've gathered this information from here, here, here, source code of cleos and the source of ecc-js:

  1. Make a transaction in json
  2. Pack the transaction (I use abieos)
  3. Then do: sha256(chain_id + packed_transaction + sha256(contextFreeData))

contextFreeData is empty so = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

  1. Then : secp256k1(privateKey, <result of 3.>)

Using secp256k1_ecdsa_sign then secp256k1_ecdsa_signature_serialize_compact

  1. Then : base58check( '0' + <result of 4.>)

I saw that for K1 sig the source code prepends a 0x00. Also the base58check seems to be:

base58check = base58(data + RIPEMD160(data)[0:4]) 
  1. Finally just prepend "SIG_K1_" to <result of 5.>

If I'm right, the total bytes that goes into base58 is 69 (= 1 + 64 + 4 ).

But still, my implementation in C++ won't work. The error I have is:

{
    "code": 500,
    "error": {
        "code": 3010010,
        "details": [
            {
                "file": "chain_plugin.cpp",
                "line_number": 2120,
                "message": "Invalid packed transaction",
                "method": "push_transaction"
            },
            {
                "file": "common.hpp",
                "line_number": 50,
                "message": "checksum == wrapped.check: ",
                "method": "apply"
            },
            {
                "file": "signature.cpp",
                "line_number": 32,
                "message": "error parsing signature",
                "method": "parse_base58"
            },
            {
                "file": "abi_serializer.hpp",
                "line_number": 787,
                "message": "Failed to deserialize variant",
                "method": "from_variant"
            }
        ],
        "name": "packed_transaction_type_exception",
        "what": "Invalid packed transaction"
    },
    "message": "Internal Service Error"
}

I will gladly update my question if there are news or something works. I'm stuck already for a week or two now...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.