Skip to content

Commit 995b7eb

Browse files
robdefeoToTeToantonio-ivanovski
authored andcommittedOct 28, 2022
fix: store mnemonic (#573)
* fix: switch to seed phrase Co-authored-by: Antonio <[email protected]> * fix: add mnemonic test case * test: e2e register * test: runInBand * test: fix auth tests * test: add decryptRootAccountKey tests * test: end to end tests * chore: bump packages version Co-authored-by: Antonio <[email protected]> Co-authored-by: Antonio Ivanovski <[email protected]> GitOrigin-RevId: b3303417e373e7fa59355233b1294c589d400550
1 parent de781c6 commit 995b7eb

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed
 

‎mnemonic/mnemonic.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package mnemonic
2+
3+
import (
4+
"crypto/sha512"
5+
6+
"golang.org/x/crypto/pbkdf2"
7+
)
8+
9+
func ToSeed(mnemonic string, password string) []byte {
10+
return pbkdf2.Key([]byte(mnemonic), []byte("mnemonic"+password), 2048, 32, sha512.New)
11+
}

‎mnemonic/mnemonic_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package mnemonic
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestToSeed(t *testing.T) {
10+
type args struct {
11+
mnemonic string
12+
password string
13+
}
14+
tests := []struct {
15+
name string
16+
args args
17+
want []byte
18+
}{
19+
{
20+
"deputy other",
21+
args{
22+
"deputy other grain consider empty next inform myself combine dish parent maple priority outdoor inherit lonely battle add humble jar silly tank item balance",
23+
"",
24+
},
25+
[]byte{196, 61, 147, 66, 207, 131, 22, 179, 98, 3, 83, 23, 116, 171, 96, 65, 14, 243, 147, 40, 21, 137, 42, 185, 147, 169, 115, 33, 38, 53, 82, 88},
26+
},
27+
}
28+
for _, tt := range tests {
29+
t.Run(tt.name, func(t *testing.T) {
30+
assert.Equal(t, tt.want, ToSeed(tt.args.mnemonic, tt.args.password))
31+
})
32+
}
33+
}

‎multikey/kind_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ package multikey
33
import (
44
"testing"
55

6-
"github.com/mailchain/mailchain/crypto/sr25519/sr25519test"
7-
86
"github.com/mailchain/mailchain/crypto"
97
"github.com/mailchain/mailchain/crypto/ed25519/ed25519test"
108
"github.com/mailchain/mailchain/crypto/secp256k1/secp256k1test"
9+
"github.com/mailchain/mailchain/crypto/sr25519/sr25519test"
1110
"github.com/stretchr/testify/assert"
1211
)
1312

0 commit comments

Comments
 (0)
Please sign in to comment.