Compare commits

..

2 Commits

Author SHA1 Message Date
georgehao
160f4c447a Feat/fix coordiantor curie recover sig (#1475)
Co-authored-by: georgehao <georgehao@users.noreply.github.com>
2024-08-06 21:43:25 +08:00
georgehao
72f88bae5e fix coordinator curie public key recover bug (#1474)
Co-authored-by: georgehao <georgehao@users.noreply.github.com>
2024-08-06 18:38:13 +08:00
2 changed files with 24 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "v4.4.41"
var tag = "v4.4.43"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -26,6 +26,22 @@ 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"`
}
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"`
@@ -80,7 +96,13 @@ 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,
}
hash, err := curieIdentity.Hash()
if err != nil {
return "", err
}