Skip to content

Commit

Permalink
Merge pull request #367 from hypersign-protocol/develop
Browse files Browse the repository at this point in the history
`v0.1.10-rc.1`: Release
  • Loading branch information
arnabghose997 authored Aug 2, 2023
2 parents f30a6ab + faee4f7 commit 2cdc37c
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 22 deletions.
80 changes: 78 additions & 2 deletions cmd/hid-noded/cmd/debug_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"crypto/ed25519"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"encoding/json"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/btcsuite/btcutil/base58"
"github.com/cosmos/cosmos-sdk/client"
ethercrypto "github.com/ethereum/go-ethereum/crypto"
bbs "github.com/hyperledger/aries-framework-go/component/kmscrypto/crypto/primitive/bbs12381g2pub"
hidnodecli "github.com/hypersign-protocol/hid-node/x/ssi/client/cli"
"github.com/hypersign-protocol/hid-node/x/ssi/types"
"github.com/multiformats/go-multibase"
Expand All @@ -22,11 +24,25 @@ func extendDebug(debugCmd *cobra.Command) *cobra.Command {
debugCmd.AddCommand(
ed25519Cmd(),
secp256k1Cmd(),
bbsCmd(),
signSSIDocCmd(),
)
return debugCmd
}

func bbsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "bbs",
Short: "bbs debug commands",
}

cmd.AddCommand(
blsRandomCmd(),
)

return cmd
}

func secp256k1Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "secp256k1",
Expand All @@ -42,6 +58,56 @@ func secp256k1Cmd() *cobra.Command {
return cmd
}

func blsRandomCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "random",
Short: "Generate random blsBbs keypair",
RunE: func(cmd *cobra.Command, args []string) error {
pubKey, privKey, err := bbs.GenerateKeyPair(sha256.New, nil)
if err != nil {
return err
}

// Convert Public Key Object to Multibase
pubKeyBytes, err := pubKey.Marshal()
if err != nil {
return err
}

publicKeyMultibase, err := multibase.Encode(multibase.Base58BTC, pubKeyBytes)
if err != nil {
return err
}

// Convert Private Object to Bytes
privKeyBytes, err := privKey.Marshal()
if err != nil {
return err
}

keyInfo := struct {
PubKeyBase64 string `json:"pub_key_base_64"`
PubKeyMultibase string `json:"pub_key_multibase"`
PrivKeyBase64 string `json:"priv_key_base_64"`
}{
PubKeyBase64: base64.StdEncoding.EncodeToString(pubKeyBytes),
PubKeyMultibase: publicKeyMultibase,
PrivKeyBase64: base64.StdEncoding.EncodeToString(privKeyBytes),
}

keyInfoJson, err := json.Marshal(keyInfo)
if err != nil {
return err
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), string(keyInfoJson))
return err
},
}

return cmd
}

func secp256k1RandomCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "random",
Expand Down Expand Up @@ -214,8 +280,13 @@ func signSchemaDocCmd() *cobra.Command {
if err != nil {
return err
}
case "bbs":
signature, err = hidnodecli.GetBBSSignature(argPrivateKey, schemaDocBytes)
if err != nil {
return err
}
default:
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth']")
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth', 'bbs']")
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), signature)
Expand Down Expand Up @@ -266,8 +337,13 @@ func signCredStatusDocCmd() *cobra.Command {
if err != nil {
return err
}
case "bbs":
signature, err = hidnodecli.GetBBSSignature(argPrivateKey, credStatusDocBytes)
if err != nil {
return err
}
default:
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth']")
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth', 'bbs']")
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), signature)
Expand Down
18 changes: 13 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ require (
github.com/gogo/protobuf v1.3.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hyperledger/aries-framework-go/component/kmscrypto v0.0.0-20230727134633-020b60b288ed
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.1
github.com/tendermint/spm v0.1.9
github.com/tendermint/tendermint v0.34.23
github.com/tendermint/tm-db v0.6.7
Expand All @@ -21,20 +22,23 @@ require (
)

require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/keyring v1.1.6 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/IBM/mathlib v0.0.3-0.20230605104224-932ab92f2ce0 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/armon/go-metrics v0.4.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd v0.22.3 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
Expand Down Expand Up @@ -70,11 +74,13 @@ require (
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
github.com/improbable-eng/grpc-web v0.14.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
Expand All @@ -86,7 +92,8 @@ require (
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mr-tron/base58 v1.1.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
Expand Down Expand Up @@ -126,6 +133,7 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
Expand Down
Loading

0 comments on commit 2cdc37c

Please sign in to comment.