github.com/hyperledger/aries-framework-go@v0.3.2/pkg/doc/signature/suite/api.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package suite
     8  
     9  import (
    10  	"github.com/hyperledger/aries-framework-go/component/models/signature/api"
    11  	"github.com/hyperledger/aries-framework-go/component/models/signature/suite"
    12  	"github.com/hyperledger/aries-framework-go/spi/crypto"
    13  )
    14  
    15  // SignatureSuite defines general signature suite structure.
    16  type SignatureSuite = suite.SignatureSuite
    17  
    18  type signer interface {
    19  	// Sign will sign document and return signature
    20  	Sign(data []byte) ([]byte, error)
    21  	// Alg return alg.
    22  	Alg() string
    23  }
    24  
    25  type verifier interface {
    26  	// Verify will verify a signature.
    27  	Verify(pubKeyValue *api.PublicKey, doc, signature []byte) error
    28  }
    29  
    30  // Opt is the SignatureSuite option.
    31  type Opt = suite.Opt
    32  
    33  // WithSigner defines a signer for the Signature Suite.
    34  func WithSigner(s signer) Opt {
    35  	return suite.WithSigner(s)
    36  }
    37  
    38  // WithVerifier defines a verifier for the Signature Suite.
    39  func WithVerifier(v verifier) Opt {
    40  	return suite.WithVerifier(v)
    41  }
    42  
    43  // WithCompactProof indicates that proof compaction is needed, by default it is not done.
    44  func WithCompactProof() Opt {
    45  	return suite.WithCompactProof()
    46  }
    47  
    48  // InitSuiteOptions initializes signature suite with options.
    49  func InitSuiteOptions(signatureSuite *SignatureSuite, opts ...Opt) *SignatureSuite {
    50  	return suite.InitSuiteOptions(signatureSuite, opts...)
    51  }
    52  
    53  // CryptoSigner defines signer based on crypto.
    54  type CryptoSigner = suite.CryptoSigner
    55  
    56  // NewCryptoSigner creates a new CryptoSigner.
    57  func NewCryptoSigner(cr crypto.Crypto, kh interface{}) *CryptoSigner {
    58  	return suite.NewCryptoSigner(cr, kh)
    59  }
    60  
    61  // CryptoVerifier defines signature verifier based on crypto.
    62  type CryptoVerifier = suite.CryptoVerifier
    63  
    64  // NewCryptoVerifier creates a new CryptoVerifier.
    65  func NewCryptoVerifier(cr crypto.Crypto) *CryptoVerifier {
    66  	return suite.NewCryptoVerifier(cr)
    67  }
    68  
    69  // ErrSignerNotDefined is returned when Sign() is called but signer option is not defined.
    70  var ErrSignerNotDefined = suite.ErrSignerNotDefined
    71  
    72  // ErrVerifierNotDefined is returned when Verify() is called but verifier option is not defined.
    73  var ErrVerifierNotDefined = suite.ErrVerifierNotDefined