Skip to content

Commit

Permalink
feat: added ecc.IDFromString() method
Browse files Browse the repository at this point in the history
  • Loading branch information
gbotrel committed Dec 6, 2023
1 parent e773088 commit 6befcf6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ecc/ecc.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ limitations under the License.
package ecc

import (
"errors"
"math/big"
"strings"

Expand Down Expand Up @@ -57,6 +58,15 @@ func Implemented() []ID {
return []ID{BN254, BLS12_377, BLS12_381, BW6_761, BLS24_315, BW6_633, BLS12_378, BW6_756, BLS24_317, STARK_CURVE, SECP256K1}
}

func IDFromString(s string) (ID, error) {
for _, id := range Implemented() {
if strings.ToLower(s) == id.String() {
return id, nil
}
}
return UNKNOWN, errors.New("unknown curve ID")
}

func (id ID) String() string {
cfg := id.config()
return strings.ToLower(cfg.EnumID)
Expand Down

0 comments on commit 6befcf6

Please sign in to comment.