Skip to content

Broadcast fails when data contains Digital Signature #43

@marius-yknotocs-com

Description

@marius-yknotocs-com
string signature = "SIG_K1_JyngtE5o5zqFGxNQZfQ7CWsvG4wfPfrxs8Z7YDTNtEGHos8Pso9z2p4EHBoNhd3UcBu7zn5iTxASfPfbAbcAdJCdoLxbAS";

var MyAction1 = new EosSharp.Core.Api.v1.Action() {
                    account = "zar",
                    authorization = new List<PermissionLevel>() { new PermissionLevel() {
                      actor = "mycontract", permission = "active" }
                    },
                    name = "dummyaction",
                    data = new {
                        sign = signature
                    }
                };

Packed data for above

1f9dcb5e92bf8736e53c0000000001000000000000aef900267519192fa54e01000000000000aef90000b86ae1696ede41001f22a5ee328c54421bddb73110f6ddce3258e214c611aac33a1532affb3adcc2bd3f3276e5223189fa58cdd0a9cb054d1360e26d2a24047e6628392a68d9dd9900

Transcoding the signature to hex

1f22a5ee328c54421bddb73110f6ddce3258e214c611aac33a1532affb3adcc2bd3f3276e5223189fa58cdd0a9cb054d1360e26d2a24047e6628392a68d9dd9920

The last byte is 0x00, should be 0x20

Confirm using commandline (cleos)

{
"expiration": "2020-05-25T10:13:38",
"ref_block_num": 47374,
"ref_block_prefix": 2492603937,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "zar",
"name": "dummyaction",
"authorization": [{
"actor": "mycontract",
"permission": "active"
}
],
"data": "001f22a5ee328c54421bddb73110f6ddce3258e214c611aac33a1532affb3adcc2bd3f3276e5223189fa58cdd0a9cb054d1360e26d2a24047e6628392a68d9dd9920"
}
],
"transaction_extensions": [],
"signatures": [],
"context_free_data": []
}

It appears that packing of the transaction is dropping the last byte of the signature?

I use the following method for signing a hash of data (the resulting sig seems to be valid):

        public static string SignHash(byte[] hash, string privateKey) {
            var sign = Secp256K1Manager.SignCompressedCompact(hash, EosSharp.Core.Helpers.CryptoHelper.GetPrivateKeyBytesWithoutCheckSum(privateKey));
            var check = new List<byte[]>() { sign, Encoding.UTF8.GetBytes("K1") };
            var checksum = Ripemd160Manager.GetHash(EosSharp.Core.Helpers.SerializationHelper.Combine(check)).Take(4).ToArray();
            return "SIG_K1_" + Base58.Encode(EosSharp.Core.Helpers.SerializationHelper.Combine(new List<byte[]>() { sign, checksum }));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions