//生成私钥和公钥
func newKeyPair() (ecdsa.PrivateKey,[]byte){
//生成椭圆曲线, secp256r1 曲线。 比特币当中的曲线是secp256k1
curve :=elliptic.P256()
private,err :=ecdsa.GenerateKey(curve,rand.Reader)
if err !=nil{
fmt.Println("error")
}
pubkey :=append(private.PublicKey.X.Bytes(),private.PublicKey.Y.Bytes()...)
return *private,pubkey
}
func main(){
//调用函数生成公钥
privatekey,public :=newKeyPair()
//打印私钥 曲线上的x点
fmt.Printf("%x\n",privatekey.D.Bytes())
//打印公钥, 曲线上的x点和y点
fmt.Printf("%x",public)
}
-
本文链接: https://dreamerjonson.com/2018/12/07/golang-35-blockchain-publickey/
-
版权声明: 本博客所有文章除特别声明外,均采用 CC BY 4.0 CN协议 许可协议。转载请注明出处!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 如何为区块链生成公钥和私钥
- 区块秘史|密码朋克的死亡圣器:公钥加密
- 从0到1学习区块链–私钥、公钥、钱包地址的含义
- 简述密码学应用四阶段:对称加密、公钥加密、区块链与高等密码学
- bitcoin:压缩公钥与未压缩公钥
- [学习笔记] “付款到公钥” 和 “付款到公钥哈希”
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Programming in Haskell
Graham Hutton / Cambridge University Press / 2007-1-18 / GBP 34.99
Haskell is one of the leading languages for teaching functional programming, enabling students to write simpler and cleaner code, and to learn how to structure and reason about programs. This introduc......一起来看看 《Programming in Haskell》 这本书的介绍吧!
在线进制转换器
各进制数互转换器
XML、JSON 在线转换
在线XML、JSON转换工具