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
Hide 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 (
...
@@ -19,8 +19,11 @@ import (
const
(
const
(
// CANAME 默认CA名称
// CANAME 默认CA名称
CANAME
=
"ca"
CANAME
=
"ca"
// CONFIGFILENAME 配置文件名
CONFIGFILENAME
=
"chain33.cryptogen.toml"
CONFIGFILENAME
=
"chain33.cryptogen.toml"
// OUTPUTDIR 证书文件输出路径
OUTPUTDIR
=
"./authdir/crypto"
OUTPUTDIR
=
"./authdir/crypto"
// ORGNAME 默认组织名
ORGNAME
=
"Chain33"
ORGNAME
=
"Chain33"
)
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/factory/csp/csp.go
View file @
a02e3273
...
@@ -9,6 +9,7 @@ import "crypto"
...
@@ -9,6 +9,7 @@ import "crypto"
const
(
const
(
// ECDSAP256KeyGen ECDSA类型
// ECDSAP256KeyGen ECDSA类型
ECDSAP256KeyGen
=
1
ECDSAP256KeyGen
=
1
// SM2P256KygGen SM2类型
SM2P256KygGen
=
2
SM2P256KygGen
=
2
)
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/factory/csp/sm2key.go
View file @
a02e3273
...
@@ -13,17 +13,17 @@ import (
...
@@ -13,17 +13,17 @@ import (
"github.com/tjfoc/gmsm/sm2"
"github.com/tjfoc/gmsm/sm2"
)
)
// SM2PrivateKey
// SM2PrivateKey
sm2私钥结构
type
SM2PrivateKey
struct
{
type
SM2PrivateKey
struct
{
PrivKey
*
sm2
.
PrivateKey
PrivKey
*
sm2
.
PrivateKey
}
}
// Bytes
// Bytes
sm2私钥转成byte
func
(
k
*
SM2PrivateKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
func
(
k
*
SM2PrivateKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
return
nil
,
errors
.
New
(
"Not supported"
)
return
nil
,
errors
.
New
(
"Not supported"
)
}
}
// SKI
// SKI
sm2私钥ski
func
(
k
*
SM2PrivateKey
)
SKI
()
(
ski
[]
byte
)
{
func
(
k
*
SM2PrivateKey
)
SKI
()
(
ski
[]
byte
)
{
if
k
.
PrivKey
==
nil
{
if
k
.
PrivKey
==
nil
{
return
nil
return
nil
...
@@ -36,27 +36,27 @@ func (k *SM2PrivateKey) SKI() (ski []byte) {
...
@@ -36,27 +36,27 @@ func (k *SM2PrivateKey) SKI() (ski []byte) {
return
hash
.
Sum
(
nil
)
return
hash
.
Sum
(
nil
)
}
}
// Symmetric
// Symmetric
sm2私钥Symmetric
func
(
k
*
SM2PrivateKey
)
Symmetric
()
bool
{
func
(
k
*
SM2PrivateKey
)
Symmetric
()
bool
{
return
false
return
false
}
}
// Private
// Private
sm2私钥
func
(
k
*
SM2PrivateKey
)
Private
()
bool
{
func
(
k
*
SM2PrivateKey
)
Private
()
bool
{
return
true
return
true
}
}
// PublicKey
// PublicKey
sm2私钥对应公钥
func
(
k
*
SM2PrivateKey
)
PublicKey
()
(
Key
,
error
)
{
func
(
k
*
SM2PrivateKey
)
PublicKey
()
(
Key
,
error
)
{
return
&
SM2PublicKey
{
&
k
.
PrivKey
.
PublicKey
},
nil
return
&
SM2PublicKey
{
&
k
.
PrivKey
.
PublicKey
},
nil
}
}
// SM2PublicKey
// SM2PublicKey
sm2公钥结构
type
SM2PublicKey
struct
{
type
SM2PublicKey
struct
{
PubKey
*
sm2
.
PublicKey
PubKey
*
sm2
.
PublicKey
}
}
// Bytes
// Bytes
sm2公钥转成byte
func
(
k
*
SM2PublicKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
func
(
k
*
SM2PublicKey
)
Bytes
()
(
raw
[]
byte
,
err
error
)
{
raw
,
err
=
sm2
.
MarshalSm2PublicKey
(
k
.
PubKey
)
raw
,
err
=
sm2
.
MarshalSm2PublicKey
(
k
.
PubKey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -65,7 +65,7 @@ func (k *SM2PublicKey) Bytes() (raw []byte, err error) {
...
@@ -65,7 +65,7 @@ func (k *SM2PublicKey) Bytes() (raw []byte, err error) {
return
return
}
}
// SKI
// SKI
sm2公钥ski
func
(
k
*
SM2PublicKey
)
SKI
()
(
ski
[]
byte
)
{
func
(
k
*
SM2PublicKey
)
SKI
()
(
ski
[]
byte
)
{
if
k
.
PubKey
==
nil
{
if
k
.
PubKey
==
nil
{
return
nil
return
nil
...
@@ -78,17 +78,17 @@ func (k *SM2PublicKey) SKI() (ski []byte) {
...
@@ -78,17 +78,17 @@ func (k *SM2PublicKey) SKI() (ski []byte) {
return
hash
.
Sum
(
nil
)
return
hash
.
Sum
(
nil
)
}
}
// Symmetric
// Symmetric
sm2公钥Symmetric
func
(
k
*
SM2PublicKey
)
Symmetric
()
bool
{
func
(
k
*
SM2PublicKey
)
Symmetric
()
bool
{
return
false
return
false
}
}
// Private
// Private
是否sm2私钥
func
(
k
*
SM2PublicKey
)
Private
()
bool
{
func
(
k
*
SM2PublicKey
)
Private
()
bool
{
return
false
return
false
}
}
// PublicKey
// PublicKey
sm2公钥
func
(
k
*
SM2PublicKey
)
PublicKey
()
(
Key
,
error
)
{
func
(
k
*
SM2PublicKey
)
PublicKey
()
(
Key
,
error
)
{
return
k
,
nil
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) {
...
@@ -44,7 +44,7 @@ func oidFromNamedCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, bool) {
return
nil
,
false
return
nil
,
false
}
}
// PrivateKeyToPEM
// PrivateKeyToPEM
私钥转pem
func
PrivateKeyToPEM
(
privateKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
func
PrivateKeyToPEM
(
privateKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
if
len
(
pwd
)
!=
0
{
if
len
(
pwd
)
!=
0
{
return
privateKeyToEncryptedPEM
(
privateKey
,
pwd
)
return
privateKeyToEncryptedPEM
(
privateKey
,
pwd
)
...
@@ -138,7 +138,7 @@ func privateKeyToEncryptedPEM(privateKey interface{}, pwd []byte) ([]byte, error
...
@@ -138,7 +138,7 @@ func privateKeyToEncryptedPEM(privateKey interface{}, pwd []byte) ([]byte, error
}
}
}
}
// PublicKeyToPEM
// PublicKeyToPEM
公钥转pem
func
PublicKeyToPEM
(
publicKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
func
PublicKeyToPEM
(
publicKey
interface
{},
pwd
[]
byte
)
([]
byte
,
error
)
{
if
len
(
pwd
)
!=
0
{
if
len
(
pwd
)
!=
0
{
return
publicKeyToEncryptedPEM
(
publicKey
,
pwd
)
return
publicKeyToEncryptedPEM
(
publicKey
,
pwd
)
...
@@ -225,7 +225,7 @@ func DERToPublicKey(raw []byte) (pub interface{}, err error) {
...
@@ -225,7 +225,7 @@ func DERToPublicKey(raw []byte) (pub interface{}, err error) {
return
key
,
err
return
key
,
err
}
}
// Clone
// Clone
克隆结构
func
Clone
(
src
[]
byte
)
[]
byte
{
func
Clone
(
src
[]
byte
)
[]
byte
{
clone
:=
make
([]
byte
,
len
(
src
))
clone
:=
make
([]
byte
,
len
(
src
))
copy
(
clone
,
src
)
copy
(
clone
,
src
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/generator.go
View file @
a02e3273
...
@@ -6,7 +6,7 @@ package generator
...
@@ -6,7 +6,7 @@ package generator
import
"crypto/x509"
import
"crypto/x509"
// CAGenerator
// CAGenerator
CA生成器接口
type
CAGenerator
interface
{
type
CAGenerator
interface
{
SignCertificate
(
baseDir
,
name
string
,
sans
[]
string
,
pub
interface
{})
(
*
x509
.
Certificate
,
error
)
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 (
...
@@ -25,14 +25,14 @@ import (
"github.com/tjfoc/gmsm/sm2"
"github.com/tjfoc/gmsm/sm2"
)
)
// EcdsaCA
// EcdsaCA
ecdsa CA结构
type
EcdsaCA
struct
{
type
EcdsaCA
struct
{
Name
string
Name
string
Signer
crypto
.
Signer
Signer
crypto
.
Signer
SignCert
*
x509
.
Certificate
SignCert
*
x509
.
Certificate
}
}
// SM2CA
// SM2CA
SM2 CA结构
type
SM2CA
struct
{
type
SM2CA
struct
{
Name
string
Name
string
Signer
crypto
.
Signer
Signer
crypto
.
Signer
...
@@ -40,7 +40,7 @@ type SM2CA struct {
...
@@ -40,7 +40,7 @@ type SM2CA struct {
Sm2Key
csp
.
Key
Sm2Key
csp
.
Key
}
}
// NewCA
// NewCA
根据类型生成CA生成器
func
NewCA
(
baseDir
,
name
string
,
signType
int
)
(
generator
.
CAGenerator
,
error
)
{
func
NewCA
(
baseDir
,
name
string
,
signType
int
)
(
generator
.
CAGenerator
,
error
)
{
if
signType
==
ty
.
AuthECDSA
{
if
signType
==
ty
.
AuthECDSA
{
return
newEcdsaCA
(
baseDir
,
name
)
return
newEcdsaCA
(
baseDir
,
name
)
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/certutils.go
View file @
a02e3273
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
"github.com/tjfoc/gmsm/sm2"
"github.com/tjfoc/gmsm/sm2"
)
)
// CreateCertificateToMem
// CreateCertificateToMem
证书转mem
func
CreateCertificateToMem
(
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
cert
[]
byte
,
err
error
)
{
func
CreateCertificateToMem
(
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
cert
[]
byte
,
err
error
)
{
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
...
@@ -26,7 +26,7 @@ func CreateCertificateToMem(template, parent *sm2.Certificate, key csp.Key) (cer
...
@@ -26,7 +26,7 @@ func CreateCertificateToMem(template, parent *sm2.Certificate, key csp.Key) (cer
return
return
}
}
// CreateCertificateToPem
// CreateCertificateToPem
证书转pem
func
CreateCertificateToPem
(
FileName
string
,
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
bool
,
error
)
{
func
CreateCertificateToPem
(
FileName
string
,
template
,
parent
*
sm2
.
Certificate
,
key
csp
.
Key
)
(
bool
,
error
)
{
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
pk
:=
key
.
(
*
csp
.
SM2PrivateKey
)
.
PrivKey
...
@@ -46,7 +46,7 @@ func CreateCertificateToPem(FileName string, template, parent *sm2.Certificate,
...
@@ -46,7 +46,7 @@ func CreateCertificateToPem(FileName string, template, parent *sm2.Certificate,
return
result
,
err
return
result
,
err
}
}
// ParseX509CertificateToSm2
// ParseX509CertificateToSm2
解析x509格式为sm2格式证书
func
ParseX509CertificateToSm2
(
x509Cert
*
x509
.
Certificate
)
*
sm2
.
Certificate
{
func
ParseX509CertificateToSm2
(
x509Cert
*
x509
.
Certificate
)
*
sm2
.
Certificate
{
sm2cert
:=
&
sm2
.
Certificate
{
sm2cert
:=
&
sm2
.
Certificate
{
Raw
:
x509Cert
.
Raw
,
Raw
:
x509Cert
.
Raw
,
...
@@ -106,7 +106,7 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
...
@@ -106,7 +106,7 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
return
sm2cert
return
sm2cert
}
}
// ParseSm2CertificateToX509
// ParseSm2CertificateToX509
解析sm2格式证书为x509格式
func
ParseSm2CertificateToX509
(
sm2Cert
*
sm2
.
Certificate
)
*
x509
.
Certificate
{
func
ParseSm2CertificateToX509
(
sm2Cert
*
sm2
.
Certificate
)
*
x509
.
Certificate
{
if
sm2Cert
==
nil
{
if
sm2Cert
==
nil
{
return
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) {
...
@@ -30,7 +30,7 @@ func getCSPFromOpts(KeyStorePath string) (csp.CSP, error) {
return
csp
.
New
(
fks
)
return
csp
.
New
(
fks
)
}
}
// GeneratePrivateKey
// GeneratePrivateKey
生成私钥
func
GeneratePrivateKey
(
keystorePath
string
,
opt
int
)
(
csp
.
Key
,
crypto
.
Signer
,
error
)
{
func
GeneratePrivateKey
(
keystorePath
string
,
opt
int
)
(
csp
.
Key
,
crypto
.
Signer
,
error
)
{
var
err
error
var
err
error
var
priv
csp
.
Key
var
priv
csp
.
Key
...
@@ -49,7 +49,7 @@ func GeneratePrivateKey(keystorePath string, opt int) (csp.Key, crypto.Signer, e
...
@@ -49,7 +49,7 @@ func GeneratePrivateKey(keystorePath string, opt int) (csp.Key, crypto.Signer, e
return
priv
,
s
,
err
return
priv
,
s
,
err
}
}
// GetECPublicKey
// GetECPublicKey
获取ecdsa公钥
func
GetECPublicKey
(
priv
csp
.
Key
)
(
*
ecdsa
.
PublicKey
,
error
)
{
func
GetECPublicKey
(
priv
csp
.
Key
)
(
*
ecdsa
.
PublicKey
,
error
)
{
pubKey
,
err
:=
priv
.
PublicKey
()
pubKey
,
err
:=
priv
.
PublicKey
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -68,7 +68,7 @@ func GetECPublicKey(priv csp.Key) (*ecdsa.PublicKey, error) {
...
@@ -68,7 +68,7 @@ func GetECPublicKey(priv csp.Key) (*ecdsa.PublicKey, error) {
return
ecPubKey
.
(
*
ecdsa
.
PublicKey
),
nil
return
ecPubKey
.
(
*
ecdsa
.
PublicKey
),
nil
}
}
// GetSM2PublicKey
// GetSM2PublicKey
获取sm2公钥
func
GetSM2PublicKey
(
priv
csp
.
Key
)
(
*
sm2
.
PublicKey
,
error
)
{
func
GetSM2PublicKey
(
priv
csp
.
Key
)
(
*
sm2
.
PublicKey
,
error
)
{
pubKey
,
err
:=
priv
.
PublicKey
()
pubKey
,
err
:=
priv
.
PublicKey
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/cert/authority/utils/io.go
View file @
a02e3273
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"os"
"os"
)
)
// DirMissingOrEmpty
// DirMissingOrEmpty
路径是否为空
func
DirMissingOrEmpty
(
path
string
)
(
bool
,
error
)
{
func
DirMissingOrEmpty
(
path
string
)
(
bool
,
error
)
{
dirExists
,
err
:=
DirExists
(
path
)
dirExists
,
err
:=
DirExists
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -32,7 +32,7 @@ func DirMissingOrEmpty(path string) (bool, error) {
...
@@ -32,7 +32,7 @@ func DirMissingOrEmpty(path string) (bool, error) {
return
false
,
nil
return
false
,
nil
}
}
// DirExists
// DirExists
目录是否存在
func
DirExists
(
path
string
)
(
bool
,
error
)
{
func
DirExists
(
path
string
)
(
bool
,
error
)
{
_
,
err
:=
os
.
Stat
(
path
)
_
,
err
:=
os
.
Stat
(
path
)
if
err
==
nil
{
if
err
==
nil
{
...
@@ -44,7 +44,7 @@ func DirExists(path string) (bool, error) {
...
@@ -44,7 +44,7 @@ func DirExists(path string) (bool, error) {
return
false
,
err
return
false
,
err
}
}
// DirEmpty
// DirEmpty
目录是否为空
func
DirEmpty
(
path
string
)
(
bool
,
error
)
{
func
DirEmpty
(
path
string
)
(
bool
,
error
)
{
f
,
err
:=
os
.
Open
(
path
)
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -59,7 +59,7 @@ func DirEmpty(path string) (bool, error) {
...
@@ -59,7 +59,7 @@ func DirEmpty(path string) (bool, error) {
return
false
,
err
return
false
,
err
}
}
// ReadFile
// ReadFile
读取文件
func
ReadFile
(
file
string
)
([]
byte
,
error
)
{
func
ReadFile
(
file
string
)
([]
byte
,
error
)
{
fileCont
,
err
:=
ioutil
.
ReadFile
(
file
)
fileCont
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -69,7 +69,7 @@ func ReadFile(file string) ([]byte, error) {
...
@@ -69,7 +69,7 @@ func ReadFile(file string) ([]byte, error) {
return
fileCont
,
nil
return
fileCont
,
nil
}
}
// ReadPemFile
// ReadPemFile
读取pem文件
func
ReadPemFile
(
file
string
)
([]
byte
,
error
)
{
func
ReadPemFile
(
file
string
)
([]
byte
,
error
)
{
bytes
,
err
:=
ReadFile
(
file
)
bytes
,
err
:=
ReadFile
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -84,7 +84,7 @@ func ReadPemFile(file string) ([]byte, error) {
...
@@ -84,7 +84,7 @@ func ReadPemFile(file string) ([]byte, error) {
return
bytes
,
nil
return
bytes
,
nil
}
}
// DeleteFile
// DeleteFile
删除文件
func
DeleteFile
(
file
string
)
error
{
func
DeleteFile
(
file
string
)
error
{
return
os
.
Remove
(
file
)
return
os
.
Remove
(
file
)
}
}
plugin/dapp/cert/authority/utils/keys.go
View file @
a02e3273
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"github.com/tjfoc/gmsm/sm2"
"github.com/tjfoc/gmsm/sm2"
)
)
// SKI
// SKI
计算ski
func
SKI
(
curve
elliptic
.
Curve
,
x
,
y
*
big
.
Int
)
(
ski
[]
byte
)
{
func
SKI
(
curve
elliptic
.
Curve
,
x
,
y
*
big
.
Int
)
(
ski
[]
byte
)
{
raw
:=
elliptic
.
Marshal
(
curve
,
x
,
y
)
raw
:=
elliptic
.
Marshal
(
curve
,
x
,
y
)
...
@@ -34,7 +34,7 @@ func SKI(curve elliptic.Curve, x, y *big.Int) (ski []byte) {
...
@@ -34,7 +34,7 @@ func SKI(curve elliptic.Curve, x, y *big.Int) (ski []byte) {
return
hash
.
Sum
(
nil
)
return
hash
.
Sum
(
nil
)
}
}
// GetPublicKeySKIFromCert
// GetPublicKeySKIFromCert
从cert字节中获取公钥ski
func
GetPublicKeySKIFromCert
(
cert
[]
byte
,
signType
int
)
(
string
,
error
)
{
func
GetPublicKeySKIFromCert
(
cert
[]
byte
,
signType
int
)
(
string
,
error
)
{
dcert
,
_
:=
pem
.
Decode
(
cert
)
dcert
,
_
:=
pem
.
Decode
(
cert
)
if
dcert
==
nil
{
if
dcert
==
nil
{
...
...
plugin/dapp/cert/types/const.go
View file @
a02e3273
...
@@ -7,6 +7,7 @@ package types
...
@@ -7,6 +7,7 @@ package types
var
(
var
(
// CertX cert执行器名
// CertX cert执行器名
CertX
=
"cert"
CertX
=
"cert"
// ExecerCert cert执行器字节
ExecerCert
=
[]
byte
(
CertX
)
ExecerCert
=
[]
byte
(
CertX
)
actionName
=
map
[
string
]
int32
{
actionName
=
map
[
string
]
int32
{
"New"
:
CertActionNew
,
"New"
:
CertActionNew
,
...
...
plugin/dapp/cert/types/errors.go
View file @
a02e3273
...
@@ -9,7 +9,10 @@ import "errors"
...
@@ -9,7 +9,10 @@ import "errors"
var
(
var
(
// ErrValidateCertFailed cert校验失败
// ErrValidateCertFailed cert校验失败
ErrValidateCertFailed
=
errors
.
New
(
"ErrValidateCertFailed"
)
ErrValidateCertFailed
=
errors
.
New
(
"ErrValidateCertFailed"
)
// ErrGetHistoryCertData 获取证书错误
ErrGetHistoryCertData
=
errors
.
New
(
"ErrGetHistoryCertData"
)
ErrGetHistoryCertData
=
errors
.
New
(
"ErrGetHistoryCertData"
)
// ErrUnknowAuthSignType 无效签名类型
ErrUnknowAuthSignType
=
errors
.
New
(
"ErrUnknowAuthSignType"
)
ErrUnknowAuthSignType
=
errors
.
New
(
"ErrUnknowAuthSignType"
)
// ErrInitializeAuthority 初始化校验器失败
ErrInitializeAuthority
=
errors
.
New
(
"ErrInitializeAuthority"
)
ErrInitializeAuthority
=
errors
.
New
(
"ErrInitializeAuthority"
)
)
)
plugin/dapp/cert/types/types.go
View file @
a02e3273
...
@@ -28,29 +28,29 @@ type CertType struct {
...
@@ -28,29 +28,29 @@ type CertType struct {
types
.
ExecTypeBase
types
.
ExecTypeBase
}
}
// NewType
// NewType
新建cert类型结构
func
NewType
()
*
CertType
{
func
NewType
()
*
CertType
{
c
:=
&
CertType
{}
c
:=
&
CertType
{}
c
.
SetChild
(
c
)
c
.
SetChild
(
c
)
return
c
return
c
}
}
// GetPayload
// GetPayload
获取payload
func
(
b
*
CertType
)
GetPayload
()
types
.
Message
{
func
(
b
*
CertType
)
GetPayload
()
types
.
Message
{
return
&
CertAction
{}
return
&
CertAction
{}
}
}
// GetName
// GetName
获取执行器名
func
(
b
*
CertType
)
GetName
()
string
{
func
(
b
*
CertType
)
GetName
()
string
{
return
CertX
return
CertX
}
}
// GetLogMap
// GetLogMap
获取logmap
func
(
b
*
CertType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
b
*
CertType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
nil
return
nil
}
}
// GetTypeMap
// GetTypeMap
获取类型map
func
(
b
*
CertType
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
b
*
CertType
)
GetTypeMap
()
map
[
string
]
int32
{
return
actionName
return
actionName
}
}
plugin/dapp/pokerbull/executor/poker.go
View file @
a02e3273
...
@@ -12,27 +12,33 @@ import (
...
@@ -12,27 +12,33 @@ import (
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
)
// 牌数,4 * 13 不带大小王
//
PokerCardNum
牌数,4 * 13 不带大小王
var
PokerCardNum
=
52
var
PokerCardNum
=
52
// 牌花色偏移
//
ColorOffset
牌花色偏移
var
ColorOffset
uint32
=
8
var
ColorOffset
uint32
=
8
// 牌花色bit掩码
//
ColorBitMask
牌花色bit掩码
var
ColorBitMask
=
0xFF
var
ColorBitMask
=
0xFF
// 每种花色的牌数
//
CardNumPerColor
每种花色的牌数
var
CardNumPerColor
=
13
var
CardNumPerColor
=
13
// 一手牌的牌数
//
CardNumPerGame
一手牌的牌数
var
CardNumPerGame
=
5
var
CardNumPerGame
=
5
const
(
const
(
// PokerbullResultX1 赌注倍数1倍
PokerbullResultX1
=
1
PokerbullResultX1
=
1
// PokerbullResultX2 赌注倍数2倍
PokerbullResultX2
=
2
PokerbullResultX2
=
2
// PokerbullResultX3 赌注倍数3倍
PokerbullResultX3
=
3
PokerbullResultX3
=
3
// PokerbullResultX4 赌注倍数4倍
PokerbullResultX4
=
4
PokerbullResultX4
=
4
// PokerbullResultX5 赌注倍数5倍
PokerbullResultX5
=
5
PokerbullResultX5
=
5
// PokerbullLeverageMax 赌注倍数最大倍数
PokerbullLeverageMax
=
PokerbullResultX1
PokerbullLeverageMax
=
PokerbullResultX1
)
)
...
...
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
a02e3273
...
@@ -21,10 +21,13 @@ import (
...
@@ -21,10 +21,13 @@ import (
const
(
const
(
// ListDESC 降序
// ListDESC 降序
ListDESC
=
int32
(
0
)
ListDESC
=
int32
(
0
)
// DefaultCount 默认一次取多少条记录
DefaultCount
=
int32
(
20
)
//默认一次取多少条记录
DefaultCount
=
int32
(
20
)
// MaxPlayerNum 最大玩家数
MaxPlayerNum
=
5
MaxPlayerNum
=
5
// MinPlayValue 最小赌注
MinPlayValue
=
10
*
types
.
Coin
MinPlayValue
=
10
*
types
.
Coin
// DefaultStyle 默认游戏类型
DefaultStyle
=
pkt
.
PlayStyleDefault
DefaultStyle
=
pkt
.
PlayStyleDefault
)
)
...
...
plugin/dapp/pokerbull/types/const.go
View file @
a02e3273
...
@@ -13,16 +13,20 @@ const (
...
@@ -13,16 +13,20 @@ const (
)
)
const
(
const
(
// PlayStyleDefault 游戏类型
// PlayStyleDefault
默认
游戏类型
PlayStyleDefault
=
iota
+
1
PlayStyleDefault
=
iota
+
1
// PlayStyleDealer 庄家玩法
PlayStyleDealer
PlayStyleDealer
)
)
const
(
const
(
// TyLogPBGameStart log for PBgame
// TyLogPBGameStart log for
start
PBgame
TyLogPBGameStart
=
721
TyLogPBGameStart
=
721
// TyLogPBGameContinue log for continue PBgame
TyLogPBGameContinue
=
722
TyLogPBGameContinue
=
722
// TyLogPBGameQuit log for quit PBgame
TyLogPBGameQuit
=
723
TyLogPBGameQuit
=
723
// TyLogPBGameQuery log for query PBgame
TyLogPBGameQuery
=
724
TyLogPBGameQuery
=
724
)
)
...
@@ -40,6 +44,8 @@ const (
...
@@ -40,6 +44,8 @@ const (
FuncNameQueryGameListByIds
=
"QueryGameListByIds"
FuncNameQueryGameListByIds
=
"QueryGameListByIds"
// FuncNameQueryGameById 根据id查询game
// FuncNameQueryGameById 根据id查询game
FuncNameQueryGameById
=
"QueryGameById"
FuncNameQueryGameById
=
"QueryGameById"
// FuncNameQueryGameByAddr 根据地址查询game
FuncNameQueryGameByAddr
=
"QueryGameByAddr"
FuncNameQueryGameByAddr
=
"QueryGameByAddr"
// FuncNameQueryGameByStatus 根据status查询game
FuncNameQueryGameByStatus
=
"QueryGameByStatus"
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