Documentation ¶
Overview ¶
Package elliptic implements several standard elliptic curves over prime fields.
Package sm2 implements china crypto standards.
Index ¶
- Variables
- func AffineToP256Point(x, y *big.Int) (out p256Point)
- func Decrypt(c []byte, key *PrivateKey) ([]byte, error)
- func Encrypt(rand io.Reader, key *PublicKey, msg []byte) (cipher []byte, err error)
- func Hexprint(in []byte)
- func Marshal(curve Curve, x, y *big.Int) []byte
- func Sign(rand io.Reader, priv *PrivateKey, msg []byte) (r, s *big.Int, err error)
- func SignWithDigest(rand io.Reader, priv *PrivateKey, digest []byte) (r, s *big.Int, err error)
- func Sm2KeyGen(rand io.Reader) (sk, pk []byte, err error)
- func Sm2Sign(sk, pk, msg []byte) ([]byte, error)
- func Sm2Verify(sign, pk, msg []byte) bool
- func Uint64ToAffine(in []uint64) (x, y *big.Int)
- func Unmarshal(curve Curve, data []byte) (x, y *big.Int)
- func Verify(pub *PublicKey, msg []byte, r, s *big.Int) bool
- func VerifyWithDigest(pub *PublicKey, digest []byte, r, s *big.Int) bool
- type Curve
- type CurveParams
- func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
- func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool
- func (curve *CurveParams) Params() *CurveParams
- func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)
- type PrivateKey
- type PublicKey
- type Sm2PrivateKey
- type Sm2PublicKey
Constants ¶
This section is empty.
Variables ¶
View Source
var DecryptionErr = errors.New("sm2: decryption error")
View Source
var EncryptionErr = errors.New("sm2: encryption error")
Functions ¶
func AffineToP256Point ¶
func Marshal ¶
Marshal converts a point into the uncompressed form specified in section 4.3.6 of ANSI X9.62.
func SignWithDigest ¶
func Uint64ToAffine ¶
Types ¶
type Curve ¶
type Curve interface { // Params returns the parameters for the curve. Params() *CurveParams // IsOnCurve reports whether the given (x,y) lies on the curve. IsOnCurve(x, y *big.Int) bool // Add returns the sum of (x1,y1) and (x2,y2) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int) // Double returns 2*(x,y) Double(x1, y1 *big.Int) (x, y *big.Int) // ScalarMult returns k*(Bx,By) where k is a number in big-endian form. ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int) // ScalarBaseMult returns k*G, where G is the base point of the group // and k is an integer in big-endian form. ScalarBaseMult(k []byte) (x, y *big.Int) }
A Curve represents a short-form Weierstrass curve with a=-3. See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
type CurveParams ¶
type CurveParams 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 curve equation Gx, Gy *big.Int // (x,y) of the base point BitSize int // the size of the underlying field Name string // the canonical name of the curve }
CurveParams contains the parameters of an elliptic curve and also provides a generic, non-constant time implementation of Curve.
func (*CurveParams) Params ¶
func (curve *CurveParams) Params() *CurveParams
func (*CurveParams) ScalarBaseMult ¶
func (*CurveParams) ScalarMult ¶
type PrivateKey ¶
func GenerateKey ¶
func GenerateKey(rand io.Reader) (*PrivateKey, error)
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
The SM2's private key contains the public key
type Sm2PrivateKey ¶
Click to show internal directories.
Click to hide internal directories.