@@ -341,129 +341,139 @@ func GetKeyPairFormLocalFile() (shares tcrsa.KeyShareList, meta *tcrsa.KeyMeta,
341
341
// }
342
342
343
343
// TestCreateKeyPair2 send ar tx by threshold signature keypair
344
- // func TestCreateKeyPair2(t *testing.T) {
345
- // cli := client.New("https://arweave.net")
346
-
347
- // target := "Ii5wAMlLNz13n26nYY45mcZErwZLjICmYd46GZvn4ck"
348
- // reward, err := cli.GetTransactionPrice(nil, &target)
349
- // assert.NoError(t, err)
350
- // // anchor, err := cli.GetTransactionAnchor() // for test
351
- // anchor, err := cli.GetLastTransactionID("KKzL8og7VFLNwxbwW6cpUY_WkE5jFjWL26cTvKfWYms")
352
- // assert.NoError(t, err)
353
- // t.Log("lastTx: ", anchor)
354
- // // read created threshold keypair for local file; need to be generated ahead of time;
355
- // keyMeta := &tcrsa.KeyMeta{}
356
- // keyMetaBy, err := ioutil.ReadFile("keyMeta.json")
357
- // assert.NoError(t, err)
358
- // err = json.Unmarshal(keyMetaBy, keyMeta)
359
- // assert.NoError(t, err)
360
-
361
- // owner := utils.Base64Encode(keyMeta.PublicKey.N.Bytes())
362
-
363
- // amount := big.NewInt(140000) // transfer amount
364
- // tags := []types.Tag{{Name: "Content-Type", Value: "application/json"}, {Name: "tcrsa", Value: "sandyTest"}}
365
- // tx := &types.Transaction{
366
- // Format: 2,
367
- // ID: "",
368
- // LastTx: anchor,
369
- // Owner: owner,
370
- // Tags: types.TagsEncode(tags),
371
- // Target: target,
372
- // Quantity: amount.String(),
373
- // Data: "",
374
- // DataSize: "0",
375
- // DataRoot: "",
376
- // Reward: fmt.Sprintf("%d", reward),
377
- // Signature: "",
378
- // Chunks: nil,
379
- // }
380
- // signData, err := types.GetSignatureData(tx)
381
- // assert.NoError(t, err)
382
- // t.Log("signData: ", signData)
383
-
384
- // // signature
385
- // keyShares := tcrsa.KeyShareList{}
386
- // keySharesBy, err := ioutil.ReadFile("keyShares.json")
387
- // assert.NoError(t, err)
388
- // err = json.Unmarshal(keySharesBy, &keyShares)
389
- // assert.NoError(t, err)
390
-
391
- // ts, err := NewTcSign(keyMeta, signData)
392
- // assert.NoError(t, err)
393
-
394
- // /* --------------------------distribute keyShares to the signers ----------------------------*/
395
- // signer01 := keyShares[0]
396
- // signer02 := keyShares[1]
397
- // signer03 := keyShares[2]
398
- // signer04 := keyShares[3]
399
- // signer05 := keyShares[4]
400
-
401
- // /* -------------------------- signers to sign data ----------------------------*/
402
- // signedData01, err := ts.ThresholdSign(signer01)
403
- // if err != nil {
404
- // panic(err)
405
- // }
406
- // t.Log(signedData01.Id)
407
-
408
- // signedData02, err := ts.ThresholdSign(signer02)
409
- // if err != nil {
410
- // panic(err)
411
- // }
412
- // t.Log(signedData02.Id)
413
-
414
- // signedData03, err := ts.ThresholdSign(signer03)
415
- // if err != nil {
416
- // panic(err)
417
- // }
418
- // t.Log(signedData03.Id)
419
-
420
- // signedData04, err := ts.ThresholdSign(signer04)
421
- // if err != nil {
422
- // panic(err)
423
- // }
424
- // t.Log(signedData04.Id)
425
-
426
- // signedData05, err := ts.ThresholdSign(signer05)
427
- // if err != nil {
428
- // panic(err)
429
- // }
430
- // t.Log(signedData05.Id)
431
-
432
- // /* -------------------------- After receiving the signature data submitted by the signers, the server verifies the signature and assembles the signature ----------------------------*/
433
- // // Collect the signer's signature data into an array
434
- // signedShares := tcrsa.SigShareList{
435
- // // signedData01,
436
- // signedData02,
437
- // signedData03,
438
- // signedData04,
439
- // // signedData05,
440
- // }
441
-
442
- // // Verify the signature of each collected signer. And what happens in practice is that the server receives the signature submitted by the signer and then it verifies it and then it puts it in the array above
443
- // for _, sd := range signedShares {
444
- // err = sd.Verify(ts.pssData, keyMeta)
445
- // if err != nil {
446
- // panic(err)
447
- // }
448
- // }
449
-
450
- // // assemble signatures
451
- // signature, err := ts.AssembleSigShares(signedShares)
452
- // if err != nil {
453
- // panic(err)
454
- // }
455
- // // Finally, RSA native PSS verification signature method is used to verify the aggregated signature
456
- // signHashed := sha256.Sum256(signData)
457
- // err = rsa.VerifyPSS(keyMeta.PublicKey, crypto.SHA256, signHashed[:], signature, nil)
458
- // if err != nil {
459
- // panic(err)
460
- // }
461
- // // assemble tx and send to ar chain
462
- // tx.AddSignature(signature)
463
- // t.Log("txHash: ", tx.ID)
464
-
465
- // status, code, err := cli.SubmitTransaction(tx)
466
- // assert.NoError(t, err)
467
- // t.Log("status: ", status)
468
- // t.Log("code: ", code)
469
- // }
344
+ func TestCreateKeyPair2 (t * testing.T ) {
345
+ // cli := client.New("https://arweave.net")
346
+ //
347
+ // target := "Ii5wAMlLNz13n26nYY45mcZErwZLjICmYd46GZvn4ck"
348
+ // reward, err := cli.GetTransactionPrice(nil, &target)
349
+ // assert.NoError(t, err)
350
+ // // anchor, err := cli.GetTransactionAnchor() // for test
351
+ // anchor, err := cli.GetLastTransactionID("KKzL8og7VFLNwxbwW6cpUY_WkE5jFjWL26cTvKfWYms")
352
+ // assert.NoError(t, err)
353
+ // t.Log("lastTx: ", anchor)
354
+ // // read created threshold keypair for local file; need to be generated ahead of time;
355
+ // keyMeta := &tcrsa.KeyMeta{}
356
+ // keyMetaBy, err := ioutil.ReadFile("keyMeta.json")
357
+ // assert.NoError(t, err)
358
+ // err = json.Unmarshal(keyMetaBy, keyMeta)
359
+ // assert.NoError(t, err)
360
+ //
361
+ // owner := utils.Base64Encode(keyMeta.PublicKey.N.Bytes())
362
+ //
363
+ // amount := big.NewInt(140000) // transfer amount
364
+ // tags := []types.Tag{{Name: "Content-Type", Value: "application/json"}, {Name: "tcrsa", Value: "sandyTest"}}
365
+ // tx := &types.Transaction{
366
+ // Format: 2,
367
+ // ID: "",
368
+ // LastTx: anchor,
369
+ // Owner: owner,
370
+ // Tags: types.TagsEncode(tags),
371
+ // Target: target,
372
+ // Quantity: amount.String(),
373
+ // Data: "",
374
+ // DataSize: "0",
375
+ // DataRoot: "",
376
+ // Reward: fmt.Sprintf("%d", reward),
377
+ // Signature: "",
378
+ // Chunks: nil,
379
+ // }
380
+ // signData, err := types.GetSignatureData(tx)
381
+ // assert.NoError(t, err)
382
+ // t.Log("signData: ", signData)
383
+ //
384
+ // // signature
385
+ // keyShares := tcrsa.KeyShareList{}
386
+ // keySharesBy, err := ioutil.ReadFile("keyShares.json")
387
+ // assert.NoError(t, err)
388
+ // err = json.Unmarshal(keySharesBy, &keyShares)
389
+ // assert.NoError(t, err)
390
+ //
391
+ // ts, err := NewTcSign(keyMeta, signData)
392
+ // assert.NoError(t, err)
393
+ //
394
+ // /* --------------------------distribute keyShares to the signers ----------------------------*/
395
+ // signer01 := keyShares[0]
396
+ // signer02 := keyShares[1]
397
+ // signer03 := keyShares[2]
398
+ // signer04 := keyShares[3]
399
+ // signer05 := keyShares[4]
400
+ //
401
+ // /* -------------------------- signers to sign data ----------------------------*/
402
+ // signedData01, err := ts.ThresholdSign(signer01)
403
+ // if err != nil {
404
+ // panic(err)
405
+ // }
406
+ // t.Log(signedData01.Id)
407
+ // bb, _ := json.Marshal(signedData01)
408
+ // t.Log(hex.EncodeToString(bb))
409
+ //
410
+ // signedData02, err := ts.ThresholdSign(signer02)
411
+ // if err != nil {
412
+ // panic(err)
413
+ // }
414
+ // t.Log(signedData02.Id)
415
+ // bb, _ = json.Marshal(signedData02)
416
+ // t.Log(hex.EncodeToString(bb))
417
+ //
418
+ // signedData03, err := ts.ThresholdSign(signer03)
419
+ // if err != nil {
420
+ // panic(err)
421
+ // }
422
+ // t.Log(signedData03.Id)
423
+ // bb, _ = json.Marshal(signedData03)
424
+ // t.Log(hex.EncodeToString(bb))
425
+ //
426
+ // signedData04, err := ts.ThresholdSign(signer04)
427
+ // if err != nil {
428
+ // panic(err)
429
+ // }
430
+ // t.Log(signedData04.Id)
431
+ // bb, _ = json.Marshal(signedData04)
432
+ // t.Log(hex.EncodeToString(bb))
433
+ //
434
+ // signedData05, err := ts.ThresholdSign(signer05)
435
+ // if err != nil {
436
+ // panic(err)
437
+ // }
438
+ // t.Log(signedData05.Id)
439
+ // bb, _ = json.Marshal(signedData05)
440
+ // t.Log(hex.EncodeToString(bb))
441
+ //
442
+ // /* -------------------------- After receiving the signature data submitted by the signers, the server verifies the signature and assembles the signature ----------------------------*/
443
+ // // Collect the signer's signature data into an array
444
+ // signedShares := tcrsa.SigShareList{
445
+ // // signedData01,
446
+ // signedData02,
447
+ // signedData03,
448
+ // signedData04,
449
+ // // signedData05,
450
+ // }
451
+ //
452
+ // // Verify the signature of each collected signer. And what happens in practice is that the server receives the signature submitted by the signer and then it verifies it and then it puts it in the array above
453
+ // for _, sd := range signedShares {
454
+ // err = sd.Verify(ts.pssData, keyMeta)
455
+ // if err != nil {
456
+ // panic(err)
457
+ // }
458
+ // }
459
+ //
460
+ // // assemble signatures
461
+ // signature, err := ts.AssembleSigShares(signedShares)
462
+ // if err != nil {
463
+ // panic(err)
464
+ // }
465
+ // // Finally, RSA native PSS verification signature method is used to verify the aggregated signature
466
+ // signHashed := sha256.Sum256(signData)
467
+ // err = rsa.VerifyPSS(keyMeta.PublicKey, crypto.SHA256, signHashed[:], signature, nil)
468
+ // if err != nil {
469
+ // panic(err)
470
+ // }
471
+ // // assemble tx and send to ar chain
472
+ // tx.AddSignature(signature)
473
+ // t.Log("txHash: ", tx.ID)
474
+ //
475
+ // status, code, err := cli.SubmitTransaction(tx)
476
+ // assert.NoError(t, err)
477
+ // t.Log("status: ", status)
478
+ // t.Log("code: ", code)
479
+ }
0 commit comments