ec2

package
v0.0.0-...-e59d3c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SafePrime = make(chan *big.Int, 1000)
	RndInt    = make(chan *big.Int, 1000)
)
View Source
var ErrIdNoEqualN = errors.New("[ERROR]: the length of input ids is not equal to the share number n.")

var ErrShareNotPass = errors.New("[ERROR]: the set of shares contain invalid share.")

View Source
var ErrMessageTooLong = errors.New("[ERROR]: message is too long.")
View Source
var ErrShareNotEnough = errors.New("[ERROR]: the shares is not enough to satisfy the threshold.")

Functions

func Combine

func Combine(shares []*ShareStruct) (*big.Int, error)

func Combine2

func Combine2(shares []*ShareStruct2) (*big.Int, error)

func GenRandomInt

func GenRandomInt(length int)

func GenRandomSafePrime

func GenRandomSafePrime(length int)

func GenerateKeyPair

func GenerateKeyPair(length int) (*PublicKey, *PrivateKey)

func GetSharesId

func GetSharesId(ss *ShareStruct2) *big.Int

func Vss

func Vss(secret *big.Int, ids []*big.Int, t int, n int) (*PolyGStruct, *PolyStruct, []*ShareStruct, error)

func Vss2Init

func Vss2Init(secret *big.Int, t int) (*PolyStruct2, *PolyGStruct2, error)

func ZkABVerify

func ZkABVerify(A []*big.Int, B []*big.Int, V []*big.Int, R []*big.Int, zkABProof *ZkABProof) bool

func ZkUVerify

func ZkUVerify(uG []*big.Int, zkUProof *ZkUProof) bool

Types

type Commitment

type Commitment struct {
	C *big.Int
	D []*big.Int
}

func (*Commitment) Commit

func (commitment *Commitment) Commit(secrets ...*big.Int) *Commitment

func (*Commitment) DeCommit

func (commitment *Commitment) DeCommit() (bool, []*big.Int)

func (*Commitment) Verify

func (commitment *Commitment) Verify() bool

type MtAZK1Proof

type MtAZK1Proof struct {
	Z  *big.Int
	U  *big.Int
	W  *big.Int
	S  *big.Int
	S1 *big.Int
	S2 *big.Int
}

func MtAZK1Prove

func MtAZK1Prove(m *big.Int, r *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) *MtAZK1Proof

func MtAZK1Prove(m *big.Int, r *big.Int, publicKey *paillier.PublicKey, zkFactProof *paillier.ZkFactProof) *MtAZK1Proof {

func (*MtAZK1Proof) MtAZK1Verify

func (mtAZK1Proof *MtAZK1Proof) MtAZK1Verify(c *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) bool

type MtAZK1Proof_nhh

type MtAZK1Proof_nhh struct {
	Z  *big.Int
	U  *big.Int
	W  *big.Int
	S  *big.Int
	S1 *big.Int
	S2 *big.Int
}

func MtAZK1Prove_nhh

func MtAZK1Prove_nhh(m *big.Int, r *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) *MtAZK1Proof_nhh

func (*MtAZK1Proof_nhh) MtAZK1Verify_nhh

func (mtAZKProof *MtAZK1Proof_nhh) MtAZK1Verify_nhh(c *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) bool

type MtAZK2Proof

type MtAZK2Proof struct {
	Z    *big.Int
	ZBar *big.Int
	T    *big.Int
	V    *big.Int
	W    *big.Int
	S    *big.Int
	S1   *big.Int
	S2   *big.Int
	T1   *big.Int
	T2   *big.Int
}

func MtAZK2Prove

func MtAZK2Prove(x *big.Int, y *big.Int, r *big.Int, c1 *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) *MtAZK2Proof

func MtAZK2Prove(x *big.Int, y *big.Int, r *big.Int, c1 *big.Int, publicKey *paillier.PublicKey, zkFactProof *paillier.ZkFactProof) *MtAZK2Proof {

func (*MtAZK2Proof) MtAZK2Verify

func (mtAZK2Proof *MtAZK2Proof) MtAZK2Verify(c1 *big.Int, c2 *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) bool

func (mtAZK2Proof *MtAZK2Proof) MtAZK2Verify(c1 *big.Int, c2 *big.Int, publicKey *paillier.PublicKey, zkFactProof *paillier.ZkFactProof) bool {

type MtAZK2Proof_nhh

type MtAZK2Proof_nhh struct {
	Z    *big.Int
	ZBar *big.Int
	T    *big.Int
	V    *big.Int
	W    *big.Int
	S    *big.Int
	S1   *big.Int
	S2   *big.Int
	T1   *big.Int
	T2   *big.Int
}

func MtAZK2Prove_nhh

func MtAZK2Prove_nhh(x *big.Int, y *big.Int, r *big.Int, c1 *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) *MtAZK2Proof_nhh

func (*MtAZK2Proof_nhh) MtAZK2Verify_nhh

func (mtAZK2Proof *MtAZK2Proof_nhh) MtAZK2Verify_nhh(c1 *big.Int, c2 *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) bool

type MtAZK3Proof

type MtAZK3Proof struct {
	Ux   *big.Int
	Uy   *big.Int
	Z    *big.Int
	ZBar *big.Int
	T    *big.Int
	V    *big.Int
	W    *big.Int
	S    *big.Int
	S1   *big.Int
	S2   *big.Int
	T1   *big.Int
	T2   *big.Int
}

func MtAZK3Prove

func MtAZK3Prove(x *big.Int, y *big.Int, r *big.Int, c1 *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) *MtAZK3Proof

func (*MtAZK3Proof) MtAZK3Verify

func (mtAZK3Proof *MtAZK3Proof) MtAZK3Verify(c1 *big.Int, c2 *big.Int, publicKey *PublicKey, zkFactProof *ZkFactProof) bool

type MtAZK3Proof_nhh

type MtAZK3Proof_nhh struct {
	Ux   *big.Int
	Uy   *big.Int
	Z    *big.Int
	ZBar *big.Int
	T    *big.Int
	V    *big.Int
	W    *big.Int
	S    *big.Int
	S1   *big.Int
	S2   *big.Int
	T1   *big.Int
	T2   *big.Int
}

func MtAZK3Prove_nhh

func MtAZK3Prove_nhh(x *big.Int, y *big.Int, r *big.Int, c1 *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) *MtAZK3Proof_nhh

func (*MtAZK3Proof_nhh) MtAZK3Verify_nhh

func (mtAZK3Proof *MtAZK3Proof_nhh) MtAZK3Verify_nhh(c1 *big.Int, c2 *big.Int, publicKey *PublicKey, ntildeH1H2 *NtildeH1H2) bool

type NtildeH1H2

type NtildeH1H2 struct {
	Ntilde *big.Int
	H1     *big.Int
	H2     *big.Int
}

func GenerateNtildeH1H2

func GenerateNtildeH1H2(length int) *NtildeH1H2

type PolyGStruct

type PolyGStruct struct {
	T     int          // threshold
	N     int          // total num
	PolyG [][]*big.Int //x and y
}

type PolyGStruct2

type PolyGStruct2 struct {
	PolyG [][]*big.Int //x and y
}

type PolyStruct

type PolyStruct struct {
	PolyGStruct
	Poly []*big.Int // coefficient set
}

type PolyStruct2

type PolyStruct2 struct {
	Poly []*big.Int // coefficient set
}

func (*PolyStruct2) Vss2

func (polyStruct *PolyStruct2) Vss2(ids []*big.Int) ([]*ShareStruct2, error)

type PrivateKey

type PrivateKey struct {
	Length string
	PublicKey
	L *big.Int // (p-1)*(q-1)
	U *big.Int // L^-1 mod N
}

func (*PrivateKey) Decrypt

func (privateKey *PrivateKey) Decrypt(cipherBigInt *big.Int) (*big.Int, error)

func (*PrivateKey) ZkFactProve

func (privateKey *PrivateKey) ZkFactProve() *ZkFactProof

type PublicKey

type PublicKey struct {
	Length string
	N      *big.Int // n = p*q, where p and q are prime
	G      *big.Int // in practical, G = N + 1
	N2     *big.Int // N2 = N * N
}

func (*PublicKey) Encrypt

func (publicKey *PublicKey) Encrypt(mBigInt *big.Int) (*big.Int, *big.Int, error)

func (publicKey *PublicKey) Encrypt(mBigInt *big.Int) (*big.Int, error) {

func (*PublicKey) HomoAdd

func (publicKey *PublicKey) HomoAdd(c1, c2 *big.Int) *big.Int

func (*PublicKey) HomoMul

func (publicKey *PublicKey) HomoMul(cipher, k *big.Int) *big.Int

func (*PublicKey) ZkFactVerify

func (publicKey *PublicKey) ZkFactVerify(zkFactProof *ZkFactProof) bool

type ShareStruct

type ShareStruct struct {
	T     int
	Id    *big.Int // ID, x coordinate
	Share *big.Int
}

func (*ShareStruct) Verify

func (share *ShareStruct) Verify(polyG *PolyGStruct) bool

type ShareStruct2

type ShareStruct2 struct {
	Id    *big.Int // ID, x coordinate
	Share *big.Int
}

func (*ShareStruct2) Verify2

func (share *ShareStruct2) Verify2(polyG *PolyGStruct2) bool

type ZkABProof

type ZkABProof struct {
	Alpha []*big.Int
	Beta  []*big.Int
	T     *big.Int
	U     *big.Int
}

func ZkABProve

func ZkABProve(a *big.Int, b *big.Int, s *big.Int, R []*big.Int) *ZkABProof

a(rho) b(l)

type ZkFactProof

type ZkFactProof struct {
	H1 *big.Int
	H2 *big.Int
	Y  *big.Int // r+(n-\phi(n))*e
	E  *big.Int
	N  *big.Int
}

type ZkUProof

type ZkUProof struct {
	E *big.Int
	S *big.Int
}

func ZkUProve

func ZkUProve(u *big.Int) *ZkUProof

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL