-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsigner_test.go
49 lines (42 loc) · 1.4 KB
/
signer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package zetaclient
import (
"github.com/btcsuite/btcd/btcec"
"github.com/ethereum/go-ethereum/crypto"
. "gopkg.in/check.v1"
)
type SignerSuite struct {
signer *TestSigner
}
var _ = Suite(&SignerSuite{})
func (s *SignerSuite) SetUpTest(c *C) {
// test private key with EVM address
//// EVM: 0x236C7f53a90493Bb423411fe4117Cb4c2De71DfB
// BTC testnet3: muGe9prUBjQwEnX19zG26fVRHNi8z7kSPo
skHex := "7b8507ba117e069f4a3f456f505276084f8c92aee86ac78ae37b4d1801d35fa8"
privateKey, err := crypto.HexToECDSA(skHex)
pkBytes := crypto.FromECDSAPub(&privateKey.PublicKey)
pk, err := btcec.ParsePubKey(pkBytes, btcec.S256())
c.Assert(err, IsNil)
c.Logf("pubkey: %d", len(pkBytes))
c.Logf("pk: %d", len(pk.SerializeCompressed()))
// Uncomment the following code to generate new random private key pairs
//privateKey, err := crypto.GenerateKey()
//privkeyBytes := crypto.FromECDSA(privateKey)
//c.Logf("privatekey %s", hex.EncodeToString(privkeyBytes))
//c.Assert(err, IsNil)
tss := TestSigner{
PrivKey: privateKey,
}
c.Logf("TSS EVMAddress %s", tss.EVMAddress().Hex())
c.Logf("TSS BTCAddress %s", tss.BTCAddress())
c.Logf("TSS BTCSegWitAddress %s", tss.BTCAddressWitnessPubkeyHash())
addr := tss.BTCAddressPubkey()
if addr != nil {
c.Logf("TSS tx script: %x", addr.ScriptAddress())
}
}
func (s *SignerSuite) Test1(c *C) {
//tss := s.signer
//pkBytes := tss.Pubkey()
//c.Logf("len of pkBytes %d", len(pkBytes))
}