forked from nanu-c/zkgroup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuuid_test.go
31 lines (23 loc) · 825 Bytes
/
uuid_test.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
package zkgroup_test
import (
"testing"
"github.com/nanu-c/zkgroup"
"github.com/stretchr/testify/require"
)
func TestUUID(t *testing.T) {
masterKey := test32_1
groupSecretParams, err := zkgroup.NewGroupSecretParams(masterKey)
require.NoError(t, err)
clientZkGroupCipher := zkgroup.NewClientZkGroupCipher(groupSecretParams)
uuid := zkgroup.UUID(randBytes(16))
uuidCiphertext, err := clientZkGroupCipher.EncryptUUID(uuid)
require.NoError(t, err)
uuidOut, err := clientZkGroupCipher.DecryptUUID(uuidCiphertext)
require.NoError(t, err)
require.Equal(t, uuid, uuidOut)
invalid := zkgroup.UUID(randBytes(32))
_, err = clientZkGroupCipher.EncryptUUID(invalid)
require.EqualError(t, err, "invalid uuid length")
_, err = clientZkGroupCipher.DecryptUUID(invalid)
require.EqualError(t, err, "invalid input")
}