Documentation ¶
Index ¶
- Variables
- func NewPedersenOpenParameter(n, s, t *big.Int) (*zkPaillier.PederssenOpenParameter, error)
- type Paillier
- func (p *Paillier) Decrypt(cBytes []byte) ([]byte, error)
- func (p *Paillier) GetNthRoot() (*big.Int, error)
- func (p *Paillier) GetPrivLambda() *big.Int
- func (p *Paillier) GetPrivMu() *big.Int
- func (p *Paillier) GetPrivP() *big.Int
- func (p *Paillier) GetPrivPhiN() *big.Int
- func (p *Paillier) GetPrivQ() *big.Int
- func (p *Paillier) GetPubG() *big.Int
- func (p *Paillier) GetPubN() *big.Int
- func (paillier *Paillier) NewPedersenParameterByPaillier() (*PederssenParameter, error)
- type PedPrivKey
- type PedPubKey
- type PederssenParameter
- type PrivateKey
- type PubKeyMessage
- func (*PubKeyMessage) Descriptor() ([]byte, []int)deprecated
- func (x *PubKeyMessage) GetG() []byte
- func (x *PubKeyMessage) GetProof() *zkproof.IntegerFactorizationProofMessage
- func (*PubKeyMessage) ProtoMessage()
- func (x *PubKeyMessage) ProtoReflect() protoreflect.Message
- func (x *PubKeyMessage) Reset()
- func (x *PubKeyMessage) String() string
- func (msg *PubKeyMessage) ToPubkey() (*PublicKey, error)
- type PublicKey
- func (pub *PublicKey) Add(c1Bytes []byte, c2Bytes []byte) ([]byte, error)
- func (pub *PublicKey) Encrypt(mBytes []byte) ([]byte, error)
- func (pub *PublicKey) EncryptWithOutputSalt(m *big.Int) (*big.Int, *big.Int, error)
- func (pub *PublicKey) GetG() *big.Int
- func (pub *PublicKey) GetMessageRange(fieldOrder *big.Int) *big.Int
- func (pub *PublicKey) GetN() *big.Int
- func (pub *PublicKey) GetNSquare() *big.Int
- func (pub *PublicKey) MulConst(cBytes []byte, scalar *big.Int) ([]byte, error)
- func (pub *PublicKey) ToPubKeyBytes() []byte
- func (pub *PublicKey) VerifyEnc([]byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrExceedMaxRetry is returned if we retried over times ErrExceedMaxRetry = errors.New("exceed max retries") //ErrInvalidInput is returned if the input is invalid ErrInvalidInput = errors.New("invalid input") //ErrInvalidMessage is returned if the message is invalid ErrInvalidMessage = errors.New("invalid message") //ErrSmallPublicKeySize is returned if the size of public key is small ErrSmallPublicKeySize = errors.New("small public key") )
View Source
var File_github_com_getamis_alice_crypto_homo_paillier_message_proto protoreflect.FileDescriptor
Functions ¶
func NewPedersenOpenParameter ¶
func NewPedersenOpenParameter(n, s, t *big.Int) (*zkPaillier.PederssenOpenParameter, error)
Types ¶
type Paillier ¶
type Paillier struct { *PublicKey PrivateKey *PrivateKey }
func NewPaillier ¶
func NewPaillierSafePrime ¶
func NewPaillierUnSafe ¶
Warning: No check the size of public key.
func (*Paillier) GetPrivLambda ¶
func (*Paillier) GetPrivPhiN ¶
func (*Paillier) NewPedersenParameterByPaillier ¶
func (paillier *Paillier) NewPedersenParameterByPaillier() (*PederssenParameter, error)
By paillier
type PederssenParameter ¶
type PederssenParameter struct { P *big.Int Q *big.Int Eulern *big.Int Lambda *big.Int PedersenOpenParameter *zkPaillier.PederssenOpenParameter }
func (*PederssenParameter) GetEulerValue ¶
func (ped *PederssenParameter) GetEulerValue() *big.Int
func (*PederssenParameter) GetP ¶
func (ped *PederssenParameter) GetP() *big.Int
func (*PederssenParameter) GetQ ¶
func (ped *PederssenParameter) GetQ() *big.Int
func (*PederssenParameter) Getlambda ¶
func (ped *PederssenParameter) Getlambda() *big.Int
type PrivateKey ¶
type PrivateKey struct { P *big.Int Q *big.Int Lambda *big.Int // λ=lcm(p−1, q−1) PhiN *big.Int // (p-1) * (q-1) Mu *big.Int // μ=(L(g^λ mod n^2))^-1 mod n }
Refer: https://en.wikipedia.org/wiki/Paillier_cryptosystem PrivateKey is (λ, μ)
type PubKeyMessage ¶
type PubKeyMessage struct { Proof *zkproof.IntegerFactorizationProofMessage `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` G []byte `protobuf:"bytes,2,opt,name=g,proto3" json:"g,omitempty"` // contains filtered or unexported fields }
func (*PubKeyMessage) Descriptor
deprecated
func (*PubKeyMessage) Descriptor() ([]byte, []int)
Deprecated: Use PubKeyMessage.ProtoReflect.Descriptor instead.
func (*PubKeyMessage) GetG ¶
func (x *PubKeyMessage) GetG() []byte
func (*PubKeyMessage) GetProof ¶
func (x *PubKeyMessage) GetProof() *zkproof.IntegerFactorizationProofMessage
func (*PubKeyMessage) ProtoMessage ¶
func (*PubKeyMessage) ProtoMessage()
func (*PubKeyMessage) ProtoReflect ¶
func (x *PubKeyMessage) ProtoReflect() protoreflect.Message
func (*PubKeyMessage) Reset ¶
func (x *PubKeyMessage) Reset()
func (*PubKeyMessage) String ¶
func (x *PubKeyMessage) String() string
func (*PubKeyMessage) ToPubkey ¶
func (msg *PubKeyMessage) ToPubkey() (*PublicKey, error)
type PublicKey ¶
PublicKey is (n, g)
func ToPaillierPubKeyWithSpecialG ¶
func ToPaillierPubKeyWithSpecialG(ped *zkPaillier.PederssenOpenParameter) *PublicKey
func (*PublicKey) Add ¶
1. Check that c1, c2 is correct. 2. Choose (r, N)=1 with r in [1, N-1] randomly. 3. Compute c1*c2*r^N mod N^2.
func (*PublicKey) EncryptWithOutputSalt ¶
func (*PublicKey) GetMessageRange ¶
func (*PublicKey) GetNSquare ¶
func (*PublicKey) MulConst ¶
1. Check that c is correct. 2. Compute scalar mod N. 3. Choose (r, N)=1 with r in [1, N-1] randomly. 4. Compute c^scalar*r^N mod N^2.
func (*PublicKey) ToPubKeyBytes ¶
Click to show internal directories.
Click to hide internal directories.