代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package crypto
import (
cb "github.com/hyperledger/fabric/protos/common"
)
// LocalSigner is a temporary stub interface which will be implemented by the local MSP
type LocalSigner interface {
SignatureHeaderMaker
Signer
}
// Signer signs messages
type Signer interface {
// Sign a message and return the signature over the digest, or error on failure
Sign(message []byte) ([]byte, error)
}
// IdentitySerializer serializes identities
type IdentitySerializer interface {
// Serialize converts an identity to bytes
Serialize() ([]byte, error)
}
// SignatureHeaderMaker creates a new SignatureHeader
type SignatureHeaderMaker interface {
// NewSignatureHeader creates a SignatureHeader with the correct signing identity and a valid nonce
NewSignatureHeader() (*cb.SignatureHeader, error)
}
// SignatureHeaderCreator creates signature headers
type SignatureHeaderCreator struct {
SignerSupport
}
// SignerSupport implements the needed support for LocalSigner
type SignerSupport interface {
Signer
IdentitySerializer
}
// NewSignatureHeaderCreator creates new signature headers
func NewSignatureHeaderCreator(ss SignerSupport) *SignatureHeaderCreator {
return &SignatureHeaderCreator{ss}
}
// NewSignatureHeader creates a SignatureHeader with the correct signing identity and a valid nonce
func (bs *SignatureHeaderCreator) NewSignatureHeader() (*cb.SignatureHeader, error) {
creator, err := bs.Serialize()
if err != nil {
return nil, err
}
nonce, err := GetRandomNonce()
if err != nil {
return nil, err
}
return &cb.SignatureHeader{
Creator: creator,
Nonce: nonce,
}, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。