当前位置: 首页 > news >正文

巴中做网站公司怎样用腾讯云做网站

巴中做网站公司,怎样用腾讯云做网站,建设厅电工证查询网站,辽阳专业建设网站文章目录 Go 语言 big.Int应用场景:大整数位运算使用举例: go sdk中crypto/ecdsa 椭圆曲线生成私钥相关结构中就有使用 Go 语言 big.Int Go 语言 big.Int 参考URL: https://blog.csdn.net/wzygis/article/details/82867793 math/big 作为 Go 语言提供的…

文章目录

    • Go 语言 big.Int
    • 应用场景:大整数位运算
    • 使用举例: go sdk中crypto/ecdsa 椭圆曲线生成私钥相关结构中就有使用

Go 语言 big.Int

Go 语言 big.Int
参考URL: https://blog.csdn.net/wzygis/article/details/82867793

math/big 作为 Go 语言提供的进行大数操作的官方库。

big.Int 用于表示 大整数。

应用场景:大整数位运算

在密码学、加密算法或者需要处理大数字的领域中,使用大整数进行位操作是非常常见的。

实战demo:来自cosmos的 bip39.go

  ...// Break entropy up into sentenceLength chunks of 11 bits// For each word AND mask the rightmost 11 bits and find the word at that index// Then bitshift entropy 11 bits right and repeat// Add to the last empty slot so we can work with LSBs instead of MSB// Entropy as an int so we can bitmask without worrying about bytes slicesentropyInt := new(big.Int).SetBytes(entropy)// Slice to hold words inwords := make([]string, sentenceLength)// Throw away big int for AND maskingword := big.NewInt(0)for i := sentenceLength - 1; i >= 0; i-- {// Get 11 right most bits and bitshift 11 to the right for next timeword.And(entropyInt, Last11BitsMask)entropyInt.Div(entropyInt, RightShift11BitsDivider)// Get the bytes representing the 11 bits as a 2 byte slicewordBytes := padByteSlice(word.Bytes(), 2)// Convert bytes to an index and add that word to the listwords[i] = WordList[binary.BigEndian.Uint16(wordBytes)]}return strings.Join(words, " "), nil
}

代码解析:

entropyInt := new(big.Int).SetBytes(entropy) 这行代码的作用是将字节切片 entropy 转换为大整数。

将这些字节数据转换为大整数可以方便进行位操作、数学运算等操作,同时也能保持精度和范围。因此,将字节转换为大整数是一种常见的做法

  • 将熵(entropy)分成长度为 sentenceLength 的 11 位比特。
  • 对于每个单词,将最右边的 11 位进行按位与(AND)运算,并找到该索引位置的单词。
  • 然后将熵向右移动 11 位,重复上述操作。

使用举例: go sdk中crypto/ecdsa 椭圆曲线生成私钥相关结构中就有使用

举例:
比如 go sdk中crypto/ecdsa 椭圆曲线生成私钥相关结构中就有使用到,demo如下:
key, err := ecdsa.GenerateKey(secp256k1.S256(), seed)

// PublicKey represents an ECDSA public key.
type PublicKey struct {elliptic.CurveX, Y *big.Int
}// PrivateKey represents an ECDSA private key.
type PrivateKey struct {PublicKeyD *big.Int
}
http://www.yayakq.cn/news/504428/

相关文章:

  • 可以做视频的一个网站百度网站提交收录入口
  • 浦东企业网站建设怎么学网站设计
  • 手机网站建设请示重庆璧山网站制作公司推荐
  • 今朝装饰和业之峰哪个好网络优化公司有哪些
  • 北京怎样建设公司网站做网站最简单
  • 怎样做网站分流赚钱做电影网站收入
  • 网站建设信息安全要求不正规网站制作
  • logo设计在线生成免费商标搜索引擎营销简称seo
  • 云服务器可以做两个网站免费同城信息发布平台
  • 礼县网站建设专门做娱乐场所的设计网站
  • 山东郓城住房和城乡建设厅网站上海网站建设费用多少
  • 网站开发的私活品牌建设提升
  • 宁波企业网站设计宝应seo
  • 外贸网站优化推广网页设计:编程学习网站素材
  • 视频网站怎么做统计上海网站建设 百家号
  • 给人做ppt的网站长景园林这个网站谁做的
  • 城市门户网站策划书个人网站需要什么页面
  • 网站建设调研报告的前言潍坊企业宣传片制作公司
  • 商城网站如何优化企业做网络推广有什么好处
  • 郴州市网站建设老王传奇新开网站
  • 做图素材网站开通会员哪个好商业网站导航怎么做
  • 惠州网站建设开发团队关于网站建设相关文章
  • 嘉兴有哪些做网站的公司软件仓库
  • python网站开发高并发网站备案时网站没有内容可以
  • 建设一个网站费用制作网站公司合同注意事项
  • wordpress配置邮件服务器长沙网站seo推广公司
  • 网站建设不完整什么意思婚恋网站 模板
  • 珠海网站设计网站建设的一些原理
  • 百度推广包做网站吗wordpress阅读量作弊
  • 网站建设6000元网站怎么伪静态