common

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package common

Package common

@author: xwc1125 @date: 2019/9/25

Package common

Package common

Package common

Package common

@author: xwc1125 @date: 2019/9/25

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRangeProof = errors.New("invalid range proof")

	ErrInvalidProofPair = errors.New("cannot prove for invalid proof pair")
)
View Source
var ErrInvalidCommitment = errors.New("invalid commitment")
View Source
var ErrInvalidPoK = errors.New("invalid proof of knowledge")
View Source
var (
	ErrInvalidPrimalityProof = errors.New(
		"invalid paillier public key primality proof",
	)
)

Functions

func Commit

func Commit(data []byte) (Comm, Nonce, error)

func NewPrivKey

func NewPrivKey(modulus *big.Int) (*eckey.SecretKey, error)

新的私钥

Types

type BitSlice

type BitSlice []byte

func (BitSlice) Bit

func (b BitSlice) Bit(i int) byte

type CiphertextPair

type CiphertextPair struct {
	C1 *big.Int
	C2 *big.Int
}

func NewCiphertextPairs

func NewCiphertextPairs(size int) []CiphertextPair

type Comm

type Comm = Uint256

func (*Comm) Verify

func (c *Comm) Verify(data []byte, nonce *Nonce) error

type Config

type Config struct {
	Q        *big.Int // q=N值
	Q3       *big.Int // q3=q/3
	QSquared *big.Int // qSquared=q^2

	NPaillierBits  int
	NthRootSecBits int
	RangeSecBits   int
}

type DLogPoK

type DLogPoK struct {
	PK  eckey.CompressedPublicKey
	Sig schnorr.Signature
}

func NewDLogPK

func NewDLogPK(plaintext []byte, sk *eckey.SecretKey) (*DLogPoK, error)

生成DLogPok(公钥和签名内容)

func (*DLogPoK) Bytes

func (p *DLogPoK) Bytes() []byte

对象转换成bytes

func (*DLogPoK) Verify

func (p *DLogPoK) Verify(plaintext []byte) error

DLogPoK 的校验

type Nonce

type Nonce = Uint256

type PaillierNthRootProof

type PaillierNthRootProof struct {
	PK      *paillier.PublicKey
	U       *big.Int
	A       *big.Int
	Z       *big.Int
	SecBits int
}

func ProvePaillierNthRoot

func ProvePaillierNthRoot(
	pk *paillier.PublicKey,
	secbits int) (*PaillierNthRootProof, error)

func (*PaillierNthRootProof) Verify

func (p *PaillierNthRootProof) Verify() error

type ProofPair

type ProofPair struct {
	J  byte
	W1 *big.Int
	R1 *big.Int
	W2 *big.Int
	R2 *big.Int
}

func NewProofPairs

func NewProofPairs(size int) []ProofPair

type RangeProof

type RangeProof struct {
	CtxtPairs  []CiphertextPair
	ProofPairs []ProofPair
}

type RangeProofProver

type RangeProofProver struct {
	X   *big.Int
	R   *big.Int
	PSK *paillier.PrivateKey
	Q   *big.Int
	Q3  *big.Int

	ChallengeComm Comm
	Accuracy      int

	SecPairs  []SecretPair
	CtxtPairs []CiphertextPair
}

随机证明的证明者

func NewRangeProofProver

func NewRangeProofProver(
	x *big.Int,
	r *big.Int,
	q *big.Int,
	q3 *big.Int,
	psk *paillier.PrivateKey,
	comm Comm,
	accuracy int) (*RangeProofProver, error)

func (*RangeProofProver) Prove

func (p *RangeProofProver) Prove(challenge BitSlice, nonce *Nonce) ([]ProofPair, error)

type RangeProofVerifier

type RangeProofVerifier struct {
	C         *big.Int
	PPK       *paillier.PublicKey
	Q3        *big.Int
	Challenge BitSlice
	Comm      Comm
	Nonce     Nonce
	Accuracy  int

	CtxtPairs []CiphertextPair
}

随机证明的验证者

func NewRangeProofVerifier

func NewRangeProofVerifier(
	q3 *big.Int,
	accuracy int) (*RangeProofVerifier, error)

func (*RangeProofVerifier) ReceiveCtxt

func (p *RangeProofVerifier) ReceiveCtxt(
	c *big.Int,
	ppk *paillier.PublicKey,
	ctxtPairs []CiphertextPair)

func (*RangeProofVerifier) Verify

func (p *RangeProofVerifier) Verify(proofPairs []ProofPair) error

type SecretPair

type SecretPair struct {
	W1 *big.Int
	R1 *big.Int
	W2 *big.Int
	R2 *big.Int
}

func NewSecretPairs

func NewSecretPairs(size int) []SecretPair

type Uint256

type Uint256 [32]byte

Jump to

Keyboard shortcuts

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