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

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