github.com/trustbloc/kms-go@v1.1.2/crypto/tinkcrypto/primitive/bbs/subtle/bls12381g2_signer.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package subtle 8 9 import "github.com/trustbloc/bbs-signature-go/bbs12381g2pub" 10 11 // BLS12381G2Signer is the BBS+ signer for BLS12-381 curve for keys on a G2 group. 12 // Currently this is the only available BBS+ signer in aries-framework-go (see `pkg/doc/bbs/bbs12381g2pub/bbs.go`). 13 // Other BBS+ signers can be added later if needed. 14 type BLS12381G2Signer struct { 15 privateKeyBytes []byte 16 bbsPrimitive *bbs12381g2pub.BBSG2Pub 17 } 18 19 // NewBLS12381G2Signer creates a new instance of BLS12381G2Signer with the provided privateKey. 20 func NewBLS12381G2Signer(privateKey []byte) *BLS12381G2Signer { 21 return &BLS12381G2Signer{ 22 privateKeyBytes: privateKey, 23 bbsPrimitive: bbs12381g2pub.New(), 24 } 25 } 26 27 // Sign will sign create signature of each message and aggregate it into a single signature using the signer's 28 // private key. 29 // returns: 30 // 31 // signature in []byte 32 // error in case of errors 33 func (s *BLS12381G2Signer) Sign(messages [][]byte) ([]byte, error) { 34 return s.bbsPrimitive.Sign(messages, s.privateKeyBytes) 35 }