pki

package
v0.0.0-...-ea1d8b2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Overview

Copyright ArxanFintech Technology Ltd. 2017 All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright ArxanFintech Technology Ltd. 2017 All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICryptoLib

type ICryptoLib interface {
	Sign(data []byte) ([]byte, error)
	Verify(data []byte, sig []byte) error
	Encrypt(data []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

ICryptoLib function set of public and private keys

type IPrivateKey

type IPrivateKey interface {
	GetUsage() string
	GetType() string
	GetRawData() []byte
	Sign(data []byte) ([]byte, error)
}

IPrivateKey function sets of private key

type IPublicKey

type IPublicKey interface {
	GetUsage() string
	GetType() string
	GetRawData() []byte
	Verify(data []byte, signature []byte) error
}

IPublicKey function sets of public key

type ISignClient

type ISignClient interface {
	// Sign a payload with creating a new signature header created by NewSignatureHeader
	DoSign(ipk IPrivateKey) (*Signature, error)

	// Verify signature
	Verify(ipk IPublicKey) error
	// GetSignature generate signature struct from SignedData
	GetSignature() *Signature
}

type ISignable

type ISignable interface {
	// 返回所有带签名数据的签名列表
	AsSignedData() ([]*SignedData, error)
	// 返回不带签名数据的签名
	NewSignedData() (*SignedData, error)
	// 附加签名
	AttachSignature(*Signature) error
}

ISignable types are those which can map their contents to a set of SignedData

type ISigner

type ISigner interface {
	// NewSignatureHeader creates a SignatureHeader with the correct signing identity and a valid nonce
	NewSignatureHeader() (*SignatureHeader, error)
	// Sign a payload with creating a new signature header created by NewSignatureHeader
	Sign(signable ISignable) error
}

ISignable types are those which can map their contents to a set of SignedData ISigner ...

type Signature

type Signature struct {
	Header *SignatureHeader `json:"header,omitempty"`
	Sign   []byte           `json:"sign,omitempty"`
}

Signature include signature header and body

type SignatureBody

type SignatureBody struct {
	Creator        commdid.Identifier `json:"creator"`         // signature creator
	Created        string             `json:"created"`         // signature created timestamp
	Nonce          string             `json:"nonce"`           // signature random string
	SignatureValue string             `json:"signature_value"` // ed25519 signature value of the request payload, base64 encoded
}

SignatureBody is used to pass the signature value to SDK

type SignatureHeader

type SignatureHeader struct {
	SignType string             `json:"sign_type,omitempty"`
	Creator  commdid.Identifier `json:"creator,omitempty"`
	Created  int64              `json:"created,omitempty"`
	Nonce    []byte             `json:"nonce,omitempty"`
}

SignatureHeader ...

type SignatureParam

type SignatureParam struct {
	Creator      commdid.Identifier `json:"creator"`       // signature creator
	Created      string             `json:"created"`       // signature created timestamp
	Nonce        string             `json:"nonce"`         // signature random string
	PrivateKey   string             `json:"private_key"`   // user ed25519 private key using for signing, base64 encoded
	SecurityCode string             `json:"security_code"` // user security code
}

SignatureParam is used to pass signature params to SDK If you had trusted key pair, you should set 'SecurityCode', otherwish, you should set 'PrivateKey'.

type SignedData

type SignedData struct {
	Data   []byte           `json:"data,omitempty"`
	Header *SignatureHeader `json:"header,omitempty"`
	Sign   []byte           `json:"sign,omitempty"`
}

SignedData is used to represent the general triplet required to verify a signature This is intended to be generic across crypto schemes, while most crypto schemes will include the signing identity and a nonce within the Data, this is left to the crypto implementation

func (*SignedData) DoSign

func (sd *SignedData) DoSign(ipk IPrivateKey) (*Signature, error)

Sign message

func (*SignedData) GetSignature

func (sd *SignedData) GetSignature() *Signature

GetSignature generate signature struct from SignedData

func (*SignedData) Verify

func (sd *SignedData) Verify(ipk IPublicKey) error

Verify signature

Jump to

Keyboard shortcuts

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