Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOverflow = fmt.Errorf("the value is overflow")
Functions ¶
func DecryptInt32 ¶
func DecryptInt32(priv *sm2.PrivateKey, ciphertext *Ciphertext) (int32, error)
DecryptInt32 decrypts ciphertext to int32, if the value overflow, it returns ErrOverflow. The negative value will be slower than positive value.
func DecryptUint32 ¶
func DecryptUint32(priv *sm2.PrivateKey, ciphertext *Ciphertext) (uint32, error)
DecryptUint32 decrypts ciphertext to uint32, if the value overflow, it returns ErrOverflow.
func Marshal ¶
func Marshal(c *Ciphertext) ([]byte, error)
Marshal converts the ciphertext to ASN.1 DER form.
Types ¶
type Ciphertext ¶
type Ciphertext struct {
// contains filtered or unexported fields
}
Ciphertext sturcture represents EL-Gamal ecnryption result.
func EncryptInt32 ¶
EncryptInt32 encrypts m with the publickey.
func EncryptUint32 ¶
EncryptUint32 encrypts m with the publickey.
func Unmarshal ¶
func Unmarshal(der []byte) (*Ciphertext, error)
Unmarshal parses ciphertext in ASN.1 DER form.
func (*Ciphertext) Add ¶
func (ret *Ciphertext) Add(c1, c2 *Ciphertext) *Ciphertext
Add returns c1 + c2.
func (*Ciphertext) ScalarMultInt32 ¶
func (ret *Ciphertext) ScalarMultInt32(c *Ciphertext, m int32) *Ciphertext
ScalarMultInt32 scalar mutiples the ciphertext with m.
func (*Ciphertext) ScalarMultUint32 ¶
func (ret *Ciphertext) ScalarMultUint32(c *Ciphertext, m uint32) *Ciphertext
ScalarMultUint32 scalar mutiples the ciphertext with m.
func (*Ciphertext) Sub ¶
func (ret *Ciphertext) Sub(c1, c2 *Ciphertext) *Ciphertext
Sub returns c1 - c2.
Click to show internal directories.
Click to hide internal directories.