tencentsig

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: MIT Imports: 21 Imported by: 0

README

腾讯登录服务(Tencent Login Service,TLS) userSig 生成

支持的 curve 包括: prime256v1, secp256k1

之前腾讯云只支持 secp256k1,后来测试发现有 prime256v1 的密钥

具体使用请参考 usersig_test.go

参考资料

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitCurve

type BitCurve struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the BitCurve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
}

A BitCurve represents a Koblitz Curve with a=0. See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

func S160

func S160() *BitCurve

S160 returns a BitCurve which implements secp160k1 (see SEC 2 section 2.4.1)

func S192

func S192() *BitCurve

S192 returns a BitCurve which implements secp192k1 (see SEC 2 section 2.5.1)

func S224

func S224() *BitCurve

S224 returns a BitCurve which implements secp224k1 (see SEC 2 section 2.6.1)

func S256

func S256() *BitCurve

S256 returns a BitCurve which implements secp256k1 (see SEC 2 section 2.7.1)

func (*BitCurve) Add

func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

Add returns the sum of (x1,y1) and (x2,y2)

func (*BitCurve) Double

func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

Double returns 2*(x,y)

func (*BitCurve) GenerateKey

func (BitCurve *BitCurve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err error)

TODO: double check if it is okay GenerateKey returns a public/private key pair. The private key is generated using the given reader, which must return random data.

func (*BitCurve) IsOnCurve

func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool

IsOnBitCurve returns true if the given (x,y) lies on the BitCurve.

func (*BitCurve) Marshal

func (BitCurve *BitCurve) Marshal(x, y *big.Int) []byte

Marshal converts a point into the form specified in section 4.3.6 of ANSI X9.62.

func (*BitCurve) Params

func (BitCurve *BitCurve) Params() *elliptic.CurveParams

func (*BitCurve) ScalarBaseMult

func (BitCurve *BitCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.

func (*BitCurve) ScalarMult

func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

TODO: double check if it is okay ScalarMult returns k*(Bx,By) where k is a number in big-endian form.

func (*BitCurve) Unmarshal

func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int)

Unmarshal converts a point, serialised by Marshal, into an x, y pair. On error, x = nil.

type Conf

type Conf struct {
	AccountType string `json:"TLS.account_type"`
	Identifier  string `json:"TLS.identifier"`
	AppidAt3rd  string `json:"TLS.appid_at_3rd"`
	SdkAppid    string `json:"TLS.sdk_appid"`
	ExpireAfter string `json:"TLS.expire_after"`
	Version     string `json:"TLS.version"`
	Time        string `json:"TLS.time"`
	Sig         string `json:"TLS.sig"`
}

func NewConf

func NewConf(sdkAppId string, identifier string) *Conf

func VerifyUserSig

func VerifyUserSig(pemPublicKey string, userSig string) (*Conf, bool, error)

func (*Conf) GenUserSig

func (c *Conf) GenUserSig(pemPrivateKey string) (string, error)

func (*Conf) WithExpire

func (c *Conf) WithExpire(expireInSeconds int) *Conf

Jump to

Keyboard shortcuts

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