github.com/tenywen/fabric@v1.0.0-beta.0.20170620030522-a5b1ed380643/common/mocks/crypto/localsigner.go (about)

     1  /*
     2  Copyright IBM Corp. 2017 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package crypto
    18  
    19  import (
    20  	cb "github.com/hyperledger/fabric/protos/common"
    21  )
    22  
    23  // FakeLocalSigner is a signer which already has identity an nonce set to fake values
    24  var FakeLocalSigner = &LocalSigner{
    25  	Identity: []byte("IdentityBytes"),
    26  	Nonce:    []byte("NonceValue"),
    27  }
    28  
    29  // LocalSigner is a mock implmeentation of crypto.LocalSigner
    30  type LocalSigner struct {
    31  	Identity []byte
    32  	Nonce    []byte
    33  }
    34  
    35  // Sign returns the msg, nil
    36  func (ls *LocalSigner) Sign(msg []byte) ([]byte, error) {
    37  	return msg, nil
    38  }
    39  
    40  // NewSignatureHeader returns a new signature header, nil
    41  func (ls *LocalSigner) NewSignatureHeader() (*cb.SignatureHeader, error) {
    42  	return &cb.SignatureHeader{
    43  		Creator: ls.Identity,
    44  		Nonce:   ls.Nonce,
    45  	}, nil
    46  }