package api import ( "encoding/base64" "strconv" ethCommon "github.com/ethereum/go-ethereum/common" "github.com/hermeznetwork/hermez-node/common" "github.com/iden3/go-iden3-crypto/babyjub" ) const exitIdx = "hez:EXIT:1" type errorMsg struct { Message string } func bjjToString(bjj *babyjub.PublicKey) string { pkComp := [32]byte(bjj.Compress()) sum := pkComp[0] for i := 1; i < len(pkComp); i++ { sum += pkComp[i] } bjjSum := append(pkComp[:], sum) return "hez:" + base64.RawURLEncoding.EncodeToString(bjjSum) } func ethAddrToHez(addr ethCommon.Address) string { return "hez:" + addr.String() } func idxToHez(idx common.Idx, tokenSymbol string) string { if idx == 1 { return exitIdx } return "hez:" + tokenSymbol + ":" + strconv.Itoa(int(idx)) }