cggmp

command
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

CGGMP example

This program demonstrates a simple CGGMP example by using go-libp2p. It contains 4 sub-commands which are

  1. dkg: generate shares
  2. reshare: refresh shares
  3. signer: sign a message
  4. signer6: sign a message using six round signer

Configuration

Common

All commands have their own configurations which are located in dkg/ folder, signer/ folder, and reshare/ folder respectively. These config files are YAML format and they should contain the required input that commands need.

There are some common inputs.

  1. port: Port that this node will listen for.
  2. peers: A list of peers (including port and ID) that this node will try to connect to.
  3. identity: The base64-encoded private key of this node used as an identity during p2p connection.
DKG
Run

Please run each command in its own terminal.

go run ./example/cggmp/main.go dkg --config ./example/cggmp/dkg/node-1.yaml
go run ./example/cggmp/main.go dkg --config ./example/cggmp/dkg/node-2.yaml
go run ./example/cggmp/main.go dkg --config ./example/cggmp/dkg/node-3.yaml
Input

Besides the common inputs, DKG will need another two inputs.

  1. rank: The rank of this node during HTSS algorithm.
  2. threshold: The threshold that needed to generate a valid signature.
  3. sessionId: A session ID known by peers.

For example, in file dkg/node-1.yaml, a complete DKG configuration is shown below.

port: 10001
identity: CAMSeTB3AgEBBCADTRFtapXCL1jD0HBkymsyQ7zivD41FRQ9zKPgL+X9MaAKBggqhkjOPQMBB6FEA0IABGxK+P4V0qqLYf2aaGiekigU+/QJsOqcTeb29ygN/cpyfyJ+YKaj9AS9yLxxzvXN+yiufU/T4x02PNxls44KYjs=
peers:
  - id: QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5
    port: 10002
  - id: QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB
    port: 10003
rank: 0
threshold: 3
sessionId: example-session
Output

After the process finished, the results will be printed in the console:

  1. share: The respective share of the node. The value of share in these output files must be different.
  2. pubkey: The public key. The value of public key in these output files must be the same.
  3. bks: The Birkhoff parameter of all nodes. Each Birkhoff parameter contains a x coordinate and a rank.
  4. rid: The rid to be used to compute ssid.
  5. partialPublicKeys: These are not part of DKG results. We run an extra process of partial public keys for convenience. The reshare process will need them.

The results can then be used in the signer or reshare.

Reshare
Run

Please run each command in its own terminal.

go run ./example/cggmp/main.go reshare --config ./example/cggmp/reshare/node-1.yaml
go run ./example/cggmp/main.go reshare --config ./example/cggmp/reshare/node-2.yaml
go run ./example/cggmp/main.go reshare --config ./example/cggmp/reshare/node-3.yaml
Input

Besides the common inputs, the reshare process will need following inputs.

  1. threshold: The threshold that determined when DKG.
  2. sessionId: A session ID known by peers.
  3. share: The respective share generated from DKG.
  4. pubkey: The public key generated from DKG.
  5. bks: The Birkhoff parameter of all peers.
  6. rid: The rid from DKG.
  7. partialPublicKeys: The partial public keys of all peers.

For example, in file reshare/node-1.yaml, a complete reshare configuration is shown below.

port: 10001
identity: CAMSeTB3AgEBBCADTRFtapXCL1jD0HBkymsyQ7zivD41FRQ9zKPgL+X9MaAKBggqhkjOPQMBB6FEA0IABGxK+P4V0qqLYf2aaGiekigU+/QJsOqcTeb29ygN/cpyfyJ+YKaj9AS9yLxxzvXN+yiufU/T4x02PNxls44KYjs=
peers:
  - id: QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5
    port: 10002
  - id: QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB
    port: 10003
threshold: 3
sessionId: example-session
share: "11562133933040963969525868072629202507879841088842340239872215449084461894996"
pubkey:
  x: "89952628954408501076756693846693837376155554544671385809102862275727343093578"
  y: "67861499276570719230631414855962384198494177886535018316352165797328817078489"
bks:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    x: "67358079961840714113669998214709698945556462341692570503437230343582427480862"
    rank: 0
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    x: "52252570271704546398098577206981141197991776990874998813948089333770203583994"
    rank: 0
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    x: "62551554486107671149738294173804165224433322962455989727296095773135128795235"
    rank: 0
rid: 23e982fceee95283043e97ee11407843ed8bbe252573b2fb6266208b066411ba
partialPublicKeys:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    x: "52467708717235291978675530679317930629196146895073678447670510456625655968816"
    y: "51321355215334599073854030298892259525419392481248634613979121549805934006852"
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    x: "91769375714244346692286707090303901980960653591777523140336566117944451602691"
    y: "63906067269784108149256444193420921508979043037560802813902540665214272407735"
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    x: "104484780820834801412324647716712771409530844545100707989704039975980559283666"
    y: "10179514457072307206980472213331439507718879321617535458487678005528212750910"

Note: All reshare config files have already contained executable configurations. However, you could also try to copy the results from DKG result files and overwrite the configurations (e.g from dkg/node-1.yaml to reshare/node-1.yaml).

Output

After the process finished, the results will be printed in the console. Each result contains a new share. The value of the new shares should be different from the old ones and should be different from each other as well.

Signer
Run

Please run each command in its own terminal.

go run ./example/cggmp/main.go signer --config ./example/cggmp/signer/node-1.yaml
go run ./example/cggmp/main.go signer --config ./example/cggmp/signer/node-2.yaml
go run ./example/cggmp/main.go signer --config ./example/cggmp/signer/node-3.yaml

or run the six round signer instead

go run ./example/cggmp/main.go signer6 --config ./example/cggmp/signer/node-1.yaml
go run ./example/cggmp/main.go signer6 --config ./example/cggmp/signer/node-2.yaml
go run ./example/cggmp/main.go signer6 --config ./example/cggmp/signer/node-3.yaml
Input

Besides the common inputs, signer will need another three inputs.

  1. threshold: The threshold that determined when DKG.
  2. sessionId: A session ID known by peers.
  3. share: The respective share generated from DKG.
  4. pubkey: The public key generated from DKG.
  5. bks: The Birkhoff parameter of all peers.
  6. rid: The rid from DKG.
  7. partialPublicKeys: The partial public keys of all peers.
  8. ySecret: The secret Y from the reshare process. This is only required by the six round signer.
  9. y: The Y from the reshare process. This is only required by the six round signer.
  10. pedParameters: The ring Pedersen parameters from the reshare process.
  11. msg: The message to be signed.

Note that msg for all participants must be the same. If the value of message is different, signing process will fail. Most of the time, this message will be a cryptographic transaction. And the transaction might be created from one party. Therefore, practically, before signing, another information exchange for the raw transaction might be required.

For example, in file signer/node-1.yaml, a complete signer configuration is shown below.

port: 10001
identity: CAMSeTB3AgEBBCADTRFtapXCL1jD0HBkymsyQ7zivD41FRQ9zKPgL+X9MaAKBggqhkjOPQMBB6FEA0IABGxK+P4V0qqLYf2aaGiekigU+/QJsOqcTeb29ygN/cpyfyJ+YKaj9AS9yLxxzvXN+yiufU/T4x02PNxls44KYjs=
peers:
  - id: QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5
    port: 10002
  - id: QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB
    port: 10003
msg: "hello cggmp"
threshold: 3
share: "48243026797439776771818084731659702600489266503219496641708858840580121169500"
pubkey:
  x: "89952628954408501076756693846693837376155554544671385809102862275727343093578"
  y: "67861499276570719230631414855962384198494177886535018316352165797328817078489"
bks:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    x: "67358079961840714113669998214709698945556462341692570503437230343582427480862"
    rank: 0
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    x: "52252570271704546398098577206981141197991776990874998813948089333770203583994"
    rank: 0
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    x: "62551554486107671149738294173804165224433322962455989727296095773135128795235"
    rank: 0
rid: 23e982fceee95283043e97ee11407843ed8bbe252573b2fb6266208b066411ba
partialPublicKeys:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    x: "43466343209819044812898590650254283864268338848185454853346116376676523395833"
    y: "44958138954252487406597617233725686958599805922133051733833387063890062269641"
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    x: "20014082463705282808687030577745396227332099274895169412637777486708670326002"
    y: "92698895086037471599141598582265538472919799139233875276103861656965364417832"
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    x: "35665291948445281373356949826184823545352819224099812635911384637323688487404"
    y: "15812061570721501004825183747451990423543863711595381300820045189151375588240"
ySecret: "104246808680696088070759571607466577972925503177945617380101381571996126224974"
paillierKey:
  p: "155371106254539016228836864854904296087987720311499399358504627510924537915127971286454162024196461848114905896606535588153256648133850314223740109365442259087948889105249733522314948013848478062757529409984987372317976079688131678124899081397550671337595547921455658721813940951142182668206557084109238570339"
  q: "164040504501449514999155806694404291218050029684245021538472775661674867962063026498640287255626572764375484047961472970420268580261875020956807730564530173984487539991636735975004582455462901510058103985416298025524261328471955227264311453159286825763544178669557048904411526656288269303914384811880960710547"
y:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    x: "111125534847249504870096751560618515205291134905439916359169074256023952977017"
    y: "31690469366950171337636591803993034571807196013535312929387913570011938796751"
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    x: "43475725579061097157398505384335470712218312375181847685255298077519846300852"
    y: "71834819169346428677991915077732239543183681440541361982041535172051320310582"
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    x: "54047972829781622033110138066274675232621501216705944735926234977481430150852"
    y: "63883349407204374843121163052565022039740730564008190104434887453372082290636"
pedParameters:
  QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5:
    n: 28724752363098296925900917167677955975082286744684433517719494331036819964356262158510035425939046035445424560551910041585037988968564944690715360844075274319298331132250387911506639670261290803058937592186510408482794329542201138474173979667377746317107658676233636009400414531560107297297096174399638341699261798013924558560253012825613479535564438090481435867072398320184242205109667586724953124874085718167812059573517231327463326433369642314446217149033366551392921316137961623221928370657056507965973797167055873760760049117632007448097492678237973555122490540803693574101961173570264082902700360367732172164321
    s: 27704356845982525902386223514916682734767409256939466427269443480529129958213956753416429813097049666427020529253852771785071451039406409193655559886315068745496124896068012719086004384418725049027070325871562194614770975234549187996769977641792549605703046107571457712145308911901067100164849405863662944903335556753406492988825662044504573652258765542724038796116924552303017309490338207870357314828369765529544356587361623232936957379203705579928699352201005535859897625654573046513337436219930029463389602462047492571036040850102590527377701044721746444108488447975268776859515893263635923150839075650364297622205
    t: 12696123765080626693518505319958899448248243307073370318401721226092424822411034244979467332054982918745862822500080632414670161094690218455187091017495725143168234820963617214251549928531428935218583556807272645111076234677799779426600433298422850167692131922971517528032949271989984518118766430529201137403871887519602300726175695315887592182092944946374820332561595573519067837877804707793516931978181543665126567061312857439011458055182158603859681175314776660075411225087413062020705771774251101607270087911394468354682532211063646343602931262973164365335644713615189178907004054062225310350777367645593788132361
  QmYhhVHmpU5X62Qxs3C7JsN1mmbqG435vCbon2qH75C7EW:
    n: 25487154654942898386063471633322681101832257349257093775447071771817744494876505535630901362995569357119237380844169272807104567944034745835322080989211859898398940014031544626562449676202007981030681240610022600995232261101624625780252743994265909908115984119102755350518000908204522369862378446576815234721425093142643823950969534162454402931962255454235184912984233888874039061552164017458258610050975535823031983526438487247640919764112745339343816909050851931683958763550325113099099126862286397393904348137124511567990589531870932862350094380337751233056851094330489178923758697837994092191727974421983878665433
    s: 6300812787102910694296363873702736602358260688381358126060604459530438432152223151592536818251432305051500325763138556531085515395175751984076389664197082624645419375085203283837091383580001376945167372696073448074730667654612574072144548591366851108472039539871942788097082623696639673768290315643058163421808127236476001317505991536286580958383352101945273036074643583804070243437734050872804715839202853677650812929393926427773321656035452690208943379118896470109583110604034441174683000430721947279562100297561488052543282698137465959081758796196743446895279653635920930787942795167633399263428986352094252148811
    t: 7937738531342424211121177451178080146515799252573988154080999150458214072733817418626044710785590010736769876127485288418478107174088331042976217141324134442180973668891797989657645770499745046032928808502873259714828212583523543255074136984588431912365823375219377755242078213070173757438567174845764610846262960608410114585277593452590823522932962075640693317385318088267173754959079338437617757306197005845205304057336399818756253941943796912347680387164851049217520387659713652551850782761411979931796950822466523760635825913019505505301015412996300238202429758813021614353285481986312905223379475463422717367531
  QmaLCt3WyUrbjqKtwKNaSdKiQnyhwGJyFsLHxhnsuQ1XRB:
    n: 23349330575044818315260003786976729201155261735565478102366718906736497283222582171198940976391780929457603114891739786904973788749038389535107595927119764449975107058860514968312831567806830574012659053621267915656666340695501038191392986359724173920638135177153796852450676108201688050919851462725925961077501790180638409685778449385691127468454970186039378866096598178965576917067067355894639541135293756510137018806809563940502385121670231121546637386076444172799451091148271778985459101934988939458519528621044311017767054705438759549252182499788169019461864772128592744866978857884507394201874096610987819048273
    s: 6498873678196244312343470116494906904536599799765984354035425171033666138745621871500066448886316304143684713608516137134757689514812651037994438203260947212966478710687873136833177729725232663968085569918864794924026994864162511167493645906504186360223040428994873721709110771492519860802645575967823185191494139966374846818340578909712005414539557113770571360100011830808230606080154527855201841470483602181289084679187379146212770085313197566032358888091576128176435825663963780256727448330913064411151337814635705967411659478012625997627124976307885685062028447342396700349948015551077312002058894181278023894248
    t: 9745732348508307438841939883848365323768594782966289242033788404351256931850621839468649014291684220616953676323525820717972412454099836615285202777197597177373560115487089076586497034263921805871312365540137073735980711359882927357900487023785420049947170019320156277215984149127075800216187761693092894821405400936355879287369952880922627132848050083395095007355885119718236792299676397612303871868429611355433861165113818915826683680226534740377015371845691602236079839639373455432454983823652500255570243267996920301202155664871482469393595132640610385176399289366346711853787251925739839412740116533580066660577

Note: All signer config files have already contained executable configurations. However, you could also try to copy the results from DKG/reshare results and overwrite the configurations.

Output

After the process finished, the results will be printed in the console. Each result contains a valid signature and all signatures should be the same (both r and s).

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL