MCPcopy Create free account
hub / github.com/CPChain/chain / Sign

Method Sign

internal/cpcapi/api.go:418–433  ·  view source on GitHub ↗

Sign calculates an Cpchain ECDSA signature for: keccack256("\x19Cpchain Signed Message:\n" + len(message) + message)) Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons. The key used to calculate the signature is de

(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string)

Source from the content-addressed store, hash-verified

416//
417// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
418func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error) {
419 // Look up the wallet containing the requested signer
420 account := accounts.Account{Address: addr}
421
422 wallet, err := s.b.AccountManager().Find(account)
423 if err != nil {
424 return nil, err
425 }
426 // Assemble sign the data with the wallet
427 signature, err := wallet.SignHashWithPassphrase(account, passwd, signHash(data))
428 if err != nil {
429 return nil, err
430 }
431 signature[64] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper
432 return signature, nil
433}
434
435// EcRecover returns the address for the account that was used to create the signature.
436// Note, this function is compatible with eth_sign and personal_sign. As such it recovers

Callers 15

SignTxFunction · 0.45
SignatureValuesMethod · 0.45
TestEIP155ChainIdFunction · 0.45
validateTxMethod · 0.45
CommitMethod · 0.45
emptyMethod · 0.45
AddBalanceMethod · 0.45
SubBalanceMethod · 0.45
gasSStoreFunction · 0.45
gasCallFunction · 0.45
gasCallCodeFunction · 0.45

Calls 4

signHashFunction · 0.85
AccountManagerMethod · 0.65
FindMethod · 0.45

Tested by 6

TestEIP155ChainIdFunction · 0.36
TestDpor_SealFunction · 0.36
Test_ecrecoverFunction · 0.36
TestDpor_SignHashFunction · 0.36
TestValidMacSigFunction · 0.36
TestHandler_AddPeerFunction · 0.36