forked from textileio/go-textile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
39 lines (33 loc) · 916 Bytes
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package core
import (
"github.com/textileio/textile-go/crypto"
"github.com/textileio/textile-go/keypair"
)
// Account returns account keypair
func (t *Textile) Account() *keypair.Full {
return t.account
}
// Sign signs input with account seed
func (t *Textile) Sign(input []byte) ([]byte, error) {
return t.account.Sign(input)
}
// Verify verifies input with account address
func (t *Textile) Verify(input []byte, sig []byte) error {
return t.account.Verify(input, sig)
}
// Encrypt encrypts input with account address
func (t *Textile) Encrypt(input []byte) ([]byte, error) {
pk, err := t.account.LibP2PPubKey()
if err != nil {
return nil, err
}
return crypto.Encrypt(pk, input)
}
// Decrypt decrypts input with account address
func (t *Textile) Decrypt(input []byte) ([]byte, error) {
sk, err := t.account.LibP2PPrivKey()
if err != nil {
return nil, err
}
return crypto.Decrypt(sk, input)
}