23 lines
365 B
Go
23 lines
365 B
Go
package x
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"xdx.jelly/xgcl/grand"
|
|
)
|
|
|
|
func TestPaillier(t *testing.T) {
|
|
// pk, sk := GenerateKey(1024)
|
|
|
|
sk, pk, err := GenerateKey(2048)
|
|
assert.Nil(t, err)
|
|
|
|
m, _ := rand.Int(grand.Reader, pk.N)
|
|
c, _ := Encrypt(m, pk, grand.Reader)
|
|
m1, _ := Decrypt(c, sk)
|
|
|
|
assert.Zero(t, m.Cmp(m1))
|
|
}
|