Code Monkey home page Code Monkey logo

Comments (3)

maoueh avatar maoueh commented on July 16, 2024

Not impossible the signature do not match, I will need to take a look. Are you able to provide me with the exact steps and data so that I can reproduce that?

There is a PR pending that might fix this #36, I will check when I get some time.

from eos-go.

cuizx avatar cuizx commented on July 16, 2024

Environment: Jungle Test Net
EOS version: 1.2.1
OS: Unbuntu Server 16.04

step 1: cleos transfer name1 name2 "10.0000 EOS" "test" -d -j //change the name to your own
{
"expiration": "2018-09-06T05:19:38",
"ref_block_num": 16295,
"ref_block_prefix": 778607569,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "name1",
"permission": "active"
}
],
"data": "0000d5cc4....................."
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_SIGNATURE SIGNED BY CLEOS WALLET"
],
"context_free_data": []
}

step 2 eos-go: the main code as the following:

package main

import (
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"

"github.com/eoscanada/eos-go"
"github.com/eoscanada/eos-go/ecc"

)

func main(){
action := &eos.Action{}

pls := make([]eos.PermissionLevel, 0)
pl := eos.PermissionLevel{}
pl.Actor = "name1"
pl.Permission = "active"
pls = append(pls, pl)

action.Account = "eosio.token"
action.Name = "transfer"
action.Authorization = pls

action.HexData, _ = hex.DecodeString("0000d5cc4.....................")
actions := make([]*eos.Action, 0)
actions = append(actions, action)

tx := &eos.Transaction{}

tx.ContextFreeActions = make([]*eos.Action, 0)
tx.Actions = actions
tx.RefBlockNum = 16295
tx.RefBlockPrefix = 778607569
t, _ := time.Parse("2006-01-02T15:04:05", "2018-09-06T05:19:38")
tx.Expiration = eos.JSONTime{t}
tx.Extensions = make([]*eos.Extension, 0)

stx := eos.NewSignedTransaction(tx)

privKey, _ := ecc.NewPrivateKey("the Private key of  name1")
txdata, cfd, _ := stx.PackedTransactionAndCFD()
chainID, _ := hex.DecodeString("038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca")
sigDigest := eos.SigDigest(chainID, txdata, cfd)

sig, _ := privKey.Sign(sigDigest)
stx.Signatures = append(stx.Signatures, sig)
fmt.Println(stx.String())    //The json string is exactly the same as that generated by cleos except sign.

}

The two signatures are different.

I tried several other ways to generate transaction, e.g.
txopts := &eos.TxOptions{}
txopts.ChainID, _ =
hex.DecodeString("038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca")
txopts.HeadBlockID, _ = hex.DecodeString("0000.....")
txopts.MaxCPUUsageMS = 0
txopts.MaxNetUsageWords = 0
txopts.DelaySecs = 0
txopts.Compress = eos.CompressionNone

The result is the same as the above.

from eos-go.

abourget avatar abourget commented on July 16, 2024

See #36 .. nothing guarantees a signature of a privkey+payload to be identical each time, for it to be valid. It will be canonical (thus recognized as valid by nodeos), but again that doesn't mean the serialization is the same.

See the linked issue for more details.

from eos-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.