Skip to content

chia-bls-signature in go, chia bls 签名工具go实现

License

Notifications You must be signed in to change notification settings

chuwt/chia-bls-go

Repository files navigation

chia-bls-go

  • go版本chia签名, 参考python-impl实现部分功能,并非bls的完全实现

Bug fix

  • 2024/01/18 Thanks for the code from coolaj86, a bug for checking length of pks on coreAggregateVerify was fixed!

  • 2023/07/08 Thanks for the report from goomario, a bug was fixed!

    • This bug was caused by the wrong use of big.Int.Bytes(), it should be replaced with big.Int.FillBytes()

主要功能

  • 生成私钥
    • 助记词
    • seed
    • hexString
    • bytes
  • 签名
  • 验签
  • 多签
  • 多签验证

安装说明

go get github.com/chuwt/chia-bls-go

使用说明

加载私钥

  1. 助记词加载
func KeyGenWithMnemonic(mnemonic, password string) PrivateKey
  1. hex string加载
func KeyFromHexString(key string) (PrivateKey, error)
  1. bytes加载
func KeyFromHexString(key string) (PrivateKey, error)

私钥

  1. 生成bytes
func (key PrivateKey) Bytes() []byte
  1. 生成hex string
func (key PrivateKey) Hex() string
  1. 派生farmerSk
func (key PrivateKey) FarmerSk() PrivateKey
  1. 派生poolSk
func (key PrivateKey) PoolSk() PrivateKey 
  1. 派生walletSk
func (key PrivateKey) WalletSk(index int) PrivateKey
  1. 派生localSk
func (key PrivateKey) LocalSk() PrivateKey
  1. 生成SyntheticSk
func (key PrivateKey) SyntheticSk(hiddenPuzzleHash []byte) PrivateKey
  1. 生成公钥
func (key PrivateKey) GetPublicKey() PublicKey

公钥

  1. 生成指纹(fingerprint)
func (key PublicKey) FingerPrint() string
  1. 生成bytes
func (key PublicKey) Bytes() []byte
  1. 生成hex string
func (key PublicKey) Hex() string

签名

  1. 签名
func (asm *AugSchemeMPL) Sign(sk PrivateKey, message []byte)
  1. 验证
func (asm *AugSchemeMPL) Verify(pk PublicKey, message []byte, sig []byte) bool
  1. 多签
// 将多个签名联合在一起
func (asm *AugSchemeMPL) Aggregate(signatures ...[]byte) ([]byte, error)
  1. 多签验证
// 公钥数组,原始信息数组,多签返回的数据
func (asm *AugSchemeMPL) AggregateVerify(pks [][]byte, messages [][]byte, sig []byte) bool
  1. 前置公钥签名
// 前置公钥签名
SignWithPrependPK(sk PrivateKey, prependPK PublicKey, message []byte)

About

chia-bls-signature in go, chia bls 签名工具go实现

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •