We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
when i write program below, it panic err:
panic: unknown public key type
privateKey, err := keypair.DeserializePrivateKey(privateKeyBytes) if err != nil { fmt.Println(err) return "", "", "", err } pub := privateKey.Public() aAddr := types.AddressFromPubKey(pub)
how to transform crypto.PublicKey to keypair.PublicKey
crypto.PublicKey
keypair.PublicKey
I have read the source code Such as: https://github.com/ontio/ontology/blob/master/cmd/account_cmd.go#L438
https://github.com/ontio/ontology/blob/master/cmd/sigsvr/store/wallet_store.go#L225
how to transform crypto.PublicKey to keypair.PublicKey or how to transform crypto.PublicKey to common.Address
common.Address
The text was updated successfully, but these errors were encountered:
Where is the privateKeyBytes come from?
privateKeyBytes
Sorry, something went wrong.
@laizy thank you very much
I have generated a keypair before , then cast to string , save it into my db when I want to make tx, I get the prvString from my db, such as below
prvString
prv, _, _:= keypair.GenerateKeyPair(keypair.PK_ETHECDSA, nil) prvString := hex.EncodeToString(keypair.SerializePrivateKey(prv)) privateKeyBytes , _:= hex.DecodeString(prvString )
If you want to send ontology transaction, you can use keypair.PK_ECDSA. keypair.PK_ETHECDSA is intend for ontology evm transaction.
keypair.PK_ECDSA
keypair.PK_ETHECDSA
The current workaround for your code is:
privateKey, err := keypair.DeserializePrivateKey(privateKeyBytes) if err != nil { fmt.Println(err) return "", "", "", err } _, pub := keypair.FromEthereumPrivateKey(privateKey.(*ec.EthereumPrivateKey).PrivateKey) aAddr := types.AddressFromPubKey(pub)
No branches or pull requests
when i write program below, it panic err:
how to transform
crypto.PublicKey
tokeypair.PublicKey
I have read the source code
Such as:
https://github.com/ontio/ontology/blob/master/cmd/account_cmd.go#L438
https://github.com/ontio/ontology/blob/master/cmd/sigsvr/store/wallet_store.go#L225
how to transform
crypto.PublicKey
tokeypair.PublicKey
or
how to transform
crypto.PublicKey
tocommon.Address
The text was updated successfully, but these errors were encountered: