Skip to content

Commit

Permalink
Merge branch 'next' of github.com:Team-Kujira/core into onion_module
Browse files Browse the repository at this point in the history
  • Loading branch information
antstalepresh committed Jun 28, 2024
2 parents cdb9595 + 690a0de commit 97d15f3
Show file tree
Hide file tree
Showing 41 changed files with 3,020 additions and 406 deletions.
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func New(
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
app.ICAHostKeeper.WithQueryRouter(app.GRPCQueryRouter())

scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
Expand Down Expand Up @@ -652,6 +653,7 @@ func New(
app.AccountKeeper,
app.BankKeeper.WithMintCoinsRestriction(denomtypes.NewdenomDenomMintCoinsRestriction()),
app.DistrKeeper,
authority,
)

app.DenomKeeper = &denomKeeper
Expand Down Expand Up @@ -694,6 +696,7 @@ func New(
*app.IBCKeeper,
app.CwICAKeeper,
app.ICAControllerKeeper,
app.TransferKeeper,
keys[ibcexported.StoreKey],
), wasmOpts...)

Expand Down Expand Up @@ -774,6 +777,7 @@ func New(
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
transferStack = cwica.NewIBCMiddleware(transferStack, app.CwICAKeeper, app.IBCKeeper.ChannelKeeper)
transferStack = onion.NewIBCModule(transferStack, app.OnionKeeper, encodingConfig.TxConfig)

// Create Interchain Accounts Stack
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const UpgradeName = "v1.1.0-beta"
const UpgradeName = "v1.1.0"

func (app App) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
Expand Down
2 changes: 2 additions & 0 deletions cmd/kujirad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"io"
"os"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"
Expand Down Expand Up @@ -88,6 +89,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
// return tmcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
cfg.Consensus.TimeoutCommit = time.Millisecond * 1500

cfg.P2P.Seeds = ""

Expand Down
47 changes: 23 additions & 24 deletions crypto/keys/authn/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import (
"crypto"
"crypto/elliptic"
"crypto/sha256"
"encoding/asn1"
"encoding/base64"
"encoding/hex"
"encoding/json"
"math/big"

cecdsa "crypto/ecdsa"
ecdsa "crypto/ecdsa"
)

type Signature struct {
AuthenticatorData string `json:"authenticatorData"`
ClientDataJSON string `json:"clientDataJSON"`
Signature string `json:"signature"`
}

// VerifyBytes verifies a signature of the form R || S.
// It rejects signatures which are not in lower-S form.
// See https://github.com/Team-Kujira/kujira.js/blob/master/src/authn/AuthnWebSigner.ts for a reference implementation
// signing a transaction with the webauthn API
func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
type CBORSignature struct {
AuthenticatorData string `json:"authenticatorData"`
ClientDataJSON string `json:"clientDataJSON"`
Signature string `json:"signature"`
}

cborSig := CBORSignature{}
err := json.Unmarshal(sigStr, &cborSig)
sig := Signature{}
err := json.Unmarshal(sigStr, &sig)
if err != nil {
return false
}

clientDataJSON, err := hex.DecodeString(cborSig.ClientDataJSON)
clientDataJSON, err := hex.DecodeString(sig.ClientDataJSON)
if err != nil {
return false
}
Expand All @@ -41,7 +41,11 @@ func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
return false
}

challenge, err := base64.RawURLEncoding.DecodeString(clientData["challenge"].(string))
challengeBase64, ok := clientData["challenge"].(string)
if !ok {
return false
}
challenge, err := base64.RawURLEncoding.DecodeString(challengeBase64)
if err != nil {
return false
}
Expand All @@ -51,29 +55,24 @@ func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
return false
}

publicKey := &cecdsa.PublicKey{Curve: elliptic.P256()}
publicKey := &ecdsa.PublicKey{Curve: elliptic.P256()}
publicKey.X, publicKey.Y = elliptic.UnmarshalCompressed(elliptic.P256(), pubKey.Key)
if publicKey.X == nil || publicKey.Y == nil {
return false
}

type ECDSASignature struct {
R, S *big.Int
}

signatureBytes, err := hex.DecodeString(cborSig.Signature)
signatureBytes, err := hex.DecodeString(sig.Signature)
if err != nil {
return false
}

e := &ECDSASignature{}
_, err = asn1.Unmarshal(signatureBytes, e)
authenticatorData, err := hex.DecodeString(sig.AuthenticatorData)
if err != nil {
return false
}

authenticatorData, err := hex.DecodeString(cborSig.AuthenticatorData)
if err != nil {
// check authenticatorData length
if len(authenticatorData) < 37 {
return false
}

Expand All @@ -83,5 +82,5 @@ func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
h := crypto.SHA256.New()
h.Write(payload)

return cecdsa.Verify(publicKey, h.Sum(nil), e.R, e.S)
return ecdsa.VerifyASN1(publicKey, h.Sum(nil), signatureBytes)
}
Loading

0 comments on commit 97d15f3

Please sign in to comment.