Skip to content

Commit a95a369

Browse files
committed
feat(): add salt
1 parent 591f521 commit a95a369

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

threshold.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ type TcSign struct {
4141
pssData []byte
4242
}
4343

44-
func NewTcSign(meta *tcrsa.KeyMeta, signData []byte) (*TcSign, error) {
44+
func NewTcSign(meta *tcrsa.KeyMeta, signData []byte, salt []byte) (*TcSign, error) {
4545
signHashed := sha256.Sum256(signData)
4646

47-
signDataByPss, err := tcrsa.PreparePssDocumentHash(meta.PublicKey.N.BitLen(), crypto.SHA256, signHashed[:], &rsa.PSSOptions{
47+
signDataByPss, err := tcrsa.PreparePssDocumentHash(meta.PublicKey.N.BitLen(), crypto.SHA256, signHashed[:], salt, &rsa.PSSOptions{
4848
SaltLength: 0,
4949
Hash: crypto.SHA256,
5050
})

threshold_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
func TestCreateTcKeyPair(t *testing.T) {
1818
exampleData := []byte("aaabbbcccddd112233")
1919
signHashed := sha256.Sum256(exampleData)
20+
salt := sha256.Sum256([]byte("everHash salt aaa"))
2021

2122
/* -------------------------- Key pair that generates RSA threshold signature on the server side ----------------------------*/
2223
bitSize := 1024 // If the values are 2048 and 4096, then the generation functions below will perform minute-level times, and we need 4096 bits as the maximum safety level for production environments.
@@ -28,7 +29,7 @@ func TestCreateTcKeyPair(t *testing.T) {
2829
panic(err)
2930
}
3031

31-
ts, err := NewTcSign(keyMeta, exampleData)
32+
ts, err := NewTcSign(keyMeta, exampleData, salt[:])
3233
if err != nil {
3334
panic(err)
3435
}
@@ -77,6 +78,8 @@ func TestCreateTcKeyPair(t *testing.T) {
7778
signedData05,
7879
}
7980

81+
ts, err = NewTcSign(keyMeta, exampleData, salt[:])
82+
assert.NoError(t, err)
8083
signature, err := ts.AssembleSigShares(signedShares)
8184
if err != nil {
8285
panic(err)

wallet_test.go

+18-19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package goar
22

33
import (
44
"encoding/base64"
5+
"github.com/everFinance/goar/types"
6+
"io/ioutil"
57
"testing"
68

79
"github.com/stretchr/testify/assert"
@@ -78,23 +80,20 @@ func TestWallet_SendDataSpeedUp01(t *testing.T) {
7880

7981
// test send big size file
8082
func TestWallet_SendDataSpeedUp02(t *testing.T) {
81-
// proxyUrl := "http://127.0.0.1:8001"
82-
// arNode := "https://arweave.net"
83-
// w, err := NewWalletFromPath("./wallet/account1.json", arNode, proxyUrl) // your wallet private key
84-
// assert.NoError(t, err)
85-
//
86-
// data, err := ioutil.ReadFile("/Users/sandyzhou/Downloads/650.zip")
87-
// if err != nil {
88-
// panic(err)
89-
// }
90-
// tags := []types.Tag{
91-
// {Name: "Content-Type", Value: "zip"},
92-
// {Name: "Sender", Value: "Sandy"},
93-
// {Name: "Receiver", Value: "pangpang"},
94-
// {Name: "Date-Size", Value: "16.6MB"},
95-
// {Name: "Data-Introduce", Value: "College 650 dormitory photos from 2014 to 2018"},
96-
// }
97-
// id, err := w.SendDataSpeedUp(data, tags, 10)
98-
// assert.NoError(t, err)
99-
// t.Logf("tx hash: %s;", id)
83+
proxyUrl := "http://127.0.0.1:8001"
84+
arNode := "https://arweave.net"
85+
w, err := NewWalletFromPath("./wallet/account1.json", arNode, proxyUrl) // your wallet private key
86+
assert.NoError(t, err)
87+
88+
data, err := ioutil.ReadFile("/Users/sandyzhou/Downloads/abc.jpeg")
89+
if err != nil {
90+
panic(err)
91+
}
92+
tags := []types.Tag{
93+
{Name: "Sender", Value: "Jie"},
94+
{Name: "Data-Introduce", Value: "Happy anniversary, my google and dearest! I‘m so grateful to have you in my life. I love you to infinity and beyond! (⁎⁍̴̛ᴗ⁍̴̛⁎)"},
95+
}
96+
id, err := w.SendDataSpeedUp(data, tags, 10)
97+
assert.NoError(t, err)
98+
t.Logf("tx hash: %s", id)
10099
}

0 commit comments

Comments
 (0)