Skip to content

Commit 31b82db

Browse files
authored
Merge pull request #17 from everFinance/fix-rsa-threshold
Fix rsa threshold
2 parents 591f521 + 245f7ba commit 31b82db

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.15
55
require (
66
github.com/everFinance/gojwk v1.0.0
77
github.com/everFinance/sandy_log v1.0.3
8-
github.com/everFinance/ttcrsa v1.1.2
8+
github.com/everFinance/ttcrsa v1.1.3
99
github.com/shopspring/decimal v1.2.0
1010
github.com/stretchr/testify v1.7.0
1111
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/everFinance/gojwk v1.0.0 h1:le/oI2NgXlrqg3MHU6ka+V30EWcD7TD6+Ilh+go79
44
github.com/everFinance/gojwk v1.0.0/go.mod h1:icXSXsIdpAczlpAtSljQlmABkMTRZENr73KHmo0GOGc=
55
github.com/everFinance/sandy_log v1.0.3 h1:8aZgMOYuerTwTobWvwqi9JgsMvh9uOc5nqymTSLgKFE=
66
github.com/everFinance/sandy_log v1.0.3/go.mod h1:Pzm6pXpGKLZxLjmPbQaKYQyD76O5JXaG8oVCiarI/Og=
7-
github.com/everFinance/ttcrsa v1.1.2 h1:/kBn+gzm0ko/uvgOcwrpI+BvZ+6R36kDgeiTyKZDyGY=
8-
github.com/everFinance/ttcrsa v1.1.2/go.mod h1:Ws7b/oDbYKaZlvyT17nm+zHmzVhGl51r/yPx/Ib5RQk=
7+
github.com/everFinance/ttcrsa v1.1.3 h1:RJl9UizbevHZUiWPHVKz1aM6yA8cmkZWaCbOGTD/L0I=
8+
github.com/everFinance/ttcrsa v1.1.3/go.mod h1:Ws7b/oDbYKaZlvyT17nm+zHmzVhGl51r/yPx/Ib5RQk=
99
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
1010
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
1111
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac h1:n1DqxAo4oWPMvH1+v+DLYlMCecgumhhgnxAPdqDIFHI=

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(), 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

+4-7
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,15 @@ func TestWallet_SendDataSpeedUp02(t *testing.T) {
8383
// w, err := NewWalletFromPath("./wallet/account1.json", arNode, proxyUrl) // your wallet private key
8484
// assert.NoError(t, err)
8585
//
86-
// data, err := ioutil.ReadFile("/Users/sandyzhou/Downloads/650.zip")
86+
// data, err := ioutil.ReadFile("/Users/sandyzhou/Downloads/abc.jpeg")
8787
// if err != nil {
8888
// panic(err)
8989
// }
9090
// 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"},
91+
// {Name: "Sender", Value: "Jie"},
92+
// {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! (⁎⁍̴̛ᴗ⁍̴̛⁎)"},
9693
// }
9794
// id, err := w.SendDataSpeedUp(data, tags, 10)
9895
// assert.NoError(t, err)
99-
// t.Logf("tx hash: %s;", id)
96+
// t.Logf("tx hash: %s", id)
10097
}

0 commit comments

Comments
 (0)