Documentation ¶
Index ¶
- Constants
- func GetArmoredPublicKey(ent *openpgp.Entity) ([]byte, error)
- func GetKeyFromIdentity(ent *openpgp.Entity, mode int) *openpgp.Key
- func GetPublicKey(buf []byte) (*packet.PublicKey, error)
- func Reconstruct(shares []Share) *math.Int
- type Counter
- type FieldP
- type PaillierPrivateKey
- type PaillierPublicKey
- type Share
Constants ¶
const ( // KeySign returns a signing key (GetKeyFromIdentity) KeySign = iota // KeyEncrypt returns a encryption key (GetKeyFromIdentity) KeyEncrypt // KeyAuth returns an authorization key (GetKeyFromIdentity) KeyAuth )
Variables ¶
This section is empty.
Functions ¶
func GetArmoredPublicKey ¶
GetArmoredPublicKey returns an armored public key for entity.
func GetKeyFromIdentity ¶
GetKeyFromIdentity returns a suitable subkey from entity for the given operation.
func GetPublicKey ¶
GetPublicKey converts an ASCII-armored public key representation into an OpenPGP key.
func Reconstruct ¶
Reconstruct secrets from number of shares: if not sufficient shares are available, the resulting secret is "random"
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a cryptographic counter (encrypted value)
func NewCounter ¶
func NewCounter(k *PaillierPublicKey) (c *Counter, err error)
NewCounter creates a new Counter instance for given public key.
type PaillierPrivateKey ¶
type PaillierPrivateKey struct { *PaillierPublicKey L, U *math.Int P, Q *math.Int }
PaillierPrivateKey data structure
func NewPaillierPrivateKey ¶
func NewPaillierPrivateKey(bits int) (key *PaillierPrivateKey, err error)
NewPaillierPrivateKey generates a new Paillier private key (key pair).
The key used in the Paillier crypto system consists of four integer values. The public key has two parameters; the private key has three parameters (one parameter is shared between the keys). As in RSA it starts with two random primes 'p' and 'q'; the public key parameter are computed as:
n := p * q g := random number from interval [0,n^2[
The private key parameters are computed as:
n := p * q l := lcm (p-1,q-1) u := (((g^l mod n^2)-1)/n) ^-1 mod n
N.B. The division by n is integer based and rounds toward zero!
func (*PaillierPrivateKey) Decrypt ¶
Decrypt message with private key.
The decryption function in the Paillier crypto scheme is:
m = D(c) = ((((c^l mod n^2)-1)/n) * u) mod n
N.B. As in the key generation process the division by n is integer
based and rounds toward zero!
func (*PaillierPrivateKey) GetPublicKey ¶
func (p *PaillierPrivateKey) GetPublicKey() *PaillierPublicKey
GetPublicKey returns the corresponding public key from a private key.
type PaillierPublicKey ¶
PaillierPublicKey data structure
func (*PaillierPublicKey) Encrypt ¶
Encrypt message with public key.
The encryption function in the Paillier crypto scheme is:
c = E(m) = (g^m * r^n) mod n^2
where 'r' is a random number from the interval [0,n[. This encryption allows different encryption results for the same message, based on the actual value of 'r'.