service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* Copyright (c) 2019. Baidu Inc. All Rights Reserved.

* Copyright (c) 2019. Baidu Inc. All Rights Reserved.

* Copyright (c) 2019. Baidu Inc. All Rights Reserved.

* Copyright (c) 2019. Baidu Inc. All Rights Reserved.

* Copyright (c) 2019. Baidu Inc. All Rights Reserved.

Index

Constants

View Source
const (
	HardenedKeyStart = 0x80000000
	Language         = 1
	StrengthHard     = 3
)

The range for hardened child keys is [2^31, 2^32 - 1].

View Source
const CERT_NAME = "root.crt"
View Source
const PRIVATEKEY_NAME = "root.key"

Variables

View Source
var (
	ErrNetExisted    = errors.New("net has been existed")
	ErrParam         = errors.New("params is illegal")
	ErrDB            = errors.New("DB operate failed")
	ErrCACert        = errors.New("can not get ca cert")
	ErrCreateCert    = errors.New("create cert failed")
	ErrCertNoExisted = errors.New("cert is not existed")
)

Functions

func AddNetAdmin

func AddNetAdmin(net, address string) error

添加一个网络和网络管理员

func AddNode

func AddNode(net, adminAddress, address string) error

添加一个节点

func CheckCaAdmin

func CheckCaAdmin(address string) bool

判断address是否有ca根权限

func CheckNetAdmin

func CheckNetAdmin(address, net string) bool

判断address是否有网络管理员权限

func CheckNode

func CheckNode(address, net string) bool

判断address是否有节点权限

func DecryptByHdKey

func DecryptByHdKey(net, adminAddress, hdPubKey, cypherText string) (string, error)

解密一笔交易

func DecryptByNetHdPriKey

func DecryptByNetHdPriKey(netHdPriKey, childHdPubKey, cypherText string) (string, error)

交易解密

func GenerateNetHdPriKey

func GenerateNetHdPriKey() (string, error)

生成网络根私钥

func GenerateNodeHdPriKey

func GenerateNodeHdPriKey(total uint32, netHdPriKey string) (string, error)

生成全节点的一级私钥

func GetRevokeList

func GetRevokeList(net, latestSerialNum string) (*[]dao.Revoke, error)

获取增量撤销列表

func RevokeNode

func RevokeNode(net, address string) (bool, error)

撤销一个节点

func WriteCert

func WriteCert(path string, cert *Cert) error

将证书写入证书文件

Types

type Cert

type Cert struct {
	Address    string
	SerialNum  string
	Cert       string
	PrivateKey string
	CaCert     string
	ValidTime  int
}

func GenerateCert

func GenerateCert(caCert *OriginalCert, net string, root bool) (*Cert, error)

生成证书

func GetNode

func GetNode(net, address string) (*Cert, string, error)

获取节点的证书

type OriginalCert

type OriginalCert struct {
	SerialNum  string
	CaCert     *x509.Certificate
	Cert       *x509.Certificate
	PrivateKey *rsa.PrivateKey
	ValidTime  int
}

func GetAdminCert

func GetAdminCert(net, adminAddress string) (*OriginalCert, string, error)

获取网络管理员的证书

func GetRootCert

func GetRootCert() (*OriginalCert, error)

获取ca根证书

Jump to

Keyboard shortcuts

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