Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
a02e3273
Commit
a02e3273
authored
Nov 21, 2018
by
pengjun
Committed by
vipwzw
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linter warning
parent
a3f9db50
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
71 additions
and
48 deletions
+71
-48
cryptogen.go
plugin/dapp/cert/authority/tools/cryptogen/cryptogen.go
+3
-0
csp.go
...in/dapp/cert/authority/tools/cryptogen/factory/csp/csp.go
+1
-0
sm2key.go
...dapp/cert/authority/tools/cryptogen/factory/csp/sm2key.go
+12
-12
keys.go
...dapp/cert/authority/tools/cryptogen/factory/utils/keys.go
+3
-3
generator.go
...app/cert/authority/tools/cryptogen/generator/generator.go
+1
-1
generatorimpl.go
...authority/tools/cryptogen/generator/impl/generatorimpl.go
+3
-3
certutils.go
...rt/authority/tools/cryptogen/generator/utils/certutils.go
+4
-4
csputils.go
...ert/authority/tools/cryptogen/generator/utils/csputils.go
+3
-3
io.go
plugin/dapp/cert/authority/utils/io.go
+6
-6
keys.go
plugin/dapp/cert/authority/utils/keys.go
+2
-2
const.go
plugin/dapp/cert/types/const.go
+1
-0
errors.go
plugin/dapp/cert/types/errors.go
+3
-0
types.go
plugin/dapp/cert/types/types.go
+5
-5
poker.go
plugin/dapp/pokerbull/executor/poker.go
+11
-5
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+5
-2
const.go
plugin/dapp/pokerbull/types/const.go
+8
-2
No files found.
plugin/dapp/cert/authority/tools/cryptogen/cryptogen.go
View file @
a02e3273
...
...
@@ -19,8 +19,11 @@ import (
const
(
// CANAME 默认CA名称
CANAME
=
"ca"
// CONFIGFILENAME 配置文件名
CONFIGFILENAME
=
"chain33.cryptogen.toml"
// OUTPUTDIR 证书文件输出路径
OUTPUTDIR
=
"./authdir/crypto"
// ORGNAME 默认组织名
ORGNAME
=
"Chain33"
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/factory/csp/csp.go
View file @
a02e3273
...
...
@@ -9,6 +9,7 @@ import "crypto"
const
(
// ECDSAP256KeyGen ECDSA类型
ECDSAP256KeyGen
=
1
// SM2P256KygGen SM2类型
SM2P256KygGen
=
2
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/factory/csp/sm2key.go
View file @
a02e3273
...
...
@@ -13,17 +13,17 @@ import (
"github.com/tjfoc/gmsm/sm2"
)
// SM2PrivateKey
// SM2PrivateKey
sm2私钥结构
type
SM2PrivateKey
struct
{
PrivKey
*
sm2
.
PrivateKey
}
// Bytes
// Bytes
sm2私钥转成byte
func
(
k
*
SM2PrivateKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
return
nil
,
errors
.
New
(
"Not supported"
)
}
// SKI
// SKI
sm2私钥ski
func
(
k
*
SM2PrivateKey
)
SKI
()
(
ski
[]
byte
)
{
if
k
.
PrivKey
==
nil
{
return
nil
...
...
@@ -36,27 +36,27 @@ func (k *SM2PrivateKey) SKI() (ski []byte) {
return
hash
.
Sum
(
nil
)
}
// Symmetric
// Symmetric
sm2私钥Symmetric
func
(
k
*
SM2PrivateKey
)
Symmetric
()
bool
{
return
false
}
// Private
// Private
sm2私钥
func
(
k
*
SM2PrivateKey
)
Private
()
bool
{
return
true
}
// PublicKey
// PublicKey
sm2私钥对应公钥
func
(
k
*
SM2PrivateKey
)
PublicKey
()
(
Key
,
error
)
{
return
&
SM2PublicKey
{
&
k
.
PrivKey
.
PublicKey
},
nil
}
// SM2PublicKey
// SM2PublicKey
sm2公钥结构
type
SM2PublicKey
struct
{
PubKey
*
sm2
.
PublicKey
}
// Bytes
// Bytes
sm2公钥转成byte
func
(
k
*
SM2PublicKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
raw
,
err
=
sm2
.
MarshalSm2PublicKey
(
k
.
PubKey
)
if
err
!=
nil
{
...
...
@@ -65,7 +65,7 @@ func (k *SM2PublicKey) Bytes() (raw []byte, err error) {
return
}
// SKI
// SKI
sm2公钥ski
func
(
k
*
SM2PublicKey
)
SKI
()
(
ski
[]
byte
)
{
if
k
.
PubKey
==
nil
{
return
nil
...
...
@@ -78,17 +78,17 @@ func (k *SM2PublicKey) SKI() (ski []byte) {
return
hash
.
Sum
(
nil
)
}
// Symmetric
// Symmetric
sm2公钥Symmetric
func
(
k
*
SM2PublicKey
)
Symmetric
()
bool
{
return
false
}
// Private
// Private
是否sm2私钥
func
(
k
*
SM2PublicKey
)
Private
()
bool
{
return
false
}
// PublicKey
// PublicKey
sm2公钥
func
(
k
*
SM2PublicKey
)
PublicKey
()
(
Key
,
error
)
{
return
k
,
nil
}
plugin/dapp/cert/authority/tools/cryptogen/factory/utils/keys.go
View file @
a02e3273
...
...
@@ -44,7 +44,7 @@ func oidFromNamedCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, bool) {
return
nil
,
false
}
// PrivateKeyToPEM
// PrivateKeyToPEM
私钥转pem
func
PrivateKeyToPEM
(
privateKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
if
len
(
pwd
)
!=
0
{
return
privateKeyToEncryptedPEM
(
privateKey
,
pwd
)
...
...
@@ -138,7 +138,7 @@ func privateKeyToEncryptedPEM(privateKey interface{}, pwd []byte) ([]byte, error
}
}
// PublicKeyToPEM
// PublicKeyToPEM
公钥转pem
func
PublicKeyToPEM
(
publicKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
if
len
(
pwd
)
!=
0
{
return
publicKeyToEncryptedPEM
(
publicKey
,
pwd
)
...
...
@@ -225,7 +225,7 @@ func DERToPublicKey(raw []byte) (pub interface{}, err error) {
return
key
,
err
}
// Clone
// Clone
克隆结构
func
Clone
(
src
[]
byte
)
[]
byte
{
clone
:=
make
([]
byte
,
len
(
src
))
copy
(
clone
,
src
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/generator.go
View file @
a02e3273
...
...
@@ -6,7 +6,7 @@ package generator
import
"crypto/x509"
// CAGenerator
// CAGenerator
CA生成器接口
type
CAGenerator
interface
{
SignCertificate
(
baseDir
,
name
string
,
sans
[]
string
,
pub
interface
{})
(
*
x509
.
Certificate
,
error
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/impl/generatorimpl.go
View file @
a02e3273
...
...
@@ -25,14 +25,14 @@ import (
"github.com/tjfoc/gmsm/sm2"
)
// EcdsaCA
// EcdsaCA
ecdsa CA结构
type
EcdsaCA
struct
{
Name
string
Signer
crypto
.
Signer
SignCert
*
x509
.
Certificate
}
// SM2CA
// SM2CA
SM2 CA结构
type
SM2CA
struct
{
Name
string
Signer
crypto
.
Signer
...
...
@@ -40,7 +40,7 @@ type SM2CA struct {
Sm2Key
csp
.
Key
}
// NewCA
// NewCA
根据类型生成CA生成器
func
NewCA
(
baseDir
,
name
string
,
signType
int
)
(
generator
.
CAGenerator
,
error
)
{
if
signType
==
ty
.
AuthECDSA
{
return
newEcdsaCA
(
baseDir
,
name
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/certutils.go
View file @
a02e3273
...
...
@@ -11,7 +11,7 @@ import (
"github.com/tjfoc/gmsm/sm2"
)
// CreateCertificateToMem
// CreateCertificateToMem
证书转mem
func
CreateCertificateToMem
(
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
cert
[]
byte
,
err
error
)
{
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
...
...
@@ -26,7 +26,7 @@ func CreateCertificateToMem(template, parent *sm2.Certificate, key csp.Key) (cer
return
}
// CreateCertificateToPem
// CreateCertificateToPem
证书转pem
func
CreateCertificateToPem
(
FileName
string
,
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
bool
,
error
)
{
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
...
...
@@ -46,7 +46,7 @@ func CreateCertificateToPem(FileName string, template, parent *sm2.Certificate,
return
result
,
err
}
// ParseX509CertificateToSm2
// ParseX509CertificateToSm2
解析x509格式为sm2格式证书
func
ParseX509CertificateToSm2
(
x509Cert
*
x509
.
Certificate
)
*
sm2
.
Certificate
{
sm2cert
:=
&
sm2
.
Certificate
{
Raw
:
x509Cert
.
Raw
,
...
...
@@ -106,7 +106,7 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
return
sm2cert
}
// ParseSm2CertificateToX509
// ParseSm2CertificateToX509
解析sm2格式证书为x509格式
func
ParseSm2CertificateToX509
(
sm2Cert
*
sm2
.
Certificate
)
*
x509
.
Certificate
{
if
sm2Cert
==
nil
{
return
nil
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/csputils.go
View file @
a02e3273
...
...
@@ -30,7 +30,7 @@ func getCSPFromOpts(KeyStorePath string) (csp.CSP, error) {
return
csp
.
New
(
fks
)
}
// GeneratePrivateKey
// GeneratePrivateKey
生成私钥
func
GeneratePrivateKey
(
keystorePath
string
,
opt
int
)
(
csp
.
Key
,
crypto
.
Signer
,
error
)
{
var
err
error
var
priv
csp
.
Key
...
...
@@ -49,7 +49,7 @@ func GeneratePrivateKey(keystorePath string, opt int) (csp.Key, crypto.Signer, e
return
priv
,
s
,
err
}
// GetECPublicKey
// GetECPublicKey
获取ecdsa公钥
func
GetECPublicKey
(
priv
csp
.
Key
)
(
*
ecdsa
.
PublicKey
,
error
)
{
pubKey
,
err
:=
priv
.
PublicKey
()
if
err
!=
nil
{
...
...
@@ -68,7 +68,7 @@ func GetECPublicKey(priv csp.Key) (*ecdsa.PublicKey, error) {
return
ecPubKey
.
(
*
ecdsa
.
PublicKey
),
nil
}
// GetSM2PublicKey
// GetSM2PublicKey
获取sm2公钥
func
GetSM2PublicKey
(
priv
csp
.
Key
)
(
*
sm2
.
PublicKey
,
error
)
{
pubKey
,
err
:=
priv
.
PublicKey
()
if
err
!=
nil
{
...
...
plugin/dapp/cert/authority/utils/io.go
View file @
a02e3273
...
...
@@ -12,7 +12,7 @@ import (
"os"
)
// DirMissingOrEmpty
// DirMissingOrEmpty
路径是否为空
func
DirMissingOrEmpty
(
path
string
)
(
bool
,
error
)
{
dirExists
,
err
:=
DirExists
(
path
)
if
err
!=
nil
{
...
...
@@ -32,7 +32,7 @@ func DirMissingOrEmpty(path string) (bool, error) {
return
false
,
nil
}
// DirExists
// DirExists
目录是否存在
func
DirExists
(
path
string
)
(
bool
,
error
)
{
_
,
err
:=
os
.
Stat
(
path
)
if
err
==
nil
{
...
...
@@ -44,7 +44,7 @@ func DirExists(path string) (bool, error) {
return
false
,
err
}
// DirEmpty
// DirEmpty
目录是否为空
func
DirEmpty
(
path
string
)
(
bool
,
error
)
{
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
...
...
@@ -59,7 +59,7 @@ func DirEmpty(path string) (bool, error) {
return
false
,
err
}
// ReadFile
// ReadFile
读取文件
func
ReadFile
(
file
string
)
([]
byte
,
error
)
{
fileCont
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
...
...
@@ -69,7 +69,7 @@ func ReadFile(file string) ([]byte, error) {
return
fileCont
,
nil
}
// ReadPemFile
// ReadPemFile
读取pem文件
func
ReadPemFile
(
file
string
)
([]
byte
,
error
)
{
bytes
,
err
:=
ReadFile
(
file
)
if
err
!=
nil
{
...
...
@@ -84,7 +84,7 @@ func ReadPemFile(file string) ([]byte, error) {
return
bytes
,
nil
}
// DeleteFile
// DeleteFile
删除文件
func
DeleteFile
(
file
string
)
error
{
return
os
.
Remove
(
file
)
}
plugin/dapp/cert/authority/utils/keys.go
View file @
a02e3273
...
...
@@ -25,7 +25,7 @@ import (
"github.com/tjfoc/gmsm/sm2"
)
// SKI
// SKI
计算ski
func
SKI
(
curve
elliptic
.
Curve
,
x
,
y
*
big
.
Int
)
(
ski
[]
byte
)
{
raw
:=
elliptic
.
Marshal
(
curve
,
x
,
y
)
...
...
@@ -34,7 +34,7 @@ func SKI(curve elliptic.Curve, x, y *big.Int) (ski []byte) {
return
hash
.
Sum
(
nil
)
}
// GetPublicKeySKIFromCert
// GetPublicKeySKIFromCert
从cert字节中获取公钥ski
func
GetPublicKeySKIFromCert
(
cert
[]
byte
,
signType
int
)
(
string
,
error
)
{
dcert
,
_
:=
pem
.
Decode
(
cert
)
if
dcert
==
nil
{
...
...
plugin/dapp/cert/types/const.go
View file @
a02e3273
...
...
@@ -7,6 +7,7 @@ package types
var
(
// CertX cert执行器名
CertX
=
"cert"
// ExecerCert cert执行器字节
ExecerCert
=
[]
byte
(
CertX
)
actionName
=
map
[
string
]
int32
{
"New"
:
CertActionNew
,
...
...
plugin/dapp/cert/types/errors.go
View file @
a02e3273
...
...
@@ -9,7 +9,10 @@ import "errors"
var
(
// ErrValidateCertFailed cert校验失败
ErrValidateCertFailed
=
errors
.
New
(
"ErrValidateCertFailed"
)
// ErrGetHistoryCertData 获取证书错误
ErrGetHistoryCertData
=
errors
.
New
(
"ErrGetHistoryCertData"
)
// ErrUnknowAuthSignType 无效签名类型
ErrUnknowAuthSignType
=
errors
.
New
(
"ErrUnknowAuthSignType"
)
// ErrInitializeAuthority 初始化校验器失败
ErrInitializeAuthority
=
errors
.
New
(
"ErrInitializeAuthority"
)
)
plugin/dapp/cert/types/types.go
View file @
a02e3273
...
...
@@ -28,29 +28,29 @@ type CertType struct {
types
.
ExecTypeBase
}
// NewType
// NewType
新建cert类型结构
func
NewType
()
*
CertType
{
c
:=
&
CertType
{}
c
.
SetChild
(
c
)
return
c
}
// GetPayload
// GetPayload
获取payload
func
(
b
*
CertType
)
GetPayload
()
types
.
Message
{
return
&
CertAction
{}
}
// GetName
// GetName
获取执行器名
func
(
b
*
CertType
)
GetName
()
string
{
return
CertX
}
// GetLogMap
// GetLogMap
获取logmap
func
(
b
*
CertType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
nil
}
// GetTypeMap
// GetTypeMap
获取类型map
func
(
b
*
CertType
)
GetTypeMap
()
map
[
string
]
int32
{
return
actionName
}
plugin/dapp/pokerbull/executor/poker.go
View file @
a02e3273
...
...
@@ -12,27 +12,33 @@ import (
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
// 牌数,4 * 13 不带大小王
//
PokerCardNum
牌数,4 * 13 不带大小王
var
PokerCardNum
=
52
// 牌花色偏移
//
ColorOffset
牌花色偏移
var
ColorOffset
uint32
=
8
// 牌花色bit掩码
//
ColorBitMask
牌花色bit掩码
var
ColorBitMask
=
0xFF
// 每种花色的牌数
//
CardNumPerColor
每种花色的牌数
var
CardNumPerColor
=
13
// 一手牌的牌数
//
CardNumPerGame
一手牌的牌数
var
CardNumPerGame
=
5
const
(
// PokerbullResultX1 赌注倍数1倍
PokerbullResultX1
=
1
// PokerbullResultX2 赌注倍数2倍
PokerbullResultX2
=
2
// PokerbullResultX3 赌注倍数3倍
PokerbullResultX3
=
3
// PokerbullResultX4 赌注倍数4倍
PokerbullResultX4
=
4
// PokerbullResultX5 赌注倍数5倍
PokerbullResultX5
=
5
// PokerbullLeverageMax 赌注倍数最大倍数
PokerbullLeverageMax
=
PokerbullResultX1
)
...
...
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
a02e3273
...
...
@@ -21,10 +21,13 @@ import (
const
(
// ListDESC 降序
ListDESC
=
int32
(
0
)
DefaultCount
=
int32
(
20
)
//默认一次取多少条记录
// DefaultCount 默认一次取多少条记录
DefaultCount
=
int32
(
20
)
// MaxPlayerNum 最大玩家数
MaxPlayerNum
=
5
// MinPlayValue 最小赌注
MinPlayValue
=
10
*
types
.
Coin
// DefaultStyle 默认游戏类型
DefaultStyle
=
pkt
.
PlayStyleDefault
)
...
...
plugin/dapp/pokerbull/types/const.go
View file @
a02e3273
...
...
@@ -13,16 +13,20 @@ const (
)
const
(
// PlayStyleDefault 游戏类型
// PlayStyleDefault
默认
游戏类型
PlayStyleDefault
=
iota
+
1
// PlayStyleDealer 庄家玩法
PlayStyleDealer
)
const
(
// TyLogPBGameStart log for PBgame
// TyLogPBGameStart log for
start
PBgame
TyLogPBGameStart
=
721
// TyLogPBGameContinue log for continue PBgame
TyLogPBGameContinue
=
722
// TyLogPBGameQuit log for quit PBgame
TyLogPBGameQuit
=
723
// TyLogPBGameQuery log for query PBgame
TyLogPBGameQuery
=
724
)
...
...
@@ -40,6 +44,8 @@ const (
FuncNameQueryGameListByIds
=
"QueryGameListByIds"
// FuncNameQueryGameById 根据id查询game
FuncNameQueryGameById
=
"QueryGameById"
// FuncNameQueryGameByAddr 根据地址查询game
FuncNameQueryGameByAddr
=
"QueryGameByAddr"
// FuncNameQueryGameByStatus 根据status查询game
FuncNameQueryGameByStatus
=
"QueryGameByStatus"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment