bls

package module
v0.0.0-...-c746da2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 10 Imported by: 0

README

chia-bls-go

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

主要功能

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

安装说明

go get github.com/stablyio/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)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AugSchemeDst = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_AUG_")
)
View Source
var GroupOrder = new(big.Int).SetBytes([]byte{
	115, 237, 167, 83, 41, 157, 125, 72, 51, 57, 216, 8, 9, 161, 216, 5,
	83, 189, 164, 2, 255, 254, 91, 254, 255, 255, 255, 255, 0, 0, 0, 1,
})
View Source
var Hidden = []byte{
	113, 29, 108, 78, 50, 201, 46, 83, 23, 155, 25, 148, 132, 207, 140, 137,
	117, 66, 188, 87, 242, 178, 37, 130, 121, 159, 157, 101, 126, 236, 70, 153,
}

Functions

func G1Generator

func G1Generator() *bls12381.PointG1

func Hash256

func Hash256(m []byte) []byte

Types

type AugSchemeMPL

type AugSchemeMPL struct{}

func (*AugSchemeMPL) Aggregate

func (asm *AugSchemeMPL) Aggregate(signatures ...[]byte) ([]byte, error)

Aggregate 多签

func (*AugSchemeMPL) AggregateVerify

func (asm *AugSchemeMPL) AggregateVerify(pks [][]byte, messages [][]byte, sig []byte) bool

AggregateVerify 多签验证

func (*AugSchemeMPL) Sign

func (asm *AugSchemeMPL) Sign(sk PrivateKey, message []byte) []byte

Sign 签名

func (*AugSchemeMPL) SignWithPrependPK

func (asm *AugSchemeMPL) SignWithPrependPK(sk PrivateKey, prependPK PublicKey, message []byte) []byte

SignWithPrependPK 前置pubKey签名

func (*AugSchemeMPL) Verify

func (asm *AugSchemeMPL) Verify(pk PublicKey, message []byte, sig []byte) bool

Verify 验证

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func DeriveChildSk

func DeriveChildSk(parentSk PrivateKey, index int) PrivateKey

func KeyFromBytes

func KeyFromBytes(keyBytes []byte) PrivateKey

func KeyFromHexString

func KeyFromHexString(key string) (PrivateKey, error)

func KeyGen

func KeyGen(seed []byte) PrivateKey

func KeyGenWithMnemonic

func KeyGenWithMnemonic(mnemonic, password string) PrivateKey

func (PrivateKey) Bytes

func (key PrivateKey) Bytes() []byte

Bytes 转成bytes

func (PrivateKey) FarmerSk

func (key PrivateKey) FarmerSk() PrivateKey

FarmerSk 派生farmerSk

func (PrivateKey) GetPublicKey

func (key PrivateKey) GetPublicKey() PublicKey

GetPublicKey 生成公钥

func (PrivateKey) Hex

func (key PrivateKey) Hex() string

Hex 转成hex string

func (PrivateKey) LocalSk

func (key PrivateKey) LocalSk() PrivateKey

LocalSk 派生LocalSk

func (PrivateKey) PoolSk

func (key PrivateKey) PoolSk() PrivateKey

PoolSk 派生PoolSk

func (PrivateKey) SyntheticSk

func (key PrivateKey) SyntheticSk(hiddenPuzzleHash []byte) PrivateKey

SyntheticSk 生成SyntheticSk

func (PrivateKey) WalletSk

func (key PrivateKey) WalletSk(index int) PrivateKey

WalletSk 派生WalletSk

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func NewPublicKey

func NewPublicKey(data []byte) (PublicKey, error)

func (PublicKey) Add

func (key PublicKey) Add(pk PublicKey) PublicKey

Add 组合公钥

func (PublicKey) Bytes

func (key PublicKey) Bytes() []byte

Bytes 转成bytes

func (PublicKey) FingerPrint

func (key PublicKey) FingerPrint() string

FingerPrint 生成指纹

func (PublicKey) G1

func (key PublicKey) G1() *bls12381.PointG1

G1 获取G1

func (PublicKey) Hex

func (key PublicKey) Hex() string

Hex 转成hex string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL