github.com/consensys/gnark-crypto@v0.14.0/signature/ecdsa/ecdsa.go (about)

     1  /*
     2  Copyright © 2020 ConsenSys
     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 ecdsa
    18  
    19  import (
    20  	"io"
    21  
    22  	"github.com/consensys/gnark-crypto/ecc"
    23  	ecdsa_bls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377/ecdsa"
    24  	ecdsa_bls12378 "github.com/consensys/gnark-crypto/ecc/bls12-378/ecdsa"
    25  	ecdsa_bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381/ecdsa"
    26  	ecdsa_bls24315 "github.com/consensys/gnark-crypto/ecc/bls24-315/ecdsa"
    27  	ecdsa_bls24317 "github.com/consensys/gnark-crypto/ecc/bls24-317/ecdsa"
    28  	ecdsa_bn254 "github.com/consensys/gnark-crypto/ecc/bn254/ecdsa"
    29  	ecdsa_bw6633 "github.com/consensys/gnark-crypto/ecc/bw6-633/ecdsa"
    30  	ecdsa_bw6756 "github.com/consensys/gnark-crypto/ecc/bw6-756/ecdsa"
    31  	ecdsa_bw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/ecdsa"
    32  	ecdsa_secp256k1 "github.com/consensys/gnark-crypto/ecc/secp256k1/ecdsa"
    33  	ecdsa_starkcurve "github.com/consensys/gnark-crypto/ecc/stark-curve/ecdsa"
    34  	"github.com/consensys/gnark-crypto/signature"
    35  )
    36  
    37  // New takes a source of randomness and returns a new key pair
    38  func New(ss ecc.ID, r io.Reader) (signature.Signer, error) {
    39  	switch ss {
    40  	case ecc.BN254:
    41  		return ecdsa_bn254.GenerateKey(r)
    42  	case ecc.BLS12_381:
    43  		return ecdsa_bls12381.GenerateKey(r)
    44  	case ecc.BLS12_377:
    45  		return ecdsa_bls12377.GenerateKey(r)
    46  	case ecc.BLS12_378:
    47  		return ecdsa_bls12378.GenerateKey(r)
    48  	case ecc.BW6_761:
    49  		return ecdsa_bw6761.GenerateKey(r)
    50  	case ecc.BW6_756:
    51  		return ecdsa_bw6756.GenerateKey(r)
    52  	case ecc.BLS24_315:
    53  		return ecdsa_bls24315.GenerateKey(r)
    54  	case ecc.BLS24_317:
    55  		return ecdsa_bls24317.GenerateKey(r)
    56  	case ecc.BW6_633:
    57  		return ecdsa_bw6633.GenerateKey(r)
    58  	case ecc.SECP256K1:
    59  		return ecdsa_secp256k1.GenerateKey(r)
    60  	case ecc.STARK_CURVE:
    61  		return ecdsa_starkcurve.GenerateKey(r)
    62  	default:
    63  		panic("not implemented")
    64  	}
    65  }