forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
36 lines (26 loc) · 769 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package signature
import (
"crypto/elliptic"
"errors"
"github.com/btcsuite/btcd/btcec"
kmsapi "github.com/Universal-Health-Chain/aries-framework-go/pkg/kms"
)
// MapECCurveToKeyType makes a mapping of Elliptic Curve to KeyType of kms.
func MapECCurveToKeyType(curve elliptic.Curve) (kmsapi.KeyType, error) {
switch curve {
case elliptic.P256():
return kmsapi.ECDSAP256TypeIEEEP1363, nil
case elliptic.P384():
return kmsapi.ECDSAP384TypeIEEEP1363, nil
case elliptic.P521():
return kmsapi.ECDSAP521TypeIEEEP1363, nil
case btcec.S256():
return kmsapi.ECDSASecp256k1TypeIEEEP1363, nil
default:
return "", errors.New("unsupported curve")
}
}