blake2b算法

什么是BLAKE

官网: http://www.blake2.net/

BLAKE及BLAKE2算法详解
参考URL: https://www.cnblogs.com/zhaoweiwei/p/blake.html

官网描述:
BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3. BLAKE2 has been adopted by many projects due to its high speed, security, and simplicity.

BLAKE2是一个比MD5、SHA-1、SHA-2和SHA-3更快的加密散列函数,但至少和最新的标准SHA-3一样安全。BLAKE2以其高速、安全和简单的特点被许多项目采用。

BLAKE2 is specified in RFC 7693, and our code and test vectors are available on GitHub, licensed under CC0 (public domain-like). BLAKE2 is also described in the 2015 book The Hash Function BLAKE.

BLAKE2是在RFC 7693中指定的,我们的代码和测试向量在GitHub上可用,在CC0(类似公共域)下授权。BLAKE2也在2015年出版的《Hash函数BLAKE》一书中描述过。

BLAKE2 comes in two flavors:
BLAKE2b (or just BLAKE2) is optimized for 64-bit platforms—including NEON-enabled ARMs—and produces digests of any size between 1 and 64 bytes
BLAKE2b(或只是BLAKE2)针对64位平台(包括支持NEON的ARMs)进行了优化,并生成1到64字节之间的任何大小的摘要
BLAKE2s is optimized for 8- to 32-bit platforms and produces digests of any size between 1 and 32 bytes
BLAKE2 includes the 4-way parallel BLAKE2bp and 8-way parallel BLAKE2sp designed for increased performance on multicore or SIMD CPUs. BLAKE2 offers these algorithms tuned to your specific requirements, such as keyed hashing (that is, MAC or PRF), hashing with a salt, updatable or incremental tree-hashing, or any combination thereof. These versions are specified in the BLAKE2 document.

BLAKE2 also includes the BLAKE2x variants, which can produce digests of arbitrary length. BLAKE2x is specified in a separate document.

BLAKE2 shines on 64-bit CPUs: on an Intel Core i5-6600 (Skylake microarchitecture, 3310MHz), BLAKE2b can process 1 gibibyte per second, or a speed rate of 3.08 cycles per byte.
BLAKE2闪耀在64位CPU上:在Intel Core i5-6600(Skylake微体系结构,3310MHz)上,BLAKE2b每秒可处理1吉比特,或每字节3.08个周期的速度。

The plot below shows how BLAKE2 outperforms MD5, SHA-1, SHA-2, and SHA-3 on a Skylake Intel CPU (speeds are for hashing using a single core; using multiple cores, BLAKE2 can be even faster):
下图显示了BLAKE2在Skylake Intel CPU上的性能如何优于MD5、SHA-1、SHA-2和SHA-3(下图使用单核进行哈希运算;使用多核时,BLAKE2可能更快)
在这里插入图片描述

总结:BLAKE2b 性能强劲,超越很多哈希算法。总之,根据官网描述,又安全有快!

为什么BLAKE2 如此之快?

BLAKE2 is fast in software because it exploits features of modern CPUs, namely instruction-level parallelism, SIMD instruction set extensions, and multiple cores. BLAKE2 also benefits from the optimization work performed during the SHA-3 competition (see for example this paper by two of the designers of BLAKE2).

BLAKE2在软件方面很快,因为它利用了现代cpu的特点,即 指令级并行、SIMD指令集扩展和多核。 BLAKE2还受益于SHA-3竞赛期间执行的优化工作(参见BLAKE2的两位设计师的示例本文)。

我该用哪一个?BLAKE2b、BLAKE2s、BLAKE2bp还是BLAKE2sp?

Q: Which should I use? BLAKE2b, BLAKE2s, BLAKE2bp, or BLAKE2sp?
A: A rule of thumb is that on 64-bit platforms the best choice is BLAKE2b, whereas on 32-bit (or smaller) platforms BLAKE2s is recommended. Or, you could try each of the four of them and see which one performs best on your deployment platform. If you do that, please write to us and let us know what you found.

Q: 我该用哪一个?BLAKE2b、BLAKE2s、BLAKE2bp还是BLAKE2sp?

A: **经验法则是,在64位平台上,最好的选择是BLAKE2b,而在32位(或更小)平台上,建议使用BLAKE2s。**或者,您可以分别尝试这四种方法,看看哪种方法在您的部署平台上性能最好。如果你这样做了,请写信告诉我们你发现了什么。

go语言下使用 bake2b

go 包 “github.com/minio/blake2b-simd”

filecoin lotus使用demo:

func (t *Ticket) Less(o *Ticket) bool {
	tDigest := blake2b.Sum256(t.VRFProof)
	oDigest := blake2b.Sum256(o.VRFProof)
	return bytes.Compare(tDigest[:], oDigest[:]) < 0
}

总结:直接引入 go 依赖包,调blake2b.Sum256传入 []byte 字节数组变量即可,返回计算的哈希值 。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西京刀客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值