Skip to content

Commit

Permalink
fix coordinator curie public key recover bug (#1474)
Browse files Browse the repository at this point in the history
Co-authored-by: georgehao <[email protected]>
  • Loading branch information
georgehao and georgehao authored Aug 6, 2024
1 parent daca3ae commit 72f88ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime/debug"
)

var tag = "v4.4.41"
var tag = "v4.4.42"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
26 changes: 25 additions & 1 deletion coordinator/internal/types/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ type LoginSchema struct {
Token string `json:"token"`
}

// TODO just use for darwin upgrade, need delete next upgrade
type identity struct {
ProverName string `json:"prover_name"`
ProverVersion string `json:"prover_version"`
Challenge string `json:"challenge"`
HardForkName string `json:"hard_fork_name"`
}

func (i *identity) Hash() ([]byte, error) {
byt, err := rlp.EncodeToBytes(i)
if err != nil {
return nil, err
}
hash := crypto.Keccak256Hash(byt)
return hash[:], nil
}

// Message the login message struct
type Message struct {
Challenge string `form:"challenge" json:"challenge" binding:"required"`
Expand Down Expand Up @@ -80,7 +97,14 @@ func (a *LoginParameter) Verify() (bool, error) {
// RecoverPublicKeyFromSignature get public key from signature.
// This method is for pre-darwin's compatible.
func (a *LoginParameter) RecoverPublicKeyFromSignature() (string, error) {
hash, err := a.Message.Hash()
curieIdentity := identity{
ProverName: a.Message.ProverName,
ProverVersion: a.Message.ProverVersion,
Challenge: a.Message.Challenge,
HardForkName: "curie",
}

hash, err := curieIdentity.Hash()
if err != nil {
return "", err
}
Expand Down

0 comments on commit 72f88ba

Please sign in to comment.