init: v1.0.0
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package ec256
|
||||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"xdx.jelly/xgcl/internal"
|
||||
)
|
||||
|
||||
const debug = false
|
||||
|
||||
func printFuncName() {
|
||||
if debug {
|
||||
fmt.Println("Calling " + internal.GetFuncName())
|
||||
}
|
||||
}
|
||||
|
||||
var _ elliptic.Curve = SM2CurveParam{}
|
||||
|
||||
// SM2CurveParam CurveParams已经实现了crypto.Curve接口,增加一层把点乘等函数覆盖了。
|
||||
type SM2CurveParam struct {
|
||||
*elliptic.CurveParams
|
||||
}
|
||||
|
||||
type combinedMulter interface {
|
||||
CombinedMult(bigX, bigY *big.Int, baseScalar, scalar []byte) (x, y *big.Int)
|
||||
}
|
||||
|
||||
// p = 2^256 - 2^224 - 2^96 + 2^64 -1
|
||||
var c256 = SM2CurveParam{CurveParams: &elliptic.CurveParams{
|
||||
Name: "Curve SM2",
|
||||
P: bigFromBase16("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF"),
|
||||
N: bigFromBase16("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123"),
|
||||
B: bigFromBase16("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93"),
|
||||
Gx: bigFromBase16("32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7"),
|
||||
Gy: bigFromBase16("BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0"),
|
||||
BitSize: 256},
|
||||
}
|
||||
|
||||
var Curve256 = c256
|
||||
|
||||
// EC256 returns the sm2-curve
|
||||
func EC256() elliptic.Curve {
|
||||
return c256
|
||||
}
|
||||
|
||||
func CurveSM2() elliptic.Curve {
|
||||
return c256
|
||||
}
|
||||
|
||||
func (SM2CurveParam) CombinedMult(bigX, bigY *big.Int, baseScalar, scalar []byte) (x, y *big.Int) {
|
||||
return CombinedMult(bigX, bigY, baseScalar, scalar)
|
||||
}
|
||||
Reference in New Issue
Block a user