github.com/turingchain2020/turingchain@v1.1.21/util/private.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package util
     6  
     7  import (
     8  	"github.com/turingchain2020/turingchain/common"
     9  	"github.com/turingchain2020/turingchain/common/crypto"
    10  	"github.com/turingchain2020/turingchain/types"
    11  )
    12  
    13  //TestPrivkeyHex :
    14  var TestPrivkeyHex = []string{
    15  	"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01",
    16  	"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944",
    17  	"B0BB75BC49A787A71F4834DA18614763B53A18291ECE6B5EDEC3AD19D150C3E7",
    18  	"56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138",
    19  	"2AFF1981291355322C7A6308D46A9C9BA311AA21D94F36B43FC6A6021A1334CF",
    20  	"2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989",
    21  }
    22  
    23  /*
    24  TestPrivkeyList : crypto.PrivKey list
    25  addr:12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
    26  addr:14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
    27  addr:1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF
    28  addr:1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
    29  addr:1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa
    30  addr:1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
    31  */
    32  var TestPrivkeyList = []crypto.PrivKey{
    33  	HexToPrivkey("4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"),
    34  	HexToPrivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"),
    35  	HexToPrivkey("B0BB75BC49A787A71F4834DA18614763B53A18291ECE6B5EDEC3AD19D150C3E7"),
    36  	HexToPrivkey("56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"),
    37  	HexToPrivkey("2AFF1981291355322C7A6308D46A9C9BA311AA21D94F36B43FC6A6021A1334CF"),
    38  	HexToPrivkey("2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"),
    39  }
    40  
    41  //HexToPrivkey : convert hex string to private key
    42  func HexToPrivkey(key string) crypto.PrivKey {
    43  	cr, err := crypto.New(types.GetSignName("", types.SECP256K1))
    44  	if err != nil {
    45  		panic(err)
    46  	}
    47  	bkey, err := common.FromHex(key)
    48  	if err != nil {
    49  		panic(err)
    50  	}
    51  	priv, err := cr.PrivKeyFromBytes(bkey)
    52  	if err != nil {
    53  		panic(err)
    54  	}
    55  	return priv
    56  }