sm9

package
v1.0.2039 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// hashmode used in h1: 0x01
	H1 hashMode = iota + 1
	// hashmode used in h2: 0x02
	H2
)

Variables

This section is empty.

Functions

func Verify

func Verify(mpk *MasterPubKey, sig *Sm9Sig, msg []byte, id []byte, hid byte) bool

sm9 verify algorithm(given sig (h',S'), message M' and user's id): B1:compute g = e(P1,Ppub); B2:compute t = g^h'; B3:compute h1 = H1(id||hid,n); B4:compute P = h1·P2+Ppub; B5:compute u = e(S',P); B6:compute w' = u·t; B7:compute h2 = H2(M'||w',n), check if h2 = h'.

Types

type MasterKey

type MasterKey struct {
	MasterPubKey
	D *big.Int
}

MasterKey contains a master secret key and a master public key.

func MasterKeyGen

func MasterKeyGen(rand io.Reader) (mk *MasterKey, err error)

generate master key for KGC(Key Generate Center).

type MasterPubKey

type MasterPubKey struct {
	Mpk *sm9curve.G2
}

G2Bytes = G2.Marshal()

type Sm9Sig

type Sm9Sig struct {
	H *big.Int
	S *sm9curve.G1
}

Sm9Sig contains a big number and an element in G1.

func Sign

func Sign(uk *UserKey, mpk *MasterPubKey, msg []byte) (sig *Sm9Sig, err error)

sm9 sign algorithm: A1:compute g = e(P1,Ppub); A2:choose random num r in [1,n-1]; A3:compute w = g^r; A4:compute h = H2(M||w,n); A5:compute l = (r-h) mod n, if l = 0 goto A2; A6:compute S = l·sk.

type UserKey

type UserKey struct {
	Sk *sm9curve.G1
}

UserKey contains a secret key. G1Bytes = G1.Marshal()

func UserKeyGen

func UserKeyGen(mk *MasterKey, id []byte, hid byte) (uk *UserKey, err error)

generate user's secret key.

Directories

Path Synopsis
Package bn256 implements a particular bilinear group.
Package bn256 implements a particular bilinear group.

Jump to

Keyboard shortcuts

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