Skip to content

Commit

Permalink
chore: upgrade go-tss to tss-lib v2
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Aug 26, 2024
1 parent a36fc6d commit 9acf979
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"time"

"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"time"

ecdsakeygen "github.com/bnb-chain/tss-lib/ecdsa/keygen"
ecdsakeygen "github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/types"
Expand Down
47 changes: 27 additions & 20 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ func start(_ *cobra.Command, _ []string) error {
if err != nil {
log.Error().Err(err).Msg("peer address error")
}
initPreParams(cfg.PreParamsPath)
err = initPreParams(cfg.PreParamsPath)
if err != nil {
return err
}
if cfg.P2PDiagnostic {
err := RunDiagnostics(startLogger, peers, hotkeyPk, cfg)
if err != nil {
Expand Down Expand Up @@ -391,26 +394,30 @@ func initPeers(peer string) ([]maddr.Multiaddr, error) {
return peers, nil
}

func initPreParams(path string) {
if path != "" {
path = filepath.Clean(path)
log.Info().Msgf("pre-params file path %s", path)
preParamsFile, err := os.Open(path)
if err != nil {
log.Error().Err(err).Msg("open pre-params file failed; skip")
} else {
bz, err := io.ReadAll(preParamsFile)
if err != nil {
log.Error().Err(err).Msg("read pre-params file failed; skip")
} else {
err = json.Unmarshal(bz, &preParams)
if err != nil {
log.Error().Err(err).Msg("unmarshal pre-params file failed; skip and generate new one")
preParams = nil // skip reading pre-params; generate new one instead
}
}
}
func initPreParams(path string) error {
if path == "" {
return nil
}
path = filepath.Clean(path)
log.Info().Msgf("pre-params file path %s", path)
preParamsFile, err := os.Open(path)
if err != nil {
return fmt.Errorf("open pre-params file: %w", err)
}

bz, err := io.ReadAll(preParamsFile)
if err != nil {
return fmt.Errorf("read pre-params file: %w", err)
}

err = json.Unmarshal(bz, &preParams)
if err != nil {
return fmt.Errorf("unmarshal pre-params file: %w", err)
}
if preParams.PaillierSK.P == nil {
return fmt.Errorf("pre-params are missing PaillierSK.{P,Q} parameters and should be regenerated")
}
return nil
}

// isObserverNode checks whether THIS node is an observer node.
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/preparams/zetaclient0.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"PaillierSK":{"N":19999163952130747960789760351783788437756051987951355569970036401244501934315272438705577988944467922102492970155408252851533852794097112218266886553586076347804115557757017279985449126837870194546917950194158856088817869376589018796114667864086028598566847973861695589083004303196605694312963960967331453606698750471421102641235873021677307589731091486775521460999458082171513731685071918681293270385071153104334613903503586831444874346531652054016464538970392294909014876824634633871501554184148693655829401315639013286485392467863637678737554558389111485917683916225530045382764297294039119124600051351150814211249,"LambdaN":9999581976065373980394880175891894218878025993975677784985018200622250967157636219352788994472233961051246485077704126425766926397048556109133443276793038173902057778878508639992724563418935097273458975097079428044408934688294509398057333932043014299283423986930847794541502151598302847156481980483665726803207844439805564908826908299383131049732286281017413122919529611290634931314211468373848862938241694978602167585393762136625122435580962508878486729843009777923588471302593033407043805894076580681612304239013813560948585228383852537633607722118782082256871296347729191161115127804109535019576521175406883452282,"PhiN":19999163952130747960789760351783788437756051987951355569970036401244501934315272438705577988944467922102492970155408252851533852794097112218266886553586076347804115557757017279985449126837870194546917950194158856088817869376589018796114667864086028598566847973861695589083004303196605694312963960967331453606415688879611129817653816598766262099464572562034826245839059222581269862628422936747697725876483389957204335170787524273250244871161925017756973459686019555847176942605186066814087611788153161363224608478027627121897170456767705075267215444237564164513742592695458382322230255608219070039153042350813766904564},"NTildei":27751913785731317561401314588152253217728532341018033146570952349857948266439815804220817588815467446516307716665513549241775208783937988610417256936545867146994706743041371293345131680171448151086694170309671283486292778243426639412725044938992517873701725006330137070569134489394538234586796972674797327961558527707455425675762370744764931280145514019295136133284528084915871623701598565821330577968131284073671734400158797160800982150954634593880871530904229027402996176777363730066986245815341196905861357768072141609870245229405943812356754513322852513347434681734563805660510650984453048567481135942146732097813,"H1i":27561956258855841139395484606566450906572976054374340673395795572404700162978995778059515299485228139352425772962548084873215102616280128304708426026182349406021553685331715999823302504724574932475811252902805356309567749243825500782237349965272997278195732138043060594209278009387869413139123717258217760369558773026393837335151469655513584729163915760124835545159150578571574024242102852384898501031964398164508802427280019310461284676702762930983763592670681066746406519089087470866348555388978893174745329039290345402036056193885195412683078301439714912339014313158992229100758385774991450029591789628252080327559,"H2i":3728689158497086873141839685259803753136983319082693856963169726229733672131113136177490814524417255268612620467671366860707614533735757821359190975354246119660178366078082228715114521844446138293061922109534401626012196214235577165710689292018952534202208597250579673907469566293203565367500274532873330046549157395771416744602137701132458921345439713375591947533341059776041205066197520027367159385233699483111938755605800865028185017605864002287172205806900860500164647247828301974000635262077178937664668984154402040254899639546189675216600248280397892382489630326684820331235755629614367050680421011963919488203,"Alpha":12023422531214934687129519427336751009035984170561091401995316889932876861127740921311384022403289655727852687123651207179666808127441651093217171624401095992093222930319273470697036100721360499771918420525219595960686726656705243231703751035078246024613303037202379961560592763983837502239948740870420991159486603826605562036000339449263579950064527369636354957917745420111193837730149039024242588057472210146671375468285242828724250764829561800066210708917523476384078739610379308948169897901580561000198663019628193284829226489567395610248716149143318042255879731755585576865932443849122426445714440683236201534278,"Beta":5216977155731439778993461291447860640876449566364806008925260703987381460229691893122780873808995223223163744678138135687392695130955126431701144250850716493320323144762645954407840190267536639011747593827794567732053411766358287215370001772078774800656600220349293422391251849464836894526916992757090542649120892603149475768335549307299570724464502418555347605473575788163359985939167794314377636554352661162839551390523751777303683251484579852979700993668013952132183651009302732527581967714766865349243790338837470546064122938436752503268419712265039843732584942630907069295257952472051299690267622482814099402925,"P":88381187817350292364427405327147330703367287364982016684112982632296448146824918798880619726847439553397534386831375002209019191421648634648182506013318106307619159619988111117766095040541079223450318951393068166232842380382197780515682551401156068869281037660390394768227141311012971150741063274439667450459,"Q":78500624598652662628885184600358941803683076507070394222241292020467077683298789581328374906370256776628646773897006681776229150698724417192594456702517705509422164083826765704615434585654776671817770799114758241307176860136745886869834508666912875775642490370066102181451552981996440342363450244264823933513}
{"PaillierSK":{"N":22404249155703516525561565565628595721419832527208242027769644997065943598686536513337379256365241125856413245501867172299077390180163600352063582902326137651093964509994754591538291308344512293124908526500483417772598373564412358049491389268474080628997671364326203566657989622651694639790941212984335063539986326798318755526271862671454692693328228117301766046975838475136270512352543053011533328876210584142892553115833795938946392840373508442432357987216712224005275352514280888342123701364667297847300736803488140505685751843995149682695739789703412114989954720671719046736875303946600168636266815705586025697069,"LambdaN":11202124577851758262780782782814297860709916263604121013884822498532971799343268256668689628182620562928206622750933586149538695090081800176031791451163068825546982254997377295769145654172256146562454263250241708886299186782206179024745694634237040314498835682163101783328994811325847319895470606492167531769843376816069727253501699868083872725082766773013729552078918107637381543401496431830253538783091717232136027899571101202370563841912003238187628306379939581028493349381459731798956922106345026619665047353681371382675640294473958215222905872796871836408996432208539975056313230108134011839221102082887972635022,"PhiN":22404249155703516525561565565628595721419832527208242027769644997065943598686536513337379256365241125856413245501867172299077390180163600352063582902326137651093964509994754591538291308344512293124908526500483417772598373564412358049491389268474080628997671364326203566657989622651694639790941212984335063539686753632139454507003399736167745450165533546027459104157836215274763086802992863660507077566183434464272055799142202404741127683824006476375256612759879162056986698762919463597913844212690053239330094707362742765351280588947916430445811745593743672817992864417079950112626460216268023678442204165775945270044,"P":155423188270897417503900305402600069059207602944020829421426043790886081015651259416417550700512646452625171875970683616184017677283944904340851043386373732156774372308792200450462187316640913127732999304643643943170217751466651883895407277897231267046127735514015746865410167002667750505663630662617792006723,"Q":144149977908403601764562629884347174103486968330286113396576216070621344533898929934608700609514503225995325440720909918021247479265557061716250331070459329791514281442569224293747669835336331480237642791481753797164253503580581368354520766212437175125834120740623349758838676727664394452160980877192288420303},"NTildei":25001033766775181948770060437247177436148077988049685688610076581089721771172272954210821075723667461856329318124923084290675787200625148578697227363674529109594223298457919940406823882612582584128939158048803761763714203660771131928494193398961896432722091475017913206308779147046633930511897539847416621360820583900810078517289048187414626609230255151268859150510023817509139049428261101487695506531592535026805684835935048733459820059235820147451958136840400956258713790424649819590245193135314967404744535297706998868748866809693457582941261219777755778048688018487509356383541688642640100871210808403023482317773,"H1i":5167254005746556739629054050483357090319654253655062550911608001145535578097443833878315389023927307196857807159417443498871637022435439481339250246568271348277992104402088442868657573881881850616151219505719753276368213985760242414323299352074776250253189351881501722452577861109692623610632859879700111928369391775155314250276186422892471239520429170204506380287743875128913592567392630685315737372743606244946238351576520231382813524909862266607485573250650672036166619264501471120502707534243141962031101134799440229447750555528285051383356504349907723676314849163709235107247867410073873510995072425017808865844,"H2i":13861184053518822761947420999313210267457200138614946938806766274069758732291678184305729349593193122616883868932008874332604011860818629480839128143169457172468175367883793444386868664480505069630497336373731350072222345261595660045251789123220445238880967646175999613884648678356143143959398576725353264524473612344556398049251699070416114328680723120122730719795422023383532233689177083788326969259182744991541511958403965204631588987022329843189425912320373826552165792090236950323824627391222836382748939842307373998500559645252758841964367339337856453209704981586987562080334659615030662003867740158152022406152,"Alpha":17800528388117174670713593843890147954261749781833782081729141165895406978288084145948818881391556445254845997795061374325164500116210163609746182927468744768016106982391571828222911120046294768975842698033263287472502597481530550107702564294759240943786673587521573637886680748277804746388113201414389778692358116071901929266595086473497819787943582022593201589127962579972857937609196969440788053033560245385709028703751357964867085773436986461053829038043627663895672311983819258075994078817415817941992289734488989856945818615855975745689041971999787391950253954799969150370518384419569316885170531865530210902575,"Beta":2706360194172456641347561926269178355816878512205329060182598640238280522729839704152749115785103855392857123555322871359398826017648932430649978427610206061584066346478821295283350734386008836738046033551271833210614403918442083086372708827180152261495139489104718756468261621649900105328529232514744788229620291446486923624332993798392308119137727567747637180191633180331481298975721291226143856239539839390656393899107944530496839106216080786330170098343301730743573288211218041904952146442238274314772600897596178489486856477407545947602919596205519982095822296913231801824343430704354029302164927747786408565113,"P":79252092502219091445583886114112175137640287607240802443453737712496494111157056238059106561695378223272128373265813581872067263396664263372582929376030498681901193284258517842055196655549836936324533655204950719264204480182369914837727627715905018801394074149583782131063977490373292436485757512661651468559,"Q":78865532055431667746272881571987800775340035900323111655679881238763872756629576003758557118356813846232330218129298553203646963270958632917453331364716828658071987352731439420680086082927738019062756206215753252896195452436767239234955552643327070572568199505854591060898357587805088619780288586692426626633}
Loading

0 comments on commit 9acf979

Please sign in to comment.