bls_sign

package
v0.0.0-...-ea90456 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair() (*PrivateKey, *PublicKey, error)

generate BLS private and public key pair

func Sign

func Sign(privateKey *PrivateKey, msg []byte) (blsSignature []byte, err error)

BLS signature uses a particular function, defined as: S = pk * H(m)

H is a hash function, for instance SHA256 or SM3. S is the signature. m is the message to sign. pk is the private key, which can be considered as a secret big number.

To verify the signature, check that whether the result of e(P, H(m)) is equal to e(G, S) or not. Which means that: e(P, H(m)) = e(G, S) G is the base point or the generator point. P is the public key = pk*G. e is a special elliptic curve pairing function which has this feature: e(x*P, Q) = e(P, x*Q).

It is true because of the pairing function described above: e(P, H(m)) = e(pk*G, H(m)) = e(G, pk*H(m)) = e(G, S)

func Verify

func Verify(publicKey *PublicKey, sig, msg []byte) (bool, error)

Types

type PrivateKey

type PrivateKey struct {
	X *big.Int
}

type PublicKey

type PublicKey struct {
	P *bls12_381_ecc.G2Affine
}

Jump to

Keyboard shortcuts

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