multisign

package
v0.0.0-...-05508b9 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinimumParticipant = 2
)

Variables

View Source
var (
	InvalidInputParamsError        = errors.New("Invalid input params")
	NotExactTheSameCurveInputError = errors.New("The private keys of all the keys are not using the the same curve")

	TooSmallNumOfkeysError = errors.New("The total num of keys should be greater than one")
	EmptyMessageError      = errors.New("Message to be sign should not be nil")
	NotValidSignatureError = errors.New("Signature is invalid")
)

Functions

func GenerateMultiSignSignature

func GenerateMultiSignSignature(s []byte, r []byte) ([]byte, error)

生成多重签名的流程如下: 1. 各方分别生成自己的随机数Ki(K1, K2, ..., Kn) --- func getRandomBytes() ([]byte, error) 2. 各方计算自己的 Ri = Ki*G,G代表基点 --- func getRiUsingRandomBytes(key *ecdsa.PublicKey, k []byte) []byte 3. 发起者收集Ri,计算:R = sum(Ri) --- func getRUsingAllRi(key *ecdsa.PublicKey, arrayOfRi [][]byte) []byte 4. 发起者收集公钥Pi,计算公共公钥:C = P1 + P2 + ... + Pn --- func getSharedPublicKeyForPrivateKeys(keys []*ecdsa.PrivateKey) ([]byte, error) 5. 各方计算自己的Si:si = Ki + HASH(C,R,m) * xi,x代表私钥中的参数大数D --- func getSiUsingKCRM(key *ecdsa.PrivateKey, k []byte, c []byte, r []byte, message []byte) []byte 6. 发起者收集Si,生成多重签名:(s1 + s2 + ... + sn, R) --- func getSUsingAllSi(arrayOfSi [][]byte) []byte --- func GenerateMultiSignSignature(s []byte, r []byte) (*MultiSignature, error) GenerateMultiSignSignature生成对特定消息的多重签名,所有参与签名的私钥必须使用同一条椭圆曲线 func GenerateMultiSignSignature(s []byte, r []byte) (*MultiSignature, error) {

func GetRUsingAllRi

func GetRUsingAllRi(key *ecdsa.PublicKey, arrayOfRi [][]byte) []byte

计算:R = k1*G + k2*G + ... + kn*G

func GetRandom32Bytes

func GetRandom32Bytes() ([]byte, error)

生成默认随机数Ki

func GetRiUsingRandomBytes

func GetRiUsingRandomBytes(key *ecdsa.PublicKey, k []byte) []byte

计算:Ri = Ki*G

func GetSUsingAllSi

func GetSUsingAllSi(arrayOfSi [][]byte) []byte

计算:S = sum(si)

func GetSharedPublicKeyForPublicKeys

func GetSharedPublicKeyForPublicKeys(keys []*ecdsa.PublicKey) ([]byte, error)

计算公共公钥:C = P1 + P2 + ... + Pn

func GetSiUsingKCRM

func GetSiUsingKCRM(key *ecdsa.PrivateKey, k []byte, c []byte, r []byte, message []byte) []byte

计算 si = ki + HASH(C,R,m) * xi x代表大数D,也就是私钥的关键参数

func MultiSign

func MultiSign(keys []*ecdsa.PrivateKey, message []byte) ([]byte, error)

生成多重签名的算法如下: 1. 生成公私钥对(x1, P1), (x2, P2), ..., (xn, Pn), x代表私钥中的参数大数D,P代表公钥 2. 生成临时随机数(k1, k2, ..., kn) 3. 计算:R = k1*G + k2*G + ... + kn*G,G代表基点 4. 计算公共公钥:C = P1 + P2 + ... + Pn 5. 各方计算:si = ki + HASH(C,R,m) * xi 6. 生成多重签名:(s1 + s2 + ... + sn, R) MultiSign生成对特定消息的多重签名,所有参与签名的私钥必须使用同一条椭圆曲线 func MultiSign(keys []*ecdsa.PrivateKey, message []byte) (*MultiSignature, error) {

func VerifyMultiSig

func VerifyMultiSig(keys []*ecdsa.PublicKey, signature []byte, message []byte) (bool, error)

验签算法如下: 1. 计算:e = sm3(C,R,m) 2. 计算:Rv = sG - eC 3. 如果Rv == R则返回true,否则返回false func VerifyMultiSig(keys []*ecdsa.PublicKey, signature *MultiSignature, message []byte) (bool, error) {

Types

This section is empty.

Jump to

Keyboard shortcuts

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