BLS算法-快速开始

什么是BLS算法

签名算法 - BLS签名算法介绍
参考URL: https://www.pianshen.com/article/1674283691/
硬核集 | 一文读懂 BLS 签名算法
参考URL: https://www.chainnews.com/articles/304739282403.htm
原创丨BLS算法的魔幻之处——秘钥共享与阈值签名
参考URL: http://www.beenews.pro/a/100063151.html
[推荐-写的清晰深入]理解 BLS 签名算法
原文链接:https://blog.csdn.net/shangsongwww/article/details/89486686

BLS签名算法是斯坦福大学计算机系三人提出:Dan Boneh,Ben Lynn以及Hovav Shacham。BLS的主要思想是待签名的消息散列到一个椭圆曲线上的一个点,并利用双线性映射e函数的交换性质,在不泄露私钥的情况下,验证签名。BLS的算法在签名合并,多签,m/n多签有丰富的应用。

BLS 签名算法是一种可以实现签名聚合和密钥聚合的算法(即可以将多个密钥聚合成一把密钥,将多个签名聚合成一个签名)。

签名聚合

现在让我们把区块中的签名都聚合在一起。假设一个区块中有 1000 笔交易,每笔交易都由 Si (签名),Pi (公钥)和 mi (消息)组成(i
在这里表示序号)。如果这些签名可以被合并,那又何必分开保存呢?毕竟,我们只关心区块中所有的签名(而不是每一个)是否正确。为获得聚合签名,只需要将区块中的所有签名加起来。

验签时,我们仍需用到所有的公钥,并计算 1001 次配对函数,好处是,区块中的签名只占 33 字节了。签名聚合可以由矿工在挖矿时完成,节省大量的区块空间。

bls算法应用api,可以更好帮助你理解bls可以做什么:
以filecoin louts项目 api 举例:

extern\filecoin-ffi\bls.go

// BLS

// SignatureBytes is the length of a BLS signature
const SignatureBytes = 96

// PrivateKeyBytes is the length of a BLS private key
const PrivateKeyBytes = 32

// PublicKeyBytes is the length of a BLS public key
const PublicKeyBytes = 48

// DigestBytes is the length of a BLS message hash/digest
const DigestBytes = 96

// Signature is a compressed affine
type Signature [SignatureBytes]byte

// PrivateKey is a compressed affine
type PrivateKey [PrivateKeyBytes]byte

// PublicKey is a compressed affine
type PublicKey [PublicKeyBytes]byte

// Message is a byte slice
type Message []byte

// Digest is a compressed affine
type Digest [DigestBytes]byte

// Used when generating a private key deterministically
type PrivateKeyGenSeed [32]byte

// 哈希计算消息摘要
// Hash computes the digest of a message
func Hash(message Message) Digest {

// Verify验证签名是否是digests-pubkeys的聚合签名
// Verify verifies that a signature is the aggregated signature of digests - pubkeys
func Verify(signature *Signature, digests []Digest, publicKeys []PublicKey) bool {

// HashVerify验证签名是否是哈希消息的聚合签名。
// HashVerify verifies that a signature is the aggregated signature of hashed messages.
func HashVerify(signature *Signature, messages []Message, publicKeys []PublicKey) bool {

// 聚合将签名聚合到一个新签名中
// Aggregate aggregates signatures together into a new signature
func Aggregate(signatures []Signature) *Signature {

//PrivateKeyGenerate生成私钥
// PrivateKeyGenerate generates a private key
func PrivateKeyGenerate() PrivateKey {

// PrivateKeyGenerate以可预测的方式生成私钥
// PrivateKeyGenerate generates a private key in a predictable manner
func PrivateKeyGenerateWithSeed(seed PrivateKeyGenSeed) PrivateKey {

// PrivateKeySign消息签名
// PrivateKeySign signs a message
func PrivateKeySign(privateKey PrivateKey, message Message) *Signature {

// PrivateKeyPublicKey获取私钥的公钥
// PrivateKeyPublicKey gets the public key for a private key
func PrivateKeyPublicKey(privateKey PrivateKey) PublicKey {

总结:
// 哈希计算消息摘要
// Verify验证签名是否是digests-pubkeys的聚合签名
// HashVerify验证签名是否是哈希消息的聚合签名。
// 聚合将签名聚合到一个新签名中
// PrivateKeyGenerate生成私钥
// PrivateKeyGenerate以可预测的方式生成私钥
// PrivateKeySign消息签名
// PrivateKeyPublicKey获取私钥的公钥

它可以进行 BLS签名,将多个BLS签名聚合起来一个签名,使用所有的公钥对聚合签名进行验签等功能。

相关单元测试代码,关键字: TestDeterministicPrivateKeyGeneration
路径:extern\filecoin-ffi\bls_test.go

BLS多签

BLS签名实现阈值签名的流程
参考URL: https://www.jianshu.com/p/f3793e0af600
干货 | 理解 BLS 签名算法
参考URL: https://www.8btc.com/media/396283

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章